#include "stdafx.h"
#include "openttd.h"
#include "gui.h"
#include "window_gui.h"
#include "viewport_func.h"
#include "news_type.h"
#include "settings_type.h"
#include "transparency.h"
#include "strings_func.h"
#include "window_func.h"
#include "date_func.h"
#include "vehicle_base.h"
#include "sound_func.h"
#include "string_func.h"
#include "widgets/dropdown_func.h"
#include "statusbar_gui.h"
#include "company_manager_face.h"
#include "table/strings.h"
Go to the source code of this file.
Data Structures | |
struct | NewsSubtypeData |
Data common to all news items of a given subtype (structure). More... | |
struct | NewsWindow |
struct | MessageHistoryWindow |
struct | MessageOptionsWindow |
Defines | |
#define | NB_WIDG_PER_SETTING 4 |
#define | NEWS_SETTINGS_LINE(basey, linenum, text) |
Macro to construct one news-setting line in the news-settings window. | |
Typedefs | |
typedef void | DrawNewsCallbackProc (struct Window *w, const NewsItem *ni) |
Enumerations | |
enum | { WIDGET_NEWSOPT_DROP_SUMMARY = 4, WIDGET_NEWSOPT_SOUNDTICKER = 6, WIDGET_NEWSOPT_START_OPTION = 8 } |
News settings window widget offset constants. More... | |
Functions | |
void | DrawNewsNewVehicleAvail (Window *w, const NewsItem *ni) |
static void | DrawNewsBankrupcy (Window *w, const NewsItem *ni) |
static void | ShowNewspaper (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, NewsSubtype subtype, uint data_a, uint data_b, void *free_data) |
Add a new newsitem to be shown. | |
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 if the news item type is INVALID_STRING_ID all news about the vehicle get deleted. | |
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 | RemoveOldNewsItems () |
void | NewsLoop () |
static void | ShowNewsMessage (NewsItem *ni) |
Do a forced show of a specific message. | |
void | ShowLastNewsMessage () |
Show previous news item. | |
static void | DrawNewsString (int x, int y, TextColour colour, const NewsItem *ni, uint maxw) |
Draw an unformatted news message truncated to a maximum length. | |
void | ShowMessageHistory () |
Display window with news messages history. | |
void | ShowMessageOptions () |
Variables | |
NewsItem | _statusbar_news_item |
bool | _news_ticker_sound |
static uint | MIN_NEWS_AMOUNT = 30 |
prefered 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 NewsItem * | _forced_news = NULL |
Forced news item. | |
static NewsItem * | _current_news = NULL |
Current news item (last item shown regularly). | |
static struct NewsSubtypeData | _news_subtype_data [NS_END] |
Data common to all news items of a given subtype (actual data). | |
NewsTypeData | _news_type_data [NT_END] |
Per-NewsType data. | |
static const Widget | _news_type13_widgets [] |
static WindowDesc | _news_type13_desc |
static const Widget | _news_type2_widgets [] |
static WindowDesc | _news_type2_desc |
static const Widget | _news_type0_widgets [] |
static WindowDesc | _news_type0_desc |
static const Widget | _message_history_widgets [] |
static const WindowDesc | _message_history_desc |
static const StringID | _message_opt [] = {STR_OFF, STR_SUMMARY, STR_FULL, INVALID_STRING_ID} |
static const int | NEWS_SETTING_BASELINE_SKIP = 12 |
Distance between two news-setting lines, should be at least 12. | |
static const Widget | _message_options_widgets [] |
static const WindowDesc | _message_options_desc |
Definition in file news_gui.cpp.
#define NEWS_SETTINGS_LINE | ( | basey, | |||
linenum, | |||||
text | ) |
Value:
{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_YELLOW, \ 4, 12, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, \ { WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, \ 13, 89, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ STR_EMPTY, STR_NULL}, \ { WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_YELLOW, \ 90, 98, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, \ { WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, \ 103, 409, basey + 1 + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 13 + linenum * NEWS_SETTING_BASELINE_SKIP, \ text, STR_NULL}
One line consists of four widgets, namely
NEWS_SETTING_BASELINE_SKIP
). Height of one line is 12, with the text label shifted 1 pixel down.First line should be widget number WIDGET_NEWSOPT_START_OPTION
basey,: | Base Y coordinate | |
linenum,: | Count, news-setting is the linenum-th line | |
text,: | StringID for the text label to display |
Definition at line 915 of file news_gui.cpp.
anonymous enum |
News settings window widget offset constants.
Definition at line 792 of file news_gui.cpp.
void AddNewsItem | ( | StringID | string, | |
NewsSubtype | subtype, | |||
uint | data_a, | |||
uint | data_b, | |||
void * | free_data | |||
) |
Add a new newsitem to be shown.
string | String to display | |
subtype | news category, any of the NewsSubtype enums (NS_) | |
data_a | news-specific value based on news type | |
data_b | news-specific value based on news type |
Definition at line 489 of file news_gui.cpp.
References _cur_year, _date, _latest_news, _oldest_news, _settings_client, _total_news, GUISettings::coloured_news_year, NewsSubtypeData::flags, ClientSettings::gui, InvalidateWindow(), lengthof, and NF_INCOLOUR.
Referenced by AircraftEntersTerminal(), ChangeIndustryProduction(), CheckOrders(), CheckSwitchToEuro(), CheckTrainCollision(), CmdBuildIndustry(), CmdCompanyCtrl(), DeliverGoodsToIndustry(), Disaster_CoalMine_Init(), DisasterTick_Airplane(), DisasterTick_Big_Ufo(), DisasterTick_Helicopter(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), MaybeNewIndustry(), ReportNewsProductionChangeIndustry(), and ShowRejectOrAcceptNews().
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.
Delete news associated with given station.
sid | station to remove news about |
Definition at line 581 of file news_gui.cpp.
References _oldest_news, DeleteNewsItem(), NS_ACCEPTANCE, NS_ARRIVAL_COMPANY, and NS_ARRIVAL_OTHER.
Referenced by Station::~Station().
static void DrawNewsString | ( | int | x, | |
int | y, | |||
TextColour | colour, | |||
const NewsItem * | ni, | |||
uint | maxw | |||
) | [static] |
Draw an unformatted news message truncated to a maximum length.
If length exceeds maximum length it will be postfixed by '...'
x,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 669 of file news_gui.cpp.
References DoDrawStringTruncated(), lastof, and lengthof.
NewsItem* _current_news = NULL [static] |
Current news item (last item shown regularly).
Definition at line 42 of file news_gui.cpp.
Referenced by DeleteNewsItem(), InitNewsItemStructs(), MoveToNextItem(), ReadyForNextItem(), and ShowLastNewsMessage().
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 39 of file news_gui.cpp.
Referenced by DeleteNewsItem(), InitNewsItemStructs(), MoveToNextItem(), ReadyForNextItem(), ShowLastNewsMessage(), and ShowNewsMessage().
const WindowDesc _message_history_desc [static] |
Initial value:
{ 240, 22, 400, 140, 400, 140, WC_MESSAGE_HISTORY, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _message_history_widgets, }
Definition at line 776 of file news_gui.cpp.
const Widget _message_history_widgets[] [static] |
Initial value:
{ { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_BROWN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_RIGHT, COLOUR_BROWN, 11, 387, 0, 13, STR_MESSAGE_HISTORY, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_STICKYBOX, RESIZE_LR, COLOUR_BROWN, 388, 399, 0, 13, 0x0, STR_STICKY_BUTTON}, { WWT_PANEL, RESIZE_RB, COLOUR_BROWN, 0, 387, 14, 139, 0x0, STR_MESSAGE_HISTORY_TIP}, { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_BROWN, 388, 399, 14, 127, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_BROWN, 388, 399, 128, 139, 0x0, STR_RESIZE_BUTTON}, { WIDGETS_END}, }
Definition at line 766 of file news_gui.cpp.
const WindowDesc _message_options_desc [static] |
Initial value:
{ 270, 22, 410, 65 + NT_END * NEWS_SETTING_BASELINE_SKIP, 410, 65 + NT_END * NEWS_SETTING_BASELINE_SKIP, WC_GAME_OPTIONS, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, _message_options_widgets, }
Definition at line 985 of file news_gui.cpp.
struct NewsSubtypeData _news_subtype_data[NS_END] [static] |
Initial value:
{ { NT_ARRIVAL_COMPANY, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, { NT_ARRIVAL_OTHER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, { NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, { NT_COMPANY_INFO, NM_NORMAL, NF_TILE, DrawNewsBankrupcy }, { NT_INDUSTRY_OPEN, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, { NT_INDUSTRY_CLOSE, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, { NT_ECONOMY, NM_NORMAL, NF_NONE, NULL }, { NT_INDUSTRY_COMPANY, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, { NT_INDUSTRY_OTHER, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, { NT_INDUSTRY_NOBODY, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, { NT_ADVICE, NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NULL }, { NT_NEW_VEHICLES, NM_NORMAL, NF_NONE, DrawNewsNewVehicleAvail }, { NT_ACCEPTANCE, NM_SMALL, NF_VIEWPORT|NF_TILE, NULL }, { NT_SUBSIDIES, NM_NORMAL, NF_TILE|NF_TILE2, NULL }, { NT_GENERAL, NM_NORMAL, NF_TILE, NULL }, }
Definition at line 123 of file news_gui.cpp.
WindowDesc _news_type0_desc [static] |
Initial value:
{ WDP_CENTER, 476, 280, 87, 280, 87, WC_NEWS_WINDOW, WC_NONE, WDF_DEF_WIDGET, _news_type0_widgets, }
Definition at line 356 of file news_gui.cpp.
const Widget _news_type0_widgets[] [static] |
Initial value:
{ { WWT_PANEL, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 279, 14, 86, 0x0, STR_NULL}, { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, COLOUR_LIGHT_BLUE, 11, 279, 0, 13, STR_012C_MESSAGE, STR_NULL}, { WWT_INSET, RESIZE_NONE, COLOUR_LIGHT_BLUE, 2, 277, 16, 64, 0x0, STR_NULL}, { WIDGETS_END}, }
Definition at line 348 of file news_gui.cpp.
WindowDesc _news_type13_desc [static] |
Initial value:
{ WDP_CENTER, 476, 430, 170, 430, 170, WC_NEWS_WINDOW, WC_NONE, WDF_DEF_WIDGET, _news_type13_widgets, }
Definition at line 328 of file news_gui.cpp.
const Widget _news_type13_widgets[] [static] |
Initial value:
{ { WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 429, 0, 169, 0x0, STR_NULL}, { WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 10, 0, 11, 0x0, STR_NULL}, { WIDGETS_END}, }
Definition at line 322 of file news_gui.cpp.
WindowDesc _news_type2_desc [static] |
Initial value:
{ WDP_CENTER, 476, 430, 130, 430, 130, WC_NEWS_WINDOW, WC_NONE, WDF_DEF_WIDGET, _news_type2_widgets, }
Definition at line 341 of file news_gui.cpp.
const Widget _news_type2_widgets[] [static] |
Initial value:
{ { WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 429, 0, 129, 0x0, STR_NULL}, { WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 10, 0, 11, 0x0, STR_NULL}, { WIDGETS_END}, }
Definition at line 335 of file news_gui.cpp.
NewsTypeData _news_type_data[NT_END] |
Initial value:
{ { "arrival_player", 60, SND_1D_APPLAUSE, ND_FULL }, { "arrival_other", 60, SND_1D_APPLAUSE, ND_FULL }, { "accident", 90, SND_BEGIN, ND_FULL }, { "company_info", 60, SND_BEGIN, ND_FULL }, { "open", 90, SND_BEGIN, ND_FULL }, { "close", 90, SND_BEGIN, ND_FULL }, { "economy", 30, SND_BEGIN, ND_FULL }, { "production_player", 30, SND_BEGIN, ND_FULL }, { "production_other", 30, SND_BEGIN, ND_FULL }, { "production_nobody", 30, SND_BEGIN, ND_FULL }, { "advice", 150, SND_BEGIN, ND_FULL }, { "new_vehicles", 30, SND_1E_OOOOH, ND_FULL }, { "acceptance", 90, SND_BEGIN, ND_FULL }, { "subsidies", 180, SND_BEGIN, ND_FULL }, { "general", 60, SND_BEGIN, ND_FULL }, }
Definition at line 149 of file news_gui.cpp.
Referenced by ConvertOldNewsSetting().