src/terraform_gui.cpp
author maedhros
Wed, 23 May 2007 13:52:10 +0000
changeset 7166 3937d5ea59df
parent 7165 37eb253f3c06
child 7818 a4a667e7ee03
permissions -rw-r--r--
(svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6432
diff changeset
     3
/** @file terraform_gui.cpp */
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6432
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1780
diff changeset
     6
#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
     7
#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
     8
#include "clear_map.h"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1095
diff changeset
     9
#include "table/sprites.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 337
diff changeset
    10
#include "table/strings.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
    11
#include "functions.h"
2154
63a6b880b4c0 (svn r2664) Remove depedency on player.h from variables.h
tron
parents: 1981
diff changeset
    12
#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
    13
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "viewport.h"
2790
789f2d2aa403 (svn r3338) Wrong file in last commit
tron
parents: 2789
diff changeset
    17
#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
    18
#include "sound.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
#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
    21
#include "signs.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2154
diff changeset
    22
#include "variables.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
1977
4392ae3d8e31 (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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
	if (success) {
541
e1cd34389f79 (svn r925) Use sound enums
tron
parents: 507
diff changeset
    27
		SndPlayTileFx(SND_1F_SPLAT, tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
		SetRedErrorSquare(_terraform_err_tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
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
    34
/** 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
    35
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
    36
{
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 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
    38
	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
    39
	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
    40
	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
    41
	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
    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 (_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
    44
6432
8fb778a7f2d7 (svn r8841) -Fix
tron
parents: 6144
diff changeset
    45
	if (ex < sx) Swap(ex, sx);
8fb778a7f2d7 (svn r8841) -Fix
tron
parents: 6144
diff changeset
    46
	if (ey < sy) Swap(ey, sy);
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
    47
	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
    48
	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
    49
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
	_generating_world = true;
1981
de031d2aed47 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1977
diff changeset
    51
	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
    52
		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
    53
			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
    54
			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
    55
			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
    56
		}
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
	} 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
    58
	_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
    59
}
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
    60
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
    61
/** 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
    62
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
    63
{
4f6f464ba3eb (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;
4f6f464ba3eb (svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents: 2186
diff changeset
    65
	bool success = false;
4f6f464ba3eb (svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents: 2186
diff changeset
    66
	int sx = TileX(start);
4f6f464ba3eb (svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents: 2186
diff changeset
    67
	int sy = TileY(start);
4f6f464ba3eb (svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents: 2186
diff changeset
    68
	int ex = TileX(end);
4f6f464ba3eb (svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents: 2186
diff changeset
    69
	int ey = TileY(end);
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 (_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
    72
6432
8fb778a7f2d7 (svn r8841) -Fix
tron
parents: 6144
diff changeset
    73
	if (ex < sx) Swap(ex, sx);
8fb778a7f2d7 (svn r8841) -Fix
tron
parents: 6144
diff changeset
    74
	if (ey < sy) Swap(ey, sy);
2615
4f6f464ba3eb (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;
4f6f464ba3eb (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;
4f6f464ba3eb (svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents: 2186
diff changeset
    77
4f6f464ba3eb (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)) {
5573
afa6f92a71fd (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)) {
afa6f92a71fd (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:
afa6f92a71fd (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:
afa6f92a71fd (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);
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5072
diff changeset
    83
				break;
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5072
diff changeset
    84
afa6f92a71fd (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
4f6f464ba3eb (svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents: 2186
diff changeset
    86
		}
5573
afa6f92a71fd (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);
afa6f92a71fd (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
4f6f464ba3eb (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);
4f6f464ba3eb (svn r3153) - Feature: [ 1276827 ] Drag and drop rocky areas in scenario editor (MeusH-ish)
Darkvater
parents: 2186
diff changeset
    90
4f6f464ba3eb (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);
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
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
    94
/**
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
    95
 * A central place to handle all X_AND_Y dragged GUI functions.
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6432
diff changeset
    96
 * @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
    97
 * 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
    98
 * @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
    99
 * allows for additional implements that are more local. For example X_Y drag
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6432
diff changeset
   100
 * of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp
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
   101
 **/
4634
897461a3e9ca (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
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
	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
   105
	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
   106
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   107
	switch (e->we.place.select_proc) {
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   108
		case DDSP_DEMOLISH_AREA:
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   109
			DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   110
			break;
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   111
		case DDSP_LEVEL_AREA:
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   112
			DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   113
			break;
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   114
		case DDSP_CREATE_ROCKS:
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   115
			GenerateRockyArea(end_tile, start_tile);
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   116
			break;
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   117
		case DDSP_CREATE_DESERT:
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   118
			GenerateDesertArea(end_tile, start_tile);
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   119
			break;
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   120
		case DDSP_CREATE_WATER:
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   121
			DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   122
			break;
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   123
		default:
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   124
			return 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
   125
	}
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
	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
   128
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
typedef void OnButtonClick(Window *w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
static const uint16 _terraform_keycodes[] = {
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 545
diff changeset
   133
	'Q',
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 545
diff changeset
   134
	'W',
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 545
diff changeset
   135
	'E',
936
245a9f54ad42 (svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents: 867
diff changeset
   136
	'D',
606
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 545
diff changeset
   137
	'U',
0e507bb0f63a (svn r1030) Some toolbar icons are arranged differently:
dominik
parents: 545
diff changeset
   138
	'I',
613
ce1bb8c92cc5 (svn r1037) Rearranged landscaping hotkeys a bit more.
dominik
parents: 608
diff changeset
   139
	'O',
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1919
diff changeset
   142
void PlaceProc_DemolishArea(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
{
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   144
	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2790
diff changeset
   147
static void PlaceProc_RaiseLand(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
{
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
   149
	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
   150
		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
   151
		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
   152
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2790
diff changeset
   155
static void PlaceProc_LowerLand(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
{
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
   157
	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
   158
		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
   159
		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
   160
	);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1919
diff changeset
   163
void PlaceProc_LevelLand(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
{
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   165
	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LEVEL_AREA);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
static void TerraformClick_Lower(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
{
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 651
diff changeset
   170
	HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerLand);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
static void TerraformClick_Raise(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
{
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 651
diff changeset
   175
	HandlePlacePushButton(w, 5, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseLand);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
static void TerraformClick_Level(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
{
1919
0ad642b26ff2 (svn r2425) - Fix (regression): wrong sprite for level-land cursor (thx Tron)
Darkvater
parents: 1914
diff changeset
   180
	HandlePlacePushButton(w, 6, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
936
245a9f54ad42 (svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents: 867
diff changeset
   183
static void TerraformClick_Dynamite(Window *w)
245a9f54ad42 (svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents: 867
diff changeset
   184
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   185
	HandlePlacePushButton(w, 7, ANIMCURSOR_DEMOLISH , 1, PlaceProc_DemolishArea);
936
245a9f54ad42 (svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents: 867
diff changeset
   186
}
245a9f54ad42 (svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents: 867
diff changeset
   187
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
static void TerraformClick_BuyLand(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   190
	HandlePlacePushButton(w, 8, SPR_CURSOR_BUY_LAND, 1, PlaceProc_BuyLand);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
static void TerraformClick_Trees(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
{
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
   195
	/* 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
   196
	ShowBuildTreesToolbar();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
static void TerraformClick_PlaceSign(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
{
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
   201
	HandlePlacePushButton(w, 10, SPR_CURSOR_SIGN, 1, PlaceProc_Sign);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
static OnButtonClick * const _terraform_button_proc[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
	TerraformClick_Lower,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
	TerraformClick_Raise,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
	TerraformClick_Level,
936
245a9f54ad42 (svn r1424) Add dynamite to landscaping toolbar (hotkey 'D')
dominik
parents: 867
diff changeset
   208
	TerraformClick_Dynamite,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
	TerraformClick_BuyLand,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
	TerraformClick_Trees,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
	TerraformClick_PlaceSign,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
static void TerraformToolbWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
{
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2817
diff changeset
   216
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
		break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2615
diff changeset
   220
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
	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
   222
		if (e->we.click.widget >= 4) _terraform_button_proc[e->we.click.widget - 4](w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2615
diff changeset
   225
	case WE_KEYPRESS: {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2615
diff changeset
   226
		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
   227
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2615
diff changeset
   228
		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
   229
			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
   230
				e->we.keypress.cont = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
				_terraform_button_proc[i](w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
			}
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2615
diff changeset
   234
		}
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2615
diff changeset
   235
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
	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
   239
		_place_proc(e->we.place.tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
	case WE_PLACE_DRAG:
7165
37eb253f3c06 (svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents: 7096
diff changeset
   243
		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
	case WE_PLACE_MOUSEUP:
7166
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   247
		if (e->we.place.pt.x != -1) {
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   248
			switch (e->we.place.select_proc) {
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   249
				case DDSP_DEMOLISH_AREA:
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   250
				case DDSP_LEVEL_AREA:
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   251
					GUIPlaceProcDragXY(e);
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   252
					break;
3937d5ea59df (svn r9901) -Codechange: Decide what to do with selected land areas based on the specific variable, not how it was highlighted.
maedhros
parents: 7165
diff changeset
   253
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
	case WE_ABORT_PLACE_OBJ:
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4634
diff changeset
   258
		RaiseWindowButtons(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
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
   264
{ 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
   265
{  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
   266
{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
   267
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4848
diff changeset
   268
{    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
   269
{   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
   270
{   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
   271
{   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
   272
{   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
   273
{   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
   274
{   WWT_IMGBTN,   RESIZE_NONE,     7, 114, 135,  14,  35, SPR_IMG_PLANTTREES,      STR_0185_PLANT_TREES_PLACE_SIGNS},
7096
fd549da22194 (svn r9814) -Fix (r1): Remove the duplicate sign sprite from openttd.grf since it's in the original data files.
maedhros
parents: 6987
diff changeset
   275
{   WWT_IMGBTN,   RESIZE_NONE,     7, 136, 157,  14,  35, SPR_IMG_SIGN,            STR_0289_PLACE_SIGN},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 30
diff changeset
   277
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
static const WindowDesc _terraform_desc = {
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6918
diff changeset
   281
	WDP_ALIGN_TBR, 22 + 36, 158, 36,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6111
diff changeset
   282
	WC_SCEN_LAND_GEN, WC_NONE,
756
d1f1dc31b6f4 (svn r1212) -Feature: sticky windows all build-toolbars
darkvater
parents: 651
diff changeset
   283
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
	_terraform_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	TerraformToolbWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
6111
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   288
void ShowTerraformToolbar(Window *link)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
{
5005
21e84e53c732 (svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents: 4994
diff changeset
   290
	if (!IsValidPlayer(_current_player)) return;
6111
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   291
	Window *w = AllocateWindowDescFront(&_terraform_desc, 0);
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   292
	if (w != NULL && link != NULL) {
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   293
		/* Align the terraform toolbar under the main toolbar and put the linked
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   294
		 * toolbar to left of it
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   295
		 */
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   296
		w->top = 22;
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   297
		link->left = w->left - link->width;
32f6149dc192 (svn r8436) -Fix
tron
parents: 5835
diff changeset
   298
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
}