src/subsidy_gui.cpp
changeset 8452 93186e0f15cb
parent 8320 6ffad7a5d242
child 8602 9e75e594a068
equal deleted inserted replaced
8451:21eef6f9f401 8452:93186e0f15cb
    90 
    90 
    91 	DrawWindowWidgets(w);
    91 	DrawWindowWidgets(w);
    92 
    92 
    93 	ConvertDateToYMD(_date, &ymd);
    93 	ConvertDateToYMD(_date, &ymd);
    94 
    94 
       
    95 	int width = w->width - 2;
    95 	y = 15;
    96 	y = 15;
    96 	x = 1;
    97 	x = 1;
    97 	DrawString(x, y, STR_2026_SUBSIDIES_ON_OFFER_FOR, TC_FROMSTRING);
    98 	DrawStringTruncated(x, y, STR_2026_SUBSIDIES_ON_OFFER_FOR, TC_FROMSTRING, width);
    98 	y += 10;
    99 	y += 10;
    99 	num = 0;
   100 	num = 0;
   100 
   101 
   101 	for (s = _subsidies; s != endof(_subsidies); s++) {
   102 	for (s = _subsidies; s != endof(_subsidies); s++) {
   102 		if (s->cargo_type != CT_INVALID && s->age < 12) {
   103 		if (s->cargo_type != CT_INVALID && s->age < 12) {
   103 			int x2;
   104 			int x2;
   104 
   105 
   105 			SetupSubsidyDecodeParam(s, 1);
   106 			SetupSubsidyDecodeParam(s, 1);
   106 			x2 = DrawString(x + 2, y, STR_2027_FROM_TO, TC_FROMSTRING);
   107 			x2 = DrawStringTruncated(x + 2, y, STR_2027_FROM_TO, TC_FROMSTRING, width);
   107 
   108 
   108 			SetDParam(0, _date - ymd.day + 384 - s->age * 32);
   109 			SetDParam(0, _date - ymd.day + 384 - s->age * 32);
   109 			DrawString(x2, y, STR_2028_BY, TC_FROMSTRING);
   110 			DrawStringTruncated(x2, y, STR_2028_BY, TC_FROMSTRING, width - x2);
   110 			y += 10;
   111 			y += 10;
   111 			num++;
   112 			num++;
   112 		}
   113 		}
   113 	}
   114 	}
   114 
   115 
   115 	if (num == 0) {
   116 	if (num == 0) {
   116 		DrawString(x + 2, y, STR_202A_NONE, TC_FROMSTRING);
   117 		DrawStringTruncated(x + 2, y, STR_202A_NONE, TC_FROMSTRING, width - 2);
   117 		y += 10;
   118 		y += 10;
   118 	}
   119 	}
   119 
   120 
   120 	DrawString(x, y + 1, STR_202B_SERVICES_ALREADY_SUBSIDISED, TC_FROMSTRING);
   121 	DrawStringTruncated(x, y + 1, STR_202B_SERVICES_ALREADY_SUBSIDISED, TC_FROMSTRING, width);
   121 	y += 10;
   122 	y += 10;
   122 	num = 0;
   123 	num = 0;
   123 
   124 
   124 	for (s = _subsidies; s != endof(_subsidies); s++) {
   125 	for (s = _subsidies; s != endof(_subsidies); s++) {
   125 		if (s->cargo_type != CT_INVALID && s->age >= 12) {
   126 		if (s->cargo_type != CT_INVALID && s->age >= 12) {
   128 			SetupSubsidyDecodeParam(s, 1);
   129 			SetupSubsidyDecodeParam(s, 1);
   129 
   130 
   130 			PlayerID player = GetStation(s->to)->owner;
   131 			PlayerID player = GetStation(s->to)->owner;
   131 			SetDParam(3, player);
   132 			SetDParam(3, player);
   132 
   133 
   133 			xt = DrawString(x + 2, y, STR_202C_FROM_TO, TC_FROMSTRING);
   134 			xt = DrawStringTruncated(x + 2, y, STR_202C_FROM_TO, TC_FROMSTRING, width - 2);
   134 
   135 
   135 			SetDParam(0, _date - ymd.day + 768 - s->age * 32);
   136 			SetDParam(0, _date - ymd.day + 768 - s->age * 32);
   136 			DrawString(xt, y, STR_202D_UNTIL, TC_FROMSTRING);
   137 			DrawStringTruncated(xt, y, STR_202D_UNTIL, TC_FROMSTRING, width - xt);
   137 			y += 10;
   138 			y += 10;
   138 			num++;
   139 			num++;
   139 		}
   140 		}
   140 	}
   141 	}
   141 
   142 
   142 	if (num == 0) DrawString(x + 2, y, STR_202A_NONE, TC_FROMSTRING);
   143 	if (num == 0) DrawStringTruncated(x + 2, y, STR_202A_NONE, TC_FROMSTRING, width - 2);
   143 }
   144 }
   144 
   145 
   145 static void SubsidiesListWndProc(Window *w, WindowEvent *e)
   146 static void SubsidiesListWndProc(Window *w, WindowEvent *e)
   146 {
   147 {
   147 	switch (e->event) {
   148 	switch (e->event) {
   156 		break;
   157 		break;
   157 	}
   158 	}
   158 }
   159 }
   159 
   160 
   160 static const Widget _subsidies_list_widgets[] = {
   161 static const Widget _subsidies_list_widgets[] = {
   161 {   WWT_CLOSEBOX,   RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,           STR_018B_CLOSE_WINDOW},
   162 {   WWT_CLOSEBOX, RESIZE_NONE,  13,   0,  10,   0,  13, STR_00C5,           STR_018B_CLOSE_WINDOW},
   162 {    WWT_CAPTION,   RESIZE_NONE, 13,  11, 617,   0,  13, STR_2025_SUBSIDIES, STR_018C_WINDOW_TITLE_DRAG_THIS},
   163 {    WWT_CAPTION, RESIZE_RIGHT, 13,  11, 307,   0,  13, STR_2025_SUBSIDIES, STR_018C_WINDOW_TITLE_DRAG_THIS},
   163 {  WWT_STICKYBOX,   RESIZE_NONE, 13, 618, 629,   0,  13, STR_NULL,           STR_STICKY_BUTTON},
   164 {  WWT_STICKYBOX, RESIZE_LR,    13, 308, 319,   0,  13, STR_NULL,           STR_STICKY_BUTTON},
   164 {      WWT_PANEL,   RESIZE_NONE, 13,   0, 629,  14, 126, 0x0,                STR_01FD_CLICK_ON_SERVICE_TO_CENTER},
   165 {      WWT_PANEL, RESIZE_RIGHT, 13,   0, 319,  14, 126, 0x0,                STR_01FD_CLICK_ON_SERVICE_TO_CENTER},
   165 {   WIDGETS_END},
   166 {   WIDGETS_END},
   166 };
   167 };
   167 
   168 
   168 static const WindowDesc _subsidies_list_desc = {
   169 static const WindowDesc _subsidies_list_desc = {
   169 	WDP_AUTO, WDP_AUTO, 630, 127, 630, 127,
   170 	WDP_AUTO, WDP_AUTO, 320, 127, 630, 127,
   170 	WC_SUBSIDIES_LIST, WC_NONE,
   171 	WC_SUBSIDIES_LIST, WC_NONE,
   171 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   172 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   172 	_subsidies_list_widgets,
   173 	_subsidies_list_widgets,
   173 	SubsidiesListWndProc
   174 	SubsidiesListWndProc
   174 };
   175 };