summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-12-29 17:56:34 +0000
committerDarkvater <Darkvater@openttd.org>2006-12-29 17:56:34 +0000
commit40c2fd5d8beb41c4bee6f69a17a1f1f0859f9a6c (patch)
tree28e65a134012fb239160a1350ca05cc3cb89cb7d
parenta7f2b8095f09bc0d032f0c6f0d35c41c26e95bda (diff)
downloadopenttd-40c2fd5d8beb41c4bee6f69a17a1f1f0859f9a6c.tar.xz
(svn r7622) -Codechange: Convert some more windows to ShowQuery. This includes the depot
sell-all popup, quit/abandon game. The language files committed in r7619 go with this.
-rw-r--r--depot_gui.c104
-rw-r--r--intro_gui.c105
-rw-r--r--lang/english.txt19
3 files changed, 43 insertions, 185 deletions
diff --git a/depot_gui.c b/depot_gui.c
index 2ce1096f3..1f27f6b13 100644
--- a/depot_gui.c
+++ b/depot_gui.c
@@ -142,89 +142,12 @@ static inline void ShowVehicleViewWindow(const Vehicle *v)
}
}
-static void DepotSellAllWndProc(Window *w, WindowEvent *e)
+static void DepotSellAllConfirmationCallback(Window *w, bool confirmed)
{
- TileIndex tile = w->window_number;
- byte vehicle_type = WP(w, depot_d).type;
-
- switch (e->event) {
- case WE_PAINT:
- if (vehicle_type == VEH_Aircraft) {
- SetDParam(0, GetStationIndex(tile)); // Airport name
- } else {
- Depot *depot = GetDepotByTile(tile);
- assert(depot != NULL);
-
- SetDParam(0, depot->town_index);
- }
- DrawWindowWidgets(w);
-
- DrawStringCentered(150, 25, STR_DEPOT_SELL_ALL_VEHICLE_CONFIRM, 0);
- DrawStringCentered(150, 38, STR_ARE_YOU_SURE, 0);
- break;
-
- case WE_CLICK:
- switch (e->we.click.widget) {
- case 4:
- DoCommandP(tile, vehicle_type, 0, NULL, CMD_DEPOT_SELL_ALL_VEHICLES);
- /* Fallthrough */
- case 3:
- DeleteWindow(w);
- break;
- }
- break;
- }
-}
-
-static const Widget _depot_sell_all_widgets[] = {
- { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
- { WWT_CAPTION, RESIZE_NONE, 14, 11, 299, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS},
- { WWT_PANEL, RESIZE_NONE, 14, 0, 299, 14, 71, 0x0, STR_NULL},
- { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 85, 144, 52, 63, STR_012E_CANCEL, STR_NULL},
- { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 155, 214, 52, 63, STR_SELL, STR_NULL},
- { WIDGETS_END},
-};
-
-static const WindowDesc _depot_sell_all_desc = {
- WDP_CENTER, WDP_CENTER, 300, 72,
- WC_DEPOT_SELL_ALL, WC_VEHICLE_DEPOT,
- WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
- _depot_sell_all_widgets,
- DepotSellAllWndProc
-};
-
-static void ShowDepotSellAllWindow(TileIndex tile, byte type)
-{
- Window *w = AllocateWindowDescFront(&_depot_sell_all_desc, tile);
-
- if (w != NULL) {
- w->caption_color = GetTileOwner(tile);
- WP(w, depot_d).type = type;
- switch (type) {
- case VEH_Train:
- w->widget[1].data = STR_8800_TRAIN_DEPOT;
- w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_TRAIN_TIP;
- w->widget[4].tooltips = STR_DEPOT_SELL_ALL_TRAIN_TIP;
- break;
-
- case VEH_Road:
- w->widget[1].data = STR_9003_ROAD_VEHICLE_DEPOT;
- w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_ROADVEH_TIP;
- w->widget[4].tooltips = STR_DEPOT_SELL_ALL_ROADVEH_TIP;
- break;
-
- case VEH_Ship:
- w->widget[1].data = STR_9803_SHIP_DEPOT;
- w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_SHIP_TIP;
- w->widget[4].tooltips = STR_DEPOT_SELL_ALL_SHIP_TIP;
- break;
-
- case VEH_Aircraft:
- w->widget[1].data = STR_A002_AIRCRAFT_HANGAR;
- w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_AIRCRAFT_TIP;
- w->widget[4].tooltips = STR_DEPOT_SELL_ALL_AIRCRAFT_TIP;
- break;
- }
+ if (confirmed) {
+ TileIndex tile = w->window_number;
+ byte vehtype = WP(w, depot_d).type;
+ DoCommandP(tile, vehtype, 0, NULL, CMD_DEPOT_SELL_ALL_VEHICLES);
}
}
@@ -849,7 +772,22 @@ static void DepotWndProc(Window *w, WindowEvent *e)
case DEPOT_WIDGET_SELL_ALL:
/* Only open the confimation window if there are anything to sell */
if (WP(w, depot_d).engine_count != 0 || WP(w, depot_d).wagon_count != 0) {
- ShowDepotSellAllWindow(w->window_number, WP(w, depot_d).type);
+ static const StringID confirm_captions[] = {
+ STR_8800_TRAIN_DEPOT,
+ STR_9003_ROAD_VEHICLE_DEPOT,
+ STR_9803_SHIP_DEPOT,
+ STR_A002_AIRCRAFT_HANGAR
+ };
+ TileIndex tile = w->window_number;
+ byte vehtype = WP(w, depot_d).type - VEH_Train;
+
+ SetDParam(0, (vehtype == VEH_Aircraft) ? GetStationIndex(tile) : GetDepotByTile(tile)->town_index);
+ ShowQuery(
+ confirm_captions[vehtype],
+ STR_DEPOT_SELL_CONFIRMATION_TEXT,
+ w,
+ DepotSellAllConfirmationCallback
+ );
}
break;
diff --git a/intro_gui.c b/intro_gui.c
index 9d0198d44..32e345aa4 100644
--- a/intro_gui.c
+++ b/intro_gui.c
@@ -106,20 +106,13 @@ void ShowSelectGameWindow(void)
AllocateWindowDesc(&_select_game_desc);
}
-static const Widget _ask_abandon_game_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_00C7_QUIT, STR_NULL},
-{ WWT_PANEL, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL},
-{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL},
-{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL},
-{ WIDGETS_END },
-};
+static void AskExitGameCallback(Window *w, bool confirmed)
+{
+ if (confirmed) _exit_game = true;
+}
-static void AskAbandonGameWndProc(Window *w, WindowEvent *e)
+void AskExitGame(void)
{
- switch (e->event) {
- case WE_PAINT:
- DrawWindowWidgets(w);
#if defined(_WIN32)
SetDParam(0, STR_0133_WINDOWS);
#elif defined(__APPLE__)
@@ -135,86 +128,26 @@ static void AskAbandonGameWndProc(Window *w, WindowEvent *e)
#else
SetDParam(0, STR_0134_UNIX);
#endif
- DrawStringMultiCenter(90, 38, STR_00CA_ARE_YOU_SURE_YOU_WANT_TO, 178);
- return;
-
- case WE_CLICK:
- switch (e->we.click.widget) {
- case 3: DeleteWindow(w); break;
- case 4: _exit_game = true; break;
- }
- break;
-
- case WE_KEYPRESS: /* Exit game on pressing 'Enter' */
- switch (e->we.keypress.keycode) {
- case WKC_RETURN:
- case WKC_NUM_ENTER:
- _exit_game = true;
- break;
- }
- break;
- }
+ ShowQuery(
+ STR_00C7_QUIT,
+ STR_00CA_ARE_YOU_SURE_YOU_WANT_TO,
+ NULL,
+ AskExitGameCallback
+ );
}
-static const WindowDesc _ask_abandon_game_desc = {
- WDP_CENTER, WDP_CENTER, 180, 92,
- WC_ASK_ABANDON_GAME,0,
- WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
- _ask_abandon_game_widgets,
- AskAbandonGameWndProc
-};
-void AskExitGame(void)
+static void AskExitToGameMenuCallback(Window *w, bool confirmed)
{
- AllocateWindowDescFront(&_ask_abandon_game_desc, 0);
+ if (confirmed) _switch_mode = SM_MENU;
}
-
-static const Widget _ask_quit_game_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 4, 11, 179, 0, 13, STR_0161_QUIT_GAME, STR_NULL},
-{ WWT_PANEL, RESIZE_NONE, 4, 0, 179, 14, 91, 0x0, STR_NULL},
-{ WWT_TEXTBTN, RESIZE_NONE, 12, 25, 84, 72, 83, STR_00C9_NO, STR_NULL},
-{ WWT_TEXTBTN, RESIZE_NONE, 12, 95, 154, 72, 83, STR_00C8_YES, STR_NULL},
-{ WIDGETS_END },
-};
-
-static void AskQuitGameWndProc(Window *w, WindowEvent *e)
-{
- switch (e->event) {
- case WE_PAINT:
- DrawWindowWidgets(w);
- DrawStringMultiCenter(
- 90, 38,
- _game_mode != GM_EDITOR ?
- STR_0160_ARE_YOU_SURE_YOU_WANT_TO : STR_029B_ARE_YOU_SURE_YOU_WANT_TO,
- 178
- );
- break;
-
- case WE_CLICK:
- switch (e->we.click.widget) {
- case 3: DeleteWindow(w); break;
- case 4: _switch_mode = SM_MENU; break;
- }
- break;
-
- case WE_KEYPRESS: /* Return to main menu on pressing 'Enter' */
- if (e->we.keypress.keycode == WKC_RETURN) _switch_mode = SM_MENU;
- break;
- }
-}
-
-static const WindowDesc _ask_quit_game_desc = {
- WDP_CENTER, WDP_CENTER, 180, 92,
- WC_QUIT_GAME,0,
- WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
- _ask_quit_game_widgets,
- AskQuitGameWndProc
-};
-
-
void AskExitToGameMenu(void)
{
- AllocateWindowDescFront(&_ask_quit_game_desc, 0);
+ ShowQuery(
+ STR_0161_QUIT_GAME,
+ (_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_QUIT_SCENARIO_QUERY,
+ NULL,
+ AskExitToGameMenuCallback
+ );
}
diff --git a/lang/english.txt b/lang/english.txt
index 59d22d20d..8a5ff5cd7 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -359,7 +359,7 @@ STR_015C_SAVE_GAME :Save game
STR_015D_LOAD_GAME :Load game
STR_015E_QUIT_GAME :Abandon game
STR_015F_QUIT :Exit
-STR_0160_ARE_YOU_SURE_YOU_WANT_TO :{YELLOW}Are you sure you want to abandon this game?
+STR_ABANDON_GAME_QUERY :{YELLOW}Are you sure you want to abandon this game?
STR_0161_QUIT_GAME :{WHITE}Abandon Game
STR_SORT_ORDER_TIP :{BLACK}Select sorting order (descending/ascending)
STR_SORT_CRITERIA_TIP :{BLACK}Select sorting criteria
@@ -738,7 +738,7 @@ STR_0299_SAVE_SCENARIO :{WHITE}Save Sce
STR_029A_PLAY_SCENARIO :{BLACK}Play Scenario
STR_PLAY_HEIGHTMAP :{BLACK}Play Heightmap
STR_PLAY_HEIGHTMAP_HINT :{BLACK}Start a new game, using a heightmap as landscape
-STR_029B_ARE_YOU_SURE_YOU_WANT_TO :{YELLOW}Are you sure you want to quit this scenario ?
+STR_QUIT_SCENARIO_QUERY :{YELLOW}Are you sure you want to quit this scenario ?
STR_029C_QUIT_EDITOR :{WHITE}Quit Editor
STR_029D_CAN_ONLY_BE_BUILT_IN_TOWNS :{WHITE}...can only be built in towns with a population of at least 1200
STR_029E_MOVE_THE_STARTING_DATE :{BLACK}Move the starting date backward 1 year
@@ -2946,20 +2946,7 @@ STR_VEH_WITH_SHARED_ORDERS_LIST :{WHITE}Shared o
STR_VEH_WITH_SHARED_ORDERS_LIST_TIP :{BLACK}Show all vehicles that share this schedule
### depot strings
-
-STR_SELL :{BLACK}Sell
-STR_DEPOT_SELL_ALL_VEHICLE_CONFIRM :{BLACK}You are about to sell all the vehicles in the depot.
-STR_ARE_YOU_SURE :{BLACK}Are you sure?
-
-STR_DEPOT_SELL_ALL_TRAIN_TIP :{BLACK}Confirm that you want to sell all the trains in the depot
-STR_DEPOT_SELL_ALL_ROADVEH_TIP :{BLACK}Confirm that you want to sell all the road vehicles in the depot
-STR_DEPOT_SELL_ALL_SHIP_TIP :{BLACK}Confirm that you want to sell all the ships in the depot
-STR_DEPOT_SELL_ALL_AIRCRAFT_TIP :{BLACK}Confirm that you want to sell all the aircraft in the hangar
-
-STR_DEPOT_SELL_ALL_CANCEL_TRAIN_TIP :{BLACK}Do not sell all trains in the depot
-STR_DEPOT_SELL_ALL_CANCEL_ROADVEH_TIP :{BLACK}Do not sell all road vehicles in the depot
-STR_DEPOT_SELL_ALL_CANCEL_SHIP_TIP :{BLACK}Do not sell all ships in the depot
-STR_DEPOT_SELL_ALL_CANCEL_AIRCRAFT_TIP :{BLACK}Do not sell all aircraft in the hangar
+STR_DEPOT_SELL_CONFIRMATION_TEXT :{YELLOW}You are about to sell all the vehicles in the depot. Are you sure?
STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TIP :{BLACK}Sell all trains in the depot
STR_DEPOT_SELL_ALL_BUTTON_ROADVEH_TIP :{BLACK}Sell all road vehicles in the depot