Merge branch 'master' into jgrpp-beta
# Conflicts: # src/company_cmd.cpp # src/economy.cpp # src/lang/swedish.txt # src/network/network_command.cpp # src/news_gui.cpp # src/saveload/saveload.h # src/script/api/script_list.cpp # src/video/cocoa/cocoa_v.mm # src/video/sdl2_v.cpp
This commit is contained in:
@@ -355,7 +355,7 @@ struct NewsWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_N_MGR_NAME:
|
||||
SetDParamStr(0, static_cast<const CompanyNewsInformation *>(this->ni->free_data)->president_name);
|
||||
SetDParamStr(0, static_cast<const CompanyNewsInformation *>(this->ni->data.get())->president_name);
|
||||
str = STR_JUST_RAW_STRING;
|
||||
break;
|
||||
|
||||
@@ -433,13 +433,13 @@ struct NewsWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_N_MGR_FACE: {
|
||||
const CompanyNewsInformation *cni = (const CompanyNewsInformation*)this->ni->free_data;
|
||||
const CompanyNewsInformation *cni = static_cast<const CompanyNewsInformation*>(this->ni->data.get());
|
||||
DrawCompanyManagerFace(cni->face, cni->colour, r.left, r.top);
|
||||
GfxFillRect(r.left, r.top, r.right, r.bottom, PALETTE_NEWSPAPER, FILLRECT_RECOLOUR);
|
||||
break;
|
||||
}
|
||||
case WID_N_MGR_NAME: {
|
||||
const CompanyNewsInformation *cni = (const CompanyNewsInformation*)this->ni->free_data;
|
||||
const CompanyNewsInformation *cni = static_cast<const CompanyNewsInformation*>(this->ni->data.get());
|
||||
SetDParamStr(0, cni->president_name);
|
||||
DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_JUST_RAW_STRING, TC_FROMSTRING, SA_CENTER);
|
||||
break;
|
||||
@@ -642,8 +642,7 @@ static bool ReadyForNextTickerItem()
|
||||
|
||||
/* Ticker message
|
||||
* Check if the status bar message is still being displayed? */
|
||||
if (IsNewsTickerShown()) return false;
|
||||
return true;
|
||||
return !IsNewsTickerShown();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -774,6 +773,27 @@ static void DeleteNewsItem(NewsItem *ni)
|
||||
SetWindowDirty(WC_MESSAGE_HISTORY, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new newsitem to be shown.
|
||||
* @param string_id String to display.
|
||||
* @param type The type of news.
|
||||
* @param flags Flags related to how to display the news.
|
||||
* @param reftype1 Type of ref1.
|
||||
* @param ref1 Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted.
|
||||
* @param reftype2 Type of ref2.
|
||||
* @param ref2 Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
|
||||
* @param data Pointer to data that must be released once the news message is cleared.
|
||||
*
|
||||
* @see NewsSubtype
|
||||
*/
|
||||
NewsItem::NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, const NewsAllocatedData *data) :
|
||||
string_id(string_id), date(_date), type(type), flags(flags), reftype1(reftype1), reftype2(reftype2), ref1(ref1), ref2(ref2), data(data)
|
||||
{
|
||||
/* show this news message in colour? */
|
||||
if (_cur_year >= _settings_client.gui.coloured_news_year) this->flags |= NF_INCOLOUR;
|
||||
CopyOutDParam(this->params, 0, lengthof(this->params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new newsitem to be shown.
|
||||
* @param string String to display
|
||||
@@ -783,31 +803,16 @@ static void DeleteNewsItem(NewsItem *ni)
|
||||
* @param ref1 Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted.
|
||||
* @param reftype2 Type of ref2
|
||||
* @param ref2 Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
|
||||
* @param free_data Pointer to data that must be freed once the news message is cleared
|
||||
* @param data Pointer to data that must be released once the news message is cleared.
|
||||
*
|
||||
* @see NewsSubtype
|
||||
*/
|
||||
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, void *free_data)
|
||||
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, const NewsAllocatedData *data)
|
||||
{
|
||||
if (_game_mode == GM_MENU) return;
|
||||
|
||||
/* Create new news item node */
|
||||
NewsItem *ni = new NewsItem;
|
||||
|
||||
ni->string_id = string;
|
||||
ni->type = type;
|
||||
ni->flags = flags;
|
||||
|
||||
/* show this news message in colour? */
|
||||
if (_cur_year >= _settings_client.gui.coloured_news_year) ni->flags |= NF_INCOLOUR;
|
||||
|
||||
ni->reftype1 = reftype1;
|
||||
ni->reftype2 = reftype2;
|
||||
ni->ref1 = ref1;
|
||||
ni->ref2 = ref2;
|
||||
ni->free_data = free_data;
|
||||
ni->date = _date;
|
||||
CopyOutDParam(ni->params, 0, lengthof(ni->params));
|
||||
NewsItem *ni = new NewsItem(string, type, flags, reftype1, ref1, reftype2, ref2, data);
|
||||
|
||||
if (_total_news++ == 0) {
|
||||
assert(_oldest_news == nullptr);
|
||||
@@ -886,8 +891,8 @@ CommandCost CmdCustomNewsItem(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
if (company != INVALID_OWNER && company != _local_company) return CommandCost();
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
char *news = stredup(text);
|
||||
SetDParamStr(0, news);
|
||||
NewsStringData *news = new NewsStringData(text);
|
||||
SetDParamStr(0, news->string);
|
||||
AddNewsItem(STR_NEWS_CUSTOM_ITEM, type, NF_NORMAL, reftype1, p2, NR_NONE, UINT32_MAX, news);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user