diff options
author | rubidium <rubidium@openttd.org> | 2008-05-19 09:18:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-05-19 09:18:51 +0000 |
commit | a1137fcdfe20d7a90cb98b5f0ae3a10a9fa6ddb7 (patch) | |
tree | 5dc2bcc3f518409e999f5c7252b2444648ddd455 /src | |
parent | b1e324dd47239b9870000580b8dbfe649f61f533 (diff) | |
download | openttd-a1137fcdfe20d7a90cb98b5f0ae3a10a9fa6ddb7.tar.xz |
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
Diffstat (limited to 'src')
-rw-r--r-- | src/news_gui.cpp | 45 | ||||
-rw-r--r-- | src/news_type.h | 9 |
2 files changed, 20 insertions, 34 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 31c6d6196..51ec29749 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -137,11 +137,6 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni) } -static DrawNewsCallbackProc * const _draw_news_callback[] = { - DrawNewsNewVehicleAvail, ///< DNC_VEHICLEAVAIL - DrawNewsBankrupcy, ///< DNC_BANKRUPCY -}; - /** * Data common to all news items of a given subtype (structure) */ @@ -149,7 +144,7 @@ struct NewsSubtypeData { NewsType type; ///< News category @see NewsType NewsMode display_mode; ///< Display mode value @see NewsMode NewsFlag flags; ///< Initial NewsFlags bits @see NewsFlag - NewsCallback callback; ///< Call-back function + DrawNewsCallbackProc *callback; ///< Call-back function }; /** @@ -157,24 +152,24 @@ struct NewsSubtypeData { */ static const struct NewsSubtypeData _news_subtype_data[NS_END] = { /* type, display_mode, flags, callback */ - { NT_ARRIVAL_PLAYER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, DNC_NONE }, ///< NS_ARRIVAL_PLAYER - { NT_ARRIVAL_OTHER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, DNC_NONE }, ///< NS_ARRIVAL_OTHER - { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_TILE, DNC_NONE }, ///< NS_ACCIDENT_TILE - { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_VEHICLE, DNC_NONE }, ///< NS_ACCIDENT_VEHICLE - { NT_COMPANY_INFO, NM_CALLBACK, NF_NONE, DNC_BANKRUPCY }, ///< NS_COMPANY_TROUBLE - { NT_COMPANY_INFO, NM_CALLBACK, NF_NONE, DNC_BANKRUPCY }, ///< NS_COMPANY_MERGER - { NT_COMPANY_INFO, NM_CALLBACK, NF_NONE, DNC_BANKRUPCY }, ///< NS_COMPANY_BANKRUPT - { NT_COMPANY_INFO, NM_CALLBACK, NF_TILE, DNC_BANKRUPCY }, ///< NS_COMPANY_NEW - { NT_OPENCLOSE, NM_THIN, NF_VIEWPORT|NF_TILE, DNC_NONE }, ///< NS_OPENCLOSE - { NT_ECONOMY, NM_NORMAL, NF_NONE, DNC_NONE }, ///< NS_ECONOMY - { NT_INDUSTRY_PLAYER, NM_THIN, NF_VIEWPORT|NF_TILE, DNC_NONE }, ///< NS_INDUSTRY_PLAYER - { NT_INDUSTRY_OTHER, NM_THIN, NF_VIEWPORT|NF_TILE, DNC_NONE }, ///< NS_INDUSTRY_OTHER - { NT_INDUSTRY_NOBODY, NM_THIN, NF_VIEWPORT|NF_TILE, DNC_NONE }, ///< NS_INDUSTRY_NOBODY - { NT_ADVICE, NM_SMALL, NF_VIEWPORT|NF_VEHICLE, DNC_NONE }, ///< NS_ADVICE - { NT_NEW_VEHICLES, NM_CALLBACK, NF_NONE, DNC_VEHICLEAVAIL }, ///< NS_NEW_VEHICLES - { NT_ACCEPTANCE, NM_SMALL, NF_VIEWPORT|NF_TILE, DNC_NONE }, ///< NS_ACCEPTANCE - { NT_SUBSIDIES, NM_NORMAL, NF_TILE|NF_TILE2, DNC_NONE }, ///< NS_SUBSIDIES - { NT_GENERAL, NM_NORMAL, NF_TILE, DNC_NONE }, ///< NS_GENERAL + { NT_ARRIVAL_PLAYER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ARRIVAL_PLAYER + { NT_ARRIVAL_OTHER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ARRIVAL_OTHER + { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_ACCIDENT_TILE + { NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ACCIDENT_VEHICLE + { NT_COMPANY_INFO, NM_CALLBACK, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_TROUBLE + { NT_COMPANY_INFO, NM_CALLBACK, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_MERGER + { NT_COMPANY_INFO, NM_CALLBACK, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_BANKRUPT + { NT_COMPANY_INFO, NM_CALLBACK, NF_TILE, DrawNewsBankrupcy }, ///< NS_COMPANY_NEW + { NT_OPENCLOSE, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_OPENCLOSE + { NT_ECONOMY, NM_NORMAL, NF_NONE, NULL }, ///< NS_ECONOMY + { NT_INDUSTRY_PLAYER, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_PLAYER + { NT_INDUSTRY_OTHER, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_OTHER + { NT_INDUSTRY_NOBODY, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_NOBODY + { NT_ADVICE, NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ADVICE + { NT_NEW_VEHICLES, NM_CALLBACK, NF_NONE, DrawNewsNewVehicleAvail }, ///< NS_NEW_VEHICLES + { NT_ACCEPTANCE, NM_SMALL, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_ACCEPTANCE + { NT_SUBSIDIES, NM_NORMAL, NF_TILE|NF_TILE2, NULL }, ///< NS_SUBSIDIES + { NT_GENERAL, NM_NORMAL, NF_TILE, NULL }, ///< NS_GENERAL }; /** Initialize the news-items data structures */ @@ -262,7 +257,7 @@ struct NewsWindow : Window { case NM_CALLBACK: this->DrawNewsBorder(); - _draw_news_callback[_news_subtype_data[this->ni->subtype].callback](this, ni); + (_news_subtype_data[this->ni->subtype].callback)(this, ni); break; default: diff --git a/src/news_type.h b/src/news_type.h index ad1d9ca94..4a34557f2 100644 --- a/src/news_type.h +++ b/src/news_type.h @@ -82,15 +82,6 @@ DECLARE_ENUM_AS_BIT_SET(NewsFlag); /** - * Special news items - */ -enum NewsCallback { - DNC_VEHICLEAVAIL = 0, ///< Show new vehicle available message. StringID is EngineID - DNC_BANKRUPCY = 1, ///< Show bankrupcy message. StringID is PlayerID (0-3) and NewsBankrupcy (4-7) - DNC_NONE = 0xFF, ///< No news callback. -}; - -/** * News display options */ enum NewsDisplay { |