2 |
2 |
3 /** @file intro_gui.cpp */ |
3 /** @file intro_gui.cpp */ |
4 |
4 |
5 #include "stdafx.h" |
5 #include "stdafx.h" |
6 #include "openttd.h" |
6 #include "openttd.h" |
7 #include "table/strings.h" |
|
8 #include "strings.h" |
|
9 #include "table/sprites.h" |
|
10 #include "functions.h" |
|
11 #include "window.h" |
|
12 #include "gui.h" |
7 #include "gui.h" |
13 #include "gfx.h" |
8 #include "window_gui.h" |
14 #include "player.h" |
9 #include "textbuf_gui.h" |
15 #include "network/network.h" |
10 #include "network/network.h" |
16 #include "variables.h" |
11 #include "variables.h" |
17 #include "settings.h" |
|
18 #include "heightmap.h" |
12 #include "heightmap.h" |
19 #include "genworld.h" |
13 #include "genworld.h" |
20 #include "network/network_gui.h" |
14 #include "network/network_gui.h" |
21 #include "newgrf.h" |
15 #include "newgrf.h" |
|
16 #include "strings_func.h" |
|
17 #include "window_func.h" |
|
18 #include "fios.h" |
|
19 #include "gfx_func.h" |
|
20 #include "settings_type.h" |
|
21 |
|
22 #include "table/strings.h" |
|
23 #include "table/sprites.h" |
22 |
24 |
23 static const Widget _select_game_widgets[] = { |
25 static const Widget _select_game_widgets[] = { |
24 { WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL}, |
26 { WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL}, |
25 { WWT_PANEL, RESIZE_NONE, 13, 0, 335, 14, 194, 0x0, STR_NULL}, |
27 { WWT_PANEL, RESIZE_NONE, 13, 0, 335, 14, 194, 0x0, STR_NULL}, |
26 { WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME}, |
28 { WWT_PUSHTXTBTN, RESIZE_NONE, 12, 10, 167, 22, 33, STR_0140_NEW_GAME, STR_02FB_START_A_NEW_GAME}, |
48 { |
50 { |
49 _opt_newgame.landscape = landscape; |
51 _opt_newgame.landscape = landscape; |
50 InvalidateWindowClasses(WC_SELECT_GAME); |
52 InvalidateWindowClasses(WC_SELECT_GAME); |
51 } |
53 } |
52 |
54 |
|
55 enum SelectGameIntroWidgets { |
|
56 SGI_GENERATE_GAME = 2, |
|
57 SGI_LOAD_GAME, |
|
58 SGI_PLAY_SCENARIO, |
|
59 SGI_PLAY_HEIGHTMAP, |
|
60 SGI_EDIT_SCENARIO, |
|
61 SGI_PLAY_NETWORK, |
|
62 SGI_TEMPERATE_LANDSCAPE, |
|
63 SGI_ARCTIC_LANDSCAPE, |
|
64 SGI_TROPIC_LANDSCAPE, |
|
65 SGI_TOYLAND_LANDSCAPE, |
|
66 SGI_OPTIONS, |
|
67 SGI_DIFFICULTIES, |
|
68 SGI_PATCHES_OPTIONS, |
|
69 SGI_GRF_SETTINGS, |
|
70 SGI_EXIT, |
|
71 }; |
|
72 |
53 static void SelectGameWndProc(Window *w, WindowEvent *e) |
73 static void SelectGameWndProc(Window *w, WindowEvent *e) |
54 { |
74 { |
55 switch (e->event) { |
75 switch (e->event) { |
56 case WE_CREATE: w->LowerWidget(_opt_newgame.landscape + 8); break; |
76 case WE_CREATE: w->LowerWidget(_opt_newgame.landscape + 8); break; |
57 |
77 |
58 case WE_PAINT: |
78 case WE_PAINT: |
59 w->SetWidgetLoweredState(8, _opt_newgame.landscape == LT_TEMPERATE); |
79 w->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _opt_newgame.landscape == LT_TEMPERATE); |
60 w->SetWidgetLoweredState(9, _opt_newgame.landscape == LT_ARCTIC); |
80 w->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _opt_newgame.landscape == LT_ARCTIC); |
61 w->SetWidgetLoweredState(10, _opt_newgame.landscape == LT_TROPIC); |
81 w->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _opt_newgame.landscape == LT_TROPIC); |
62 w->SetWidgetLoweredState(11, _opt_newgame.landscape == LT_TOYLAND); |
82 w->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _opt_newgame.landscape == LT_TOYLAND); |
63 SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level); |
83 SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level); |
64 DrawWindowWidgets(w); |
84 DrawWindowWidgets(w); |
65 break; |
85 break; |
66 |
86 |
67 case WE_CLICK: |
87 case WE_CLICK: |
68 #ifdef ENABLE_NETWORK |
88 #ifdef ENABLE_NETWORK |
69 /* Do not create a network server when you (just) have closed one of the game |
89 /* Do not create a network server when you (just) have closed one of the game |
70 * creation/load windows for the network server. */ |
90 * creation/load windows for the network server. */ |
71 if (2 <= e->we.click.widget && e->we.click.widget <= 6) _is_network_server = false; |
91 if (SGI_GENERATE_GAME <= e->we.click.widget && e->we.click.widget <= SGI_EDIT_SCENARIO) _is_network_server = false; |
72 #endif /* ENABLE_NETWORK */ |
92 #endif /* ENABLE_NETWORK */ |
73 |
93 |
74 switch (e->we.click.widget) { |
94 switch (e->we.click.widget) { |
75 case 2: ShowGenerateLandscape(); break; |
95 case SGI_GENERATE_GAME: ShowGenerateLandscape(); break; |
76 case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break; |
96 case SGI_LOAD_GAME: ShowSaveLoadDialog(SLD_LOAD_GAME); break; |
77 case 4: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; |
97 case SGI_PLAY_SCENARIO: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; |
78 case 5: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break; |
98 case SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break; |
79 case 6: StartScenarioEditor(); break; |
99 case SGI_EDIT_SCENARIO: StartScenarioEditor(); break; |
80 case 7: |
100 |
81 if (!_network_available) { |
101 case SGI_PLAY_NETWORK: |
82 ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); |
102 if (!_network_available) { |
83 } else { |
103 ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); |
84 ShowNetworkGameWindow(); |
104 } else { |
|
105 ShowNetworkGameWindow(); |
|
106 } |
|
107 break; |
|
108 |
|
109 case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE: |
|
110 case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE: |
|
111 w->RaiseWidget(_opt_newgame.landscape + SGI_TEMPERATE_LANDSCAPE); |
|
112 SetNewLandscapeType(e->we.click.widget - SGI_TEMPERATE_LANDSCAPE); |
|
113 break; |
|
114 |
|
115 case SGI_OPTIONS: ShowGameOptions(); break; |
|
116 case SGI_DIFFICULTIES: ShowGameDifficulty(); break; |
|
117 case SGI_PATCHES_OPTIONS: ShowPatchesSelection(); break; |
|
118 case SGI_GRF_SETTINGS: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break; |
|
119 case SGI_EXIT: HandleExitGameRequest(); break; |
85 } |
120 } |
86 break; |
121 break; |
87 case 8: case 9: case 10: case 11: |
|
88 w->RaiseWidget(_opt_newgame.landscape + 8); |
|
89 SetNewLandscapeType(e->we.click.widget - 8); |
|
90 break; |
|
91 case 12: ShowGameOptions(); break; |
|
92 case 13: ShowGameDifficulty(); break; |
|
93 case 14: ShowPatchesSelection(); break; |
|
94 case 15: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break; |
|
95 case 16: HandleExitGameRequest(); break; |
|
96 } |
|
97 break; |
|
98 } |
122 } |
99 } |
123 } |
100 |
124 |
101 static const WindowDesc _select_game_desc = { |
125 static const WindowDesc _select_game_desc = { |
102 WDP_CENTER, WDP_CENTER, 336, 195, 336, 195, |
126 WDP_CENTER, WDP_CENTER, 336, 195, 336, 195, |