changeset 9571:481237bb59f9 draft

(svn r13597) -Codechange: Enumification of the Map menu items. The rework allowed to remove a function, by merging two quite similar ones.
author belugas <belugas@openttd.org>
date Sat, 21 Jun 2008 01:40:56 +0000
parents 932dc24e565c
children 7c23a341f695
files src/toolbar_gui.cpp
diffstat 1 files changed, 25 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -291,27 +291,37 @@
 
 /* --- Map button menu --- */
 
+enum MapMenuEntries {
+	MME_SHOW_SMALLMAP        = 0,
+	MME_SHOW_EXTRAVIEWPORTS,
+	MME_SHOW_SIGNLISTS,
+	MME_SHOW_TOWNDIRECTORY,    ///< This entry is only used in Editor mode
+	MME_MENUCOUNT_NORMAL = 3,
+	MME_MENUCOUNT_EDITOR = 4,
+};
+
 static void ToolbarMapClick(Window *w)
 {
-	PopupMainToolbMenu(w, TBN_SMALLMAP, STR_02DE_MAP_OF_WORLD, 3);
+	PopupMainToolbMenu(w, TBN_SMALLMAP, STR_02DE_MAP_OF_WORLD, MME_MENUCOUNT_NORMAL);
+}
+
+static void ToolbarScenMapTownDir(Window *w)
+{
+	/* Scenario editor button, Use different button to activate.
+	 * This scheme will allow to have an action (SEMA_MAP_CLICK, which is in fact
+	 * an entry in _menu_clicked_procs) while at the same time having a start button
+	 * who is not at the same index as its action
+	 * @see ToolbarMenuWindow::OnMouseLoop */
+	PopupMainToolbMenu(w, TBSE_SMALLMAP | SEMA_MAP_CLICK, STR_02DE_MAP_OF_WORLD, MME_MENUCOUNT_EDITOR);
 }
 
 static void MenuClickMap(int index)
 {
 	switch (index) {
-		case 0: ShowSmallMap();            break;
-		case 1: ShowExtraViewPortWindow(); break;
-		case 2: ShowSignList();            break;
-	}
-}
-
-static void MenuClickScenMap(int index)
-{
-	switch (index) {
-		case 0: ShowSmallMap();            break;
-		case 1: ShowExtraViewPortWindow(); break;
-		case 2: ShowSignList();            break;
-		case 3: ShowTownDirectory();       break;
+		case MME_SHOW_SMALLMAP:       ShowSmallMap();            break;
+		case MME_SHOW_EXTRAVIEWPORTS: ShowExtraViewPortWindow(); break;
+		case MME_SHOW_SIGNLISTS:      ShowSignList();            break;
+		case MME_SHOW_TOWNDIRECTORY:  if (_game_mode == GM_EDITOR) ShowTownDirectory(); break;
 	}
 }
 
@@ -682,16 +692,6 @@
 	_left_button_clicked = false;
 }
 
-static void ToolbarScenMapTownDir(Window *w)
-{
-	/* Scenario editor button, Use different button to activate.
-	 * This scheme will allow to have an action (SEMA_MAP_CLICK, which is in fact
-	 * an entry in _menu_clicked_procs) while at the same time having a start button
-	 * who is not at the same index as its action
-	 * @see ToolbarMenuWindow::OnMouseLoop */
-	PopupMainToolbMenu(w, TBSE_SMALLMAP | SEMA_MAP_CLICK, STR_02DE_MAP_OF_WORLD, 4);
-}
-
 static void ToolbarScenZoomIn(Window *w)
 {
 	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
@@ -1314,7 +1314,7 @@
 	MenuClickShowRoad,    /* 14 */
 	MenuClickShowShips,   /* 15 */
 	MenuClickShowAir,     /* 16 */
-	MenuClickScenMap,     /* 17 */
+	MenuClickMap,         /* 17 */
 	NULL,                 /* 18 */
 	MenuClickBuildRail,   /* 19 */
 	MenuClickBuildRoad,   /* 20 */