(svn r6695) -Fix FS#356: disable main toolbar buttons showing company list drop downs when there are no companies

This commit is contained in:
glx 2006-10-08 21:00:13 +00:00
parent 73f1ffe84f
commit fa3afe220e

View File

@ -1761,9 +1761,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = {
static void MainToolbarWndProc(Window *w, WindowEvent *e) static void MainToolbarWndProc(Window *w, WindowEvent *e)
{ {
switch (e->event) { switch (e->event) {
case WE_PAINT: { case WE_PAINT:
bool is_spectator = _current_player == OWNER_SPECTATOR;
// Draw brown-red toolbar bg. // Draw brown-red toolbar bg.
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2); GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | PALETTE_MODIFIER_GREYOUT); 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 /* If spectator, disable all construction buttons
* ie : Build road, rail, ships, airports and landscaping * ie : Build road, rail, ships, airports and landscaping
* Since enabled state is the default, just disable when needed */ * Since enabled state is the default, just disable when needed */
SetWindowWidgetDisabledState(w, 19, is_spectator); SetWindowWidgetsDisabledState(w, _current_player == OWNER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
SetWindowWidgetDisabledState(w, 20, is_spectator); /* disable company list drop downs, if there are no companies */
SetWindowWidgetDisabledState(w, 21, is_spectator); SetWindowWidgetsDisabledState(w, ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
SetWindowWidgetDisabledState(w, 22, is_spectator);
SetWindowWidgetDisabledState(w, 23, is_spectator);
DrawWindowWidgets(w); DrawWindowWidgets(w);
break; break;
}
case WE_CLICK: { case WE_CLICK: {
if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget)) if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget))