summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2016-10-30 17:36:57 +0000
committerfrosch <frosch@openttd.org>2016-10-30 17:36:57 +0000
commit30574a7cada538518c57e192e171fdd094075f9e (patch)
treed7f54831496cfded848c51cc23b41cab0d09c072 /src
parent31f046bd9bfec6be5b5a24f113f3b301376763e6 (diff)
downloadopenttd-30574a7cada538518c57e192e171fdd094075f9e.tar.xz
(svn r27671) -Codechange: Replace magic numbers in the toolbar with the already existing WID_TN_xxx. (Wolf01)
Diffstat (limited to 'src')
-rw-r--r--src/toolbar_gui.cpp364
-rw-r--r--src/widgets/toolbar_widget.h3
2 files changed, 346 insertions, 21 deletions
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 2649552f4..f253be8b3 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -1469,36 +1469,302 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
{
static const uint SMALLEST_ARRANGEMENT = 14;
static const uint BIGGEST_ARRANGEMENT = 20;
+
+ /* The number of buttons of each row of the toolbar should match the number of items which we want to be visible.
+ * The total number of buttons should be equal to arrangable_count * 2.
+ * No bad things happen, but we could see strange behaviours if we have buttons < (arrangable_count * 2) like a
+ * pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is
+ * enough space.
+ */
static const byte arrange14[] = {
- 0, 1, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 29,
- 2, 3, 4, 5, 6, 7, 8, 9, 12, 14, 26, 27, 28, 29,
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_TRAINS,
+ WID_TN_ROADVEHS,
+ WID_TN_SHIPS,
+ WID_TN_AIRCRAFTS,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_SWITCH_BAR,
+ // lower toolbar
+ WID_TN_SETTINGS,
+ WID_TN_SAVE,
+ WID_TN_SMALL_MAP,
+ WID_TN_TOWNS,
+ WID_TN_SUBSIDIES,
+ WID_TN_STATIONS,
+ WID_TN_FINANCES,
+ WID_TN_COMPANIES,
+ WID_TN_GRAPHS,
+ WID_TN_INDUSTRIES,
+ WID_TN_MUSIC_SOUND,
+ WID_TN_MESSAGES,
+ WID_TN_HELP,
+ WID_TN_SWITCH_BAR,
};
static const byte arrange15[] = {
- 0, 1, 4, 15, 16, 17, 18, 21, 22, 23, 24, 25, 19, 20, 29,
- 0, 2, 4, 3, 5, 6, 7, 8, 9, 12, 14, 26, 27, 28, 29,
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SMALL_MAP,
+ WID_TN_TRAINS,
+ WID_TN_ROADVEHS,
+ WID_TN_SHIPS,
+ WID_TN_AIRCRAFTS,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
+ // lower toolbar
+ WID_TN_PAUSE,
+ WID_TN_SETTINGS,
+ WID_TN_SMALL_MAP,
+ WID_TN_SAVE,
+ WID_TN_TOWNS,
+ WID_TN_SUBSIDIES,
+ WID_TN_STATIONS,
+ WID_TN_FINANCES,
+ WID_TN_COMPANIES,
+ WID_TN_GRAPHS,
+ WID_TN_INDUSTRIES,
+ WID_TN_MUSIC_SOUND,
+ WID_TN_MESSAGES,
+ WID_TN_HELP,
+ WID_TN_SWITCH_BAR,
};
static const byte arrange16[] = {
- 0, 1, 2, 4, 15, 16, 17, 18, 21, 22, 23, 24, 25, 19, 20, 29,
- 0, 1, 3, 5, 6, 7, 8, 9, 12, 14, 26, 27, 28, 19, 20, 29,
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SETTINGS,
+ WID_TN_SMALL_MAP,
+ WID_TN_TRAINS,
+ WID_TN_ROADVEHS,
+ WID_TN_SHIPS,
+ WID_TN_AIRCRAFTS,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
+ // lower toolbar
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SAVE,
+ WID_TN_TOWNS,
+ WID_TN_SUBSIDIES,
+ WID_TN_STATIONS,
+ WID_TN_FINANCES,
+ WID_TN_COMPANIES,
+ WID_TN_GRAPHS,
+ WID_TN_INDUSTRIES,
+ WID_TN_MUSIC_SOUND,
+ WID_TN_MESSAGES,
+ WID_TN_HELP,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
};
static const byte arrange17[] = {
- 0, 1, 2, 4, 6, 15, 16, 17, 18, 21, 22, 23, 24, 25, 19, 20, 29,
- 0, 1, 3, 4, 6, 5, 7, 8, 9, 12, 14, 26, 27, 28, 19, 20, 29,
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SETTINGS,
+ WID_TN_SMALL_MAP,
+ WID_TN_SUBSIDIES,
+ WID_TN_TRAINS,
+ WID_TN_ROADVEHS,
+ WID_TN_SHIPS,
+ WID_TN_AIRCRAFTS,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
+ // lower toolbar
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SAVE,
+ WID_TN_SMALL_MAP,
+ WID_TN_SUBSIDIES,
+ WID_TN_TOWNS,
+ WID_TN_STATIONS,
+ WID_TN_FINANCES,
+ WID_TN_COMPANIES,
+ WID_TN_GRAPHS,
+ WID_TN_INDUSTRIES,
+ WID_TN_MUSIC_SOUND,
+ WID_TN_MESSAGES,
+ WID_TN_HELP,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
};
static const byte arrange18[] = {
- 0, 1, 2, 4, 5, 6, 7, 8, 9, 14, 21, 22, 23, 24, 25, 19, 20, 29,
- 0, 1, 3, 4, 5, 6, 7, 12, 15, 16, 17, 18, 26, 27, 28, 19, 20, 29,
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SETTINGS,
+ WID_TN_SMALL_MAP,
+ WID_TN_TOWNS,
+ WID_TN_SUBSIDIES,
+ WID_TN_STATIONS,
+ WID_TN_FINANCES,
+ WID_TN_COMPANIES,
+ WID_TN_INDUSTRIES,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
+ // lower toolbar
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SAVE,
+ WID_TN_SMALL_MAP,
+ WID_TN_TOWNS,
+ WID_TN_SUBSIDIES,
+ WID_TN_STATIONS,
+ WID_TN_GRAPHS,
+ WID_TN_TRAINS,
+ WID_TN_ROADVEHS,
+ WID_TN_SHIPS,
+ WID_TN_AIRCRAFTS,
+ WID_TN_MUSIC_SOUND,
+ WID_TN_MESSAGES,
+ WID_TN_HELP,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
};
static const byte arrange19[] = {
- 0, 1, 2, 4, 5, 6, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 19, 20, 29,
- 0, 1, 3, 4, 7, 8, 9, 12, 14, 27, 21, 22, 23, 24, 25, 28, 19, 20, 29,
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SETTINGS,
+ WID_TN_SMALL_MAP,
+ WID_TN_TOWNS,
+ WID_TN_SUBSIDIES,
+ WID_TN_TRAINS,
+ WID_TN_ROADVEHS,
+ WID_TN_SHIPS,
+ WID_TN_AIRCRAFTS,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_MUSIC_SOUND,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
+ // lower toolbar
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SAVE,
+ WID_TN_SMALL_MAP,
+ WID_TN_STATIONS,
+ WID_TN_FINANCES,
+ WID_TN_COMPANIES,
+ WID_TN_GRAPHS,
+ WID_TN_INDUSTRIES,
+ WID_TN_MESSAGES,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_HELP,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
};
static const byte arrange20[] = {
- 0, 1, 2, 4, 5, 6, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 11, 19, 20, 29,
- 0, 1, 3, 4, 7, 8, 9, 12, 14, 27, 21, 22, 23, 24, 25, 10, 28, 19, 20, 29,
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SETTINGS,
+ WID_TN_SMALL_MAP,
+ WID_TN_TOWNS,
+ WID_TN_SUBSIDIES,
+ WID_TN_TRAINS,
+ WID_TN_ROADVEHS,
+ WID_TN_SHIPS,
+ WID_TN_AIRCRAFTS,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_MUSIC_SOUND,
+ WID_TN_GOAL,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
+ // lower toolbar
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SAVE,
+ WID_TN_SMALL_MAP,
+ WID_TN_STATIONS,
+ WID_TN_FINANCES,
+ WID_TN_COMPANIES,
+ WID_TN_GRAPHS,
+ WID_TN_INDUSTRIES,
+ WID_TN_MESSAGES,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_STORY,
+ WID_TN_HELP,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_SWITCH_BAR,
};
static const byte arrange_all[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
+ WID_TN_PAUSE,
+ WID_TN_FAST_FORWARD,
+ WID_TN_SETTINGS,
+ WID_TN_SAVE,
+ WID_TN_SMALL_MAP,
+ WID_TN_TOWNS,
+ WID_TN_SUBSIDIES,
+ WID_TN_STATIONS,
+ WID_TN_FINANCES,
+ WID_TN_COMPANIES,
+ WID_TN_STORY,
+ WID_TN_GOAL,
+ WID_TN_GRAPHS,
+ WID_TN_LEAGUE,
+ WID_TN_INDUSTRIES,
+ WID_TN_TRAINS,
+ WID_TN_ROADVEHS,
+ WID_TN_SHIPS,
+ WID_TN_AIRCRAFTS,
+ WID_TN_ZOOM_IN,
+ WID_TN_ZOOM_OUT,
+ WID_TN_RAILS,
+ WID_TN_ROADS,
+ WID_TN_WATER,
+ WID_TN_AIR,
+ WID_TN_LANDSCAPE,
+ WID_TN_MUSIC_SOUND,
+ WID_TN_MESSAGES,
+ WID_TN_HELP
};
/* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */
@@ -1540,14 +1806,65 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
/* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const
{
static const byte arrange_all[] = {
- 0, 1, 2, 3, 4, 18, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 26, 28,
+ WID_TE_PAUSE,
+ WID_TE_FAST_FORWARD,
+ WID_TE_SETTINGS,
+ WID_TE_SAVE,
+ WID_TE_SPACER,
+ WID_TE_DATE_PANEL,
+ WID_TE_SMALL_MAP,
+ WID_TE_ZOOM_IN,
+ WID_TE_ZOOM_OUT,
+ WID_TE_LAND_GENERATE,
+ WID_TE_TOWN_GENERATE,
+ WID_TE_INDUSTRY,
+ WID_TE_ROADS,
+ WID_TE_WATER,
+ WID_TE_TREES,
+ WID_TE_SIGNS,
+ WID_TE_MUSIC_SOUND,
+ WID_TE_HELP,
};
static const byte arrange_nopanel[] = {
- 0, 1, 2, 3, 18, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 26, 28,
+ WID_TE_PAUSE,
+ WID_TE_FAST_FORWARD,
+ WID_TE_SETTINGS,
+ WID_TE_SAVE,
+ WID_TE_DATE_PANEL,
+ WID_TE_SMALL_MAP,
+ WID_TE_ZOOM_IN,
+ WID_TE_ZOOM_OUT,
+ WID_TE_LAND_GENERATE,
+ WID_TE_TOWN_GENERATE,
+ WID_TE_INDUSTRY,
+ WID_TE_ROADS,
+ WID_TE_WATER,
+ WID_TE_TREES,
+ WID_TE_SIGNS,
+ WID_TE_MUSIC_SOUND,
+ WID_TE_HELP,
};
static const byte arrange_switch[] = {
- 18, 8, 11, 12, 13, 14, 15, 16, 17, 29,
- 0, 1, 2, 3, 18, 9, 10, 26, 28, 29,
+ WID_TE_DATE_PANEL,
+ WID_TE_SMALL_MAP,
+ WID_TE_LAND_GENERATE,
+ WID_TE_TOWN_GENERATE,
+ WID_TE_INDUSTRY,
+ WID_TE_ROADS,
+ WID_TE_WATER,
+ WID_TE_TREES,
+ WID_TE_SIGNS,
+ WID_TE_SWITCH_BAR,
+ // lower toolbar
+ WID_TE_PAUSE,
+ WID_TE_FAST_FORWARD,
+ WID_TE_SETTINGS,
+ WID_TE_SAVE,
+ WID_TE_DATE_PANEL,
+ WID_TE_ZOOM_IN,
+ WID_TE_ZOOM_OUT,
+ WID_TE_MUSIC_SOUND,
+ WID_TE_HELP, WID_TE_SWITCH_BAR,
};
/* If we can place all buttons *and* the panels, show them. */
@@ -1901,7 +2218,14 @@ static NWidgetBase *MakeMainToolbar(int *biggest_index)
NWidgetMainToolbarContainer *hor = new NWidgetMainToolbarContainer();
for (uint i = 0; i < WID_TN_END; i++) {
switch (i) {
- case 4: case 8: case 15: case 19: case 21: case 26: hor->Add(new NWidgetSpacer(0, 0)); break;
+ case WID_TN_SMALL_MAP:
+ case WID_TN_FINANCES:
+ case WID_TN_VEHICLE_START:
+ case WID_TN_ZOOM_IN:
+ case WID_TN_BUILDING_TOOLS_START:
+ case WID_TN_MUSIC_SOUND:
+ hor->Add(new NWidgetSpacer(0, 0));
+ break;
}
hor->Add(new NWidgetLeaf(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i));
}
diff --git a/src/widgets/toolbar_widget.h b/src/widgets/toolbar_widget.h
index 6ede3ad63..434a238ac 100644
--- a/src/widgets/toolbar_widget.h
+++ b/src/widgets/toolbar_widget.h
@@ -36,7 +36,8 @@ enum ToolbarNormalWidgets {
WID_TN_AIRCRAFTS, ///< Aircraft menu.
WID_TN_ZOOM_IN, ///< Zoom in the main viewport.
WID_TN_ZOOM_OUT, ///< Zoom out the main viewport.
- WID_TN_RAILS, ///< Rail building menu.
+ WID_TN_BUILDING_TOOLS_START, ///< Helper for the offset of the building tools
+ WID_TN_RAILS = WID_TN_BUILDING_TOOLS_START, ///< Rail building menu.
WID_TN_ROADS, ///< Road building menu.
WID_TN_WATER, ///< Water building toolbar.
WID_TN_AIR, ///< Airport building toolbar.