summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-02-06 15:50:15 +0000
committermaedhros <maedhros@openttd.org>2007-02-06 15:50:15 +0000
commit310a299a4300bb4f4f8b3051feeb8700f1d82b7f (patch)
treecfc4e9076c3459214d8ba05d24bbb64358acfbd6
parentd3dc34c965fe1062654ad6fe22a8bcc7b0507a1b (diff)
downloadopenttd-310a299a4300bb4f4f8b3051feeb8700f1d82b7f.tar.xz
(svn r8612) -Fix (r117) [FS#582]: When the currently selected player in the performance
details window is no longer active, choose the first active player instead of the first player as that may also be inactive.
-rw-r--r--src/graph_gui.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index da300fa97..8188414eb 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -911,7 +911,7 @@ void ShowCompanyLeagueTable(void)
static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
{
- static PlayerID _performance_rating_detail_player = PLAYER_FIRST;
+ static PlayerID _performance_rating_detail_player = INVALID_PLAYER;
switch (e->event) {
case WE_PAINT: {
@@ -923,6 +923,32 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
// Draw standard stuff
DrawWindowWidgets(w);
+ /* Check if the currently selected player is still active. */
+ if (_performance_rating_detail_player == INVALID_PLAYER || !GetPlayer(_performance_rating_detail_player)->is_active) {
+ if (_performance_rating_detail_player != INVALID_PLAYER) {
+ /* Raise and disable the widget for the previous selection. */
+ RaiseWindowWidget(w, _performance_rating_detail_player + 13);
+ DisableWindowWidget(w, _performance_rating_detail_player + 13);
+ SetWindowDirty(w);
+
+ _performance_rating_detail_player = INVALID_PLAYER;
+ }
+
+ for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
+ if (GetPlayer(i)->is_active) {
+ /* Lower the widget corresponding to this player. */
+ LowerWindowWidget(w, i + 13);
+ SetWindowDirty(w);
+
+ _performance_rating_detail_player = i;
+ break;
+ }
+ }
+ }
+
+ /* If there are no active players, don't display anything else. */
+ if (_performance_rating_detail_player == INVALID_PLAYER) break;
+
// Paint the player icons
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
if (!GetPlayer(i)->is_active) {
@@ -930,16 +956,11 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
if (!IsWindowWidgetDisabled(w, i + 13)) {
// Bah, player gone :(
DisableWindowWidget(w, i + 13);
- // Is this player selected? If so, select first player (always save? :s)
- if (IsWindowWidgetLowered(w, i + 13)) {
- RaiseWindowWidget(w, i + 13);
- LowerWindowWidget(w, 13);
- _performance_rating_detail_player = PLAYER_FIRST;
- }
+
// We need a repaint
SetWindowDirty(w);
}
- continue;
+ continue;
}
// Check if we have the player marked as inactive
@@ -1058,8 +1079,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
w->custom[0] = DAY_TICKS;
w->custom[1] = 5;
- _performance_rating_detail_player = PLAYER_FIRST;
- LowerWindowWidget(w, _performance_rating_detail_player + 13);
+ if (_performance_rating_detail_player != INVALID_PLAYER) LowerWindowWidget(w, _performance_rating_detail_player + 13);
SetWindowDirty(w);
break;