author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9778 | c5dd94ed7c16 |
child 10180 | a99cf854c6d0 |
permissions | -rw-r--r-- |
9148
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
2 |
|
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
3 |
/** @file tree_gui.cpp GUIs for building trees. */ |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
4 |
|
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
6 |
#include "openttd.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
7 |
#include "window_gui.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
8 |
#include "gfx_func.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
9 |
#include "tilehighlight_func.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
10 |
#include "player_func.h" |
9659
187142ff9b6c
(svn r13731) -Codechange: make a pool of the array of players.
rubidium
parents:
9652
diff
changeset
|
11 |
#include "player_base.h" |
9148
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
12 |
#include "command_func.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
13 |
#include "sound_func.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
14 |
#include "settings_type.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
15 |
|
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
16 |
#include "table/sprites.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
17 |
#include "table/strings.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
18 |
#include "table/tree_land.h" |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
19 |
|
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
20 |
void PlaceTreesRandomly(); |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
21 |
|
9195
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
22 |
class BuildTreesWindow : public Window |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
23 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
24 |
uint16 base; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
25 |
uint16 count; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
26 |
int tree_to_plant; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
27 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
28 |
enum BuildTreesWidgets { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
29 |
BTW_CLOSE, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
30 |
BTW_CAPTION, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
31 |
BTW_BACKGROUND, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
32 |
BTW_TYPE_11, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
33 |
BTW_TYPE_12, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
34 |
BTW_TYPE_13, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
35 |
BTW_TYPE_14, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
36 |
BTW_TYPE_21, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
37 |
BTW_TYPE_22, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
38 |
BTW_TYPE_23, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
39 |
BTW_TYPE_24, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
40 |
BTW_TYPE_31, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
41 |
BTW_TYPE_32, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
42 |
BTW_TYPE_33, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
43 |
BTW_TYPE_34, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
44 |
BTW_TYPE_RANDOM, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
45 |
BTW_MANY_RANDOM, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
46 |
}; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
47 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
48 |
public: |
9203
082fbf0500c4
(svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium
parents:
9195
diff
changeset
|
49 |
BuildTreesWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
9195
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
50 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
51 |
if (_game_mode != GM_EDITOR) { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
52 |
this->HideWidget(BTW_MANY_RANDOM); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
53 |
int offset = this->widget[BTW_MANY_RANDOM].bottom - this->widget[BTW_MANY_RANDOM].top; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
54 |
this->height -= offset; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
55 |
this->widget[BTW_BACKGROUND].bottom -= offset; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
56 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
57 |
ResetObjectToPlace(); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
58 |
this->FindWindowPlacementAndResize(desc); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
59 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
60 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
61 |
virtual void OnPaint() |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
62 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
63 |
static const PalSpriteID tree_sprites[] = { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
64 |
{ 0x655, PAL_NONE }, { 0x663, PAL_NONE }, { 0x678, PAL_NONE }, { 0x62B, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
65 |
{ 0x647, PAL_NONE }, { 0x639, PAL_NONE }, { 0x64E, PAL_NONE }, { 0x632, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
66 |
{ 0x67F, PAL_NONE }, { 0x68D, PAL_NONE }, { 0x69B, PAL_NONE }, { 0x6A9, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
67 |
{ 0x6AF, PAL_NONE }, { 0x6D2, PAL_NONE }, { 0x6D9, PAL_NONE }, { 0x6C4, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
68 |
{ 0x6CB, PAL_NONE }, { 0x6B6, PAL_NONE }, { 0x6BD, PAL_NONE }, { 0x6E0, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
69 |
{ 0x72E, PAL_NONE }, { 0x734, PAL_NONE }, { 0x74A, PAL_NONE }, { 0x74F, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
70 |
{ 0x76B, PAL_NONE }, { 0x78F, PAL_NONE }, { 0x788, PAL_NONE }, { 0x77B, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
71 |
{ 0x75F, PAL_NONE }, { 0x774, PAL_NONE }, { 0x720, PAL_NONE }, { 0x797, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
72 |
{ 0x79E, PAL_NONE }, { 0x7A5, PALETTE_TO_GREEN }, { 0x7AC, PALETTE_TO_RED }, { 0x7B3, PAL_NONE }, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
73 |
{ 0x7BA, PAL_NONE }, { 0x7C1, PALETTE_TO_RED, }, { 0x7C8, PALETTE_TO_PALE_GREEN }, { 0x7CF, PALETTE_TO_YELLOW }, { 0x7D6, PALETTE_TO_RED } |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
74 |
}; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
75 |
|
9273
35e0224ea8f1
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
9203
diff
changeset
|
76 |
this->DrawWidgets(); |
9195
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
77 |
|
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
78 |
int i = this->base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; |
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9358
diff
changeset
|
79 |
int count = this->count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; |
9195
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
80 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
81 |
int x = 18; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
82 |
int y = 54; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
83 |
do { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
84 |
DrawSprite(tree_sprites[i].sprite, tree_sprites[i].pal, x, y); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
85 |
x += 35; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
86 |
if (!(++i & 3)) { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
87 |
x -= 35 * 4; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
88 |
y += 47; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
89 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
90 |
} while (--count); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
91 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
92 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
93 |
virtual void OnClick(Point pt, int widget) |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
94 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
95 |
switch (widget) { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
96 |
case BTW_TYPE_11: case BTW_TYPE_12: case BTW_TYPE_13: case BTW_TYPE_14: |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
97 |
case BTW_TYPE_21: case BTW_TYPE_22: case BTW_TYPE_23: case BTW_TYPE_24: |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
98 |
case BTW_TYPE_31: case BTW_TYPE_32: case BTW_TYPE_33: case BTW_TYPE_34: |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
99 |
if (widget - BTW_TYPE_11 >= this->count) break; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
100 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
101 |
if (HandlePlacePushButton(this, widget, SPR_CURSOR_TREE, VHM_RECT, NULL)) { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
102 |
this->tree_to_plant = this->base + widget - BTW_TYPE_11; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
103 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
104 |
break; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
105 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
106 |
case BTW_TYPE_RANDOM: // tree of random type. |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
107 |
if (HandlePlacePushButton(this, BTW_TYPE_RANDOM, SPR_CURSOR_TREE, VHM_RECT, NULL)) { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
108 |
this->tree_to_plant = -1; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
109 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
110 |
break; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
111 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
112 |
case BTW_MANY_RANDOM: // place trees randomly over the landscape |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
113 |
this->LowerWidget(BTW_MANY_RANDOM); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
114 |
this->flags4 |= 5 << WF_TIMEOUT_SHL; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
115 |
SndPlayFx(SND_15_BEEP); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
116 |
PlaceTreesRandomly(); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
117 |
MarkWholeScreenDirty(); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
118 |
break; |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
119 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
120 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
121 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
122 |
virtual void OnPlaceObject(Point pt, TileIndex tile) |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
123 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
124 |
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_PLANT_TREES); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
125 |
VpSetPlaceSizingLimit(20); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
126 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
127 |
|
9295
ee2d463700e3
(svn r13162) -Fix (r13160): trees couldn't be planted, correct function wasn't overloaded
smatz
parents:
9273
diff
changeset
|
128 |
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) |
9195
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
129 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
130 |
VpSelectTilesWithMethod(pt.x, pt.y, select_method); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
131 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
132 |
|
9295
ee2d463700e3
(svn r13162) -Fix (r13160): trees couldn't be planted, correct function wasn't overloaded
smatz
parents:
9273
diff
changeset
|
133 |
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) |
9195
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
134 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
135 |
if (pt.x != -1 && select_proc == DDSP_PLANT_TREES) { |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
136 |
DoCommandP(end_tile, this->tree_to_plant, start_tile, NULL, |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
137 |
CMD_PLANT_TREE | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE)); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
138 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
139 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
140 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
141 |
virtual void OnTimeout() |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
142 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
143 |
this->RaiseWidget(BTW_MANY_RANDOM); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
144 |
this->InvalidateWidget(BTW_MANY_RANDOM); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
145 |
} |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
146 |
|
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
147 |
virtual void OnPlaceObjectAbort() |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
148 |
{ |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
149 |
this->RaiseButtons(); |
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
150 |
} |
9148
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
151 |
}; |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
152 |
|
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
153 |
static const Widget _build_trees_widgets[] = { |
9778
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
154 |
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BTW_CLOSE |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
155 |
{ WWT_CAPTION, RESIZE_NONE, COLOUR_DARK_GREEN, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BTW_CAPTION |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
156 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 142, 14, 183, 0x0, STR_NULL}, // BTW_BACKGROUND |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
157 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_11 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
158 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_12 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
159 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 72, 105, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_13 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
160 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 107, 140, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_14 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
161 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 35, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_21 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
162 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 37, 70, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_22 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
163 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 72, 105, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_23 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
164 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 107, 140, 63, 108, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_24 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
165 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 35, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_31 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
166 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 37, 70, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_32 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
167 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 72, 105, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_33 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
168 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 107, 140, 110, 155, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, // BTW_TYPE_34 |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
169 |
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 140, 157, 168, STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TIP}, // BTW_TYPE_RANDOM |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9659
diff
changeset
|
170 |
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 2, 140, 170, 181, STR_028A_RANDOM_TREES, STR_028B_PLANT_TREES_RANDOMLY_OVER}, // BTW_MANY_RANDOM |
9148
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
171 |
{ WIDGETS_END}, |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
172 |
}; |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
173 |
|
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
174 |
static const WindowDesc _build_trees_desc = { |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
175 |
WDP_AUTO, WDP_AUTO, 143, 184, 143, 184, |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
176 |
WC_BUILD_TREES, WC_NONE, |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
177 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
9195
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
178 |
_build_trees_widgets, |
9148
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
179 |
}; |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
180 |
|
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
181 |
void ShowBuildTreesToolbar() |
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
182 |
{ |
9652
0405e98d8e96
(svn r13719) -Codechange: rename IsValidPlayer to IsValidPlayerID in line with all other structs/classes that are in a pool.
rubidium
parents:
9413
diff
changeset
|
183 |
if (_game_mode != GM_EDITOR && !IsValidPlayerID(_current_player)) return; |
9195
738780fcebc8
(svn r13061) -Codechange: make a class of the BuildTreesWindow.
glx
parents:
9148
diff
changeset
|
184 |
AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0); |
9148
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
diff
changeset
|
185 |
} |