2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-04-04 03:21:14 +00:00
|
|
|
/** @file terraform_gui.cpp */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2006-12-27 12:38:02 +00:00
|
|
|
#include "bridge_map.h"
|
2006-03-05 10:19:33 +00:00
|
|
|
#include "clear_map.h"
|
2005-02-13 11:18:02 +00:00
|
|
|
#include "table/sprites.h"
|
2004-11-25 10:47:30 +00:00
|
|
|
#include "table/strings.h"
|
2005-07-22 07:02:20 +00:00
|
|
|
#include "functions.h"
|
2005-07-21 19:36:43 +00:00
|
|
|
#include "player.h"
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
#include "tile.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "window.h"
|
|
|
|
#include "gui.h"
|
|
|
|
#include "viewport.h"
|
2005-12-24 20:53:02 +00:00
|
|
|
#include "gfx.h"
|
2004-11-05 23:12:33 +00:00
|
|
|
#include "sound.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "command.h"
|
|
|
|
#include "vehicle.h"
|
2005-01-12 11:21:28 +00:00
|
|
|
#include "signs.h"
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "variables.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (success) {
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
|
|
|
SetRedErrorSquare(_terraform_err_tile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
/** Scenario editor command that generates desert areas */
|
|
|
|
static void GenerateDesertArea(TileIndex end, TileIndex start)
|
|
|
|
{
|
|
|
|
int size_x, size_y;
|
|
|
|
int sx = TileX(start);
|
|
|
|
int sy = TileY(start);
|
|
|
|
int ex = TileX(end);
|
|
|
|
int ey = TileY(end);
|
|
|
|
|
|
|
|
if (_game_mode != GM_EDITOR) return;
|
|
|
|
|
2007-02-22 08:43:02 +00:00
|
|
|
if (ex < sx) Swap(ex, sx);
|
|
|
|
if (ey < sy) Swap(ey, sy);
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
size_x = (ex - sx) + 1;
|
|
|
|
size_y = (ey - sy) + 1;
|
|
|
|
|
2005-04-19 18:30:31 +00:00
|
|
|
_generating_world = true;
|
2005-06-25 16:44:57 +00:00
|
|
|
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
|
2005-04-19 18:30:31 +00:00
|
|
|
if (GetTileType(tile) != MP_WATER) {
|
2006-03-30 19:16:44 +00:00
|
|
|
SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_INVALID : TROPICZONE_DESERT);
|
2005-05-08 21:00:56 +00:00
|
|
|
DoCommandP(tile, 0, 0, NULL, CMD_LANDSCAPE_CLEAR);
|
2005-04-19 18:30:31 +00:00
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
}
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
} END_TILE_LOOP(tile, size_x, size_y, 0);
|
2005-04-19 18:30:31 +00:00
|
|
|
_generating_world = false;
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
}
|
|
|
|
|
2006-02-13 21:15:00 +00:00
|
|
|
/** Scenario editor command that generates rocky areas */
|
2005-11-07 16:19:45 +00:00
|
|
|
static void GenerateRockyArea(TileIndex end, TileIndex start)
|
|
|
|
{
|
|
|
|
int size_x, size_y;
|
|
|
|
bool success = false;
|
|
|
|
int sx = TileX(start);
|
|
|
|
int sy = TileY(start);
|
|
|
|
int ex = TileX(end);
|
|
|
|
int ey = TileY(end);
|
|
|
|
|
|
|
|
if (_game_mode != GM_EDITOR) return;
|
|
|
|
|
2007-02-22 08:43:02 +00:00
|
|
|
if (ex < sx) Swap(ex, sx);
|
|
|
|
if (ey < sy) Swap(ey, sy);
|
2005-11-07 16:19:45 +00:00
|
|
|
size_x = (ex - sx) + 1;
|
|
|
|
size_y = (ey - sy) + 1;
|
|
|
|
|
|
|
|
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
|
2006-12-27 12:38:02 +00:00
|
|
|
switch (GetTileType(tile)) {
|
|
|
|
case MP_CLEAR:
|
|
|
|
case MP_TREES:
|
|
|
|
MakeClear(tile, CLEAR_ROCKS, 3);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: continue;
|
2005-11-07 16:19:45 +00:00
|
|
|
}
|
2006-12-27 12:38:02 +00:00
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
|
success = true;
|
2005-11-07 16:19:45 +00:00
|
|
|
} END_TILE_LOOP(tile, size_x, size_y, 0);
|
|
|
|
|
|
|
|
if (success) SndPlayTileFx(SND_1F_SPLAT, end);
|
|
|
|
}
|
|
|
|
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
/**
|
|
|
|
* A central place to handle all X_AND_Y dragged GUI functions.
|
2007-04-04 03:21:14 +00:00
|
|
|
* @param e WindowEvent variable holding in its higher bits (excluding the lower
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
* 4, since that defined the X_Y drag) the type of action to be performed
|
|
|
|
* @return Returns true if the action was found and handled, and false otherwise. This
|
|
|
|
* allows for additional implements that are more local. For example X_Y drag
|
2007-04-04 03:21:14 +00:00
|
|
|
* of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
**/
|
2006-09-23 02:39:24 +00:00
|
|
|
bool GUIPlaceProcDragXY(const WindowEvent *e)
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
{
|
2006-09-23 02:39:24 +00:00
|
|
|
TileIndex start_tile = e->we.place.starttile;
|
|
|
|
TileIndex end_tile = e->we.place.tile;
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
|
2007-05-23 12:45:56 +00:00
|
|
|
switch (e->we.place.select_proc) {
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_DEMOLISH_AREA:
|
2007-05-23 12:45:56 +00:00
|
|
|
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
|
|
|
|
break;
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_LEVEL_AREA:
|
2007-09-04 11:58:27 +00:00
|
|
|
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND);
|
2007-05-23 12:45:56 +00:00
|
|
|
break;
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_CREATE_ROCKS:
|
2007-05-23 12:45:56 +00:00
|
|
|
GenerateRockyArea(end_tile, start_tile);
|
|
|
|
break;
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_CREATE_DESERT:
|
2007-05-23 12:45:56 +00:00
|
|
|
GenerateDesertArea(end_tile, start_tile);
|
|
|
|
break;
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_CREATE_WATER:
|
2007-09-04 11:58:27 +00:00
|
|
|
DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS));
|
2007-05-23 12:45:56 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
typedef void OnButtonClick(Window *w);
|
|
|
|
|
|
|
|
static const uint16 _terraform_keycodes[] = {
|
2004-12-12 17:42:04 +00:00
|
|
|
'Q',
|
|
|
|
'W',
|
|
|
|
'E',
|
2005-01-08 09:24:15 +00:00
|
|
|
'D',
|
2004-12-12 17:42:04 +00:00
|
|
|
'U',
|
|
|
|
'I',
|
2004-12-12 18:51:24 +00:00
|
|
|
'O',
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void PlaceProc_DemolishArea(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-05-23 13:52:10 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-01-05 12:40:50 +00:00
|
|
|
static void PlaceProc_RaiseLand(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-06-10 19:40:43 +00:00
|
|
|
DoCommandP(
|
|
|
|
tile, SLOPE_N, 1, CcTerraform,
|
2007-09-04 11:58:27 +00:00
|
|
|
CMD_TERRAFORM_LAND | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE)
|
2006-06-10 19:40:43 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-01-05 12:40:50 +00:00
|
|
|
static void PlaceProc_LowerLand(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-06-10 19:40:43 +00:00
|
|
|
DoCommandP(
|
|
|
|
tile, SLOPE_N, 0, CcTerraform,
|
2007-09-04 11:58:27 +00:00
|
|
|
CMD_TERRAFORM_LAND | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE)
|
2006-06-10 19:40:43 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
void PlaceProc_LevelLand(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-05-23 13:52:10 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LEVEL_AREA);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TerraformClick_Lower(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerLand);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TerraformClick_Raise(Window *w)
|
|
|
|
{
|
2004-12-22 00:18:40 +00:00
|
|
|
HandlePlacePushButton(w, 5, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseLand);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TerraformClick_Level(Window *w)
|
|
|
|
{
|
2005-06-06 17:30:52 +00:00
|
|
|
HandlePlacePushButton(w, 6, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-01-08 09:24:15 +00:00
|
|
|
static void TerraformClick_Dynamite(Window *w)
|
|
|
|
{
|
2005-06-06 13:47:06 +00:00
|
|
|
HandlePlacePushButton(w, 7, ANIMCURSOR_DEMOLISH , 1, PlaceProc_DemolishArea);
|
2005-01-08 09:24:15 +00:00
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static void TerraformClick_BuyLand(Window *w)
|
|
|
|
{
|
2005-06-06 13:47:06 +00:00
|
|
|
HandlePlacePushButton(w, 8, SPR_CURSOR_BUY_LAND, 1, PlaceProc_BuyLand);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TerraformClick_Trees(Window *w)
|
|
|
|
{
|
2006-05-11 14:05:23 +00:00
|
|
|
/* This button is NOT a place-push-button, so don't treat it as such */
|
|
|
|
ShowBuildTreesToolbar();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TerraformClick_PlaceSign(Window *w)
|
|
|
|
{
|
2005-06-06 13:47:06 +00:00
|
|
|
HandlePlacePushButton(w, 10, SPR_CURSOR_SIGN, 1, PlaceProc_Sign);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static OnButtonClick * const _terraform_button_proc[] = {
|
|
|
|
TerraformClick_Lower,
|
|
|
|
TerraformClick_Raise,
|
|
|
|
TerraformClick_Level,
|
2005-01-08 09:24:15 +00:00
|
|
|
TerraformClick_Dynamite,
|
2004-12-12 17:42:04 +00:00
|
|
|
TerraformClick_BuyLand,
|
2004-08-09 17:04:08 +00:00
|
|
|
TerraformClick_Trees,
|
|
|
|
TerraformClick_PlaceSign,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void TerraformToolbWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
2006-02-01 07:36:15 +00:00
|
|
|
switch (e->event) {
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_PAINT:
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
break;
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
case WE_CLICK:
|
2006-09-23 02:39:24 +00:00
|
|
|
if (e->we.click.widget >= 4) _terraform_button_proc[e->we.click.widget - 4](w);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
|
2005-11-14 19:48:04 +00:00
|
|
|
case WE_KEYPRESS: {
|
|
|
|
uint i;
|
2004-12-12 22:05:08 +00:00
|
|
|
|
2005-11-14 19:48:04 +00:00
|
|
|
for (i = 0; i != lengthof(_terraform_keycodes); i++) {
|
2006-09-23 02:39:24 +00:00
|
|
|
if (e->we.keypress.keycode == _terraform_keycodes[i]) {
|
|
|
|
e->we.keypress.cont = false;
|
2004-08-09 17:04:08 +00:00
|
|
|
_terraform_button_proc[i](w);
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
2005-11-14 19:48:04 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
case WE_PLACE_OBJ:
|
2006-09-23 02:39:24 +00:00
|
|
|
_place_proc(e->we.place.tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case WE_PLACE_DRAG:
|
2007-05-23 12:45:56 +00:00
|
|
|
VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_PLACE_MOUSEUP:
|
2007-05-23 13:52:10 +00:00
|
|
|
if (e->we.place.pt.x != -1) {
|
|
|
|
switch (e->we.place.select_proc) {
|
|
|
|
case DDSP_DEMOLISH_AREA:
|
|
|
|
case DDSP_LEVEL_AREA:
|
|
|
|
GUIPlaceProcDragXY(e);
|
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_ABORT_PLACE_OBJ:
|
2006-10-03 20:16:20 +00:00
|
|
|
RaiseWindowButtons(w);
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Widget _terraform_widgets[] = {
|
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
2005-04-02 23:05:09 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 145, 0, 13, STR_LANDSCAPING_TOOLBAR, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
|
{WWT_STICKYBOX, RESIZE_NONE, 7, 146, 157, 0, 13, STR_NULL, STR_STICKY_BUTTON},
|
|
|
|
|
2006-10-24 14:15:17 +00:00
|
|
|
{ WWT_PANEL, RESIZE_NONE, 7, 66, 69, 14, 35, 0x0, STR_NULL},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 70, 91, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 92, 113, 14, 35, SPR_IMG_BUY_LAND, STR_0329_PURCHASE_LAND_FOR_FUTURE},
|
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_PLANTTREES, STR_0185_PLANT_TREES_PLACE_SIGNS},
|
2007-05-08 14:28:55 +00:00
|
|
|
{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_SIGN, STR_0289_PLACE_SIGN},
|
2004-09-07 21:48:09 +00:00
|
|
|
|
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WindowDesc _terraform_desc = {
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_ALIGN_TBR, 22 + 36, 158, 36, 158, 36,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SCEN_LAND_GEN, WC_NONE,
|
2004-12-22 00:18:40 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
2004-08-09 17:04:08 +00:00
|
|
|
_terraform_widgets,
|
|
|
|
TerraformToolbWndProc
|
|
|
|
};
|
|
|
|
|
2007-01-28 10:09:40 +00:00
|
|
|
void ShowTerraformToolbar(Window *link)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-10-31 21:15:56 +00:00
|
|
|
if (!IsValidPlayer(_current_player)) return;
|
2007-01-28 10:09:40 +00:00
|
|
|
Window *w = AllocateWindowDescFront(&_terraform_desc, 0);
|
|
|
|
if (w != NULL && link != NULL) {
|
|
|
|
/* Align the terraform toolbar under the main toolbar and put the linked
|
|
|
|
* toolbar to left of it
|
|
|
|
*/
|
|
|
|
w->top = 22;
|
|
|
|
link->left = w->left - link->width;
|
2007-07-25 11:27:30 +00:00
|
|
|
|
|
|
|
SetWindowDirty(link);
|
2007-01-28 10:09:40 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|