summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2006-10-08 21:00:13 +0000
committerglx <glx@openttd.org>2006-10-08 21:00:13 +0000
commitfa3afe220edc938f19b4368cd1edb0d1d52e71a8 (patch)
tree81d47c28d146525986025533f6afb463eeb7abb5
parent73f1ffe84fd02a169e2f21c92e3d6d019cf226dd (diff)
downloadopenttd-fa3afe220edc938f19b4368cd1edb0d1d52e71a8.tar.xz
(svn r6695) -Fix FS#356: disable main toolbar buttons showing company list drop downs when there are no companies
-rw-r--r--main_gui.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/main_gui.c b/main_gui.c
index b04622e6e..3d047814c 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -1761,9 +1761,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = {
static void MainToolbarWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
- case WE_PAINT: {
- bool is_spectator = _current_player == OWNER_SPECTATOR;
-
+ case WE_PAINT:
// Draw brown-red toolbar bg.
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | PALETTE_MODIFIER_GREYOUT);
@@ -1771,15 +1769,12 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
/* If spectator, disable all construction buttons
* ie : Build road, rail, ships, airports and landscaping
* Since enabled state is the default, just disable when needed */
- SetWindowWidgetDisabledState(w, 19, is_spectator);
- SetWindowWidgetDisabledState(w, 20, is_spectator);
- SetWindowWidgetDisabledState(w, 21, is_spectator);
- SetWindowWidgetDisabledState(w, 22, is_spectator);
- SetWindowWidgetDisabledState(w, 23, is_spectator);
+ SetWindowWidgetsDisabledState(w, _current_player == OWNER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
+ /* disable company list drop downs, if there are no companies */
+ SetWindowWidgetsDisabledState(w, ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
DrawWindowWidgets(w);
break;
- }
case WE_CLICK: {
if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget))