734 |
734 |
735 DeleteWindowById(WC_TOOLBAR_MENU, 0); |
735 DeleteWindowById(WC_TOOLBAR_MENU, 0); |
736 w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); |
736 w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); |
737 w->flags4 &= ~WF_WHITE_BORDER_MASK; |
737 w->flags4 &= ~WF_WHITE_BORDER_MASK; |
738 WP(w,menu_d).item_count = 0; |
738 WP(w,menu_d).item_count = 0; |
739 WP(w,menu_d).sel_index = (_local_player != OWNER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); |
739 WP(w,menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); |
740 if (_networking && main_button == 9) { |
740 if (_networking && main_button == 9) { |
741 if (_local_player != OWNER_SPECTATOR) { |
741 if (_local_player != PLAYER_SPECTATOR) { |
742 WP(w,menu_d).sel_index++; |
742 WP(w,menu_d).sel_index++; |
743 } else { |
743 } else { |
744 /* Select client list by default for spectators */ |
744 /* Select client list by default for spectators */ |
745 WP(w,menu_d).sel_index = 0; |
745 WP(w,menu_d).sel_index = 0; |
746 } |
746 } |
800 } |
800 } |
801 |
801 |
802 static void ToolbarIndustryClick(Window *w) |
802 static void ToolbarIndustryClick(Window *w) |
803 { |
803 { |
804 /* Disable build-industry menu if we are a spectator */ |
804 /* Disable build-industry menu if we are a spectator */ |
805 PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == OWNER_SPECTATOR) ? (1 << 1) : 0); |
805 PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0); |
806 } |
806 } |
807 |
807 |
808 static void ToolbarTrainClick(Window *w) |
808 static void ToolbarTrainClick(Window *w) |
809 { |
809 { |
810 const Vehicle *v; |
810 const Vehicle *v; |
1805 GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | PALETTE_MODIFIER_GREYOUT); |
1805 GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | PALETTE_MODIFIER_GREYOUT); |
1806 |
1806 |
1807 /* If spectator, disable all construction buttons |
1807 /* If spectator, disable all construction buttons |
1808 * ie : Build road, rail, ships, airports and landscaping |
1808 * ie : Build road, rail, ships, airports and landscaping |
1809 * Since enabled state is the default, just disable when needed */ |
1809 * Since enabled state is the default, just disable when needed */ |
1810 SetWindowWidgetsDisabledState(w, _current_player == OWNER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END); |
1810 SetWindowWidgetsDisabledState(w, _current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END); |
1811 /* disable company list drop downs, if there are no companies */ |
1811 /* disable company list drop downs, if there are no companies */ |
1812 SetWindowWidgetsDisabledState(w, ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END); |
1812 SetWindowWidgetsDisabledState(w, ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END); |
1813 |
1813 |
1814 DrawWindowWidgets(w); |
1814 DrawWindowWidgets(w); |
1815 break; |
1815 break; |
1818 if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget)) |
1818 if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget)) |
1819 _toolbar_button_procs[e->we.click.widget](w); |
1819 _toolbar_button_procs[e->we.click.widget](w); |
1820 } break; |
1820 } break; |
1821 |
1821 |
1822 case WE_KEYPRESS: { |
1822 case WE_KEYPRESS: { |
1823 PlayerID local = (_local_player != OWNER_SPECTATOR) ? _local_player : 0; |
1823 PlayerID local = (_local_player != PLAYER_SPECTATOR) ? _local_player : 0; |
1824 |
1824 |
1825 switch (e->we.keypress.keycode) { |
1825 switch (e->we.keypress.keycode) { |
1826 case WKC_F1: case WKC_PAUSE: |
1826 case WKC_F1: case WKC_PAUSE: |
1827 ToolbarPauseClick(w); |
1827 ToolbarPauseClick(w); |
1828 break; |
1828 break; |
2138 |
2138 |
2139 static void StatusBarWndProc(Window *w, WindowEvent *e) |
2139 static void StatusBarWndProc(Window *w, WindowEvent *e) |
2140 { |
2140 { |
2141 switch (e->event) { |
2141 switch (e->event) { |
2142 case WE_PAINT: { |
2142 case WE_PAINT: { |
2143 const Player *p = (_local_player == OWNER_SPECTATOR) ? NULL : GetPlayer(_local_player); |
2143 const Player *p = (_local_player == PLAYER_SPECTATOR) ? NULL : GetPlayer(_local_player); |
2144 |
2144 |
2145 DrawWindowWidgets(w); |
2145 DrawWindowWidgets(w); |
2146 SetDParam(0, _date); |
2146 SetDParam(0, _date); |
2147 DrawStringCentered( |
2147 DrawStringCentered( |
2148 70, 1, (_pause || _patches.status_long_date) ? STR_00AF : STR_00AE, 0 |
2148 70, 1, (_pause || _patches.status_long_date) ? STR_00AF : STR_00AE, 0 |