summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2008-06-13 01:57:48 +0000
committerbelugas <belugas@openttd.org>2008-06-13 01:57:48 +0000
commit5d828d8eee1a2cfcaf209b938b1845b42f11691e (patch)
tree1cc8884073d7bbc4873b0ef1e92fe40cd15d6061
parent3d07e5ca10cb4a4c86470c3d67701a61698625ee (diff)
downloadopenttd-5d828d8eee1a2cfcaf209b938b1845b42f11691e.tar.xz
(svn r13504) -Codechange: enumify some widgets for scenario editor. More work is required.
-rw-r--r--src/toolbar_gui.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 3b878815e..bd8df7d5d 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -989,6 +989,18 @@ static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
};
struct ScenarioEditorToolbarWindow : Window {
+private:
+ enum ToolbarScenEditorWidgets {
+ TBSE_PAUSE = 0,
+ TBSE_FASTFORWARD,
+ TBSE_SPACERPANEL = 4,
+ TBSE_DATEBACKWARD = 6,
+ TBSE_DATEFORWARD,
+ TBSE_ZOOMIN = 9,
+ TBSE_ZOOMOUT,
+ };
+
+public:
ScenarioEditorToolbarWindow(const WindowDesc *desc) : Window(desc)
{
CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
@@ -1000,8 +1012,8 @@ struct ScenarioEditorToolbarWindow : Window {
virtual void OnPaint()
{
- this->SetWidgetDisabledState(6, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
- this->SetWidgetDisabledState(7, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
+ this->SetWidgetDisabledState(TBSE_DATEBACKWARD, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
+ this->SetWidgetDisabledState(TBSE_DATEFORWARD, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
/* Draw brown-red toolbar bg. */
GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
@@ -1010,12 +1022,13 @@ struct ScenarioEditorToolbarWindow : Window {
this->DrawWidgets();
SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
- DrawStringCenteredTruncated(this->widget[6].right, this->widget[7].left, 6, STR_00AF, TC_FROMSTRING);
+ DrawStringCenteredTruncated(this->widget[TBSE_DATEBACKWARD].right, this->widget[TBSE_DATEFORWARD].left, 6, STR_00AF, TC_FROMSTRING);
/* We hide this panel when the toolbar space gets too small */
- if (this->widget[4].left != this->widget[4].right) {
- DrawStringCenteredTruncated(this->widget[4].left + 1, this->widget[4].right - 1, 1, STR_0221_OPENTTD, TC_FROMSTRING);
- DrawStringCenteredTruncated(this->widget[4].left + 1, this->widget[4].right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
+ const Widget *panel = &this->widget[TBSE_SPACERPANEL];
+ if (panel->left != panel->right) {
+ DrawStringCenteredTruncated(panel->left + 1, panel->right - 1, 1, STR_0221_OPENTTD, TC_FROMSTRING);
+ DrawStringCenteredTruncated(panel->left + 1, panel->right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
}
}
@@ -1142,20 +1155,20 @@ struct ScenarioEditorToolbarWindow : Window {
virtual void OnTick()
{
- if (this->IsWidgetLowered(0) != !!_pause_game) {
- this->ToggleWidgetLoweredState(0);
+ if (this->IsWidgetLowered(TBSE_PAUSE) != !!_pause_game) {
+ this->ToggleWidgetLoweredState(TBSE_PAUSE);
this->SetDirty();
}
- if (this->IsWidgetLowered(1) != !!_fast_forward) {
- this->ToggleWidgetLoweredState(1);
+ if (this->IsWidgetLowered(TBSE_FASTFORWARD) != !!_fast_forward) {
+ this->ToggleWidgetLoweredState(TBSE_FASTFORWARD);
this->SetDirty();
}
}
virtual void OnInvalidateData(int data)
{
- if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, 9, 10);
+ if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBSE_ZOOMIN, TBSE_ZOOMOUT);
}
};