mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-08 01:10:28 +00:00
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
This commit is contained in:
parent
b6b73f7089
commit
6582f0b44a
28
depot_gui.c
28
depot_gui.c
@ -301,21 +301,22 @@ static void DrawDepotWindow(Window *w)
|
|||||||
TileIndex tile = w->window_number;
|
TileIndex tile = w->window_number;
|
||||||
int x, y, i, hnum, max;
|
int x, y, i, hnum, max;
|
||||||
uint16 num = WP(w, depot_d).engine_count;
|
uint16 num = WP(w, depot_d).engine_count;
|
||||||
bool is_localplayer = IsTileOwner(tile, _local_player);
|
|
||||||
|
|
||||||
/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
|
/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
|
||||||
uint16 rows_in_display = w->widget[DEPOT_WIDGET_MATRIX].data >> 8;
|
uint16 rows_in_display = w->widget[DEPOT_WIDGET_MATRIX].data >> 8;
|
||||||
uint16 boxes_in_each_row = w->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
|
uint16 boxes_in_each_row = w->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
|
||||||
|
|
||||||
/* setup disabled buttons */
|
/* setup disabled buttons */
|
||||||
SetWindowWidgetDisabledState(w, DEPOT_WIDGET_STOP_ALL, !is_localplayer);
|
SetWindowWidgetsDisabledState(w, !IsTileOwner(tile, _local_player),
|
||||||
SetWindowWidgetDisabledState(w, DEPOT_WIDGET_START_ALL, !is_localplayer);
|
DEPOT_WIDGET_STOP_ALL,
|
||||||
SetWindowWidgetDisabledState(w, DEPOT_WIDGET_SELL, !is_localplayer);
|
DEPOT_WIDGET_START_ALL,
|
||||||
SetWindowWidgetDisabledState(w, DEPOT_WIDGET_SELL_CHAIN, !is_localplayer);
|
DEPOT_WIDGET_SELL,
|
||||||
SetWindowWidgetDisabledState(w, DEPOT_WIDGET_SELL_ALL, !is_localplayer);
|
DEPOT_WIDGET_SELL_CHAIN,
|
||||||
SetWindowWidgetDisabledState(w, DEPOT_WIDGET_BUILD, !is_localplayer);
|
DEPOT_WIDGET_SELL_ALL,
|
||||||
SetWindowWidgetDisabledState(w, DEPOT_WIDGET_CLONE, !is_localplayer);
|
DEPOT_WIDGET_BUILD,
|
||||||
SetWindowWidgetDisabledState(w, DEPOT_WIDGET_AUTOREPLACE, !is_localplayer);
|
DEPOT_WIDGET_CLONE,
|
||||||
|
DEPOT_WIDGET_AUTOREPLACE,
|
||||||
|
WIDGET_LIST_END);
|
||||||
|
|
||||||
/* determine amount of items for scroller */
|
/* determine amount of items for scroller */
|
||||||
if (WP(w, depot_d).type == VEH_Train) {
|
if (WP(w, depot_d).type == VEH_Train) {
|
||||||
@ -1001,10 +1002,11 @@ void ShowDepotWindow(TileIndex tile, byte type)
|
|||||||
(w->vscroll.cap * 0x100) // number of rows to draw on the background
|
(w->vscroll.cap * 0x100) // number of rows to draw on the background
|
||||||
+ (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) {
|
|
||||||
HideWindowWidget(w, DEPOT_WIDGET_H_SCROLL);
|
SetWindowWidgetsHiddenState(w, type != VEH_Train,
|
||||||
HideWindowWidget(w, DEPOT_WIDGET_SELL_CHAIN);
|
DEPOT_WIDGET_H_SCROLL,
|
||||||
}
|
DEPOT_WIDGET_H_SCROLL,
|
||||||
|
WIDGET_LIST_END);
|
||||||
|
|
||||||
/* Move the widgets to their right locations */
|
/* Move the widgets to their right locations */
|
||||||
ResizeWindowWidgets(w, widget_moves, lengthof(widget_moves), horizontal, vertical);
|
ResizeWindowWidgets(w, widget_moves, lengthof(widget_moves), horizontal, vertical);
|
||||||
|
@ -1402,10 +1402,12 @@ static void CreateVehicleListWindow(Window *w)
|
|||||||
if (player == _local_player) {
|
if (player == _local_player) {
|
||||||
HideWindowWidget(w, VLW_WIDGET_OTHER_PLAYER_FILLER);
|
HideWindowWidget(w, VLW_WIDGET_OTHER_PLAYER_FILLER);
|
||||||
} else {
|
} else {
|
||||||
HideWindowWidget(w, VLW_WIDGET_SEND_TO_DEPOT);
|
SetWindowWidgetsHiddenState(w, true,
|
||||||
HideWindowWidget(w, VLW_WIDGET_AUTOREPLACE);
|
VLW_WIDGET_SEND_TO_DEPOT,
|
||||||
HideWindowWidget(w, VLW_WIDGET_STOP_ALL);
|
VLW_WIDGET_AUTOREPLACE,
|
||||||
HideWindowWidget(w, VLW_WIDGET_START_ALL);
|
VLW_WIDGET_STOP_ALL,
|
||||||
|
VLW_WIDGET_START_ALL,
|
||||||
|
WIDGET_LIST_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up the window widgets */
|
/* Set up the window widgets */
|
||||||
@ -1601,14 +1603,12 @@ static void DrawVehicleListWindow(Window *w)
|
|||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (owner == _local_player) {
|
SetWindowWidgetsDisabledState(w, vl->l.list_length == 0,
|
||||||
bool list_isempty = vl->l.list_length == 0;
|
VLW_WIDGET_SEND_TO_DEPOT,
|
||||||
|
VLW_WIDGET_AUTOREPLACE,
|
||||||
SetWindowWidgetDisabledState(w, VLW_WIDGET_SEND_TO_DEPOT, list_isempty);
|
VLW_WIDGET_STOP_ALL,
|
||||||
SetWindowWidgetDisabledState(w, VLW_WIDGET_AUTOREPLACE, list_isempty);
|
VLW_WIDGET_START_ALL,
|
||||||
SetWindowWidgetDisabledState(w, VLW_WIDGET_STOP_ALL, list_isempty);
|
WIDGET_LIST_END);
|
||||||
SetWindowWidgetDisabledState(w, VLW_WIDGET_START_ALL, list_isempty);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user