mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r6612) -Codechange: Use accessors for hidden_state.
Another step toward merging XTDwidget. The only two files not converted (window.h and widget.c) will be done at the very last commit)
This commit is contained in:
parent
21591b5219
commit
2c45339e0a
|
@ -552,10 +552,14 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case WE_MOUSELOOP: {
|
case WE_MOUSELOOP: {
|
||||||
const Vehicle *v = GetVehicle(w->window_number);
|
const Vehicle *v = GetVehicle(w->window_number);
|
||||||
uint32 h = IsAircraftInHangarStopped(v) ? 1 << 7 : 1 << 11;
|
bool plane_stopped = IsAircraftInHangarStopped(v);
|
||||||
|
|
||||||
if (h != w->hidden_state) {
|
/* Widget 7 (send to hangar) must be hidden if the plane is already stopped in hangar.
|
||||||
w->hidden_state = h;
|
* 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);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -71,7 +71,7 @@ static const byte widget_moves[] = {
|
||||||
|
|
||||||
/* Widget array for all depot windows.
|
/* Widget array for all depot windows.
|
||||||
* If a widget is needed in some windows only (like train specific), add it for all 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!!! */
|
* 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[]
|
/* 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
|
+ (type == VEH_Train ? 1 : w->hscroll.cap); // number of boxes in each row. Trains always have just one
|
||||||
|
|
||||||
if (type != VEH_Train) {
|
if (type != VEH_Train) {
|
||||||
SETBIT(w->hidden_state, DEPOT_WIDGET_H_SCROLL);
|
HideWindowWidget(w, DEPOT_WIDGET_H_SCROLL);
|
||||||
SETBIT(w->hidden_state, DEPOT_WIDGET_SELL_CHAIN);
|
HideWindowWidget(w, DEPOT_WIDGET_SELL_CHAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move the widgets to their right locations */
|
/* Move the widgets to their right locations */
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
|
||||||
case WE_CREATE: {
|
case WE_CREATE: {
|
||||||
int i;
|
int i;
|
||||||
Player *p2;
|
Player *p2;
|
||||||
w->hidden_state = 0;
|
|
||||||
w->disabled_state = 0;
|
w->disabled_state = 0;
|
||||||
|
|
||||||
// Hide the player who are not active
|
// Hide the player who are not active
|
||||||
|
|
|
@ -654,7 +654,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
||||||
if (!IsWindowOfPrototype(w, _other_player_company_widgets)) {
|
if (!IsWindowOfPrototype(w, _other_player_company_widgets)) {
|
||||||
AssignWidgetToWindow(w, (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_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 {
|
} else {
|
||||||
if (p->location_of_house == 0) SETBIT(dis, 7);
|
if (p->location_of_house == 0) SETBIT(dis, 7);
|
||||||
|
|
||||||
|
|
|
@ -337,13 +337,19 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
|
||||||
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
|
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_MOUSELOOP:
|
case WE_MOUSELOOP: {
|
||||||
{
|
|
||||||
const Vehicle *v = GetVehicle(w->window_number);
|
const Vehicle *v = GetVehicle(w->window_number);
|
||||||
uint32 h = IsRoadVehInDepotStopped(v) ? 1 << 7 | 1 << 8 : 1 << 11 | 1 << 12;
|
bool rv_stopped = IsRoadVehInDepotStopped(v);
|
||||||
|
|
||||||
if (h != w->hidden_state) {
|
/* Widget 7 (send to depot) must be hidden if the truck/bus is already stopped in depot.
|
||||||
w->hidden_state = h;
|
* 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);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
ship_gui.c
13
ship_gui.c
|
@ -477,13 +477,16 @@ static void ShipViewWndProc(Window *w, WindowEvent *e)
|
||||||
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
|
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_MOUSELOOP:
|
case WE_MOUSELOOP: {
|
||||||
{
|
|
||||||
const Vehicle *v = GetVehicle(w->window_number);
|
const Vehicle *v = GetVehicle(w->window_number);
|
||||||
uint32 h = IsShipInDepotStopped(v) ? 1 << 7 : 1 << 11;
|
bool ship_stopped = IsShipInDepotStopped(v);
|
||||||
|
|
||||||
if (h != w->hidden_state) {
|
/* Widget 7 (send to depot) must be hidden if the ship is already stopped in depot.
|
||||||
w->hidden_state = h;
|
* 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);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
15
train_gui.c
15
train_gui.c
|
@ -564,12 +564,17 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case WE_MOUSELOOP: {
|
case WE_MOUSELOOP: {
|
||||||
const Vehicle *v = GetVehicle(w->window_number);
|
const Vehicle *v = GetVehicle(w->window_number);
|
||||||
uint32 h;
|
bool train_stopped = CheckTrainStoppedInDepot(v) >= 0;
|
||||||
|
|
||||||
assert(v->type == VEH_Train);
|
/* Widget 7 (send to depot) must be hidden if the train is already stopped in hangar.
|
||||||
h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9)| (1 << 7) : (1 << 12) | (1 << 13);
|
* Widget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
|
||||||
if (h != w->hidden_state) {
|
* This sytem allows to have two buttons, on top of each other.
|
||||||
w->hidden_state = h;
|
* 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);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1393,12 +1393,12 @@ static void CreateVehicleListWindow(Window *w)
|
||||||
/* Hide the widgets that we will not use in this window
|
/* Hide the widgets that we will not use in this window
|
||||||
* Some windows contains actions only fit for the owner */
|
* Some windows contains actions only fit for the owner */
|
||||||
if (player == _local_player) {
|
if (player == _local_player) {
|
||||||
SETBIT(w->hidden_state, VLW_WIDGET_OTHER_PLAYER_FILLER);
|
HideWindowWidget(w, VLW_WIDGET_OTHER_PLAYER_FILLER);
|
||||||
} else {
|
} else {
|
||||||
SETBIT(w->hidden_state, VLW_WIDGET_SEND_TO_DEPOT);
|
HideWindowWidget(w, VLW_WIDGET_SEND_TO_DEPOT);
|
||||||
SETBIT(w->hidden_state, VLW_WIDGET_AUTOREPLACE);
|
HideWindowWidget(w, VLW_WIDGET_AUTOREPLACE);
|
||||||
SETBIT(w->hidden_state, VLW_WIDGET_STOP_ALL);
|
HideWindowWidget(w, VLW_WIDGET_STOP_ALL);
|
||||||
SETBIT(w->hidden_state, VLW_WIDGET_START_ALL);
|
HideWindowWidget(w, VLW_WIDGET_START_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up the window widgets */
|
/* Set up the window widgets */
|
||||||
|
|
Loading…
Reference in New Issue