mirror of https://github.com/OpenTTD/OpenTTD
(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.release/0.6
parent
3dc645ce0a
commit
7a685a35fc
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue