diff options
-rw-r--r-- | aircraft_gui.c | 12 | ||||
-rw-r--r-- | depot_gui.c | 6 | ||||
-rw-r--r-- | graph_gui.c | 2 | ||||
-rw-r--r-- | player_gui.c | 2 | ||||
-rw-r--r-- | roadveh_gui.c | 18 | ||||
-rw-r--r-- | ship_gui.c | 15 | ||||
-rw-r--r-- | train_gui.c | 17 | ||||
-rw-r--r-- | vehicle_gui.c | 10 |
8 files changed, 50 insertions, 32 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c index 8b503bd3c..97b88c062 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -552,10 +552,14 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e) case WE_MOUSELOOP: { const Vehicle *v = GetVehicle(w->window_number); - uint32 h = IsAircraftInHangarStopped(v) ? 1 << 7 : 1 << 11; - - if (h != w->hidden_state) { - w->hidden_state = h; + bool plane_stopped = IsAircraftInHangarStopped(v); + + /* Widget 7 (send to hangar) must be hidden if the plane is already stopped in hangar. + * Widget 11 (clone) should then be shown, since cloning is allowed only while in hangar and stopped. + * This sytem allows to have two buttons, on top of each other*/ + if (plane_stopped != IsWindowWidgetHidden(w, 7) || plane_stopped == IsWindowWidgetHidden(w, 11)) { + SetWindowWidgetHiddenState(w, 7, plane_stopped); // send to hangar + SetWindowWidgetHiddenState(w, 11, !plane_stopped); // clone SetWindowDirty(w); } } break; diff --git a/depot_gui.c b/depot_gui.c index a72887212..83554a89d 100644 --- a/depot_gui.c +++ b/depot_gui.c @@ -71,7 +71,7 @@ static const byte widget_moves[] = { /* Widget array for all depot windows. * If a widget is needed in some windows only (like train specific), add it for all windows - * and use w->hidden_state in ShowDepotWindow() to remove it in the windows where it should not be + * and use HideWindowWidget in ShowDepotWindow() to remove it in the windows where it should not be * Keep the widget numbers in sync with the enum or really bad stuff will happen!!! */ /* When adding widgets, place them as you would place them for the ship depot and define how you want it to move in widget_moves[] @@ -968,8 +968,8 @@ void ShowDepotWindow(TileIndex tile, byte type) + (type == VEH_Train ? 1 : w->hscroll.cap); // number of boxes in each row. Trains always have just one if (type != VEH_Train) { - SETBIT(w->hidden_state, DEPOT_WIDGET_H_SCROLL); - SETBIT(w->hidden_state, DEPOT_WIDGET_SELL_CHAIN); + HideWindowWidget(w, DEPOT_WIDGET_H_SCROLL); + HideWindowWidget(w, DEPOT_WIDGET_SELL_CHAIN); } /* Move the widgets to their right locations */ diff --git a/graph_gui.c b/graph_gui.c index a24f17019..ee725b526 100644 --- a/graph_gui.c +++ b/graph_gui.c @@ -1010,7 +1010,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) case WE_CREATE: { int i; Player *p2; - w->hidden_state = 0; + w->disabled_state = 0; // Hide the player who are not active diff --git a/player_gui.c b/player_gui.c index 4065cd675..d227f485f 100644 --- a/player_gui.c +++ b/player_gui.c @@ -654,7 +654,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) if (!IsWindowOfPrototype(w, _other_player_company_widgets)) { AssignWidgetToWindow(w, (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets); - if (!_networking) SETBIT(w->hidden_state, 11); // hide company-password widget + SetWindowWidgetHiddenState(w, 11, !_networking); // Hide company-password widget } else { if (p->location_of_house == 0) SETBIT(dis, 7); diff --git a/roadveh_gui.c b/roadveh_gui.c index 01c8f459e..2a5066c1f 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -337,13 +337,19 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); break; - case WE_MOUSELOOP: - { + case WE_MOUSELOOP: { const Vehicle *v = GetVehicle(w->window_number); - uint32 h = IsRoadVehInDepotStopped(v) ? 1 << 7 | 1 << 8 : 1 << 11 | 1 << 12; - - if (h != w->hidden_state) { - w->hidden_state = h; + bool rv_stopped = IsRoadVehInDepotStopped(v); + + /* Widget 7 (send to depot) must be hidden if the truck/bus is already stopped in depot. + * Widget 11 (clone) should then be shown, since cloning is allowed only while in depot and stopped. + * This sytem allows to have two buttons, on top of each other. + * The same system applies to widget 8 and 12, force turn around and refit. */ + if (rv_stopped != IsWindowWidgetHidden(w, 7) || rv_stopped == IsWindowWidgetHidden(w, 11)) { + SetWindowWidgetHiddenState(w, 7, rv_stopped); // send to depot + SetWindowWidgetHiddenState(w, 8, rv_stopped); // force turn around + SetWindowWidgetHiddenState(w, 11, !rv_stopped); // clone + SetWindowWidgetHiddenState(w, 12, !rv_stopped); // refit SetWindowDirty(w); } } diff --git a/ship_gui.c b/ship_gui.c index bf1114d1c..7d8cfa868 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -477,13 +477,16 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); break; - case WE_MOUSELOOP: - { + case WE_MOUSELOOP: { const Vehicle *v = GetVehicle(w->window_number); - uint32 h = IsShipInDepotStopped(v) ? 1 << 7 : 1 << 11; - - if (h != w->hidden_state) { - w->hidden_state = h; + bool ship_stopped = IsShipInDepotStopped(v); + + /* Widget 7 (send to depot) must be hidden if the ship is already stopped in depot. + * Widget 11 (clone) should then be shown, since cloning is allowed only while in depot and stopped. + * This sytem allows to have two buttons, on top of each otherother*/ + if (ship_stopped != IsWindowWidgetHidden(w, 7) || ship_stopped == IsWindowWidgetHidden(w, 11)) { + SetWindowWidgetHiddenState(w, 7, ship_stopped); // send to depot + SetWindowWidgetHiddenState(w, 11, !ship_stopped); // clone SetWindowDirty(w); } } diff --git a/train_gui.c b/train_gui.c index 5f3e7b93f..9e5a6986f 100644 --- a/train_gui.c +++ b/train_gui.c @@ -564,12 +564,17 @@ static void TrainViewWndProc(Window *w, WindowEvent *e) case WE_MOUSELOOP: { const Vehicle *v = GetVehicle(w->window_number); - uint32 h; - - assert(v->type == VEH_Train); - h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9)| (1 << 7) : (1 << 12) | (1 << 13); - if (h != w->hidden_state) { - w->hidden_state = h; + bool train_stopped = CheckTrainStoppedInDepot(v) >= 0; + + /* Widget 7 (send to depot) must be hidden if the train is already stopped in hangar. + * Widget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped. + * This sytem allows to have two buttons, on top of each other. + * The same system applies to widget 9 and 12, reverse direction and refit*/ + if (train_stopped != IsWindowWidgetHidden(w, 7) || train_stopped == IsWindowWidgetHidden(w, 13)) { + SetWindowWidgetHiddenState(w, 7, train_stopped); // send to depot + SetWindowWidgetHiddenState(w, 9, train_stopped); // reverse direction + SetWindowWidgetHiddenState(w, 12, !train_stopped); // refit + SetWindowWidgetHiddenState(w, 13, !train_stopped); // clone SetWindowDirty(w); } break; diff --git a/vehicle_gui.c b/vehicle_gui.c index 51596726b..b5068a0b9 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -1393,12 +1393,12 @@ static void CreateVehicleListWindow(Window *w) /* Hide the widgets that we will not use in this window * Some windows contains actions only fit for the owner */ if (player == _local_player) { - SETBIT(w->hidden_state, VLW_WIDGET_OTHER_PLAYER_FILLER); + HideWindowWidget(w, VLW_WIDGET_OTHER_PLAYER_FILLER); } else { - SETBIT(w->hidden_state, VLW_WIDGET_SEND_TO_DEPOT); - SETBIT(w->hidden_state, VLW_WIDGET_AUTOREPLACE); - SETBIT(w->hidden_state, VLW_WIDGET_STOP_ALL); - SETBIT(w->hidden_state, VLW_WIDGET_START_ALL); + HideWindowWidget(w, VLW_WIDGET_SEND_TO_DEPOT); + HideWindowWidget(w, VLW_WIDGET_AUTOREPLACE); + HideWindowWidget(w, VLW_WIDGET_STOP_ALL); + HideWindowWidget(w, VLW_WIDGET_START_ALL); } /* Set up the window widgets */ |