author | bjarni |
Wed, 27 Sep 2006 14:05:15 +0000 | |
changeset 4651 | 73d828df1b28 |
parent 4650 | 52adab371ed7 |
child 4652 | f85116c065f1 |
permissions | -rw-r--r-- |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1 |
/* $Id$ */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
2 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
4 |
#include "openttd.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
5 |
#include "functions.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
6 |
#include "ship.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
7 |
#include "table/strings.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
8 |
#include "table/sprites.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
9 |
#include "gui.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
10 |
#include "gfx.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
11 |
#include "vehicle.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
12 |
#include "viewport.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
13 |
#include "command.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
14 |
#include "depot.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
15 |
#include "vehicle_gui.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
16 |
#include "station_map.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
17 |
#include "newgrf_engine.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
18 |
#include "train.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
19 |
|
4649
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
20 |
enum { |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
21 |
WIDGET_DEPOT_MOVE_NONE = 0 << 0, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
22 |
WIDGET_DEPOT_MOVE_RIGHT = 1 << 0, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
23 |
WIDGET_DEPOT_MOVE_LEFT = 1 << 1, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
24 |
WIDGET_DEPOT_MOVE_TOP = 1 << 2, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
25 |
WIDGET_DEPOT_MOVE_BOTTOM = 1 << 3, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
26 |
|
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
27 |
DEPOT_MOVE_NONE = WIDGET_DEPOT_MOVE_NONE, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
28 |
DEPOT_STRETCH_RIGHT = WIDGET_DEPOT_MOVE_RIGHT, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
29 |
DEPOT_MOVE_RIGHT = WIDGET_DEPOT_MOVE_RIGHT | WIDGET_DEPOT_MOVE_LEFT, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
30 |
DEPOT_STRETCH_DOWN = WIDGET_DEPOT_MOVE_BOTTOM, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
31 |
DEPOT_MOVE_DOWN = WIDGET_DEPOT_MOVE_BOTTOM | WIDGET_DEPOT_MOVE_TOP, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
32 |
DEPOT_STRETCH_DOWN_RIGHT = DEPOT_STRETCH_DOWN | DEPOT_STRETCH_RIGHT, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
33 |
DEPOT_MOVE_DOWN_RIGHT = DEPOT_MOVE_RIGHT | DEPOT_MOVE_DOWN, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
34 |
DEPOT_MOVE_RIGHT_STRETCH_DOWN = DEPOT_MOVE_RIGHT | DEPOT_STRETCH_DOWN, |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
35 |
}; |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
36 |
|
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
37 |
/* |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
38 |
* Since all depot window sizes aren't the same, we need to modify sizes a little. |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
39 |
* It's done with the following arrays of widget indexes. Each of them tells if a widget side should be moved and in what direction. |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
40 |
* How long they should be moved and for what window types are controlled in ShowDepotWindow() |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
41 |
*/ |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
42 |
|
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
43 |
/* Names of the widgets. Keep them in the same order as in the widget array */ |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
44 |
typedef enum DepotWindowWidgets { |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
45 |
DEPOT_WIDGET_CLOSEBOX = 0, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
46 |
DEPOT_WIDGET_CAPTION, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
47 |
DEPOT_WIDGET_STICKY, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
48 |
DEPOT_WIDGET_STOP_ALL, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
49 |
DEPOT_WIDGET_START_ALL, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
50 |
DEPOT_WIDGET_SELL, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
51 |
DEPOT_WIDGET_SELL_ALL, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
52 |
DEPOT_WIDGET_MATRIX, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
53 |
DEPOT_WIDGET_V_SCROLL, // Vertical scrollbar |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
54 |
DEPOT_WIDGET_H_SCROLL, // Horizontal scrollbar |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
55 |
DEPOT_WIDGET_BUILD, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
56 |
DEPOT_WIDGET_CLONE, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
57 |
DEPOT_WIDGET_LOCATION, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
58 |
DEPOT_WIDGET_RESIZE, |
4651
73d828df1b28
(svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents:
4650
diff
changeset
|
59 |
DEPOT_WIDGET_LAST, // used to assert if DepotWindowWidgets and widget_moves got different lengths. Due to this usage, it needs to be last |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
60 |
} DepotWindowWidget; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
61 |
|
4649
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
62 |
/* Define how to move each widget. The order is important */ |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
63 |
static const byte widget_moves[] = { |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
64 |
DEPOT_MOVE_NONE, // DEPOT_WIDGET_CLOSEBOX |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
65 |
DEPOT_STRETCH_RIGHT, // DEPOT_WIDGET_CAPTION |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
66 |
DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_STICKY |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
67 |
DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_STOP_ALL |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
68 |
DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_START_ALL |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
69 |
DEPOT_MOVE_RIGHT, // DEPOT_WIDGET_SELL |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
70 |
DEPOT_MOVE_NONE, // DEPOT_WIDGET_SELL_ALL |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
71 |
DEPOT_STRETCH_DOWN_RIGHT, // DEPOT_WIDGET_MATRIX |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
72 |
DEPOT_MOVE_RIGHT_STRETCH_DOWN, // DEPOT_WIDGET_V_SCROLL |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
73 |
DEPOT_MOVE_NONE, // DEPOT_WIDGET_H_SCROLL |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
74 |
DEPOT_MOVE_DOWN, // DEPOT_WIDGET_BUILD |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
75 |
DEPOT_MOVE_DOWN, // DEPOT_WIDGET_CLONE |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
76 |
DEPOT_MOVE_DOWN, // DEPOT_WIDGET_LOCATION |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
77 |
DEPOT_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_RESIZE |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
78 |
}; |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
79 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
80 |
/* Widget array for all depot windows. |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
81 |
* If a widget is needed in some windows only (like train specific), add it for all windows |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
82 |
* and use w->hidden_state in ShowDepotWindow() to remove it in the windows where it should not be |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
83 |
* Keep the widget numbers in sync with the enum or really bad stuff will happen!!! */ |
4649
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
84 |
|
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
85 |
/* 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[] |
4650
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
86 |
* 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 |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
87 |
* 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. |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
88 |
* Changing the size of those here will not have an effect at all. It should be done in ShowDepotWindow() |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
89 |
*/ |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
90 |
static const Widget _depot_widgets[] = { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
91 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DEPOT_WIDGET_CLOSEBOX |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
92 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 292, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DEPOT_WIDGET_CAPTION |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
93 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 293, 304, 0, 13, 0x0, STR_STICKY_BUTTON}, // DEPOT_WIDGET_STICKY |
4640
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
94 |
|
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
95 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 270, 280, 14, 25, SPR_FLAG_VEH_STOPPED,STR_MASS_STOP_DEPOT_TOOLTIP}, // DEPOT_WIDGET_STOP_ALL |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
96 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 281, 292, 14, 25, SPR_FLAG_VEH_RUNNING,STR_MASS_START_DEPOT_TOOLTIP}, // DEPOT_WIDGET_START_ALL |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
97 |
{ WWT_IMGBTN, RESIZE_LRB, 14, 270, 292, 26, 61, 0x2A9, STR_NULL}, // DEPOT_WIDGET_SELL |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
98 |
{ WWT_PANEL, RESIZE_LRTB, 14, 326, 348, 0, 0, 0x2BF, STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, // DEPOT_WIDGET_SELL_ALL, trains only |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
99 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
100 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 269, 14, 61, 0x0, STR_NULL}, // DEPOT_WIDGET_MATRIX |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
101 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 293, 304, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // DEPOT_WIDGET_V_SCROLL |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
102 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
103 |
{ WWT_HSCROLLBAR, RESIZE_RTB, 14, 0, 325, 98, 109, 0x0, STR_HSCROLL_BAR_SCROLLS_LIST}, // DEPOT_WIDGET_H_SCROLL, trains only |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
104 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
105 |
/* The buttons in the bottom of the window. left and right is not important as they are later resized to be equal in size |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
106 |
* This calculation is based on right in DEPOT_WIDGET_LOCATION and it presumes left of DEPOT_WIDGET_BUILD is 0 */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
107 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 96, 62, 73, 0x0, STR_NULL}, // DEPOT_WIDGET_BUILD |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
108 |
{WWT_NODISTXTBTN, RESIZE_TB, 14, 97, 194, 62, 73, 0x0, STR_NULL}, // DEPOT_WIDGET_CLONE |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
109 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 195, 292, 62, 73, STR_00E4_LOCATION, STR_NULL}, // DEPOT_WIDGET_LOCATION |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
110 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 293, 304, 62, 73, 0x0, STR_RESIZE_BUTTON}, // DEPOT_WIDGET_RESIZE |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
111 |
{ WIDGETS_END}, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
112 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
113 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
114 |
static void DepotWndProc(Window *w, WindowEvent *e); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
115 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
116 |
static const WindowDesc _train_depot_desc = { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
117 |
-1, -1, 361, 122, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
118 |
WC_VEHICLE_DEPOT,0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
119 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
120 |
_depot_widgets, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
121 |
DepotWndProc |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
122 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
123 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
124 |
static const WindowDesc _road_depot_desc = { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
125 |
-1, -1, 315, 68, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
126 |
WC_VEHICLE_DEPOT,0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
127 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
128 |
_depot_widgets, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
129 |
DepotWndProc |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
130 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
131 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
132 |
static const WindowDesc _ship_depot_desc = { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
133 |
-1, -1, 305, 74, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
134 |
WC_VEHICLE_DEPOT,0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
135 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
136 |
_depot_widgets, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
137 |
DepotWndProc |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
138 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
139 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
140 |
static const WindowDesc _aircraft_depot_desc = { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
141 |
-1, -1, 331, 74, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
142 |
WC_VEHICLE_DEPOT,0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
143 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
144 |
_depot_widgets, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
145 |
DepotWndProc |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
146 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
147 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
148 |
extern int WagonLengthToPixels(int len); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
149 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
150 |
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
151 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
152 |
if (!success) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
153 |
CcCloneShip(true, tile, p1, p2); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
154 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
155 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
156 |
static inline void ShowVehicleViewWindow(const Vehicle *v) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
157 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
158 |
switch (v->type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
159 |
case VEH_Train: ShowTrainViewWindow(v); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
160 |
case VEH_Road: ShowRoadVehViewWindow(v); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
161 |
case VEH_Ship: ShowShipViewWindow(v); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
162 |
case VEH_Aircraft: ShowAircraftViewWindow(v); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
163 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
164 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
165 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
166 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
167 |
static void DrawDepotWindow(Window *w) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
168 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
169 |
Vehicle **vl = WP(w, depot_d).vehicle_list; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
170 |
TileIndex tile; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
171 |
int x, y, i, hnum, max; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
172 |
uint16 num = WP(w, depot_d).engine_count; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
173 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
174 |
tile = w->window_number; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
175 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
176 |
/* setup disabled buttons */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
177 |
w->disabled_state = |
4644
22c723f7a095
(svn r6520) -Fix r6515: "start all" and "stop all" buttons in depot windows are now disabled if you do not own the depot
bjarni
parents:
4641
diff
changeset
|
178 |
IsTileOwner(tile, _local_player) ? 0 : ( (1 << DEPOT_WIDGET_STOP_ALL) | (1 << DEPOT_WIDGET_START_ALL) | |
22c723f7a095
(svn r6520) -Fix r6515: "start all" and "stop all" buttons in depot windows are now disabled if you do not own the depot
bjarni
parents:
4641
diff
changeset
|
179 |
(1 << DEPOT_WIDGET_SELL) | (1 << DEPOT_WIDGET_SELL_ALL) | (1 << DEPOT_WIDGET_BUILD) | (1 << DEPOT_WIDGET_CLONE)); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
180 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
181 |
/* determine amount of items for scroller */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
182 |
if (WP(w, depot_d).type == VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
183 |
hnum = 8; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
184 |
for (num = 0; num < WP(w, depot_d).engine_count; num++) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
185 |
const Vehicle *v = vl[num]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
186 |
hnum = maxu(hnum, v->u.rail.cached_total_length); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
187 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
188 |
/* Always have 1 empty row, so people can change the setting of the train */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
189 |
SetVScrollCount(w, WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count + 1); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
190 |
SetHScrollCount(w, WagonLengthToPixels(hnum)); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
191 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
192 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
193 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
194 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
195 |
/* locate the depot struct */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
196 |
if (WP(w, depot_d).type == VEH_Aircraft) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
197 |
SetDParam(0, GetStationIndex(tile)); // Airport name |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
198 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
199 |
Depot *depot = GetDepotByTile(tile); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
200 |
assert(depot != NULL); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
201 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
202 |
SetDParam(0, depot->town_index); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
203 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
204 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
205 |
DrawWindowWidgets(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
206 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
207 |
x = 2; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
208 |
y = 15; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
209 |
num = w->vscroll.pos * w->hscroll.cap; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
210 |
if (WP(w, depot_d).type == VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
211 |
max = min(WP(w, depot_d).engine_count, w->vscroll.pos + w->vscroll.cap); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
212 |
num = w->vscroll.pos; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
213 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
214 |
max = min(WP(w, depot_d).engine_count, num + (w->vscroll.cap * w->hscroll.cap)); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
215 |
num = w->vscroll.pos * w->hscroll.cap; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
216 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
217 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
218 |
for (; num < max; num++) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
219 |
const Vehicle *v = vl[num]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
220 |
byte diff_x = 0, diff_y = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
221 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
222 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
223 |
case VEH_Train: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
224 |
DrawTrainImage(v, x + 21, y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,depot_d).sel); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
225 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
226 |
/* Number of wagons relative to a standard length wagon (rounded up) */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
227 |
SetDParam(0, (v->u.rail.cached_total_length + 7) / 8); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
228 |
DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
229 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
230 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
231 |
case VEH_Road: DrawRoadVehImage( v, x + 24, y, WP(w, depot_d).sel); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
232 |
case VEH_Ship: DrawShipImage( v, x + 19, y, WP(w, depot_d).sel); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
233 |
case VEH_Aircraft: DrawAircraftImage(v, x + 12, y, WP(w, depot_d).sel); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
234 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
235 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
236 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
237 |
if (w->resize.step_height == 14) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
238 |
/* VEH_Train and VEH_Road, which are low */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
239 |
diff_x = 15; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
240 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
241 |
/* VEH_Ship and VEH_Aircraft, which are tall */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
242 |
diff_y = 12; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
243 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
244 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
245 |
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + diff_x, y + diff_y); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
246 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
247 |
SetDParam(0, v->unitnumber); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
248 |
DrawString(x, y + 2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
249 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
250 |
if (WP(w, depot_d).type == VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
251 |
y += w->resize.step_height; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
252 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
253 |
if ((x += w->resize.step_width) == 2 + (int)w->resize.step_width * w->hscroll.cap) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
254 |
x = 2; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
255 |
y += w->resize.step_height; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
256 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
257 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
258 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
259 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
260 |
max = min(WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count, w->vscroll.pos + w->vscroll.cap); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
261 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
262 |
/* draw the train wagons, that do not have an engine in front */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
263 |
for (; num < max; num++) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
264 |
const Vehicle *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
265 |
const Vehicle *u; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
266 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
267 |
DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w,depot_d).sel); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
268 |
DrawString(x, y + 2, STR_8816, 0); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
269 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
270 |
/*Draw the train counter */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
271 |
i = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
272 |
u = v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
273 |
do i++; while ( (u=u->next) != NULL); // Determine length of train |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
274 |
SetDParam(0, i); // Set the counter |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
275 |
DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
276 |
y += 14; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
277 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
278 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
279 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
280 |
typedef struct GetDepotVehiclePtData { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
281 |
Vehicle *head; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
282 |
Vehicle *wagon; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
283 |
} GetDepotVehiclePtData; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
284 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
285 |
enum { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
286 |
MODE_ERROR = 1, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
287 |
MODE_DRAG_VEHICLE = 0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
288 |
MODE_SHOW_VEHICLE = -1, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
289 |
MODE_START_STOP = -2, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
290 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
291 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
292 |
static int GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh, GetDepotVehiclePtData *d) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
293 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
294 |
Vehicle **vl = WP(w, depot_d).vehicle_list; |
4641
388b816eef86
(svn r6516) -Fix r6513: killed warnings about two variables being used uninitialized
bjarni
parents:
4640
diff
changeset
|
295 |
uint xt, row, xm = 0, ym = 0; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
296 |
int pos, skip = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
297 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
298 |
if (WP(w, depot_d).type == VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
299 |
xt = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
300 |
x -= 23; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
301 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
302 |
xt = x / w->resize.step_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
303 |
xm = x % w->resize.step_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
304 |
if (xt >= w->hscroll.cap) return MODE_ERROR; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
305 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
306 |
ym = (y - 14) % w->resize.step_height; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
307 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
308 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
309 |
row = (y - 14) / w->resize.step_height; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
310 |
if (row >= w->vscroll.cap) return MODE_ERROR; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
311 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
312 |
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
313 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
314 |
if (WP(w, depot_d).type == VEH_Train) pos = row + w->vscroll.pos; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
315 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
316 |
if (WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count <= pos) return MODE_ERROR; // empty block, so no vehicle is selected |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
317 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
318 |
if (WP(w, depot_d).engine_count > pos) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
319 |
*veh = vl[pos]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
320 |
skip = w->hscroll.pos; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
321 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
322 |
vl = WP(w, depot_d).wagon_list; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
323 |
pos -= WP(w, depot_d).engine_count; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
324 |
*veh = vl[pos]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
325 |
/* free wagons don't have an initial loco. */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
326 |
x -= _traininfo_vehicle_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
327 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
328 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
329 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
330 |
case VEH_Train: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
331 |
Vehicle *v = *veh; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
332 |
d->head = d->wagon = v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
333 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
334 |
/* either pressed the flag or the number, but only when it's a loco */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
335 |
if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? MODE_START_STOP : MODE_SHOW_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
336 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
337 |
skip = (skip * 8) / _traininfo_vehicle_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
338 |
x = (x * 8) / _traininfo_vehicle_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
339 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
340 |
/* Skip vehicles that are scrolled off the list */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
341 |
x += skip; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
342 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
343 |
/* find the vehicle in this row that was clicked */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
344 |
while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->next; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
345 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
346 |
/* if an articulated part was selected, find its parent */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
347 |
while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
348 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
349 |
d->wagon = v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
350 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
351 |
return MODE_DRAG_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
352 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
353 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
354 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
355 |
case VEH_Road: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
356 |
if (xm >= 24) return MODE_DRAG_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
357 |
if (xm <= 16) return MODE_SHOW_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
358 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
359 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
360 |
case VEH_Ship: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
361 |
if (xm >= 19) return MODE_DRAG_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
362 |
if (ym <= 10) return MODE_SHOW_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
363 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
364 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
365 |
case VEH_Aircraft: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
366 |
if (xm >= 12) return MODE_DRAG_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
367 |
if (ym <= 12) return MODE_SHOW_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
368 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
369 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
370 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
371 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
372 |
return MODE_START_STOP; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
373 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
374 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
375 |
static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
376 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
377 |
Vehicle *v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
378 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
379 |
v = GetVehicle(sel); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
380 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
381 |
if (v == wagon) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
382 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
383 |
if (wagon == NULL) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
384 |
if (head != NULL) wagon = GetLastVehicleInChain(head); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
385 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
386 |
wagon = GetPrevVehicleInChain(wagon); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
387 |
if (wagon == NULL) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
388 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
389 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
390 |
if (wagon == v) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
391 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
392 |
DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE)); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
393 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
394 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
395 |
static void DepotClick(Window *w, int x, int y) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
396 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
397 |
GetDepotVehiclePtData gdvp; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
398 |
Vehicle *v = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
399 |
int mode = GetVehicleFromDepotWndPt(w, x, y, &v, &gdvp); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
400 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
401 |
/* share / copy orders */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
402 |
if (_thd.place_mode && mode <= 0) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
403 |
_place_clicked_vehicle = (WP(w, depot_d).type == VEH_Train ? gdvp.head : v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
404 |
return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
405 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
406 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
407 |
if (WP(w, depot_d).type == VEH_Train) v = gdvp.wagon; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
408 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
409 |
switch (mode) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
410 |
case MODE_ERROR: // invalid |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
411 |
return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
412 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
413 |
case MODE_DRAG_VEHICLE: { // start dragging of vehicle |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
414 |
VehicleID sel = WP(w, depot_d).sel; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
415 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
416 |
if (WP(w, depot_d).type == VEH_Train && sel != INVALID_VEHICLE) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
417 |
WP(w,depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
418 |
TrainDepotMoveVehicle(v, sel, gdvp.head); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
419 |
} else if (v != NULL) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
420 |
int image; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
421 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
422 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
423 |
case VEH_Train: image = GetTrainImage(v, DIR_W); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
424 |
case VEH_Road: image = GetRoadVehImage(v, DIR_W); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
425 |
case VEH_Ship: image = GetShipImage(v, DIR_W); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
426 |
case VEH_Aircraft: image = GetAircraftImage(v, DIR_W); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
427 |
default: NOT_REACHED(); image = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
428 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
429 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
430 |
WP(w, depot_d).sel = v->index; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
431 |
SetWindowDirty(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
432 |
SetObjectToPlaceWnd(GetVehiclePalette(v) | image, 4, w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
433 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
434 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
435 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
436 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
437 |
case MODE_SHOW_VEHICLE: // show info window |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
438 |
ShowVehicleViewWindow(v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
439 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
440 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
441 |
case MODE_START_STOP: { // click start/stop flag |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
442 |
uint command; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
443 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
444 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
445 |
case VEH_Train: command = CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
446 |
case VEH_Road: command = CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
447 |
case VEH_Ship: command = CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
448 |
case VEH_Aircraft: command = CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
449 |
default: NOT_REACHED(); command = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
450 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
451 |
DoCommandP(v->tile, v->index, 0, NULL, command); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
452 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
453 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
454 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
455 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
456 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
457 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
458 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
459 |
/** |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
460 |
* Clones a vehicle |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
461 |
* @param *v is the original vehicle to clone |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
462 |
* @param *w is the window of the depot where the clone is build |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
463 |
*/ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
464 |
static void HandleCloneVehClick(const Vehicle *v, const Window *w) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
465 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
466 |
uint error_str; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
467 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
468 |
if (v == NULL) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
469 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
470 |
if (v->type == VEH_Train && !IsFrontEngine(v)) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
471 |
v = GetFirstVehicleInChain(v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
472 |
/* Do nothing when clicking on a train in depot with no loc attached */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
473 |
if (!IsFrontEngine(v)) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
474 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
475 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
476 |
switch (v->type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
477 |
case VEH_Train: error_str = CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
478 |
case VEH_Road: error_str = CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
479 |
case VEH_Ship: error_str = CMD_MSG(STR_980D_CAN_T_BUILD_SHIP); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
480 |
case VEH_Aircraft: error_str = CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
481 |
default: return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
482 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
483 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
484 |
DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | error_str); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
485 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
486 |
ResetObjectToPlace(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
487 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
488 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
489 |
static void ClonePlaceObj(const Window *w) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
490 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
491 |
const Vehicle *v = CheckMouseOverVehicle(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
492 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
493 |
if (v != NULL) HandleCloneVehClick(v, w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
494 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
495 |
|
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
496 |
static void ResizeDepotButtons(Window *w) |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
497 |
{ |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
498 |
/* We got the widget moved around. Now we will make some widgets to fill the gab between some widgets in equal sizes */ |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
499 |
|
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
500 |
/* Make the buttons in the bottom equal in size */ |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
501 |
w->widget[DEPOT_WIDGET_LOCATION].right = w->widget[DEPOT_WIDGET_RESIZE].left - 1; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
502 |
w->widget[DEPOT_WIDGET_BUILD].right = w->widget[DEPOT_WIDGET_LOCATION].right / 3; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
503 |
w->widget[DEPOT_WIDGET_LOCATION].left = w->widget[DEPOT_WIDGET_BUILD].right * 2; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
504 |
w->widget[DEPOT_WIDGET_CLONE].left = w->widget[DEPOT_WIDGET_BUILD].right + 1; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
505 |
w->widget[DEPOT_WIDGET_CLONE].right = w->widget[DEPOT_WIDGET_LOCATION].left - 1; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
506 |
|
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
507 |
if (WP(w, depot_d).type == VEH_Train) { |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
508 |
/* Divide the size of DEPOT_WIDGET_SELL into two equally big buttons so DEPOT_WIDGET_SELL and DEPOT_WIDGET_SELL_ALL will get the same size. |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
509 |
* This way it will stay the same even if DEPOT_WIDGET_SELL_ALL is resized for some reason */ |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
510 |
w->widget[DEPOT_WIDGET_SELL_ALL].bottom = w->widget[DEPOT_WIDGET_RESIZE].top - 1; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
511 |
w->widget[DEPOT_WIDGET_SELL_ALL].top = ((w->widget[DEPOT_WIDGET_SELL_ALL].bottom - w->widget[DEPOT_WIDGET_SELL].top) / 2) + w->widget[DEPOT_WIDGET_SELL].top; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
512 |
w->widget[DEPOT_WIDGET_SELL].bottom = w->widget[DEPOT_WIDGET_SELL_ALL].top - 1; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
513 |
} |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
514 |
} |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
515 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
516 |
static void DepotWndProc(Window *w, WindowEvent *e) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
517 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
518 |
switch (e->event) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
519 |
case WE_CREATE: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
520 |
WP(w, depot_d).vehicle_list = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
521 |
WP(w, depot_d).wagon_list = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
522 |
WP(w, depot_d).engine_count = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
523 |
WP(w, depot_d).wagon_count = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
524 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
525 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
526 |
case WE_PAINT: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
527 |
/* Generate the vehicle list |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
528 |
* It's ok to use the wagon pointers for non-trains as they will be ignored */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
529 |
BuildDepotVehicleList(WP(w, depot_d).type, w->window_number, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
530 |
&WP(w, depot_d).vehicle_list, &WP(w, depot_d).engine_list_length, &WP(w, depot_d).engine_count, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
531 |
&WP(w, depot_d).wagon_list, &WP(w, depot_d).wagon_list_length, &WP(w, depot_d).wagon_count); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
532 |
DrawDepotWindow(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
533 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
534 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
535 |
case WE_CLICK: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
536 |
switch (e->we.click.widget) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
537 |
case DEPOT_WIDGET_MATRIX: // List |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
538 |
DepotClick(w, e->we.click.pt.x, e->we.click.pt.y); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
539 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
540 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
541 |
case DEPOT_WIDGET_BUILD: // Build vehicle |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
542 |
ResetObjectToPlace(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
543 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
544 |
case VEH_Train: ShowBuildTrainWindow(w->window_number); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
545 |
case VEH_Road: ShowBuildRoadVehWindow(w->window_number); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
546 |
case VEH_Ship: ShowBuildShipWindow(w->window_number); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
547 |
case VEH_Aircraft: ShowBuildAircraftWindow(w->window_number); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
548 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
549 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
550 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
551 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
552 |
case DEPOT_WIDGET_CLONE: // Clone button |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
553 |
InvalidateWidget(w, DEPOT_WIDGET_CLONE); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
554 |
TOGGLEBIT(w->click_state, DEPOT_WIDGET_CLONE); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
555 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
556 |
if (HASBIT(w->click_state, DEPOT_WIDGET_CLONE)) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
557 |
_place_clicked_vehicle = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
558 |
SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
559 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
560 |
ResetObjectToPlace(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
561 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
562 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
563 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
564 |
case DEPOT_WIDGET_LOCATION: ScrollMainWindowToTile(w->window_number); break; |
4640
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
565 |
|
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
566 |
case DEPOT_WIDGET_STOP_ALL: |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
567 |
case DEPOT_WIDGET_START_ALL: |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
568 |
DoCommandP(w->window_number, WP(w, depot_d).type, e->we.click.widget == DEPOT_WIDGET_START_ALL ? 1 : 0, NULL, CMD_MASS_START_STOP); |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
569 |
break; |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
570 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
571 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
572 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
573 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
574 |
case WE_PLACE_OBJ: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
575 |
ClonePlaceObj(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
576 |
} break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
577 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
578 |
case WE_ABORT_PLACE_OBJ: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
579 |
CLRBIT(w->click_state, DEPOT_WIDGET_CLONE); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
580 |
InvalidateWidget(w, DEPOT_WIDGET_CLONE); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
581 |
} break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
582 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
583 |
/* check if a vehicle in a depot was clicked.. */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
584 |
case WE_MOUSELOOP: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
585 |
const Vehicle *v = _place_clicked_vehicle; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
586 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
587 |
/* since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
588 |
if (v != NULL && HASBIT(w->click_state, DEPOT_WIDGET_CLONE)) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
589 |
_place_clicked_vehicle = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
590 |
HandleCloneVehClick(v, w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
591 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
592 |
} break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
593 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
594 |
case WE_DESTROY: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
595 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
596 |
free((void*)WP(w, depot_d).vehicle_list); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
597 |
free((void*)WP(w, depot_d).wagon_list); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
598 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
599 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
600 |
case WE_DRAGDROP: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
601 |
switch (e->we.click.widget) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
602 |
case DEPOT_WIDGET_MATRIX: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
603 |
Vehicle *v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
604 |
VehicleID sel = WP(w, depot_d).sel; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
605 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
606 |
WP(w, depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
607 |
SetWindowDirty(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
608 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
609 |
if (WP(w, depot_d).type == VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
610 |
GetDepotVehiclePtData gdvp; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
611 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
612 |
if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, &gdvp) == 0 && |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
613 |
sel != INVALID_VEHICLE) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
614 |
if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
615 |
DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
616 |
} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
617 |
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
618 |
} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
619 |
ShowTrainViewWindow(gdvp.head); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
620 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
621 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
622 |
} else if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, NULL) == 0 && |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
623 |
v != NULL && |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
624 |
sel == v->index) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
625 |
ShowVehicleViewWindow(v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
626 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
627 |
} break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
628 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
629 |
case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_ALL: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
630 |
if (!HASBIT(w->disabled_state, DEPOT_WIDGET_SELL) && |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
631 |
WP(w, depot_d).sel != INVALID_VEHICLE) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
632 |
Vehicle *v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
633 |
uint command; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
634 |
int sell_cmd; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
635 |
bool is_engine; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
636 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
637 |
if (HASBIT(w->disabled_state, e->we.click.widget)) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
638 |
if (WP(w, depot_d).sel == INVALID_VEHICLE) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
639 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
640 |
HandleButtonClick(w, e->we.click.widget); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
641 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
642 |
v = GetVehicle(WP(w, depot_d).sel); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
643 |
WP(w, depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
644 |
SetWindowDirty(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
645 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
646 |
sell_cmd = (v->type == VEH_Train && (e->we.click.widget == DEPOT_WIDGET_SELL_ALL || _ctrl_pressed)) ? 1 : 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
647 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
648 |
is_engine = (!(v->type == VEH_Train && !IsFrontEngine(v))); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
649 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
650 |
if (is_engine) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
651 |
_backup_orders_tile = v->tile; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
652 |
BackupVehicleOrders(v, _backup_orders_data); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
653 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
654 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
655 |
switch (v->type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
656 |
case VEH_Train: command = CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
657 |
case VEH_Road: command = CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
658 |
case VEH_Ship: command = CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
659 |
case VEH_Aircraft: command = CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
660 |
default: NOT_REACHED(); command = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
661 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
662 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
663 |
if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, command) && is_engine) _backup_orders_tile = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
664 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
665 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
666 |
default: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
667 |
WP(w, depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
668 |
SetWindowDirty(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
669 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
670 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
671 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
672 |
case WE_RESIZE: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
673 |
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
674 |
w->hscroll.cap += e->we.sizing.diff.x / (int)w->resize.step_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
675 |
w->widget[DEPOT_WIDGET_MATRIX].data = (w->vscroll.cap << 8) + (WP(w, depot_d).type == VEH_Train ? 1 : w->hscroll.cap); |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
676 |
ResizeDepotButtons(w); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
677 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
678 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
679 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
680 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
681 |
static void SetupStringsForDepotWindow(Window *w, byte type) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
682 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
683 |
switch (type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
684 |
case VEH_Train: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
685 |
w->widget[DEPOT_WIDGET_CAPTION].data = STR_8800_TRAIN_DEPOT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
686 |
w->widget[DEPOT_WIDGET_SELL].tooltips = STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
687 |
w->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_883F_TRAINS_CLICK_ON_TRAIN_FOR; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
688 |
w->widget[DEPOT_WIDGET_BUILD].data = STR_8815_NEW_VEHICLES; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
689 |
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_8840_BUILD_NEW_TRAIN_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
690 |
w->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_TRAIN; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
691 |
w->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_TRAIN_DEPOT_INFO; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
692 |
w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_8842_CENTER_MAIN_VIEW_ON_TRAIN; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
693 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
694 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
695 |
case VEH_Road: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
696 |
w->widget[DEPOT_WIDGET_CAPTION].data = STR_9003_ROAD_VEHICLE_DEPOT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
697 |
w->widget[DEPOT_WIDGET_SELL].tooltips = STR_9024_DRAG_ROAD_VEHICLE_TO_HERE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
698 |
w->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_9022_VEHICLES_CLICK_ON_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
699 |
w->widget[DEPOT_WIDGET_BUILD].data = STR_9004_NEW_VEHICLES; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
700 |
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_9023_BUILD_NEW_ROAD_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
701 |
w->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_ROAD_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
702 |
w->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_ROAD_VEHICLE_DEPOT_INFO; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
703 |
w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9025_CENTER_MAIN_VIEW_ON_ROAD; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
704 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
705 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
706 |
case VEH_Ship: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
707 |
w->widget[DEPOT_WIDGET_CAPTION].data = STR_9803_SHIP_DEPOT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
708 |
w->widget[DEPOT_WIDGET_SELL].tooltips = STR_9821_DRAG_SHIP_TO_HERE_TO_SELL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
709 |
w->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_981F_SHIPS_CLICK_ON_SHIP_FOR; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
710 |
w->widget[DEPOT_WIDGET_BUILD].data = STR_9804_NEW_SHIPS; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
711 |
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_9820_BUILD_NEW_SHIP; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
712 |
w->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_SHIP; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
713 |
w->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_SHIP_DEPOT_INFO; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
714 |
w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9822_CENTER_MAIN_VIEW_ON_SHIP; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
715 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
716 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
717 |
case VEH_Aircraft: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
718 |
w->widget[DEPOT_WIDGET_CAPTION].data = STR_A002_AIRCRAFT_HANGAR; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
719 |
w->widget[DEPOT_WIDGET_SELL].tooltips = STR_A023_DRAG_AIRCRAFT_TO_HERE_TO; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
720 |
w->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
721 |
w->widget[DEPOT_WIDGET_BUILD].data = STR_A003_NEW_AIRCRAFT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
722 |
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_A022_BUILD_NEW_AIRCRAFT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
723 |
w->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_AIRCRAFT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
724 |
w->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
725 |
w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_A024_CENTER_MAIN_VIEW_ON_HANGAR; |
4640
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
726 |
|
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
727 |
/* Special strings only for hangars (using hangar instead of depot and so on) */ |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
728 |
w->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_HANGAR_TOOLTIP; |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
729 |
w->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_HANGAR_TOOLTIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
730 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
731 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
732 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
733 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
734 |
/** Opens a depot window |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
735 |
* @param tile The tile where the depot/hangar is located |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
736 |
* @param type The type of vehicles in the depot |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
737 |
*/ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
738 |
void ShowDepotWindow(TileIndex tile, byte type) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
739 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
740 |
Window *w; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
741 |
|
4651
73d828df1b28
(svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents:
4650
diff
changeset
|
742 |
/* First we ensure that the widget counts are equal in all 3 lists to prevent bad stuff from happening */ |
73d828df1b28
(svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents:
4650
diff
changeset
|
743 |
assert(lengthof(widget_moves) == lengthof(_depot_widgets)); |
73d828df1b28
(svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents:
4650
diff
changeset
|
744 |
assert(lengthof(widget_moves) == DEPOT_WIDGET_LAST); |
73d828df1b28
(svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents:
4650
diff
changeset
|
745 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
746 |
switch (type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
747 |
case VEH_Train: w = AllocateWindowDescFront(&_train_depot_desc, tile); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
748 |
case VEH_Road: w = AllocateWindowDescFront(&_road_depot_desc, tile); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
749 |
case VEH_Ship: w = AllocateWindowDescFront(&_ship_depot_desc, tile); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
750 |
case VEH_Aircraft: w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
751 |
default: NOT_REACHED(); w = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
752 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
753 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
754 |
if (w != NULL) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
755 |
int16 horizontal = 0, vertical = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
756 |
w->caption_color = GetTileOwner(tile); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
757 |
WP(w, depot_d).type = type; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
758 |
WP(w, depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
759 |
_backup_orders_tile = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
760 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
761 |
/* Resize the window according to the vehicle type */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
762 |
switch (type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
763 |
case VEH_Train: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
764 |
horizontal = 56; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
765 |
vertical = 48; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
766 |
w->vscroll.cap = 6; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
767 |
w->hscroll.cap = 10 * 29; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
768 |
w->resize.step_width = 1; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
769 |
w->resize.step_height = 14; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
770 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
771 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
772 |
case VEH_Road: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
773 |
horizontal = 10; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
774 |
vertical = -6; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
775 |
w->vscroll.cap = 3; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
776 |
w->hscroll.cap = 5; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
777 |
w->resize.step_width = 56; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
778 |
w->resize.step_height = 14; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
779 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
780 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
781 |
case VEH_Ship: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
782 |
w->vscroll.cap = 2; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
783 |
w->hscroll.cap = 3; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
784 |
w->resize.step_width = 90; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
785 |
w->resize.step_height = 24; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
786 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
787 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
788 |
case VEH_Aircraft: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
789 |
horizontal = 26; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
790 |
w->vscroll.cap = 2; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
791 |
w->hscroll.cap = 4; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
792 |
w->resize.step_width = 74; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
793 |
w->resize.step_height = 24; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
794 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
795 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
796 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
797 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
798 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
799 |
SetupStringsForDepotWindow(w, type); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
800 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
801 |
w->widget[DEPOT_WIDGET_MATRIX].data = |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
802 |
(w->vscroll.cap * 0x100) // number of rows to draw on the background |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
803 |
+ (type == VEH_Train ? 1 : w->hscroll.cap); // number of boxes in each row. Trains always have just one |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
804 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
805 |
if (type != VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
806 |
SETBIT(w->hidden_state, DEPOT_WIDGET_H_SCROLL); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
807 |
SETBIT(w->hidden_state, DEPOT_WIDGET_SELL_ALL); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
808 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
809 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
810 |
/* Move the widgets to their right locations |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
811 |
* Note: it's signed values so negative will make the widget move left and not right, or up instead of down */ |
4649
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
812 |
{ |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
813 |
byte i; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
814 |
|
4649
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
815 |
for (i = 0; i < lengthof(widget_moves); i++) { |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
816 |
if (widget_moves[i] & WIDGET_DEPOT_MOVE_LEFT) w->widget[i].left += horizontal; |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
817 |
if (widget_moves[i] & WIDGET_DEPOT_MOVE_RIGHT) w->widget[i].right += horizontal; |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
818 |
if (widget_moves[i] & WIDGET_DEPOT_MOVE_TOP) w->widget[i].top += vertical; |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
819 |
if (widget_moves[i] & WIDGET_DEPOT_MOVE_BOTTOM) w->widget[i].bottom += vertical; |
38d1633a897d
(svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents:
4646
diff
changeset
|
820 |
} |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
821 |
} |
4650
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
822 |
|
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
823 |
if (type == VEH_Train) { |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
824 |
/* Now we move the train only widgets so they are placed correctly |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
825 |
* Doing it here will ensure that they move if the widget they are placed on top of/aligned to are moved */ |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
826 |
|
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
827 |
/* DEPOT_WIDGET_H_SCROLL is placed in the lowest part of DEPOT_WIDGET_MATRIX */ |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
828 |
w->widget[DEPOT_WIDGET_H_SCROLL].left = w->widget[DEPOT_WIDGET_MATRIX].left; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
829 |
w->widget[DEPOT_WIDGET_H_SCROLL].right = w->widget[DEPOT_WIDGET_MATRIX].right; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
830 |
w->widget[DEPOT_WIDGET_H_SCROLL].bottom = w->widget[DEPOT_WIDGET_MATRIX].bottom; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
831 |
w->widget[DEPOT_WIDGET_H_SCROLL].top = w->widget[DEPOT_WIDGET_MATRIX].bottom - 11; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
832 |
w->widget[DEPOT_WIDGET_MATRIX].bottom -= 12; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
833 |
|
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
834 |
/* DEPOT_WIDGET_SELL_ALL is under DEPOT_WIDGET_SELL. They got the same left and right and height is controlled in ResizeDepotButtons() */ |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
835 |
w->widget[DEPOT_WIDGET_SELL_ALL].left = w->widget[DEPOT_WIDGET_SELL].left; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
836 |
w->widget[DEPOT_WIDGET_SELL_ALL].right = w->widget[DEPOT_WIDGET_SELL].right; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
837 |
} |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
838 |
ResizeDepotButtons(w); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
839 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
840 |
} |