src/news_gui.cpp
changeset 10603 891ea39eacbb
parent 10595 7957c71b0dfe
child 10607 1ab30cead125
equal deleted inserted replaced
10602:b6ae8f54d78f 10603:891ea39eacbb
    17 #include "sound_func.h"
    17 #include "sound_func.h"
    18 #include "string_func.h"
    18 #include "string_func.h"
    19 #include "widgets/dropdown_func.h"
    19 #include "widgets/dropdown_func.h"
    20 #include "map_func.h"
    20 #include "map_func.h"
    21 #include "statusbar_gui.h"
    21 #include "statusbar_gui.h"
       
    22 #include "player_face.h"
    22 
    23 
    23 #include "table/sprites.h"
    24 #include "table/sprites.h"
    24 #include "table/strings.h"
    25 #include "table/strings.h"
    25 
    26 
    26 /** @file news_gui.cpp
    27 /** @file news_gui.cpp
    71 static void MoveToNextItem();
    72 static void MoveToNextItem();
    72 
    73 
    73 
    74 
    74 typedef void DrawNewsCallbackProc(struct Window *w, const NewsItem *ni);
    75 typedef void DrawNewsCallbackProc(struct Window *w, const NewsItem *ni);
    75 void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni);
    76 void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni);
    76 void DrawNewsBankrupcy(Window *w, const NewsItem *ni);
    77 
       
    78 static void DrawNewsBankrupcy(Window *w, const NewsItem *ni)
       
    79 {
       
    80 	Player *p = GetPlayer((PlayerID)(ni->data_b));
       
    81 	DrawPlayerFace(p->face, p->player_color, 2, 23);
       
    82 	GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE));
       
    83 
       
    84 	SetDParam(0, p->index);
       
    85 
       
    86 	DrawStringMultiCenter(49, 148, STR_7058_PRESIDENT, 94);
       
    87 
       
    88 	switch (ni->subtype) {
       
    89 		case NS_COMPANY_TROUBLE:
       
    90 			DrawStringCentered(w->width >> 1, 1, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE, TC_FROMSTRING);
       
    91 
       
    92 			SetDParam(0, p->index);
       
    93 
       
    94 			DrawStringMultiCenter(
       
    95 				((w->width - 101) >> 1) + 98,
       
    96 				90,
       
    97 				STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED,
       
    98 				w->width - 101);
       
    99 			break;
       
   100 
       
   101 		case NS_COMPANY_MERGER:
       
   102 			DrawStringCentered(w->width >> 1, 1, STR_7059_TRANSPORT_COMPANY_MERGER, TC_FROMSTRING);
       
   103 			SetDParam(0, ni->params[2]);
       
   104 			SetDParam(1, p->index);
       
   105 			SetDParam(2, ni->params[4]);
       
   106 			DrawStringMultiCenter(
       
   107 				((w->width - 101) >> 1) + 98,
       
   108 				90,
       
   109 				ni->params[4] == 0 ? STR_707F_HAS_BEEN_TAKEN_OVER_BY : STR_705A_HAS_BEEN_SOLD_TO_FOR,
       
   110 				w->width - 101);
       
   111 			break;
       
   112 
       
   113 		case NS_COMPANY_BANKRUPT:
       
   114 			DrawStringCentered(w->width >> 1, 1, STR_705C_BANKRUPT, TC_FROMSTRING);
       
   115 			SetDParam(0, p->index);
       
   116 			DrawStringMultiCenter(
       
   117 				((w->width - 101) >> 1) + 98,
       
   118 				90,
       
   119 				STR_705D_HAS_BEEN_CLOSED_DOWN_BY,
       
   120 				w->width - 101);
       
   121 			break;
       
   122 
       
   123 		case NS_COMPANY_NEW:
       
   124 			DrawStringCentered(w->width >> 1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, TC_FROMSTRING);
       
   125 			SetDParam(0, p->index);
       
   126 			SetDParam(1, ni->params[3]);
       
   127 			DrawStringMultiCenter(
       
   128 				((w->width - 101) >> 1) + 98,
       
   129 				90,
       
   130 				STR_705F_STARTS_CONSTRUCTION_NEAR,
       
   131 				w->width - 101);
       
   132 			break;
       
   133 
       
   134 		default:
       
   135 			NOT_REACHED();
       
   136 	}
       
   137 }
       
   138 
    77 
   139 
    78 static DrawNewsCallbackProc * const _draw_news_callback[] = {
   140 static DrawNewsCallbackProc * const _draw_news_callback[] = {
    79 	DrawNewsNewVehicleAvail,  ///< DNC_VEHICLEAVAIL
   141 	DrawNewsNewVehicleAvail,  ///< DNC_VEHICLEAVAIL
    80 	DrawNewsBankrupcy,        ///< DNC_BANKRUPCY
   142 	DrawNewsBankrupcy,        ///< DNC_BANKRUPCY
    81 };
   143 };