news_gui.cpp File Reference

GUI functions related to news messages. More...

#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 (WDP_CENTER, 476, 430, 170, 430, 170, WC_NEWS_WINDOW, WC_NONE, WDF_DEF_WIDGET, _news_type13_widgets)
static const Widget _news_type2_widgets []
static WindowDesc _news_type2_desc (WDP_CENTER, 476, 430, 130, 430, 130, WC_NEWS_WINDOW, WC_NONE, WDF_DEF_WIDGET, _news_type2_widgets)
static const Widget _news_type0_widgets []
static WindowDesc _news_type0_desc (WDP_CENTER, 476, 280, 87, 280, 87, WC_NEWS_WINDOW, WC_NONE, WDF_DEF_WIDGET, _news_type0_widgets)
static const Widget _message_history_widgets []
static const WindowDesc _message_history_desc (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)
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 (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)


Detailed Description

GUI functions related to news messages.

Definition in file news_gui.cpp.


Define Documentation

#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}
Macro to construct one news setting line in the news - settings window.

One line consists of four widgets, namely

  • A [<] button
  • A [...] label
  • A [>] button
  • A text label describing the news category Horizontal positions of the widgets are hard coded, vertical start position is (basey + linenum * 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

Parameters:
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.


Enumeration Type Documentation

anonymous enum

News settings window widget offset constants.

Enumerator:
WIDGET_NEWSOPT_DROP_SUMMARY  Dropdown that adjusts at once the level for all settings.
WIDGET_NEWSOPT_SOUNDTICKER  Button activating sound on events.
WIDGET_NEWSOPT_START_OPTION  First widget that is part of a group [<] .. [.].

Definition at line 792 of file news_gui.cpp.


Function Documentation

void AddNewsItem ( StringID  string,
NewsSubtype  subtype,
uint  data_a,
uint  data_b,
void *  free_data 
)

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.

Parameters:
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 '...'

Parameters:
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.


Variable Documentation

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 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.

struct NewsSubtypeData _news_subtype_data[NS_END] [static]

Initial value:

Data common to all news items of a given subtype (actual data).

Definition at line 123 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.

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.

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.

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 },  
}
Per-NewsType data.

Definition at line 149 of file news_gui.cpp.

Referenced by ConvertOldNewsSetting().


Generated on Sun Mar 15 22:49:56 2009 for openttd by  doxygen 1.5.6