author | KUDr |
Mon, 01 Jan 2007 23:37:39 +0000 | |
branch | custombridgeheads |
changeset 5629 | 7cb2c58f4a7c |
parent 5573 | afa6f92a71fd |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1780
diff
changeset
|
4 |
#include "openttd.h" |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
5 |
#include "bridge_map.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3076
diff
changeset
|
6 |
#include "clear_map.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1095
diff
changeset
|
7 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
337
diff
changeset
|
8 |
#include "table/strings.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
9 |
#include "functions.h" |
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
1981
diff
changeset
|
10 |
#include "player.h" |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
11 |
#include "tile.h" |
0 | 12 |
#include "window.h" |
13 |
#include "gui.h" |
|
14 |
#include "viewport.h" |
|
2790 | 15 |
#include "gfx.h" |
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
16 |
#include "sound.h" |
0 | 17 |
#include "command.h" |
18 |
#include "vehicle.h" |
|
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
987
diff
changeset
|
19 |
#include "signs.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2154
diff
changeset
|
20 |
#include "variables.h" |
0 | 21 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1919
diff
changeset
|
22 |
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 23 |
{ |
24 |
if (success) { |
|
541 | 25 |
SndPlayTileFx(SND_1F_SPLAT, tile); |
0 | 26 |
} else { |
27 |
SetRedErrorSquare(_terraform_err_tile); |
|
28 |
} |
|
29 |
} |
|
30 |
||
31 |
||
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
32 |
/** Scenario editor command that generates desert areas */ |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
33 |
static void GenerateDesertArea(TileIndex end, TileIndex start) |
c4ae19bfebf7
(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 |
{ |
c4ae19bfebf7
(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 |
int size_x, size_y; |
c4ae19bfebf7
(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 |
int sx = TileX(start); |
c4ae19bfebf7
(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 sy = TileY(start); |
c4ae19bfebf7
(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 ex = TileX(end); |
c4ae19bfebf7
(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 ey = TileY(end); |
c4ae19bfebf7
(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 |
|
c4ae19bfebf7
(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 |
if (_game_mode != GM_EDITOR) return; |
c4ae19bfebf7
(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 |
|
c4ae19bfebf7
(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 (ex < sx) intswap(ex, sx); |
c4ae19bfebf7
(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 |
if (ey < sy) intswap(ey, sy); |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
45 |
size_x = (ex - sx) + 1; |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
46 |
size_y = (ey - sy) + 1; |
c4ae19bfebf7
(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 |
|
1710
65510674894c
(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
|
48 |
_generating_world = true; |
1981 | 49 |
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { |
1710
65510674894c
(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 |
if (GetTileType(tile) != MP_WATER) { |
3379
ea8aa9e71328
(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
|
51 |
SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_INVALID : TROPICZONE_DESERT); |
1780
93fde4f32bfc
(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
|
52 |
DoCommandP(tile, 0, 0, NULL, CMD_LANDSCAPE_CLEAR); |
1710
65510674894c
(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
|
53 |
MarkTileDirtyByTile(tile); |
65510674894c
(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
|
54 |
} |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
55 |
} END_TILE_LOOP(tile, size_x, size_y, 0); |
1710
65510674894c
(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 |
_generating_world = false; |
1632
c4ae19bfebf7
(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 |
} |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
58 |
|
3017
915fae59d5e0
(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
|
59 |
/** Scenario editor command that generates rocky areas */ |
2615
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
60 |
static void GenerateRockyArea(TileIndex end, TileIndex start) |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
61 |
{ |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
62 |
int size_x, size_y; |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
63 |
bool success = false; |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
64 |
int sx = TileX(start); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
65 |
int sy = TileY(start); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
66 |
int ex = TileX(end); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
67 |
int ey = TileY(end); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
68 |
|
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
69 |
if (_game_mode != GM_EDITOR) return; |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
70 |
|
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
71 |
if (ex < sx) intswap(ex, sx); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
72 |
if (ey < sy) intswap(ey, sy); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
73 |
size_x = (ex - sx) + 1; |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
74 |
size_y = (ey - sy) + 1; |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
75 |
|
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
76 |
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
77 |
switch (GetTileType(tile)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
78 |
case MP_CLEAR: |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
79 |
MakeClear(tile, CLEAR_ROCKS, 3); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
80 |
break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
81 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
82 |
case MP_TREES: |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
83 |
MakeClear(tile, CLEAR_ROCKS, 3); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
84 |
ClearBridgeMiddle(tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
85 |
break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
86 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
87 |
default: continue; |
2615
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
88 |
} |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
89 |
MarkTileDirtyByTile(tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5072
diff
changeset
|
90 |
success = true; |
2615
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
91 |
} END_TILE_LOOP(tile, size_x, size_y, 0); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
92 |
|
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
93 |
if (success) SndPlayTileFx(SND_1F_SPLAT, end); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
94 |
} |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
95 |
|
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
96 |
/** |
c4ae19bfebf7
(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 |
* A central place to handle all X_AND_Y dragged GUI functions. |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
98 |
* @param e @WindowEvent variable holding in its higher bits (excluding the lower |
1632
c4ae19bfebf7
(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 |
* 4, since that defined the X_Y drag) the type of action to be performed |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
100 |
* @return Returns true if the action was found and handled, and false otherwise. This |
c4ae19bfebf7
(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 |
* allows for additional implements that are more local. For example X_Y drag |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
102 |
* of convertrail which belongs in rail_gui.c and not terraform_gui.c |
c4ae19bfebf7
(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
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
104 |
bool GUIPlaceProcDragXY(const WindowEvent *e) |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
105 |
{ |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
106 |
TileIndex start_tile = e->we.place.starttile; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
107 |
TileIndex end_tile = e->we.place.tile; |
1632
c4ae19bfebf7
(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 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
109 |
switch (e->we.place.userdata >> 4) { |
1632
c4ae19bfebf7
(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 |
case GUI_PlaceProc_DemolishArea >> 4: |
c4ae19bfebf7
(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 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
c4ae19bfebf7
(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 |
break; |
c4ae19bfebf7
(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 |
case GUI_PlaceProc_LevelArea >> 4: |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
114 |
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO); |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
115 |
break; |
2615
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
116 |
case GUI_PlaceProc_RockyArea >> 4: |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
117 |
GenerateRockyArea(end_tile, start_tile); |
4f6f464ba3eb
(svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents:
2186
diff
changeset
|
118 |
break; |
1632
c4ae19bfebf7
(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 |
case GUI_PlaceProc_DesertArea >> 4: |
c4ae19bfebf7
(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 |
GenerateDesertArea(end_tile, start_tile); |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
121 |
break; |
c4ae19bfebf7
(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 |
case GUI_PlaceProc_WaterArea >> 4: |
4087
5ae6c880d66c
(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
|
123 |
DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS)); |
1632
c4ae19bfebf7
(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 |
break; |
c4ae19bfebf7
(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 |
default: return false; |
c4ae19bfebf7
(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 |
} |
c4ae19bfebf7
(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 |
|
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
128 |
return true; |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
129 |
} |
0 | 130 |
|
131 |
typedef void OnButtonClick(Window *w); |
|
132 |
||
133 |
static const uint16 _terraform_keycodes[] = { |
|
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
134 |
'Q', |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
135 |
'W', |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
136 |
'E', |
936
245a9f54ad42
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
137 |
'D', |
606
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
138 |
'U', |
0e507bb0f63a
(svn r1030) Some toolbar icons are arranged differently:
dominik
parents:
545
diff
changeset
|
139 |
'I', |
613
ce1bb8c92cc5
(svn r1037) Rearranged landscaping hotkeys a bit more.
dominik
parents:
608
diff
changeset
|
140 |
'O', |
0 | 141 |
}; |
142 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1919
diff
changeset
|
143 |
void PlaceProc_DemolishArea(TileIndex tile) |
0 | 144 |
{ |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
145 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea); |
0 | 146 |
} |
147 |
||
2817 | 148 |
static void PlaceProc_RaiseLand(TileIndex tile) |
0 | 149 |
{ |
4007
98f6f57d0e0d
(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 |
DoCommandP( |
98f6f57d0e0d
(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 |
tile, SLOPE_N, 1, CcTerraform, |
98f6f57d0e0d
(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
|
152 |
CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE) |
98f6f57d0e0d
(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
|
153 |
); |
0 | 154 |
} |
155 |
||
2817 | 156 |
static void PlaceProc_LowerLand(TileIndex tile) |
0 | 157 |
{ |
4007
98f6f57d0e0d
(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 |
DoCommandP( |
98f6f57d0e0d
(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 |
tile, SLOPE_N, 0, CcTerraform, |
98f6f57d0e0d
(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
|
160 |
CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE) |
98f6f57d0e0d
(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
|
161 |
); |
0 | 162 |
} |
163 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1919
diff
changeset
|
164 |
void PlaceProc_LevelLand(TileIndex tile) |
0 | 165 |
{ |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
166 |
VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea); |
0 | 167 |
} |
168 |
||
169 |
static void TerraformClick_Lower(Window *w) |
|
170 |
{ |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
651
diff
changeset
|
171 |
HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerLand); |
0 | 172 |
} |
173 |
||
174 |
static void TerraformClick_Raise(Window *w) |
|
175 |
{ |
|
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
651
diff
changeset
|
176 |
HandlePlacePushButton(w, 5, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseLand); |
0 | 177 |
} |
178 |
||
179 |
static void TerraformClick_Level(Window *w) |
|
180 |
{ |
|
1919
0ad642b26ff2
(svn r2425) - Fix (regression): wrong sprite for level-land cursor (thx Tron)
Darkvater
parents:
1914
diff
changeset
|
181 |
HandlePlacePushButton(w, 6, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand); |
0 | 182 |
} |
183 |
||
936
245a9f54ad42
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
184 |
static void TerraformClick_Dynamite(Window *w) |
245a9f54ad42
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
185 |
{ |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
186 |
HandlePlacePushButton(w, 7, ANIMCURSOR_DEMOLISH , 1, PlaceProc_DemolishArea); |
936
245a9f54ad42
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
187 |
} |
245a9f54ad42
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
188 |
|
0 | 189 |
static void TerraformClick_BuyLand(Window *w) |
190 |
{ |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
191 |
HandlePlacePushButton(w, 8, SPR_CURSOR_BUY_LAND, 1, PlaceProc_BuyLand); |
0 | 192 |
} |
193 |
||
194 |
static void TerraformClick_Trees(Window *w) |
|
195 |
{ |
|
3817
a7baf79a424e
(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
|
196 |
/* This button is NOT a place-push-button, so don't treat it as such */ |
a7baf79a424e
(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
|
197 |
ShowBuildTreesToolbar(); |
0 | 198 |
} |
199 |
||
200 |
static void TerraformClick_PlaceSign(Window *w) |
|
201 |
{ |
|
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
202 |
HandlePlacePushButton(w, 10, SPR_CURSOR_SIGN, 1, PlaceProc_Sign); |
0 | 203 |
} |
204 |
||
205 |
static OnButtonClick * const _terraform_button_proc[] = { |
|
206 |
TerraformClick_Lower, |
|
207 |
TerraformClick_Raise, |
|
208 |
TerraformClick_Level, |
|
936
245a9f54ad42
(svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents:
867
diff
changeset
|
209 |
TerraformClick_Dynamite, |
0 | 210 |
TerraformClick_BuyLand, |
211 |
TerraformClick_Trees, |
|
212 |
TerraformClick_PlaceSign, |
|
213 |
}; |
|
214 |
||
215 |
static void TerraformToolbWndProc(Window *w, WindowEvent *e) |
|
216 |
{ |
|
2952 | 217 |
switch (e->event) { |
0 | 218 |
case WE_PAINT: |
219 |
DrawWindowWidgets(w); |
|
220 |
break; |
|
2639 | 221 |
|
0 | 222 |
case WE_CLICK: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
223 |
if (e->we.click.widget >= 4) _terraform_button_proc[e->we.click.widget - 4](w); |
0 | 224 |
break; |
225 |
||
2639 | 226 |
case WE_KEYPRESS: { |
227 |
uint i; |
|
616
3ab1124303e0
(svn r1040) Fix: All character hotkeys are disabled now when a window for typing is open
dominik
parents:
613
diff
changeset
|
228 |
|
2639 | 229 |
for (i = 0; i != lengthof(_terraform_keycodes); i++) { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
230 |
if (e->we.keypress.keycode == _terraform_keycodes[i]) { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
231 |
e->we.keypress.cont = false; |
0 | 232 |
_terraform_button_proc[i](w); |
233 |
break; |
|
234 |
} |
|
2639 | 235 |
} |
236 |
break; |
|
0 | 237 |
} |
238 |
||
239 |
case WE_PLACE_OBJ: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
240 |
_place_proc(e->we.place.tile); |
0 | 241 |
return; |
242 |
||
243 |
case WE_PLACE_DRAG: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
244 |
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF); |
0 | 245 |
break; |
246 |
||
247 |
case WE_PLACE_MOUSEUP: |
|
4994
ec6d8b5551f4
(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
|
248 |
if (e->we.place.pt.x != -1 && |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4087
diff
changeset
|
249 |
(e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4007
diff
changeset
|
250 |
GUIPlaceProcDragXY(e); |
0 | 251 |
} |
252 |
break; |
|
253 |
||
254 |
case WE_ABORT_PLACE_OBJ: |
|
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4634
diff
changeset
|
255 |
RaiseWindowButtons(w); |
0 | 256 |
break; |
257 |
} |
|
258 |
} |
|
259 |
||
260 |
static const Widget _terraform_widgets[] = { |
|
1632
c4ae19bfebf7
(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_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
262 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 145, 0, 13, STR_LANDSCAPING_TOOLBAR, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1363
diff
changeset
|
263 |
{WWT_STICKYBOX, RESIZE_NONE, 7, 146, 157, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
756
diff
changeset
|
264 |
|
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
265 |
{ WWT_PANEL, RESIZE_NONE, 7, 66, 69, 14, 35, 0x0, STR_NULL}, |
074f734a91ca
(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, 0, 21, 14, 35, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND}, |
074f734a91ca
(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, 22, 43, 14, 35, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND}, |
074f734a91ca
(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, 44, 65, 14, 35, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP}, |
074f734a91ca
(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, 70, 91, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, |
074f734a91ca
(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, 92, 113, 14, 35, SPR_IMG_BUY_LAND, STR_0329_PURCHASE_LAND_FOR_FUTURE}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
271 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_PLANTTREES, STR_0185_PLANT_TREES_PLACE_SIGNS}, |
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4848
diff
changeset
|
272 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_PLACE_SIGN, STR_0289_PLACE_SIGN}, |
0 | 273 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
30
diff
changeset
|
274 |
{ WIDGETS_END}, |
0 | 275 |
}; |
276 |
||
277 |
static const WindowDesc _terraform_desc = { |
|
5072
df5bde83a4bc
(svn r7130) -Codechange: Handle the positioning of windows through the desc->left/top settings with
Darkvater
parents:
5070
diff
changeset
|
278 |
WDP_ALIGN_TBR, 22+36, 158, 36, |
5070
0bbf5264bfb7
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5005
diff
changeset
|
279 |
WC_SCEN_LAND_GEN, 0, |
756
d1f1dc31b6f4
(svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents:
651
diff
changeset
|
280 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
0 | 281 |
_terraform_widgets, |
282 |
TerraformToolbWndProc |
|
283 |
}; |
|
284 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
988
diff
changeset
|
285 |
void ShowTerraformToolbar(void) |
0 | 286 |
{ |
5005
21e84e53c732
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4994
diff
changeset
|
287 |
if (!IsValidPlayer(_current_player)) return; |
0 | 288 |
AllocateWindowDescFront(&_terraform_desc, 0); |
289 |
} |