misc_gui.c
changeset 4171 5c6e60c392c3
parent 4133 f9878fb9a365
child 4211 5ee54ab361c9
equal deleted inserted replaced
4170:81bafc4dd1b9 4171:5c6e60c392c3
    41 } LandInfoData;
    41 } LandInfoData;
    42 
    42 
    43 static void LandInfoWndProc(Window *w, WindowEvent *e)
    43 static void LandInfoWndProc(Window *w, WindowEvent *e)
    44 {
    44 {
    45 	if (e->event == WE_PAINT) {
    45 	if (e->event == WE_PAINT) {
    46 		const LandInfoData* lid;
    46 		const LandInfoData *lid;
    47 		StringID str;
    47 		StringID str;
    48 		int i;
    48 		int i;
    49 
    49 
    50 		DrawWindowWidgets(w);
    50 		DrawWindowWidgets(w);
    51 
    51 
   486 					120,
   486 					120,
   487 					30,
   487 					30,
   488 					_errmsg_message_1,
   488 					_errmsg_message_1,
   489 					238);
   489 					238);
   490 		} else {
   490 		} else {
   491 			const Player* p = GetPlayer(GetDParamX(_errmsg_decode_params,2));
   491 			const Player *p = GetPlayer(GetDParamX(_errmsg_decode_params,2));
   492 			DrawPlayerFace(p->face, p->player_color, 2, 16);
   492 			DrawPlayerFace(p->face, p->player_color, 2, 16);
   493 
   493 
   494 			DrawStringMultiCenter(
   494 			DrawStringMultiCenter(
   495 				214,
   495 				214,
   496 				(_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45),
   496 				(_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45),
   716 		GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
   716 		GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
   717 		DrawStationCoverageText(accepts, sx, sy, mask);
   717 		DrawStationCoverageText(accepts, sx, sy, mask);
   718 	}
   718 	}
   719 }
   719 }
   720 
   720 
   721 void CheckRedrawStationCoverage(const Window* w)
   721 void CheckRedrawStationCoverage(const Window *w)
   722 {
   722 {
   723 	if (_thd.dirty & 1) {
   723 	if (_thd.dirty & 1) {
   724 		_thd.dirty &= ~1;
   724 		_thd.dirty &= ~1;
   725 		SetWindowDirty(w);
   725 		SetWindowDirty(w);
   726 	}
   726 	}
  1195 	uint sort_start = 0;
  1195 	uint sort_start = 0;
  1196 	uint sort_end = 0;
  1196 	uint sort_end = 0;
  1197 	uint s_amount;
  1197 	uint s_amount;
  1198 	int i;
  1198 	int i;
  1199 
  1199 
  1200 	/*	Directories are always above the files (FIOS_TYPE_DIR)
  1200 	/* Directories are always above the files (FIOS_TYPE_DIR)
  1201 	 *	Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
  1201 	 * Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
  1202 	 *	Only sort savegames/scenarios, not directories
  1202 	 * Only sort savegames/scenarios, not directories
  1203 	 */
  1203 	 */
  1204 	for (i = 0; i < _fios_num; i++) {
  1204 	for (i = 0; i < _fios_num; i++) {
  1205 		switch (_fios_list[i].type) {
  1205 		switch (_fios_list[i].type) {
  1206 			case FIOS_TYPE_DIR:    sort_start++; break;
  1206 			case FIOS_TYPE_DIR:    sort_start++; break;
  1207 			case FIOS_TYPE_PARENT: sort_start++; break;
  1207 			case FIOS_TYPE_PARENT: sort_start++; break;
  1216 
  1216 
  1217 static void GenerateFileName(void)
  1217 static void GenerateFileName(void)
  1218 {
  1218 {
  1219 	/* Check if we are not a specatator who wants to generate a name..
  1219 	/* Check if we are not a specatator who wants to generate a name..
  1220 	    Let's use the name of player #0 for now. */
  1220 	    Let's use the name of player #0 for now. */
  1221 	const Player* p = GetPlayer(_local_player < MAX_PLAYERS ? _local_player : 0);
  1221 	const Player *p = GetPlayer(_local_player < MAX_PLAYERS ? _local_player : 0);
  1222 
  1222 
  1223 	SetDParam(0, p->name_1);
  1223 	SetDParam(0, p->name_1);
  1224 	SetDParam(1, p->name_2);
  1224 	SetDParam(1, p->name_2);
  1225 	SetDParam(2, _date);
  1225 	SetDParam(2, _date);
  1226 	GetString(_edit_str_buf, STR_4004);
  1226 	GetString(_edit_str_buf, STR_4004);
  1272 			15, 16
  1272 			15, 16
  1273 		);
  1273 		);
  1274 
  1274 
  1275 		y = w->widget[7].top + 1;
  1275 		y = w->widget[7].top + 1;
  1276 		for (pos = w->vscroll.pos; pos < _fios_num; pos++) {
  1276 		for (pos = w->vscroll.pos; pos < _fios_num; pos++) {
  1277 			const FiosItem* item = _fios_list + pos;
  1277 			const FiosItem *item = _fios_list + pos;
  1278 
  1278 
  1279 			DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->width - 18);
  1279 			DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->width - 18);
  1280 			y += 10;
  1280 			y += 10;
  1281 			if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break;
  1281 			if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break;
  1282 		}
  1282 		}
  1501 {  WWT_SCROLLBAR,    RESIZE_LRB,     7,   245,   256,    26,   307, 0x0,								STR_0190_SCROLL_BAR_SCROLLS_LIST},
  1501 {  WWT_SCROLLBAR,    RESIZE_LRB,     7,   245,   256,    26,   307, 0x0,								STR_0190_SCROLL_BAR_SCROLLS_LIST},
  1502 {  WWT_RESIZEBOX,   RESIZE_LRTB,     7,   245,   256,   308,   319, 0x0,								STR_RESIZE_BUTTON},
  1502 {  WWT_RESIZEBOX,   RESIZE_LRTB,     7,   245,   256,   308,   319, 0x0,								STR_RESIZE_BUTTON},
  1503 {   WIDGETS_END},
  1503 {   WIDGETS_END},
  1504 };
  1504 };
  1505 
  1505 
  1506 static void SelectScenarioWndProc(Window* w, WindowEvent* e)
  1506 static void SelectScenarioWndProc(Window *w, WindowEvent *e)
  1507 {
  1507 {
  1508 	const int list_start = 45;
  1508 	const int list_start = 45;
  1509 
  1509 
  1510 	switch (e->event) {
  1510 	switch (e->event) {
  1511 	case WE_PAINT: {
  1511 	case WE_PAINT: {
  1558 		case 6: /* Click the listbox */
  1558 		case 6: /* Click the listbox */
  1559 			if (e->click.pt.y < list_start) {
  1559 			if (e->click.pt.y < list_start) {
  1560 				GenRandomNewGame(Random(), InteractiveRandom());
  1560 				GenRandomNewGame(Random(), InteractiveRandom());
  1561 			} else {
  1561 			} else {
  1562 				int y = (e->click.pt.y - list_start) / 10;
  1562 				int y = (e->click.pt.y - list_start) / 10;
  1563 				const char* name;
  1563 				const char *name;
  1564 				const FiosItem *file;
  1564 				const FiosItem *file;
  1565 
  1565 
  1566 				if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return;
  1566 				if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return;
  1567 
  1567 
  1568 				file = _fios_list + y;
  1568 				file = _fios_list + y;