(svn r8627) [0.5] -Backport from trunk (8409, 8420 + 8421, 8533, 8612):

-Regression: When the latest news was deleted, the news queue wrapped back to the oldest item, showing all news again.
-Regression [FS#573]: ShowLastNewsMessage could show an out-of-bounds news item because it did not checked if a previous item actually existed the first time it is called (forced news is INVALID_NEWS).
-Codechange: Rename the 'New <vehtype>' button of the global vehicle lists to 'Available <vehtype>' as it is a view-only list, not one from which you can purchase (rolling) stock.
-Fix: segmentation fault when the toolbar gets removed and you have selected one of the items in a submenu of the toolbar. 
-Fix [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.
This commit is contained in:
rubidium 2007-02-08 11:03:00 +00:00
parent 0543461f5e
commit 61b95ff1fc
6 changed files with 52 additions and 22 deletions

View File

@ -906,7 +906,7 @@ void ShowCompanyLeagueTable(void)
static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
{
static PlayerID _performance_rating_detail_player = 0;
static PlayerID _performance_rating_detail_player = INVALID_PLAYER;
switch (e->event) {
case WE_PAINT: {
@ -919,6 +919,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 (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 (i = 0; i < MAX_PLAYERS; i++) {
if (!GetPlayer(i)->is_active) {
@ -926,16 +952,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 = 0;
}
// We need a repaint
SetWindowDirty(w);
}
continue;
continue;
}
// Check if we have the player marked as inactive
@ -1054,8 +1075,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
w->custom[0] = DAY_TICKS;
w->custom[1] = 5;
_performance_rating_detail_player = 0;
LowerWindowWidget(w, _performance_rating_detail_player + 13);
if (_performance_rating_detail_player != INVALID_PLAYER) LowerWindowWidget(w, _performance_rating_detail_player + 13);
SetWindowDirty(w);
break;

View File

@ -394,6 +394,10 @@ STR_ENGINE_SORT_CARGO_CAPACITY :Cargo Capacity
STR_NO_WAITING_CARGO :{BLACK}No cargo of any type is waiting
STR_SELECT_ALL_FACILITIES :{BLACK}Select all facilities
STR_SELECT_ALL_TYPES :{BLACK}Select all cargo types (including no waiting cargo)
STR_AVAILABLE_TRAINS :{BLACK}Available Trains
STR_AVAILABLE_ROAD_VEHICLES :{BLACK}Available Vehicles
STR_AVAILABLE_SHIPS :{BLACK}Available Ships
STR_AVAILABLE_AIRCRAFT :{BLACK}Available Aircraft
STR_AVAILABLE_ENGINES_TIP :{BLACK}See a list of available engine designs for this vehicle type.
STR_MANAGE_LIST :{BLACK}Manage list
STR_MANAGE_LIST_TIP :{BLACK}Send instructions to all vehicles in this list

View File

@ -558,7 +558,7 @@ void ShowLastNewsMessage(void)
/* Not forced any news yet, show the current one, unless a news window is
* open (which can only be the current one), then show the previous item */
const Window *w = FindWindowById(WC_NEWS_WINDOW, 0);
ShowNewsMessage((w == NULL) ? _current_news : decreaseIndex(_current_news));
ShowNewsMessage((w == NULL || (_current_news == _oldest_news)) ? _current_news : decreaseIndex(_current_news));
} else if (_forced_news == _oldest_news) {
/* We have reached the oldest news, start anew with the latest */
ShowNewsMessage(_latest_news);
@ -918,9 +918,11 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
for (i = n;; i = decreaseIndex(i)) {
_news_items[i] = _news_items[decreaseIndex(i)];
if (i == _current_news) _current_news = increaseIndex(_current_news);
if (i == _forced_news) _forced_news = increaseIndex(_forced_news);
if (i == visible_news) WP(w, news_d).ni = &_news_items[increaseIndex(visible_news)];
if (i != _latest_news) {
if (i == _current_news) _current_news = increaseIndex(_current_news);
if (i == _forced_news) _forced_news = increaseIndex(_forced_news);
if (i == visible_news) WP(w, news_d).ni = &_news_items[increaseIndex(visible_news)];
}
if (i == _oldest_news) break;
}

View File

@ -83,6 +83,9 @@ typedef byte WindowClass;
enum {
INVALID_YEAR = -1,
INVALID_DATE = -1,
PLAYER_FIRST = 0x00,
INVALID_PLAYER = 0xFF,
};
typedef int32 Year;

View File

@ -1400,7 +1400,7 @@ enum VehicleListWindowWidgets {
VLW_WIDGET_LIST,
VLW_WIDGET_SCROLLBAR,
VLW_WIDGET_OTHER_PLAYER_FILLER,
VLW_WIDGET_NEW_VEHICLES,
VLW_WIDGET_AVAILABLE_VEHICLES,
VLW_WIDGET_MANAGE_VEHICLES,
VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN,
VLW_WIDGET_STOP_ALL,
@ -1448,10 +1448,10 @@ static void CreateVehicleListWindow(Window *w)
* Some windows contains actions only fit for the owner */
if (player == _local_player) {
HideWindowWidget(w, VLW_WIDGET_OTHER_PLAYER_FILLER);
SetWindowWidgetDisabledState(w, VLW_WIDGET_NEW_VEHICLES, window_type != VLW_STANDARD);
SetWindowWidgetDisabledState(w, VLW_WIDGET_AVAILABLE_VEHICLES, window_type != VLW_STANDARD);
} else {
SetWindowWidgetsHiddenState(w, true,
VLW_WIDGET_NEW_VEHICLES,
VLW_WIDGET_AVAILABLE_VEHICLES,
VLW_WIDGET_MANAGE_VEHICLES,
VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN,
VLW_WIDGET_STOP_ALL,
@ -1464,22 +1464,22 @@ static void CreateVehicleListWindow(Window *w)
switch (vl->vehicle_type) {
case VEH_Train:
w->widget[VLW_WIDGET_LIST].tooltips = STR_883D_TRAINS_CLICK_ON_TRAIN_FOR;
w->widget[VLW_WIDGET_NEW_VEHICLES].data = STR_8815_NEW_VEHICLES;
w->widget[VLW_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_TRAINS;
break;
case VEH_Road:
w->widget[VLW_WIDGET_LIST].tooltips = STR_901A_ROAD_VEHICLES_CLICK_ON;
w->widget[VLW_WIDGET_NEW_VEHICLES].data = STR_9004_NEW_VEHICLES;
w->widget[VLW_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_ROAD_VEHICLES;
break;
case VEH_Ship:
w->widget[VLW_WIDGET_LIST].tooltips = STR_9823_SHIPS_CLICK_ON_SHIP_FOR;
w->widget[VLW_WIDGET_NEW_VEHICLES].data = STR_9804_NEW_SHIPS;
w->widget[VLW_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_SHIPS;
break;
case VEH_Aircraft:
w->widget[VLW_WIDGET_LIST].tooltips = STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT;
w->widget[VLW_WIDGET_NEW_VEHICLES].data = STR_A003_NEW_AIRCRAFT;
w->widget[VLW_WIDGET_AVAILABLE_VEHICLES].data = STR_AVAILABLE_AIRCRAFT;
break;
default: NOT_REACHED();
@ -1742,7 +1742,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
}
} break;
case VLW_WIDGET_NEW_VEHICLES:
case VLW_WIDGET_AVAILABLE_VEHICLES:
switch (vl->vehicle_type) {
case VEH_Train: ShowBuildTrainWindow(0); break;
case VEH_Road: ShowBuildRoadVehWindow(0); break;

View File

@ -1870,6 +1870,7 @@ restart_search:
/* Delete all always on-top windows to get an empty screen */
void HideVitalWindows(void)
{
DeleteWindowById(WC_TOOLBAR_MENU, 0);
DeleteWindowById(WC_MAIN_TOOLBAR, 0);
DeleteWindowById(WC_STATUS_BAR, 0);
}