author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6491 | 00dc414c909d |
child 6600 | 1482680e3303 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6422
6679df1c05ba
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6106
diff
changeset
|
3 |
/** @file terraform_gui.cpp */ |
6679df1c05ba
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6106
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1780
diff
changeset
|
6 |
#include "openttd.h" |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
7 |
#include "bridge_map.h" |
3144
33e42feae531
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3076
diff
changeset
|
8 |
#include "clear_map.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1095
diff
changeset
|
9 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
337
diff
changeset
|
10 |
#include "table/strings.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
11 |
#include "functions.h" |
2154
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
1981
diff
changeset
|
12 |
#include "player.h" |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
13 |
#include "tile.h" |
0 | 14 |
#include "window.h" |
15 |
#include "gui.h" |
|
16 |
#include "viewport.h" |
|
2790 | 17 |
#include "gfx.h" |
337
cbe0c766c947
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
18 |
#include "sound.h" |
0 | 19 |
#include "command.h" |
20 |
#include "vehicle.h" |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
987
diff
changeset
|
21 |
#include "signs.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2154
diff
changeset
|
22 |
#include "variables.h" |
0 | 23 |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1919
diff
changeset
|
24 |
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 25 |
{ |
26 |
if (success) { |
|
541 | 27 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 28 |
} else { |
29 |
SetRedErrorSquare(_terraform_err_tile); |
|
30 |
} |
|
31 |
} |
|
32 |
||
33 |
||
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
34 |
/** Scenario editor command that generates desert areas */ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
35 |
static void GenerateDesertArea(TileIndex end, TileIndex start) |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
36 |
{ |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
37 |
int size_x, size_y; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
38 |
int sx = TileX(start); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
39 |
int sy = TileY(start); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
40 |
int ex = TileX(end); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
41 |
int ey = TileY(end); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
42 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
43 |
if (_game_mode != GM_EDITOR) return; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
44 |
|
6106 | 45 |
if (ex < sx) Swap(ex, sx); |
46 |
if (ey < sy) Swap(ey, sy); |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
47 |
size_x = (ex - sx) + 1; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
48 |
size_y = (ey - sy) + 1; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
49 |
|
1710
c0a2a17cf887
(svn r2214) - Fix: Dragging the desert tool over half-desert turns it into full-desert; dragging the tool while pressing ctrl, will remove the desert area.
Darkvater
parents:
1632
diff
changeset
|
50 |
_generating_world = true; |
1981 | 51 |
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { |
1710
c0a2a17cf887
(svn r2214) - Fix: Dragging the desert tool over half-desert turns it into full-desert; dragging the tool while pressing ctrl, will remove the desert area.
Darkvater
parents:
1632
diff
changeset
|
52 |
if (GetTileType(tile) != MP_WATER) { |
3379
50b253bb9819
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3144
diff
changeset
|
53 |
SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_INVALID : TROPICZONE_DESERT); |
1780
082dfd92c20b
(svn r2284) - Fix (regression): [ 1197177 ] Scenario editor: desert add/remove tool removes industries. Fixed a bit too agressive desert generator. It still does remove the industry (sand's a bitch on machinery), but at least it does it cleanly :)
Darkvater
parents:
1710
diff
changeset
|
54 |
DoCommandP(tile, 0, 0, NULL, CMD_LANDSCAPE_CLEAR); |
1710
c0a2a17cf887
(svn r2214) - Fix: Dragging the desert tool over half-desert turns it into full-desert; dragging the tool while pressing ctrl, will remove the desert area.
Darkvater
parents:
1632
diff
changeset
|
55 |
MarkTileDirtyByTile(tile); |
c0a2a17cf887
(svn r2214) - Fix: Dragging the desert tool over half-desert turns it into full-desert; dragging the tool while pressing ctrl, will remove the desert area.
Darkvater
parents:
1632
diff
changeset
|
56 |
} |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
57 |
} END_TILE_LOOP(tile, size_x, size_y, 0); |
1710
c0a2a17cf887
(svn r2214) - Fix: Dragging the desert tool over half-desert turns it into full-desert; dragging the tool while pressing ctrl, will remove the desert area.
Darkvater
parents:
1632
diff
changeset
|
58 |
_generating_world = false; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
59 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
60 |
|
3017
a75caf4efa2d
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2955
diff
changeset
|
61 |
/** Scenario editor command that generates rocky areas */ |
2615
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
62 |
static void GenerateRockyArea(TileIndex end, TileIndex start) |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
63 |
{ |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
64 |
int size_x, size_y; |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
65 |
bool success = false; |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
66 |
int sx = TileX(start); |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
67 |
int sy = TileY(start); |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
68 |
int ex = TileX(end); |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
69 |
int ey = TileY(end); |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
70 |
|
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
71 |
if (_game_mode != GM_EDITOR) return; |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
72 |
|
6106 | 73 |
if (ex < sx) Swap(ex, sx); |
74 |
if (ey < sy) Swap(ey, sy); |
|
2615
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
75 |
size_x = (ex - sx) + 1; |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
76 |
size_y = (ey - sy) + 1; |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
77 |
|
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
78 |
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
79 |
switch (GetTileType(tile)) { |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
80 |
case MP_CLEAR: |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
81 |
case MP_TREES: |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
82 |
MakeClear(tile, CLEAR_ROCKS, 3); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
83 |
break; |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
84 |
|
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
85 |
default: continue; |
2615
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
86 |
} |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
87 |
MarkTileDirtyByTile(tile); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
88 |
success = true; |
2615
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
89 |
} END_TILE_LOOP(tile, size_x, size_y, 0); |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
90 |
|
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
91 |
if (success) SndPlayTileFx(SND_1F_SPLAT, end); |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
92 |
} |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
93 |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
94 |
/** |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
95 |
* A central place to handle all X_AND_Y dragged GUI functions. |
6422
6679df1c05ba
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6106
diff
changeset
|
96 |
* @param e WindowEvent variable holding in its higher bits (excluding the lower |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
97 |
* 4, since that defined the X_Y drag) the type of action to be performed |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
98 |
* @return Returns true if the action was found and handled, and false otherwise. This |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
99 |
* allows for additional implements that are more local. For example X_Y drag |
6422
6679df1c05ba
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6106
diff
changeset
|
100 |
* of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
101 |
**/ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
102 |
bool GUIPlaceProcDragXY(const WindowEvent *e) |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
103 |
{ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
104 |
TileIndex start_tile = e->we.place.starttile; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
105 |
TileIndex end_tile = e->we.place.tile; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
106 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
107 |
switch (e->we.place.userdata >> 4) { |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
108 |
case GUI_PlaceProc_DemolishArea >> 4: |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
109 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
110 |
break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
111 |
case GUI_PlaceProc_LevelArea >> 4: |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
112 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
113 |
break; |
2615
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
114 |
case GUI_PlaceProc_RockyArea >> 4: |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
115 |
GenerateRockyArea(end_tile, start_tile); |
e97a3034eef4
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
116 |
break; |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
117 |
case GUI_PlaceProc_DesertArea >> 4: |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
118 |
GenerateDesertArea(end_tile, start_tile); |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
119 |
break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
120 |
case GUI_PlaceProc_WaterArea >> 4: |
4087
d6a79200cb20
(svn r5403) - Feature: Allow building canals at sea-level, using ctrl to toggle canal or plain water tile. This allows building of non-raisable sea-level water ways (useful in multiplayer) and dikes for low-level areas.
peter1138
parents:
4080
diff
changeset
|
121 |
DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS)); |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
122 |
break; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
123 |
default: return false; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
124 |
} |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
125 |
|
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
126 |
return true; |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
127 |
} |
0 | 128 |
|
129 |
typedef void OnButtonClick(Window *w); |
|
130 |
||
131 |
static const uint16 _terraform_keycodes[] = { |
|
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
132 |
'Q', |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
133 |
'W', |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
134 |
'E', |
936
2f79a0bd8bb1
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
135 |
'D', |
606
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
136 |
'U', |
da90c837064c
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
137 |
'I', |
613
a0e37d7c9ba8
(svn r1037) Rearranged landscaping hotkeys a bit more.
dominik
parents:
608
diff
changeset
|
138 |
'O', |
0 | 139 |
}; |
140 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1919
diff
changeset
|
141 |
void PlaceProc_DemolishArea(TileIndex tile) |
0 | 142 |
{ |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
143 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea); |
0 | 144 |
} |
145 |
||
2817 | 146 |
static void PlaceProc_RaiseLand(TileIndex tile) |
0 | 147 |
{ |
4007
3cf15b6d81f5
(svn r5218) Remove GenericRaiseLowerLand(). It's not really as generic as the its name suggests, it's just an unnecessary indirection
tron
parents:
3977
diff
changeset
|
148 |
DoCommandP( |
3cf15b6d81f5
(svn r5218) Remove GenericRaiseLowerLand(). It's not really as generic as the its name suggests, it's just an unnecessary indirection
tron
parents:
3977
diff
changeset
|
149 |
tile, SLOPE_N, 1, CcTerraform, |
3cf15b6d81f5
(svn r5218) Remove GenericRaiseLowerLand(). It's not really as generic as the its name suggests, it's just an unnecessary indirection
tron
parents:
3977
diff
changeset
|
150 |
CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE) |
3cf15b6d81f5
(svn r5218) Remove GenericRaiseLowerLand(). It's not really as generic as the its name suggests, it's just an unnecessary indirection
tron
parents:
3977
diff
changeset
|
151 |
); |
0 | 152 |
} |
153 |
||
2817 | 154 |
static void PlaceProc_LowerLand(TileIndex tile) |
0 | 155 |
{ |
4007
3cf15b6d81f5
(svn r5218) Remove GenericRaiseLowerLand(). It's not really as generic as the its name suggests, it's just an unnecessary indirection
tron
parents:
3977
diff
changeset
|
156 |
DoCommandP( |
3cf15b6d81f5
(svn r5218) Remove GenericRaiseLowerLand(). It's not really as generic as the its name suggests, it's just an unnecessary indirection
tron
parents:
3977
diff
changeset
|
157 |
tile, SLOPE_N, 0, CcTerraform, |
3cf15b6d81f5
(svn r5218) Remove GenericRaiseLowerLand(). It's not really as generic as the its name suggests, it's just an unnecessary indirection
tron
parents:
3977
diff
changeset
|
158 |
CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE) |
3cf15b6d81f5
(svn r5218) Remove GenericRaiseLowerLand(). It's not really as generic as the its name suggests, it's just an unnecessary indirection
tron
parents:
3977
diff
changeset
|
159 |
); |
0 | 160 |
} |
161 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1919
diff
changeset
|
162 |
void PlaceProc_LevelLand(TileIndex tile) |
0 | 163 |
{ |
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
164 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea); |
0 | 165 |
} |
166 |
||
167 |
static void TerraformClick_Lower(Window *w) |
|
168 |
{ |
|
756
b76998029c12
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
651
diff
changeset
|
169 |
HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerLand); |
0 | 170 |
} |
171 |
||
172 |
static void TerraformClick_Raise(Window *w) |
|
173 |
{ |
|
756
b76998029c12
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
651
diff
changeset
|
174 |
HandlePlacePushButton(w, 5, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseLand); |
0 | 175 |
} |
176 |
||
177 |
static void TerraformClick_Level(Window *w) |
|
178 |
{ |
|
1919
ca41cc314d40
(svn r2425) - Fix (regression): wrong sprite for level-land cursor (thx Tron)
Darkvater
parents:
1914
diff
changeset
|
179 |
HandlePlacePushButton(w, 6, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand); |
0 | 180 |
} |
181 |
||
936
2f79a0bd8bb1
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
182 |
static void TerraformClick_Dynamite(Window *w) |
2f79a0bd8bb1
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
183 |
{ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
184 |
HandlePlacePushButton(w, 7, ANIMCURSOR_DEMOLISH , 1, PlaceProc_DemolishArea); |
936
2f79a0bd8bb1
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
185 |
} |
2f79a0bd8bb1
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
186 |
|
0 | 187 |
static void TerraformClick_BuyLand(Window *w) |
188 |
{ |
|
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
189 |
HandlePlacePushButton(w, 8, SPR_CURSOR_BUY_LAND, 1, PlaceProc_BuyLand); |
0 | 190 |
} |
191 |
||
192 |
static void TerraformClick_Trees(Window *w) |
|
193 |
{ |
|
3817
96de009b0592
(svn r4827) -Fix (FS#160) In the terraform toolbar, don't treat the plant tree button as place-push-button, because it isn't
celestar
parents:
3447
diff
changeset
|
194 |
/* This button is NOT a place-push-button, so don't treat it as such */ |
96de009b0592
(svn r4827) -Fix (FS#160) In the terraform toolbar, don't treat the plant tree button as place-push-button, because it isn't
celestar
parents:
3447
diff
changeset
|
195 |
ShowBuildTreesToolbar(); |
0 | 196 |
} |
197 |
||
198 |
static void TerraformClick_PlaceSign(Window *w) |
|
199 |
{ |
|
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
200 |
HandlePlacePushButton(w, 10, SPR_CURSOR_SIGN, 1, PlaceProc_Sign); |
0 | 201 |
} |
202 |
||
203 |
static OnButtonClick * const _terraform_button_proc[] = { |
|
204 |
TerraformClick_Lower, |
|
205 |
TerraformClick_Raise, |
|
206 |
TerraformClick_Level, |
|
936
2f79a0bd8bb1
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
207 |
TerraformClick_Dynamite, |
0 | 208 |
TerraformClick_BuyLand, |
209 |
TerraformClick_Trees, |
|
210 |
TerraformClick_PlaceSign, |
|
211 |
}; |
|
212 |
||
213 |
static void TerraformToolbWndProc(Window *w, WindowEvent *e) |
|
214 |
{ |
|
2952 | 215 |
switch (e->event) { |
0 | 216 |
case WE_PAINT: |
217 |
DrawWindowWidgets(w); |
|
218 |
break; |
|
2639 | 219 |
|
0 | 220 |
case WE_CLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
221 |
if (e->we.click.widget >= 4) _terraform_button_proc[e->we.click.widget - 4](w); |
0 | 222 |
break; |
223 |
||
2639 | 224 |
case WE_KEYPRESS: { |
225 |
uint i; |
|
616
63b0ac55529e
(svn r1040) Fix: All character hotkeys are disabled now when a window for typing is open
dominik
parents:
613
diff
changeset
|
226 |
|
2639 | 227 |
for (i = 0; i != lengthof(_terraform_keycodes); i++) { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
228 |
if (e->we.keypress.keycode == _terraform_keycodes[i]) { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
229 |
e->we.keypress.cont = false; |
0 | 230 |
_terraform_button_proc[i](w); |
231 |
break; |
|
232 |
} |
|
2639 | 233 |
} |
234 |
break; |
|
0 | 235 |
} |
236 |
||
237 |
case WE_PLACE_OBJ: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
238 |
_place_proc(e->we.place.tile); |
0 | 239 |
return; |
240 |
||
241 |
case WE_PLACE_DRAG: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
242 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF); |
0 | 243 |
break; |
244 |
||
245 |
case WE_PLACE_MOUSEUP: |
|
4994
aec94128f5d5
(svn r7000) -Fix: Incorrect use of e->we.click when the event is a 'place'. This didn't cause any
Darkvater
parents:
4938
diff
changeset
|
246 |
if (e->we.place.pt.x != -1 && |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
247 |
(e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4007
diff
changeset
|
248 |
GUIPlaceProcDragXY(e); |
0 | 249 |
} |
250 |
break; |
|
251 |
||
252 |
case WE_ABORT_PLACE_OBJ: |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
253 |
RaiseWindowButtons(w); |
0 | 254 |
break; |
255 |
} |
|
256 |
} |
|
257 |
||
258 |
static const Widget _terraform_widgets[] = { |
|
1632
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
259 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
260 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 145, 0, 13, STR_LANDSCAPING_TOOLBAR, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
10c391e108b7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
261 |
{WWT_STICKYBOX, RESIZE_NONE, 7, 146, 157, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
756
diff
changeset
|
262 |
|
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
263 |
{ WWT_PANEL, RESIZE_NONE, 7, 66, 69, 14, 35, 0x0, STR_NULL}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
264 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
265 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
266 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
267 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 70, 91, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
268 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 92, 113, 14, 35, SPR_IMG_BUY_LAND, STR_0329_PURCHASE_LAND_FOR_FUTURE}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
269 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_PLANTTREES, STR_0185_PLANT_TREES_PLACE_SIGNS}, |
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
270 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_PLACE_SIGN, STR_0289_PLACE_SIGN}, |
0 | 271 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
30
diff
changeset
|
272 |
{ WIDGETS_END}, |
0 | 273 |
}; |
274 |
||
275 |
static const WindowDesc _terraform_desc = { |
|
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6422
diff
changeset
|
276 |
WDP_ALIGN_TBR, 22 + 36, 158, 36, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5860
diff
changeset
|
277 |
WC_SCEN_LAND_GEN, WC_NONE, |
756
b76998029c12
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
651
diff
changeset
|
278 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 279 |
_terraform_widgets, |
280 |
TerraformToolbWndProc |
|
281 |
}; |
|
282 |
||
5860 | 283 |
void ShowTerraformToolbar(Window *link) |
0 | 284 |
{ |
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
285 |
if (!IsValidPlayer(_current_player)) return; |
5860 | 286 |
Window *w = AllocateWindowDescFront(&_terraform_desc, 0); |
287 |
if (w != NULL && link != NULL) { |
|
288 |
/* Align the terraform toolbar under the main toolbar and put the linked |
|
289 |
* toolbar to left of it |
|
290 |
*/ |
|
291 |
w->top = 22; |
|
292 |
link->left = w->left - link->width; |
|
293 |
} |
|
0 | 294 |
} |