1000 static void ToolbarScenDateBackward(Window *w) |
998 static void ToolbarScenDateBackward(Window *w) |
1001 { |
999 { |
1002 // don't allow too fast scrolling |
1000 // don't allow too fast scrolling |
1003 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
1001 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
1004 HandleButtonClick(w, 6); |
1002 HandleButtonClick(w, 6); |
1005 InvalidateWidget(w, 5); |
1003 SetWindowDirty(w); |
1006 |
1004 |
1007 if (_date > MinDate) SetDate(ConvertYMDToDate(_cur_year - 1, 0, 1)); |
1005 _patches_newgame.starting_year = clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR); |
|
1006 SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
1008 } |
1007 } |
1009 _left_button_clicked = false; |
1008 _left_button_clicked = false; |
1010 } |
1009 } |
1011 |
1010 |
1012 static void ToolbarScenDateForward(Window *w) |
1011 static void ToolbarScenDateForward(Window *w) |
1013 { |
1012 { |
1014 // don't allow too fast scrolling |
1013 // don't allow too fast scrolling |
1015 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
1014 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
1016 HandleButtonClick(w, 7); |
1015 HandleButtonClick(w, 7); |
1017 InvalidateWidget(w, 5); |
1016 SetWindowDirty(w); |
1018 |
1017 |
1019 if (_date < MaxDate) SetDate(ConvertYMDToDate(_cur_year + 1, 0, 1)); |
1018 _patches_newgame.starting_year = clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR); |
|
1019 SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
1020 } |
1020 } |
1021 _left_button_clicked = false; |
1021 _left_button_clicked = false; |
1022 } |
1022 } |
1023 |
1023 |
1024 static void ToolbarScenMapTownDir(Window *w) |
1024 static void ToolbarScenMapTownDir(Window *w) |
1049 |
1049 |
1050 assert(w != 0); |
1050 assert(w != 0); |
1051 |
1051 |
1052 vp = w->viewport; |
1052 vp = w->viewport; |
1053 |
1053 |
1054 if (_game_mode != GM_MENU) { |
1054 if (_game_mode != GM_MENU && !IsGeneratingWorld()) { |
1055 if ((in && vp->zoom == 0) || (!in && vp->zoom == 2)) |
1055 if ((in && vp->zoom == 0) || (!in && vp->zoom == 2)) |
1056 return; |
1056 return; |
1057 |
1057 |
1058 pt = GetTileZoomCenterWindow(in,w); |
1058 pt = GetTileZoomCenterWindow(in,w); |
1059 if (pt.x != -1) { |
1059 if (pt.x != -1) { |
1060 ScrollWindowTo(pt.x, pt.y, w); |
1060 ScrollWindowTo(pt.x, pt.y, w); |
1061 |
1061 |
1062 DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w); |
1062 DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w); |
1063 } |
1063 } |
1064 } |
1064 } |
1065 } |
|
1066 |
|
1067 static void ResetLandscape(void) |
|
1068 { |
|
1069 _random_seeds[0][0] = InteractiveRandom(); |
|
1070 _random_seeds[0][1] = InteractiveRandom(); |
|
1071 |
|
1072 GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y); |
|
1073 MarkWholeScreenDirty(); |
|
1074 } |
|
1075 |
|
1076 static const Widget _ask_reset_landscape_widgets[] = { |
|
1077 { WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
1078 { WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_022C_RESET_LANDSCAPE, STR_NULL}, |
|
1079 { WWT_IMGBTN, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL}, |
|
1080 { WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL}, |
|
1081 { WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL}, |
|
1082 { WIDGETS_END}, |
|
1083 }; |
|
1084 |
|
1085 // Ask first to reset landscape or to make a random landscape |
|
1086 static void AskResetLandscapeWndProc(Window *w, WindowEvent *e) |
|
1087 { |
|
1088 uint mode = w->window_number; |
|
1089 |
|
1090 switch (e->event) { |
|
1091 case WE_PAINT: |
|
1092 DrawWindowWidgets(w); |
|
1093 DrawStringMultiCenter( |
|
1094 90, 38, |
|
1095 mode ? STR_022D_ARE_YOU_SURE_YOU_WANT_TO : STR_GENERATE_RANDOM_LANDSCAPE, |
|
1096 168 |
|
1097 ); |
|
1098 break; |
|
1099 case WE_CLICK: |
|
1100 switch (e->click.widget) { |
|
1101 case 3: |
|
1102 DeleteWindow(w); |
|
1103 break; |
|
1104 case 4: |
|
1105 DeleteWindow(w); |
|
1106 DeleteWindowByClass(WC_INDUSTRY_VIEW); |
|
1107 DeleteWindowByClass(WC_TOWN_VIEW); |
|
1108 DeleteWindowByClass(WC_LAND_INFO); |
|
1109 |
|
1110 if (mode) { // reset landscape |
|
1111 ResetLandscape(); |
|
1112 } else { // make random landscape |
|
1113 SndPlayFx(SND_15_BEEP); |
|
1114 _switch_mode = SM_GENRANDLAND; |
|
1115 } |
|
1116 break; |
|
1117 } |
|
1118 break; |
|
1119 } |
|
1120 } |
|
1121 |
|
1122 static const WindowDesc _ask_reset_landscape_desc = { |
|
1123 230,205, 180, 92, |
|
1124 WC_ASK_RESET_LANDSCAPE,0, |
|
1125 WDF_STD_BTN | WDF_DEF_WIDGET, |
|
1126 _ask_reset_landscape_widgets, |
|
1127 AskResetLandscapeWndProc, |
|
1128 }; |
|
1129 |
|
1130 static void AskResetLandscape(uint mode) |
|
1131 { |
|
1132 AllocateWindowDescFront(&_ask_reset_landscape_desc, mode); |
|
1133 } |
1065 } |
1134 |
1066 |
1135 // TODO - Incorporate into game itself to allow for ingame raising/lowering of |
1067 // TODO - Incorporate into game itself to allow for ingame raising/lowering of |
1136 // larger chunks at the same time OR remove altogether, as we have 'level land' ? |
1068 // larger chunks at the same time OR remove altogether, as we have 'level land' ? |
1137 /** |
1069 /** |
1236 |
1168 |
1237 static const Widget _scen_edit_land_gen_widgets[] = { |
1169 static const Widget _scen_edit_land_gen_widgets[] = { |
1238 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1170 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1239 { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0223_LAND_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1171 { WWT_CAPTION, RESIZE_NONE, 7, 11, 169, 0, 13, STR_0223_LAND_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1240 { WWT_STICKYBOX, RESIZE_NONE, 7, 170, 181, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
1172 { WWT_STICKYBOX, RESIZE_NONE, 7, 170, 181, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
1241 { WWT_IMGBTN, RESIZE_NONE, 7, 0, 181, 14, 101, STR_NULL, STR_NULL}, |
1173 { WWT_IMGBTN, RESIZE_NONE, 7, 0, 181, 14, 95, STR_NULL, STR_NULL}, |
1242 |
|
1243 { WWT_IMGBTN, RESIZE_NONE, 14, 2, 23, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
1174 { WWT_IMGBTN, RESIZE_NONE, 14, 2, 23, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
1244 { WWT_IMGBTN, RESIZE_NONE, 14, 24, 45, 14, 35, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND}, |
1175 { WWT_IMGBTN, RESIZE_NONE, 14, 24, 45, 14, 35, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND}, |
1245 { WWT_IMGBTN, RESIZE_NONE, 14, 46, 67, 14, 35, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND}, |
1176 { WWT_IMGBTN, RESIZE_NONE, 14, 46, 67, 14, 35, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND}, |
1246 { WWT_IMGBTN, RESIZE_NONE, 14, 68, 89, 14, 35, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP}, |
1177 { WWT_IMGBTN, RESIZE_NONE, 14, 68, 89, 14, 35, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP}, |
1247 { WWT_IMGBTN, RESIZE_NONE, 14, 90, 111, 14, 35, SPR_IMG_BUILD_CANAL, STR_CREATE_LAKE}, |
1178 { WWT_IMGBTN, RESIZE_NONE, 14, 90, 111, 14, 35, SPR_IMG_BUILD_CANAL, STR_CREATE_LAKE}, |
1248 { WWT_IMGBTN, RESIZE_NONE, 14, 112, 134, 14, 35, SPR_IMG_ROCKS, STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE}, |
1179 { WWT_IMGBTN, RESIZE_NONE, 14, 112, 134, 14, 35, SPR_IMG_ROCKS, STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE}, |
1249 { WWT_IMGBTN, RESIZE_NONE, 14, 135, 157, 14, 35, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, // XXX - dynamic |
1180 { WWT_IMGBTN, RESIZE_NONE, 14, 135, 157, 14, 35, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, // XXX - dynamic |
1250 { WWT_IMGBTN, RESIZE_NONE, 14, 158, 179, 14, 35, SPR_IMG_TRANSMITTER, STR_028E_PLACE_TRANSMITTER}, |
1181 { WWT_IMGBTN, RESIZE_NONE, 14, 158, 179, 14, 35, SPR_IMG_TRANSMITTER, STR_028E_PLACE_TRANSMITTER}, |
1251 { WWT_TEXTBTN, RESIZE_NONE, 14, 139, 149, 43, 54, STR_0224, STR_0228_INCREASE_SIZE_OF_LAND_AREA}, |
1182 { WWT_TEXTBTN, RESIZE_NONE, 14, 139, 149, 43, 54, STR_0224, STR_0228_INCREASE_SIZE_OF_LAND_AREA}, |
1252 { WWT_TEXTBTN, RESIZE_NONE, 14, 139, 149, 56, 67, STR_0225, STR_0229_DECREASE_SIZE_OF_LAND_AREA}, |
1183 { WWT_TEXTBTN, RESIZE_NONE, 14, 139, 149, 56, 67, STR_0225, STR_0229_DECREASE_SIZE_OF_LAND_AREA}, |
1253 { WWT_TEXTBTN, RESIZE_NONE, 14, 34, 149, 75, 86, STR_0226_RANDOM_LAND, STR_022A_GENERATE_RANDOM_LAND}, |
1184 { WWT_TEXTBTN, RESIZE_NONE, 14, 34, 149, 75, 86, STR_SE_NEW_WORLD, STR_022A_GENERATE_RANDOM_LAND}, |
1254 { WWT_TEXTBTN, RESIZE_NONE, 14, 34, 149, 88, 99, STR_0227_RESET_LAND, STR_022B_RESET_LANDSCAPE}, |
|
1255 { WIDGETS_END}, |
1185 { WIDGETS_END}, |
1256 }; |
1186 }; |
1257 |
1187 |
1258 static const int8 _multi_terraform_coords[][2] = { |
1188 static const int8 _multi_terraform_coords[][2] = { |
1259 { 0, -2}, |
1189 { 0, -2}, |
2078 GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2); |
2005 GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2); |
2079 GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | PALETTE_MODIFIER_GREYOUT); |
2006 GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | PALETTE_MODIFIER_GREYOUT); |
2080 |
2007 |
2081 DrawWindowWidgets(w); |
2008 DrawWindowWidgets(w); |
2082 |
2009 |
2083 SetDParam(0, _date); |
2010 SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
2084 DrawStringCentered(298, 6, STR_00AF, 0); |
2011 DrawStringCentered(298, 6, STR_00AF, 0); |
2085 |
2012 |
2086 SetDParam(0, _date); |
2013 SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
2087 DrawStringCentered(161, 1, STR_0221_OPENTTD, 0); |
2014 DrawStringCentered(161, 1, STR_0221_OPENTTD, 0); |
2088 DrawStringCentered(161, 11,STR_0222_SCENARIO_EDITOR, 0); |
2015 DrawStringCentered(161, 11,STR_0222_SCENARIO_EDITOR, 0); |
2089 |
2016 |
2090 break; |
2017 break; |
2091 |
2018 |
2433 break; |
2360 break; |
2434 case GM_EDITOR: |
2361 case GM_EDITOR: |
2435 w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL); |
2362 w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL); |
2436 AssignWindowViewport(w, 0, 0, width, height, 0, 0); |
2363 AssignWindowViewport(w, 0, 0, width, height, 0, 0); |
2437 |
2364 |
2438 w = AllocateWindowDesc(&_toolb_scen_desc); |
2365 ShowVitalWindows(); |
2439 w->disabled_state = 1 << 9; |
|
2440 CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
|
2441 |
|
2442 PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_scen_desc) |
|
2443 break; |
2366 break; |
2444 default: |
2367 default: |
2445 NOT_REACHED(); |
2368 NOT_REACHED(); |
2446 } |
2369 } |
2447 } |
2370 } |
2448 |
2371 |
2449 void ShowVitalWindows(void) |
2372 void ShowVitalWindows(void) |
2450 { |
2373 { |
2451 Window *w; |
2374 Window *w; |
2452 |
2375 |
2453 w = AllocateWindowDesc(&_toolb_normal_desc); |
2376 if (_game_mode != GM_EDITOR) { |
2454 w->disabled_state = 1 << 17; // disable zoom-in button (by default game is zoomed in) |
2377 w = AllocateWindowDesc(&_toolb_normal_desc); |
|
2378 /* Disable zoom-in for normal things, and zoom-out if we come |
|
2379 * from world-generating. */ |
|
2380 w->disabled_state = IsGeneratingWorld() ? (1 << 18) : (1 << 17); |
|
2381 } else { |
|
2382 w = AllocateWindowDesc(&_toolb_scen_desc); |
|
2383 /* Disable zoom-in for normal things, and zoom-out if we come |
|
2384 * from world-generating. */ |
|
2385 w->disabled_state = IsGeneratingWorld() ? (1 << 10) : (1 << 9); |
|
2386 } |
2455 CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
2387 CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
2456 |
2388 |
2457 if (_networking) { // if networking, disable fast-forward button |
2389 if (_networking) { |
|
2390 /* If networking, disable fast-forward button */ |
2458 SETBIT(w->disabled_state, 1); |
2391 SETBIT(w->disabled_state, 1); |
2459 if (!_network_server) // if not server, disable pause button |
2392 /* If not server, disable pause button */ |
2460 SETBIT(w->disabled_state, 0); |
2393 if (!_network_server) SETBIT(w->disabled_state, 0); |
2461 } |
2394 } |
2462 |
2395 |
2463 PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_normal_desc) |
2396 /* 'w' is for sure a WC_MAIN_TOOLBAR */ |
|
2397 PositionMainToolbar(w); |
|
2398 |
|
2399 /* Status bad only for normal games */ |
|
2400 if (_game_mode == GM_EDITOR) return; |
2464 |
2401 |
2465 _main_status_desc.top = _screen.height - 12; |
2402 _main_status_desc.top = _screen.height - 12; |
2466 w = AllocateWindowDesc(&_main_status_desc); |
2403 w = AllocateWindowDesc(&_main_status_desc); |
2467 CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
2404 CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
2468 |
2405 |