GUI functions related to news messages. More...
#include "stdafx.h"
#include "gui.h"
#include "viewport_func.h"
#include "strings_func.h"
#include "window_func.h"
#include "date_func.h"
#include "vehicle_base.h"
#include "vehicle_func.h"
#include "vehicle_gui.h"
#include "station_base.h"
#include "industry.h"
#include "town.h"
#include "sound_func.h"
#include "string_func.h"
#include "widgets/dropdown_func.h"
#include "statusbar_gui.h"
#include "company_manager_face.h"
#include "company_func.h"
#include "engine_base.h"
#include "engine_gui.h"
#include "core/geometry_func.hpp"
#include "command_func.h"
#include "company_base.h"
#include "settings_internal.h"
#include "widgets/news_widget.h"
#include "table/strings.h"
Go to the source code of this file.
Data Structures | |
struct | NewsWindow |
Window class displaying a news item. More... | |
struct | MessageHistoryWindow |
Functions | |
static TileIndex | GetReferenceTile (NewsReferenceType reftype, uint32 ref) |
Get the position a news-reference is referencing. | |
WindowDesc * | GetNewsWindowLayout (NewsFlag flags) |
assert_compile (lengthof(_news_type_data)==NT_END) | |
static void | ShowNewspaper (const NewsItem *ni) |
Open up an own newspaper window for the news item. | |
static void | ShowTicker (const NewsItem *ni) |
Show news item in the ticker. | |
void | InitNewsItemStructs () |
Initialize the news-items data structures. | |
static bool | ReadyForNextItem () |
Are we ready to show another news item? Only if nothing is in the newsticker and no newspaper is displayed. | |
static void | MoveToNextItem () |
Move to the next news item. | |
void | AddNewsItem (StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, void *free_data) |
Add a new newsitem to be shown. | |
CommandCost | CmdCustomNewsItem (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Create a new custom news item. | |
static void | DeleteNewsItem (NewsItem *ni) |
Delete a news item from the queue. | |
void | DeleteVehicleNews (VehicleID vid, StringID news) |
Delete a news item type about a vehicle. | |
void | DeleteStationNews (StationID sid) |
Remove news regarding given station so there are no 'unknown station now accepts Mail' or 'First train arrived at unknown station' news items. | |
void | DeleteIndustryNews (IndustryID iid) |
Remove news regarding given industry. | |
void | DeleteInvalidEngineNews () |
Remove engine announcements for invalid engines. | |
static void | RemoveOldNewsItems () |
void | ChangeVehicleNews (VehicleID from_index, VehicleID to_index) |
Report a change in vehicle IDs (due to autoreplace) to affected vehicle news. | |
void | NewsLoop () |
static void | ShowNewsMessage (const NewsItem *ni) |
Do a forced show of a specific message. | |
void | ShowLastNewsMessage () |
Show previous news item. | |
static void | DrawNewsString (uint left, uint right, int y, TextColour colour, const NewsItem *ni) |
Draw an unformatted news message truncated to a maximum length. | |
void | ShowMessageHistory () |
Display window with news messages history. | |
Variables | |
const NewsItem * | _statusbar_news_item = NULL |
static uint | MIN_NEWS_AMOUNT = 30 |
preferred minimum amount of news messages | |
static uint | _total_news = 0 |
current number of news items | |
static NewsItem * | _oldest_news = NULL |
head of news items queue | |
static NewsItem * | _latest_news = NULL |
tail of news items queue | |
static const NewsItem * | _forced_news = NULL |
Forced news item. | |
static const NewsItem * | _current_news = NULL |
Current news item (last item shown regularly). | |
static const NWidgetPart | _nested_normal_news_widgets [] |
static WindowDesc | _normal_news_desc (WDP_MANUAL, NULL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, _nested_normal_news_widgets, lengthof(_nested_normal_news_widgets)) |
static const NWidgetPart | _nested_vehicle_news_widgets [] |
static WindowDesc | _vehicle_news_desc (WDP_MANUAL, NULL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, _nested_vehicle_news_widgets, lengthof(_nested_vehicle_news_widgets)) |
static const NWidgetPart | _nested_company_news_widgets [] |
static WindowDesc | _company_news_desc (WDP_MANUAL, NULL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, _nested_company_news_widgets, lengthof(_nested_company_news_widgets)) |
static const NWidgetPart | _nested_thin_news_widgets [] |
static WindowDesc | _thin_news_desc (WDP_MANUAL, NULL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, _nested_thin_news_widgets, lengthof(_nested_thin_news_widgets)) |
static const NWidgetPart | _nested_small_news_widgets [] |
static WindowDesc | _small_news_desc (WDP_MANUAL, NULL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, _nested_small_news_widgets, lengthof(_nested_small_news_widgets)) |
static WindowDesc * | _news_window_layout [] |
Window layouts for news items. | |
static NewsTypeData | _news_type_data [] |
Per-NewsType data. | |
static const NWidgetPart | _nested_message_history [] |
static WindowDesc | _message_history_desc (WDP_AUTO,"list_news", 400, 140, WC_MESSAGE_HISTORY, WC_NONE, 0, _nested_message_history, lengthof(_nested_message_history)) |
GUI functions related to news messages.
Definition in file news_gui.cpp.
void AddNewsItem | ( | StringID | string, | |
NewsType | type, | |||
NewsFlag | flags, | |||
NewsReferenceType | reftype1, | |||
uint32 | ref1, | |||
NewsReferenceType | reftype2, | |||
uint32 | ref2, | |||
void * | free_data | |||
) |
Add a new newsitem to be shown.
string | String to display | |
type | news category | |
flags | display flags for the news | |
reftype1 | Type of ref1 | |
ref1 | Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleteing the news when the object is deleted. | |
reftype2 | Type of ref2 | |
ref2 | Reference 2 to some object: Used for scrolling after clicking on the news, and for deleteing the news when the object is deleted. | |
free_data | Pointer to data that must be freed once the news message is cleared |
Definition at line 633 of file news_gui.cpp.
References _cur_year, _date, _settings_client, _total_news, GUISettings::coloured_news_year, CopyOutDParam(), NewsItem::date, NewsItem::flags, NewsItem::free_data, ClientSettings::gui, lengthof, NewsItem::next, NewsItem::params, NewsItem::prev, NewsItem::ref1, NewsItem::ref2, NewsItem::reftype1, NewsItem::reftype2, SetWindowDirty(), NewsItem::string_id, NewsItem::type, and WC_MESSAGE_HISTORY.
Referenced by AddVehicleAdviceNewsItem(), AddVehicleNewsItem(), Subsidy::AwardTo(), CheckSwitchToEuro(), CmdCustomNewsItem(), CreateSubsidy(), GenerateCompanyName(), NewVehicleAvailable(), ShowRejectOrAcceptNews(), and SubsidyMonthlyLoop().
Report a change in vehicle IDs (due to autoreplace) to affected vehicle news.
from_index | the old vehicle ID | |
to_index | the new vehicle ID |
Definition at line 857 of file news_gui.cpp.
References NewsItem::next, NF_VEHICLE_PARAM0, and NR_VEHICLE.
Referenced by CopyHeadSpecificThings().
CommandCost CmdCustomNewsItem | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Create a new custom news item.
tile | unused | |
flags | type of operation | |
p1 | various bitstuffed elements
| |
p2 | First reference of the news message. | |
text | The text of the news message. |
Definition at line 683 of file news_gui.cpp.
References _current_company, _local_company, AddNewsItem(), CMD_ERROR, DC_EXEC, GB(), INVALID_OWNER, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::IsValidID(), SpecializedStation< Station, false >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), IsValidTile(), NF_NORMAL, NR_ENGINE, NR_INDUSTRY, NR_NONE, NR_STATION, NR_TILE, NR_TOWN, NR_VEHICLE, NT_END, OWNER_DEITY, SetDParamStr(), and StrEmpty().
void DeleteIndustryNews | ( | IndustryID | iid | ) |
Remove news regarding given industry.
iid | industry to remove news about |
Definition at line 812 of file news_gui.cpp.
References DeleteNewsItem(), NewsItem::next, NR_INDUSTRY, NewsItem::ref1, NewsItem::ref2, NewsItem::reftype1, and NewsItem::reftype2.
void DeleteStationNews | ( | StationID | sid | ) |
Remove news regarding given station so there are no 'unknown station now accepts Mail' or 'First train arrived at unknown station' news items.
sid | station to remove news about |
Definition at line 795 of file news_gui.cpp.
References DeleteNewsItem(), NewsItem::next, NR_STATION, NewsItem::ref1, NewsItem::ref2, NewsItem::reftype1, and NewsItem::reftype2.
Referenced by Station::~Station().
Delete a news item type about a vehicle.
When the news item type is INVALID_STRING_ID all news about the vehicle gets deleted.
vid | The vehicle to remove the news for. | |
news | The news type to remove. |
Definition at line 776 of file news_gui.cpp.
References DeleteNewsItem(), INVALID_STRING_ID, NewsItem::next, NR_VEHICLE, NewsItem::ref1, NewsItem::ref2, NewsItem::reftype1, NewsItem::reftype2, and NewsItem::string_id.
Referenced by AircraftHandleDestTooFar(), CmdStartStopVehicle(), DeleteOrderWarnings(), Vehicle::HandlePathfindingResult(), and Vehicle::~Vehicle().
static void DrawNewsString | ( | uint | left, | |
uint | right, | |||
int | y, | |||
TextColour | colour, | |||
const NewsItem * | ni | |||
) | [static] |
Draw an unformatted news message truncated to a maximum length.
If length exceeds maximum length it will be postfixed by '...'
left | the left most location for the string | |
right | the right most location for the string | |
y | position of the string | |
colour | the colour the string will be shown in | |
*ni | NewsItem being printed | |
maxw | maximum width of string in pixels |
Definition at line 955 of file news_gui.cpp.
References CopyInDParam(), DrawString(), lastof, lengthof, NewsItem::params, NewsItem::string_id, and Utf8Encode().
Referenced by MessageHistoryWindow::DrawWidget().
static TileIndex GetReferenceTile | ( | NewsReferenceType | reftype, | |
uint32 | ref | |||
) | [static] |
Get the position a news-reference is referencing.
reftype | The type of reference. | |
ref | The reference. |
Definition at line 66 of file news_gui.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::Get(), SpecializedStation< Station, false >::Get(), INVALID_TILE, NR_INDUSTRY, NR_STATION, NR_TILE, NR_TOWN, TileDiffXY(), and BaseStation::xy.
Referenced by NewsWindow::OnClick().
const NewsItem* _current_news = NULL [static] |
Current news item (last item shown regularly).
Definition at line 57 of file news_gui.cpp.
const NewsItem* _forced_news = NULL [static] |
Forced news item.
Users can force an item by accessing the history or "last message". If the message being shown was forced by the user, a pointer is stored in _forced_news. Otherwise, _forced_news variable is NULL. item the user has asked for
Definition at line 54 of file news_gui.cpp.
const NWidgetPart _nested_company_news_widgets[] [static] |
{ NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(NWID_VERTICAL), NWidget(WWT_TEXT, COLOUR_WHITE, WID_N_CLOSEBOX), SetDataTip(STR_SILVER_CROSS, STR_NULL), SetPadding(0, 0, 0, 1), NWidget(NWID_SPACER), SetFill(0, 1), EndContainer(), NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_TITLE), SetFill(1, 1), SetMinimalSize(410, 20), SetDataTip(STR_EMPTY, STR_NULL), EndContainer(), NWidget(NWID_HORIZONTAL), SetPadding(0, 1, 1, 1), NWidget(NWID_VERTICAL), NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_MGR_FACE), SetMinimalSize(93, 119), SetPadding(2, 6, 2, 1), NWidget(NWID_HORIZONTAL), NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_MGR_NAME), SetMinimalSize(93, 24), SetPadding(0, 0, 0, 1), NWidget(NWID_SPACER), SetFill(1, 0), EndContainer(), NWidget(NWID_SPACER), SetFill(0, 1), EndContainer(), NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_COMPANY_MSG), SetFill(1, 1), SetMinimalSize(328, 150), EndContainer(), EndContainer(), }
Definition at line 127 of file news_gui.cpp.
const NWidgetPart _nested_message_history[] [static] |
{ NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MESSAGE_HISTORY, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), NWidget(WWT_SHADEBOX, COLOUR_BROWN), NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN), NWidget(WWT_STICKYBOX, COLOUR_BROWN), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_BROWN, WID_MH_BACKGROUND), SetMinimalSize(200, 125), SetDataTip(0x0, STR_MESSAGE_HISTORY_TOOLTIP), SetResize(1, 12), SetScrollbar(WID_MH_SCROLLBAR), EndContainer(), NWidget(NWID_VERTICAL), NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_MH_SCROLLBAR), NWidget(WWT_RESIZEBOX, COLOUR_BROWN), EndContainer(), EndContainer(), }
Definition at line 1094 of file news_gui.cpp.
const NWidgetPart _nested_normal_news_widgets[] [static] |
{ NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(WWT_TEXT, COLOUR_WHITE, WID_N_CLOSEBOX), SetDataTip(STR_SILVER_CROSS, STR_NULL), SetPadding(0, 0, 0, 1), NWidget(NWID_SPACER), SetFill(1, 0), NWidget(NWID_VERTICAL), NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_DATE), SetDataTip(STR_DATE_LONG_SMALL, STR_NULL), NWidget(NWID_SPACER), SetFill(0, 1), EndContainer(), EndContainer(), NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_MESSAGE), SetMinimalSize(428, 154), SetPadding(0, 5, 1, 5), EndContainer(), }
Definition at line 78 of file news_gui.cpp.
const NWidgetPart _nested_small_news_widgets[] [static] |
{ NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, WID_N_CLOSEBOX), NWidget(WWT_EMPTY, COLOUR_LIGHT_BLUE, WID_N_CAPTION), SetFill(1, 0), EndContainer(), NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_N_HEADLINE), NWidget(WWT_INSET, COLOUR_LIGHT_BLUE, WID_N_INSET), SetPadding(2, 2, 2, 2), NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT), SetPadding(1, 1, 1, 1), SetMinimalSize(274, 47), SetFill(1, 0), EndContainer(), NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_MESSAGE), SetMinimalSize(275, 20), SetFill(1, 0), SetPadding(0, 5, 0, 5), EndContainer(), }
Definition at line 181 of file news_gui.cpp.
const NWidgetPart _nested_thin_news_widgets[] [static] |
{ NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(WWT_TEXT, COLOUR_WHITE, WID_N_CLOSEBOX), SetDataTip(STR_SILVER_CROSS, STR_NULL), SetPadding(0, 0, 0, 1), NWidget(NWID_SPACER), SetFill(1, 0), NWidget(NWID_VERTICAL), NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_DATE), SetDataTip(STR_DATE_LONG_SMALL, STR_NULL), NWidget(NWID_SPACER), SetFill(0, 1), EndContainer(), EndContainer(), NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_MESSAGE), SetMinimalSize(428, 48), SetFill(1, 0), SetPadding(0, 5, 0, 5), NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT), SetMinimalSize(426, 70), SetPadding(1, 2, 2, 2), EndContainer(), }
Definition at line 158 of file news_gui.cpp.
const NWidgetPart _nested_vehicle_news_widgets[] [static] |
{ NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(NWID_VERTICAL), NWidget(WWT_TEXT, COLOUR_WHITE, WID_N_CLOSEBOX), SetDataTip(STR_SILVER_CROSS, STR_NULL), SetPadding(0, 0, 0, 1), NWidget(NWID_SPACER), SetFill(0, 1), EndContainer(), NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_VEH_TITLE), SetFill(1, 1), SetMinimalSize(419, 55), SetDataTip(STR_EMPTY, STR_NULL), EndContainer(), NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_VEH_BKGND), SetPadding(0, 25, 1, 25), NWidget(NWID_VERTICAL), NWidget(WWT_EMPTY, INVALID_COLOUR, WID_N_VEH_NAME), SetMinimalSize(369, 33), SetFill(1, 0), NWidget(WWT_EMPTY, INVALID_COLOUR, WID_N_VEH_SPR), SetMinimalSize(369, 32), SetFill(1, 0), NWidget(WWT_EMPTY, INVALID_COLOUR, WID_N_VEH_INFO), SetMinimalSize(369, 46), SetFill(1, 0), EndContainer(), EndContainer(), EndContainer(), }
Definition at line 100 of file news_gui.cpp.
NewsTypeData _news_type_data[] [static] |
{ NewsTypeData("news_display.arrival_player", 60, SND_1D_APPLAUSE ), NewsTypeData("news_display.arrival_other", 60, SND_1D_APPLAUSE ), NewsTypeData("news_display.accident", 90, SND_BEGIN ), NewsTypeData("news_display.company_info", 60, SND_BEGIN ), NewsTypeData("news_display.open", 90, SND_BEGIN ), NewsTypeData("news_display.close", 90, SND_BEGIN ), NewsTypeData("news_display.economy", 30, SND_BEGIN ), NewsTypeData("news_display.production_player", 30, SND_BEGIN ), NewsTypeData("news_display.production_other", 30, SND_BEGIN ), NewsTypeData("news_display.production_nobody", 30, SND_BEGIN ), NewsTypeData("news_display.advice", 150, SND_BEGIN ), NewsTypeData("news_display.new_vehicles", 30, SND_1E_OOOOH ), NewsTypeData("news_display.acceptance", 90, SND_BEGIN ), NewsTypeData("news_display.subsidies", 180, SND_BEGIN ), NewsTypeData("news_display.general", 60, SND_BEGIN ), }
Per-NewsType data.
Definition at line 225 of file news_gui.cpp.
WindowDesc* _news_window_layout[] [static] |
{ &_thin_news_desc, &_small_news_desc, &_normal_news_desc, &_vehicle_news_desc, &_company_news_desc, }
Window layouts for news items.
Definition at line 207 of file news_gui.cpp.