summaryrefslogtreecommitdiff
path: root/depot_gui.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-09-28 23:05:03 +0000
committerbjarni <bjarni@openttd.org>2006-09-28 23:05:03 +0000
commit4ccdb0686f3b401199efc975e8ce9f75bbcde0d7 (patch)
treeb9c5f2fcf23245015608eafaccdf02f62b94eda6 /depot_gui.c
parent1ae8aa4b809c3ddff032e2f3de7317490efa5235 (diff)
downloadopenttd-4ccdb0686f3b401199efc975e8ce9f75bbcde0d7.tar.xz
(svn r6562) -Codechange: merged the vehicle list window widget arrays
It made no sense to maintain 8 nearly identically arrays when a single one can do the job Also made the two buttons always use half of the bottom width each, even when resizing
Diffstat (limited to 'depot_gui.c')
-rw-r--r--depot_gui.c64
1 files changed, 19 insertions, 45 deletions
diff --git a/depot_gui.c b/depot_gui.c
index 405c6df02..6c254c11f 100644
--- a/depot_gui.c
+++ b/depot_gui.c
@@ -18,23 +18,7 @@
#include "vehicle_gui.h"
#include "station_map.h"
#include "newgrf_engine.h"
-
-enum {
- WIDGET_DEPOT_MOVE_NONE = 0 << 0,
- WIDGET_DEPOT_MOVE_RIGHT = 1 << 0,
- WIDGET_DEPOT_MOVE_LEFT = 1 << 1,
- WIDGET_DEPOT_MOVE_TOP = 1 << 2,
- WIDGET_DEPOT_MOVE_BOTTOM = 1 << 3,
-
- DEPOT_MOVE_NONE = WIDGET_DEPOT_MOVE_NONE,
- DEPOT_STRETCH_RIGHT = WIDGET_DEPOT_MOVE_RIGHT,
- DEPOT_MOVE_RIGHT = WIDGET_DEPOT_MOVE_RIGHT | WIDGET_DEPOT_MOVE_LEFT,
- DEPOT_STRETCH_DOWN = WIDGET_DEPOT_MOVE_BOTTOM,
- DEPOT_MOVE_DOWN = WIDGET_DEPOT_MOVE_BOTTOM | WIDGET_DEPOT_MOVE_TOP,
- DEPOT_STRETCH_DOWN_RIGHT = DEPOT_STRETCH_DOWN | DEPOT_STRETCH_RIGHT,
- DEPOT_MOVE_DOWN_RIGHT = DEPOT_MOVE_RIGHT | DEPOT_MOVE_DOWN,
- DEPOT_MOVE_RIGHT_STRETCH_DOWN = DEPOT_MOVE_RIGHT | DEPOT_STRETCH_DOWN,
-};
+#include "resize_window_widgets.h"
/*
* Since all depot window sizes aren't the same, we need to modify sizes a little.
@@ -65,22 +49,22 @@ typedef enum DepotWindowWidgets {
/* Define how to move each widget. The order is important */
static const byte widget_moves[] = {
- DEPOT_MOVE_NONE, // DEPOT_WIDGET_CLOSEBOX
- DEPOT_STRETCH_RIGHT, // DEPOT_WIDGET_CAPTION
- DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_STICKY
- DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_STOP_ALL
- DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_START_ALL
- DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_SELL
- DEPOT_MOVE_NONE, // DEPOT_WIDGET_SELL_CHAIN
- DEPOT_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_SELL_ALL
- DEPOT_STRETCH_DOWN_RIGHT, // DEPOT_WIDGET_MATRIX
- DEPOT_MOVE_RIGHT_STRETCH_DOWN, // DEPOT_WIDGET_V_SCROLL
- DEPOT_MOVE_NONE, // DEPOT_WIDGET_H_SCROLL
- DEPOT_MOVE_DOWN, // DEPOT_WIDGET_BUILD
- DEPOT_MOVE_DOWN, // DEPOT_WIDGET_CLONE
- DEPOT_MOVE_DOWN, // DEPOT_WIDGET_LOCATION
- DEPOT_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_AUTOREPLACE
- DEPOT_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_RESIZE
+ WIDGET_MOVE_NONE, // DEPOT_WIDGET_CLOSEBOX
+ WIDGET_STRETCH_RIGHT, // DEPOT_WIDGET_CAPTION
+ WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_STICKY
+ WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_STOP_ALL
+ WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_START_ALL
+ WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_SELL
+ WIDGET_MOVE_NONE, // DEPOT_WIDGET_SELL_CHAIN
+ WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_SELL_ALL
+ WIDGET_STRETCH_DOWN_RIGHT, // DEPOT_WIDGET_MATRIX
+ WIDGET_MOVE_RIGHT_STRETCH_DOWN, // DEPOT_WIDGET_V_SCROLL
+ WIDGET_MOVE_NONE, // DEPOT_WIDGET_H_SCROLL
+ WIDGET_MOVE_DOWN, // DEPOT_WIDGET_BUILD
+ WIDGET_MOVE_DOWN, // DEPOT_WIDGET_CLONE
+ WIDGET_MOVE_DOWN, // DEPOT_WIDGET_LOCATION
+ WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_AUTOREPLACE
+ WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_RESIZE
};
/* Widget array for all depot windows.
@@ -906,18 +890,8 @@ void ShowDepotWindow(TileIndex tile, byte type)
SETBIT(w->hidden_state, DEPOT_WIDGET_SELL_CHAIN);
}
- /* Move the widgets to their right locations
- * Note: it's signed values so negative will make the widget move left and not right, or up instead of down */
- {
- byte i;
-
- for (i = 0; i < lengthof(widget_moves); i++) {
- if (widget_moves[i] & WIDGET_DEPOT_MOVE_LEFT) w->widget[i].left += horizontal;
- if (widget_moves[i] & WIDGET_DEPOT_MOVE_RIGHT) w->widget[i].right += horizontal;
- if (widget_moves[i] & WIDGET_DEPOT_MOVE_TOP) w->widget[i].top += vertical;
- if (widget_moves[i] & WIDGET_DEPOT_MOVE_BOTTOM) w->widget[i].bottom += vertical;
- }
- }
+ /* Move the widgets to their right locations */
+ ResizeWindowWidgets(w, widget_moves, lengthof(widget_moves), horizontal, vertical);
if (type == VEH_Train) {
/* Now we move the train only widgets so they are placed correctly