summaryrefslogtreecommitdiff
path: root/depot_gui.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-09-27 13:53:59 +0000
committerbjarni <bjarni@openttd.org>2006-09-27 13:53:59 +0000
commit1da48c9037026b0f4619977f5afafa0a22f7009c (patch)
tree67b8df10fbf9121d5c472e74eced22fd8cc324d7 /depot_gui.c
parentde6b8d8b30d704bf0c4be018afdab939b1667c0d (diff)
downloadopenttd-1da48c9037026b0f4619977f5afafa0a22f7009c.tar.xz
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
This will ensure that say the horizontal scrollbar is as wide as the matrix even if only the matrix is altered in size This is meant to make it easier to add more widgets without coding a lot of vehicle type specific stuff (you should still check all windows though)
Diffstat (limited to 'depot_gui.c')
-rw-r--r--depot_gui.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/depot_gui.c b/depot_gui.c
index 578bea336..31ecd71f5 100644
--- a/depot_gui.c
+++ b/depot_gui.c
@@ -82,7 +82,10 @@ static const byte widget_moves[] = {
* 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[]
- * If you want a widget for one window only, set it to be hidden in ShowDepotWindow() for the windows where you don't want it */
+ * If you want a widget for one window only, set it to be hidden in ShowDepotWindow() for the windows where you don't want it
+ * NOTE: the train only widgets are moved/resized in ShowDepotWindow() so they follow certain other widgets if they are moved to ensure that they stick together.
+ * Changing the size of those here will not have an effect at all. It should be done in ShowDepotWindow()
+ */
static const Widget _depot_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DEPOT_WIDGET_CLOSEBOX
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 292, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DEPOT_WIDGET_CAPTION
@@ -759,7 +762,6 @@ void ShowDepotWindow(TileIndex tile, byte type)
w->hscroll.cap = 10 * 29;
w->resize.step_width = 1;
w->resize.step_height = 14;
- w->widget[DEPOT_WIDGET_MATRIX].bottom -= 12; // Make room for the horizontal scrollbar
break;
case VEH_Road:
@@ -812,6 +814,22 @@ void ShowDepotWindow(TileIndex tile, byte type)
if (widget_moves[i] & WIDGET_DEPOT_MOVE_BOTTOM) w->widget[i].bottom += vertical;
}
}
+
+ if (type == VEH_Train) {
+ /* Now we move the train only widgets so they are placed correctly
+ * Doing it here will ensure that they move if the widget they are placed on top of/aligned to are moved */
+
+ /* DEPOT_WIDGET_H_SCROLL is placed in the lowest part of DEPOT_WIDGET_MATRIX */
+ w->widget[DEPOT_WIDGET_H_SCROLL].left = w->widget[DEPOT_WIDGET_MATRIX].left;
+ w->widget[DEPOT_WIDGET_H_SCROLL].right = w->widget[DEPOT_WIDGET_MATRIX].right;
+ w->widget[DEPOT_WIDGET_H_SCROLL].bottom = w->widget[DEPOT_WIDGET_MATRIX].bottom;
+ w->widget[DEPOT_WIDGET_H_SCROLL].top = w->widget[DEPOT_WIDGET_MATRIX].bottom - 11;
+ w->widget[DEPOT_WIDGET_MATRIX].bottom -= 12;
+
+ /* DEPOT_WIDGET_SELL_ALL is under DEPOT_WIDGET_SELL. They got the same left and right and height is controlled in ResizeDepotButtons() */
+ w->widget[DEPOT_WIDGET_SELL_ALL].left = w->widget[DEPOT_WIDGET_SELL].left;
+ w->widget[DEPOT_WIDGET_SELL_ALL].right = w->widget[DEPOT_WIDGET_SELL].right;
+ }
ResizeDepotButtons(w);
}
}