summaryrefslogtreecommitdiff
path: root/main_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-11-08 22:21:14 +0000
committertron <tron@openttd.org>2004-11-08 22:21:14 +0000
commit603618a75b6b55ca46ce015d97d462e2b7f83fb7 (patch)
treed3ff0a3edc383c5afb961168c3efad0aa9d3c1c5 /main_gui.c
parentb78bbf80bf050e04814d0f60e9769a4bdf1e7068 (diff)
downloadopenttd-603618a75b6b55ca46ce015d97d462e2b7f83fb7.tar.xz
(svn r532) Disable date change buttons in scenario editor if date limit is reached.
Note: It's a /bit/ ugly, need to find a cleaner way While I'm here enlarge the start date window to 1920-2000 (was 1950-1975).
Diffstat (limited to 'main_gui.c')
-rw-r--r--main_gui.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/main_gui.c b/main_gui.c
index 89ef09a59..3f927aa3a 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -16,6 +16,10 @@
#include "table/animcursors.h"
+/* Min/Max date for scenario editor */
+static const uint MinDate = 0; // 1920-01-01
+static const uint MaxDate = 29220; // 2000-01-01
+
extern void DoTestSave();
extern void DoTestLoad();
@@ -859,9 +863,8 @@ static void ToolbarScenDateBackward(Window *w)
HandleButtonClick(w, 6);
InvalidateWidget(w, 5);
- if (_date > 0x2ACE) {
+ if (_date > MinDate)
SetDate(ConvertYMDToDay(_cur_year - 1, 0, 1));
- }
}
_left_button_clicked = false;
}
@@ -873,9 +876,8 @@ static void ToolbarScenDateForward(Window *w)
HandleButtonClick(w, 7);
InvalidateWidget(w, 5);
- if (_date < 0x4E79) {
+ if (_date < MaxDate)
SetDate(ConvertYMDToDay(_cur_year + 1, 0, 1));
- }
}
_left_button_clicked = false;
}
@@ -1864,6 +1866,16 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT:
+ /* XXX look for better place for these */
+ if (_date <= MinDate)
+ SETBIT(w->disabled_state, 6);
+ else
+ CLRBIT(w->disabled_state, 6);
+ if (_date >= MaxDate)
+ SETBIT(w->disabled_state, 7);
+ else
+ CLRBIT(w->disabled_state, 7);
+
// Draw brown-red toolbar bg.
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
GfxFillRect(0, 0, w->width-1, w->height-1, 0x80B4);