@@ -138,13 +138,13 @@ static const Widget _air_toolbar_widgets
};
static const WindowDesc _air_toolbar_desc = {
WDP_ALIGN_TBR, 22, 64, 36, 64, 36,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_CONSTRUCTION,
_air_toolbar_widgets,
void ShowBuildAirToolbar()
{
if (!IsValidCompanyID(_local_company)) return;
@@ -299,13 +299,13 @@ static const Widget _build_airport_picke
{ WIDGETS_END},
static const WindowDesc _build_airport_desc = {
WDP_AUTO, WDP_AUTO, 148, 240, 148, 240,
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION,
_build_airport_picker_widgets,
static void ShowBuildAirportPicker(Window *parent)
new AirportPickerWindow(&_build_airport_desc, parent);
@@ -469,20 +469,20 @@ static const Widget _replace_vehicle_wid
static const WindowDesc _replace_rail_vehicle_desc = {
WDP_AUTO, WDP_AUTO, 456, 140, 456, 140,
WC_REPLACE_VEHICLE, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE | WDF_CONSTRUCTION,
_replace_vehicle_widgets,
static const WindowDesc _replace_vehicle_desc = {
WDP_AUTO, WDP_AUTO, 456, 118, 456, 118,
RailType ReplaceVehicleWindow::sel_railtype = RAILTYPE_RAIL;
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
@@ -267,13 +267,13 @@ static const Widget _build_bridge_widget
/* Window definition for the rail bridge selection window */
static const WindowDesc _build_bridge_desc = {
WDP_AUTO, WDP_AUTO, 200, 114, 200, 114,
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE | WDF_CONSTRUCTION,
_build_bridge_widgets,
/**
* Prepare the data for the build a bridge window.
* If we can't build a bridge under the given conditions
@@ -1179,13 +1179,13 @@ struct BuildVehicleWindow : Window {
}
static const WindowDesc _build_vehicle_desc = {
WDP_AUTO, WDP_AUTO, 240, 174, 240, 256,
WC_BUILD_VEHICLE, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE | WDF_CONSTRUCTION,
_build_vehicle_widgets,
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type)
/* We want to be able to open both Available Train as Available Ships,
@@ -43,14 +43,12 @@ static int32 ClickMoneyCheat(int32 p1, i
*/
static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
while ((uint)p1 < GetCompanyPoolSize()) {
if (IsValidCompanyID((CompanyID)p1)) {
SetLocalCompany((CompanyID)p1);
MarkWholeScreenDirty();
return _local_company;
p1 += p2;
@@ -80,12 +80,18 @@ void SetLocalCompany(CompanyID new_compa
const Company *c = GetCompany(new_company);
_settings_client.gui.autorenew = c->engine_renew;
_settings_client.gui.autorenew_months = c->engine_renew_months;
_settings_client.gui.autorenew_money = c->engine_renew_money;
InvalidateWindow(WC_GAME_OPTIONS, 0);
/* Delete any construction windows... */
DeleteConstructionWindows();
/* ... and redraw the whole screen. */
bool IsHumanCompany(CompanyID company)
return !GetCompany(company)->is_ai;
@@ -1093,21 +1093,21 @@ public:
/** normal/simple company manager face selection window description */
static const WindowDesc _select_company_manager_face_desc = {
WDP_AUTO, WDP_AUTO, 190, 163, 190, 163,
WC_COMPANY_MANAGER_FACE, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION,
_select_company_manager_face_widgets,
/** advanced company manager face selection window description */
static const WindowDesc _select_company_manager_face_adv_desc = {
WDP_AUTO, WDP_AUTO, 220, 220, 220, 220,
_select_company_manager_face_adv_widgets,
* Open the simple/advanced company manager face selection window
*
@@ -1515,13 +1515,13 @@ static const Widget _buy_company_widgets
static const WindowDesc _buy_company_desc = {
153, 171, 334, 137, 334, 137,
WC_BUY_COMPANY, WC_NONE,
_buy_company_widgets,
void ShowBuyCompanyDialog(CompanyID company)
@@ -273,13 +273,13 @@ static const Widget _build_docks_toolb_w
static const WindowDesc _build_docks_toolbar_desc = {
WDP_ALIGN_TBR, 22, 160, 36, 160, 36,
_build_docks_toolb_widgets,
void ShowBuildDocksToolbar()
@@ -308,13 +308,13 @@ static const Widget _build_docks_scen_to
/* Window definition for the build docks in scenario editor window */
static const WindowDesc _build_docks_scen_toolbar_desc = {
WDP_AUTO, WDP_AUTO, 115, 36, 115, 36,
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
_build_docks_scen_toolb_widgets,
void ShowBuildDocksScenToolbar()
AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER);
@@ -394,13 +394,13 @@ static const Widget _build_dock_station_
static const WindowDesc _build_dock_station_desc = {
WDP_AUTO, WDP_AUTO, 148, 75, 148, 75,
_build_dock_station_widgets,
static void ShowBuildDockStationPicker(Window *parent)
new BuildDocksStationWindow(&_build_dock_station_desc, parent);
@@ -468,13 +468,13 @@ static const Widget _build_docks_depot_w
static const WindowDesc _build_docks_depot_desc = {
WDP_AUTO, WDP_AUTO, 204, 86, 204, 86,
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
_build_docks_depot_widgets,
static void ShowBuildDocksDepotPicker(Window *parent)
@@ -96,13 +96,13 @@ struct EnginePreviewWindow : Window {
static const WindowDesc _engine_preview_desc = {
WDP_CENTER, WDP_CENTER, 300, 192, 300, 192,
WC_ENGINE_PREVIEW, WC_NONE,
_engine_preview_widgets,
void ShowEnginePreviewWindow(EngineID engine)
@@ -85,13 +85,13 @@ static const Widget _build_industry_widg
/** Window definition of the dynamic place industries gui */
static const WindowDesc _build_industry_desc = {
WDP_AUTO, WDP_AUTO, 170, 212, 170, 212,
WC_BUILD_INDUSTRY, WC_NONE,
_build_industry_widgets,
class BuildIndustryWindow : public Window {
int selected_index; ///< index of the element in the matrix
IndustryType selected_type; ///< industry corresponding to the above index
@@ -843,16 +843,12 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
/* if not valid player, force spectator, else check player exists */
if (!IsValidCompanyID(company_id)) company_id = COMPANY_SPECTATOR;
if (client_id == _network_own_client_id) {
_network_playas = company_id;
SetLocalCompany(company_id);
/* Disable any buttons in any windows the client is now not supposed to get to, and do it fast. */
/* Do this ASAP else the client has a chance of sending DoCommands with an incorrect company_id (=kick)! */
return NETWORK_RECV_STATUS_OKAY;
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CONFIG_UPDATE)
@@ -348,13 +348,12 @@ static void LoadIntroGame()
} else {
SetLocalCompany(COMPANY_FIRST);
_pause_game = 0;
_cursor.fix_at = false;
CheckForMissingGlyphsInLoadedLanguagePack();
/* Play main theme */
if (_music_driver->IsSongPlaying()) ResetMusic();
@@ -789,14 +788,12 @@ static void MakeNewGame(bool from_height
GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
static void MakeNewEditorWorldDone()
SetLocalCompany(OWNER_NONE);
static void MakeNewEditorWorld()
_game_mode = GM_EDITOR;
@@ -1271,13 +1271,13 @@ static const Widget _other_orders_widget
static const WindowDesc _other_orders_desc = {
WDP_AUTO, WDP_AUTO, 386, 88, 386, 88,
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
_other_orders_widgets,
void ShowOrdersWindow(const Vehicle *v)
DeleteWindowById(WC_VEHICLE_DETAILS, v->index, false);
@@ -790,13 +790,13 @@ static const Widget _build_rail_widgets[
static const WindowDesc _build_rail_desc = {
WDP_ALIGN_TBR, 22, 350, 36, 350, 36,
_build_rail_widgets,
/** Configures the rail toolbar for railtype given
* @param railtype the railtype to display
@@ -1332,21 +1332,21 @@ static const Widget _newstation_builder_
/** High level window description of the default station-build window */
static const WindowDesc _station_builder_desc = {
WDP_AUTO, WDP_AUTO, 148, 200, 148, 200,
_station_builder_widgets,
/** High level window description of the newGRF station-build window */
static const WindowDesc _newstation_builder_desc = {
WDP_AUTO, WDP_AUTO, 148, 290, 148, 290,
_newstation_builder_widgets,
/** Open station build window */
static void ShowStationBuilder(Window *parent)
@@ -1509,13 +1509,13 @@ static const Widget _signal_builder_widg
/** Signal selection window description */
static const WindowDesc _signal_builder_desc = {
WDP_AUTO, WDP_AUTO, 154, 68, 154, 68,
WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
_signal_builder_widgets,
* Open the signal selection window
@@ -1583,13 +1583,13 @@ static const Widget _build_depot_widgets
static const WindowDesc _build_depot_desc = {
WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
_build_depot_widgets,
static void ShowBuildTrainDepotPicker(Window *parent)
new BuildRailDepotWindow(&_build_depot_desc, parent);
@@ -1684,13 +1684,13 @@ static const Widget _build_waypoint_widg
static const WindowDesc _build_waypoint_desc = {
WDP_AUTO, WDP_AUTO, 344, 92, 344, 92,
_build_waypoint_widgets,
static void ShowBuildWaypointPicker(Window *parent)
new BuildRailWaypointWindow(&_build_waypoint_desc, parent);
@@ -641,13 +641,13 @@ static const Widget _build_road_widgets[
static const WindowDesc _build_road_desc = {
WDP_ALIGN_TBR, 22, 263, 36, 263, 36,
_build_road_widgets,
/** Widget definition of the build tram toolbar */
static const Widget _build_tramway_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // RTW_CLOSEBOX
@@ -669,13 +669,13 @@ static const Widget _build_tramway_widge
static const WindowDesc _build_tramway_desc = {
WDP_ALIGN_TBR, 22, 241, 36, 241, 36,
_build_tramway_widgets,
void ShowBuildRoadToolbar(RoadType roadtype)
@@ -705,13 +705,13 @@ static const Widget _build_road_scen_wid
static const WindowDesc _build_road_scen_desc = {
WDP_AUTO, WDP_AUTO, 197, 36, 197, 36,
_build_road_scen_widgets,
void ShowBuildRoadScenToolbar()
_cur_roadtype = ROADTYPE_ROAD;
@@ -784,13 +784,13 @@ static const Widget _build_road_depot_wi
static const WindowDesc _build_road_depot_desc = {
_build_road_depot_widgets,
static void ShowRoadDepotPicker(Window *parent)
new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
@@ -932,13 +932,13 @@ static const Widget _rv_station_picker_w
static const WindowDesc _rv_station_picker_desc = {
WDP_AUTO, WDP_AUTO, 207, 177, 207, 177,
WC_BUS_STATION, WC_BUILD_TOOLBAR,
_rv_station_picker_widgets,
static void ShowRVStationPicker(Window *parent, RoadStopType rs)
new BuildRoadStationWindow(&_rv_station_picker_desc, parent, rs);
@@ -329,13 +329,13 @@ static const Widget _query_sign_edit_wid
{ WIDGETS_END },
static const WindowDesc _query_sign_edit_desc = {
190, 170, 260, 42, 260, 42,
WC_QUERY_STRING, WC_NONE,
_query_sign_edit_widgets,
void HandleClickOnSign(const Sign *si)
if (_ctrl_pressed && si->owner == _local_company) {
@@ -1207,13 +1207,13 @@ struct SelectStationWindow : Window {
static const WindowDesc _select_station_desc = {
WDP_AUTO, WDP_AUTO, 200, 92, 200, 182,
WC_SELECT_STATION, WC_NONE,
_select_station_widgets,
* Check whether we need to show the station selection window.
@@ -325,13 +325,13 @@ static const Widget _terraform_widgets[]
static const WindowDesc _terraform_desc = {
WDP_ALIGN_TBR, 22 + 36, 158, 36, 158, 36,
WC_SCEN_LAND_GEN, WC_NONE,
_terraform_widgets,
void ShowTerraformToolbar(Window *link)
@@ -706,13 +706,13 @@ struct ScenarioEditorLandscapeGeneration
static const WindowDesc _scen_edit_land_gen_desc = {
WDP_AUTO, WDP_AUTO, 163, 103, 163, 103,
_scen_edit_land_gen_widgets,
void ShowEditorTerraformToolbar()
AllocateWindowDescFront<ScenarioEditorLandscapeGenerationWindow>(&_scen_edit_land_gen_desc, 0);
@@ -354,13 +354,13 @@ static const Widget _timetable_widgets[]
{ WIDGETS_END }
static const WindowDesc _timetable_desc = {
WDP_AUTO, WDP_AUTO, 400, 130, 400, 130,
WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW,
_timetable_widgets,
void ShowTimetableWindow(const Vehicle *v)
@@ -171,13 +171,13 @@ static const Widget _build_trees_widgets
static const WindowDesc _build_trees_desc = {
WDP_AUTO, WDP_AUTO, 143, 184, 143, 184,
WC_BUILD_TREES, WC_NONE,
_build_trees_widgets,
void ShowBuildTreesToolbar()
if (_game_mode != GM_EDITOR && !IsValidCompanyID(_local_company)) return;
@@ -411,13 +411,13 @@ static const Widget _vehicle_refit_widge
static const WindowDesc _vehicle_refit_desc = {
WDP_AUTO, WDP_AUTO, 240, 174, 240, 174,
WC_VEHICLE_REFIT, WC_VEHICLE_VIEW,
_vehicle_refit_widgets,
/** Show the refit window for a vehicle
* @param *v The vehicle to show the refit window for
* @param order of the vehicle ( ? )
@@ -2188,12 +2188,34 @@ restart_search:
delete w;
goto restart_search;
* Delete all windows that are used for construction of vehicle etc.
* Once done with that invalidate the others to ensure they get refreshed too.
void DeleteConstructionWindows()
Window *w;
restart_search:
/* When we find the window to delete, we need to restart the search
* as deleting this window could cascade in deleting (many) others
* anywhere in the z-array */
FOR_ALL_WINDOWS_FROM_BACK(w) {
if (w->desc_flags & WDF_CONSTRUCTION) {
FOR_ALL_WINDOWS_FROM_BACK(w) w->SetDirty();
/** Delete all always on-top windows to get an empty screen */
void HideVitalWindows()
DeleteWindowById(WC_TOOLBAR_MENU, 0);
DeleteWindowById(WC_MAIN_TOOLBAR, 0);
DeleteWindowById(WC_STATUS_BAR, 0);
@@ -25,12 +25,13 @@ void InputLoop();
void InvalidateThisWindowData(Window *w, int data = 0);
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data = 0);
void InvalidateWindowClassesData(WindowClass cls, int data = 0);
void DeleteNonVitalWindows();
void DeleteAllNonVitalWindows();
void DeleteConstructionWindows();
void HideVitalWindows();
void ShowVitalWindows();
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
void InvalidateWindow(WindowClass cls, WindowNumber number);
void InvalidateWindowClasses(WindowClass cls);
@@ -121,12 +121,13 @@ struct WindowDesc {
* Window default widget/window handling flags
enum WindowDefaultFlag {
WDF_STD_TOOLTIPS = 1 << 0, ///< use standard routine when displaying tooltips
WDF_DEF_WIDGET = 1 << 1, ///< Default widget control for some widgets in the on click event, @see DispatchLeftClickEvent()
WDF_STD_BTN = 1 << 2, ///< Default handling for close and titlebar widgets (widget no 0 and 1)
WDF_CONSTRUCTION = 1 << 3, ///< This window is used for construction; close it whenever changing company.
WDF_UNCLICK_BUTTONS = 1 << 4, ///< Unclick buttons when the window event times out
WDF_STICKY_BUTTON = 1 << 5, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2)
WDF_RESIZABLE = 1 << 6, ///< Window can be resized
WDF_MODAL = 1 << 7, ///< The window is a modal child of some other window, meaning the parent is 'inactive'
Status change: