summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-03 10:53:49 +0000
committerrubidium <rubidium@openttd.org>2009-01-03 10:53:49 +0000
commit6913ae5a5fc242f898e3bcb53f170ba644e0942e (patch)
tree27b39d836dfc5b6bc151254b32b67bb35b9572b6
parent8ff93c2c1468e387ef467aaf099ade3f980daa00 (diff)
downloadopenttd-6913ae5a5fc242f898e3bcb53f170ba644e0942e.tar.xz
(svn r14795) -Codechange: replace a magic number with a constant (Alberth)
-rw-r--r--src/settings_gui.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 2506cd206..bf80685a2 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -583,6 +583,8 @@ void ShowGameDifficulty()
new GameDifficultyWindow();
}
+static const int SETTING_HEIGHT = 11; ///< Height of a single patch setting in the tree view
+
static const char *_patches_ui[] = {
"gui.vehicle_speed",
"gui.status_long_date",
@@ -785,10 +787,10 @@ struct PatchesSelectionWindow : Window {
}
/* Resize the window to fit the largest patch tab */
- ResizeWindowForWidget(this, PATCHSEL_OPTIONSPANEL, 0, patches_max * 11);
+ ResizeWindowForWidget(this, PATCHSEL_OPTIONSPANEL, 0, patches_max * SETTING_HEIGHT);
/* Recentre the window for the new size */
- this->top = this->top - (patches_max * 11) / 2;
+ this->top = this->top - (patches_max * SETTING_HEIGHT) / 2;
this->LowerWidget(PATCHSEL_INTERFACE);
@@ -848,7 +850,7 @@ struct PatchesSelectionWindow : Window {
}
}
DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING);
- y += 11;
+ y += SETTING_HEIGHT;
}
}
@@ -869,8 +871,8 @@ struct PatchesSelectionWindow : Window {
x = pt.x - 5; // Shift x coordinate
if (x < 0) return; // Clicked left of the entry
- btn = y / 11; // Compute which setting is selected
- if (y % 11 > 9) return; // Clicked too low at the setting
+ btn = y / SETTING_HEIGHT; // Compute which setting is selected
+ if (y % SETTING_HEIGHT > SETTING_HEIGHT - 2) return; // Clicked too low at the setting
if (btn >= page->num) return; // Clicked below the last setting of the page
sd = page->entries[btn].setting;