2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file terraform_gui.cpp GUI related to terraforming the map. */
|
2007-04-04 03:21:14 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2006-03-05 10:19:33 +00:00
|
|
|
#include "clear_map.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_func.h"
|
|
|
|
#include "company_base.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "gui.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
2009-01-02 21:01:13 +00:00
|
|
|
#include "window_func.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2008-03-31 07:25:49 +00:00
|
|
|
#include "signs_func.h"
|
2007-12-29 09:24:26 +00:00
|
|
|
#include "sound_func.h"
|
2009-07-22 11:35:35 +00:00
|
|
|
#include "base_station_base.h"
|
2008-01-06 18:56:43 +00:00
|
|
|
#include "textbuf_gui.h"
|
2008-01-09 21:05:03 +00:00
|
|
|
#include "genworld.h"
|
2008-01-31 17:54:13 +00:00
|
|
|
#include "tree_map.h"
|
2008-05-07 09:07:19 +00:00
|
|
|
#include "landscape_type.h"
|
2008-05-07 13:10:15 +00:00
|
|
|
#include "tilehighlight_func.h"
|
2009-11-28 14:30:00 +00:00
|
|
|
#include "strings_func.h"
|
2010-08-28 19:43:41 +00:00
|
|
|
#include "newgrf_object.h"
|
|
|
|
#include "object.h"
|
2010-07-03 13:28:48 +00:00
|
|
|
#include "hotkeys.h"
|
2011-02-05 16:07:23 +00:00
|
|
|
#include "engine_base.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
|
2010-01-11 18:46:09 +00:00
|
|
|
void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2010-01-11 18:46:09 +00:00
|
|
|
if (result.Succeeded()) {
|
2004-12-04 09:26:39 +00:00
|
|
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
2008-01-07 00:45:05 +00:00
|
|
|
extern TileIndex _terraform_err_tile;
|
2004-08-09 17:04:08 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (_game_mode != GM_EDITOR) return;
|
|
|
|
|
2005-04-19 18:30:31 +00:00
|
|
|
_generating_world = true;
|
2010-01-04 18:49:27 +00:00
|
|
|
|
|
|
|
TileArea ta(start, end);
|
|
|
|
TILE_AREA_LOOP(tile, ta) {
|
2009-05-13 10:57:32 +00:00
|
|
|
SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT);
|
|
|
|
DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
|
|
|
|
MarkTileDirtyByTile(tile);
|
2009-07-26 21:50:30 +00:00
|
|
|
}
|
2005-04-19 18:30:31 +00:00
|
|
|
_generating_world = false;
|
2011-01-30 19:14:48 +00:00
|
|
|
InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
|
(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)
|
|
|
|
{
|
|
|
|
if (_game_mode != GM_EDITOR) return;
|
|
|
|
|
2010-01-04 18:49:27 +00:00
|
|
|
bool success = false;
|
|
|
|
TileArea ta(start, end);
|
2005-11-07 16:19:45 +00:00
|
|
|
|
2010-01-04 18:49:27 +00:00
|
|
|
TILE_AREA_LOOP(tile, ta) {
|
2006-12-27 12:38:02 +00:00
|
|
|
switch (GetTileType(tile)) {
|
|
|
|
case MP_TREES:
|
2008-01-31 17:54:13 +00:00
|
|
|
if (GetTreeGround(tile) == TREE_GROUND_SHORE) continue;
|
2010-08-01 20:52:11 +00:00
|
|
|
/* FALL THROUGH */
|
2008-01-31 17:54:13 +00:00
|
|
|
case MP_CLEAR:
|
2006-12-27 12:38:02 +00:00
|
|
|
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;
|
2009-07-26 21:50:30 +00:00
|
|
|
}
|
2005-11-07 16:19:45 +00:00
|
|
|
|
|
|
|
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.
|
2009-09-19 09:51:14 +00:00
|
|
|
* @param proc Procedure related to the dragging
|
|
|
|
* @param start_tile Begin of the dragging
|
|
|
|
* @param end_tile End of the dragging
|
(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 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
|
2010-08-01 19:44:49 +00:00
|
|
|
*/
|
2008-05-18 12:40:38 +00:00
|
|
|
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_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
|
|
|
{
|
2009-01-21 02:31:55 +00:00
|
|
|
if (!_settings_game.construction.freeform_edges) {
|
|
|
|
/* When end_tile is MP_VOID, the error tile will not be visible to the
|
|
|
|
* user. This happens when terraforming at the southern border. */
|
|
|
|
if (TileX(end_tile) == MapMaxX()) end_tile += TileDiffXY(-1, 0);
|
|
|
|
if (TileY(end_tile) == MapMaxY()) end_tile += TileDiffXY(0, -1);
|
|
|
|
}
|
2009-01-14 13:11:39 +00:00
|
|
|
|
2008-05-18 12:40:38 +00:00
|
|
|
switch (proc) {
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_DEMOLISH_AREA:
|
2010-12-13 15:34:30 +00:00
|
|
|
DoCommandP(end_tile, start_tile, _ctrl_pressed ? 1 : 0, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound10);
|
2007-05-23 12:45:56 +00:00
|
|
|
break;
|
2008-01-04 18:18:46 +00:00
|
|
|
case DDSP_RAISE_AND_LEVEL_AREA:
|
2010-12-13 15:34:30 +00:00
|
|
|
DoCommandP(end_tile, start_tile, LM_RAISE << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform);
|
2008-01-04 18:18:46 +00:00
|
|
|
break;
|
|
|
|
case DDSP_LOWER_AND_LEVEL_AREA:
|
2010-12-13 15:34:30 +00:00
|
|
|
DoCommandP(end_tile, start_tile, LM_LOWER << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform);
|
2008-01-04 18:18:46 +00:00
|
|
|
break;
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_LEVEL_AREA:
|
2010-12-13 15:34:30 +00:00
|
|
|
DoCommandP(end_tile, start_tile, LM_LEVEL << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform);
|
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;
|
|
|
|
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
|
|
|
|
2010-12-24 15:06:58 +00:00
|
|
|
/**
|
|
|
|
* Start a drag for demolishing an area.
|
|
|
|
* @param tile Position of one corner.
|
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
2008-05-22 20:44:24 +00:00
|
|
|
/** Enum referring to the widgets of the terraform toolbar */
|
|
|
|
enum TerraformToolbarWidgets {
|
2010-08-28 19:43:41 +00:00
|
|
|
TTW_SHOW_PLACE_OBJECT, ///< Should the place object button be shown?
|
2008-05-22 20:44:24 +00:00
|
|
|
TTW_BUTTONS_START, ///< Start of pushable buttons
|
|
|
|
TTW_LOWER_LAND = TTW_BUTTONS_START, ///< Lower land button
|
|
|
|
TTW_RAISE_LAND, ///< Raise land button
|
|
|
|
TTW_LEVEL_LAND, ///< Level land button
|
|
|
|
TTW_DEMOLISH, ///< Demolish aka dynamite button
|
|
|
|
TTW_BUY_LAND, ///< Buy land button
|
|
|
|
TTW_PLANT_TREES, ///< Plant trees button (note: opens seperate window, no place-push-button)
|
|
|
|
TTW_PLACE_SIGN, ///< Place sign button
|
2010-08-28 19:43:41 +00:00
|
|
|
TTW_PLACE_OBJECT, ///< Place object button
|
2008-05-22 20:44:24 +00:00
|
|
|
};
|
|
|
|
|
2010-12-24 15:06:18 +00:00
|
|
|
/** Terra form toolbar managing class. */
|
2008-05-18 21:53:45 +00:00
|
|
|
struct TerraformToolbarWindow : Window {
|
2010-12-24 15:06:18 +00:00
|
|
|
int last_user_action; ///< Last started user action.
|
|
|
|
|
2009-07-18 15:29:16 +00:00
|
|
|
TerraformToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
2008-05-18 21:53:45 +00:00
|
|
|
{
|
2010-08-28 19:43:41 +00:00
|
|
|
/* This is needed as we like to have the tree available on OnInit. */
|
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
this->FinishInitNested(desc, window_number);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = WIDGET_LIST_END;
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
~TerraformToolbarWindow()
|
|
|
|
{
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2010-08-28 19:43:41 +00:00
|
|
|
virtual void OnInit()
|
|
|
|
{
|
|
|
|
/* Don't show the place object button when there are no objects to place. */
|
|
|
|
NWidgetStacked *show_object = this->GetWidget<NWidgetStacked>(TTW_SHOW_PLACE_OBJECT);
|
|
|
|
show_object->SetDisplayedPlane(ObjectClass::GetCount() != 0 ? 0 : SZSP_NONE);
|
|
|
|
}
|
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-18 21:53:45 +00:00
|
|
|
{
|
2010-12-24 15:03:19 +00:00
|
|
|
if (widget < TTW_BUTTONS_START) return;
|
|
|
|
|
|
|
|
switch (widget) {
|
|
|
|
case TTW_LOWER_LAND: // Lower land button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, TTW_LOWER_LAND, ANIMCURSOR_LOWERLAND, HT_POINT | HT_DIAGONAL);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_RAISE_LAND: // Raise land button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, TTW_RAISE_LAND, ANIMCURSOR_RAISELAND, HT_POINT | HT_DIAGONAL);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_LEVEL_LAND: // Level land button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, TTW_LEVEL_LAND, SPR_CURSOR_LEVEL_LAND, HT_POINT | HT_DIAGONAL);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_DEMOLISH: // Demolish aka dynamite button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, TTW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_BUY_LAND: // Buy land button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, TTW_BUY_LAND, SPR_CURSOR_BUY_LAND, HT_RECT);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_PLANT_TREES: // Plant trees button
|
2010-12-24 15:04:33 +00:00
|
|
|
/* This button is NOT a place-push-button, so don't treat it as such */
|
|
|
|
this->HandleButtonClick(TTW_PLANT_TREES);
|
|
|
|
ShowBuildTreesToolbar();
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_PLACE_SIGN: // Place sign button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, TTW_PLACE_SIGN, SPR_CURSOR_SIGN, HT_RECT);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_PLACE_OBJECT: // Place object button
|
2010-12-24 15:04:33 +00:00
|
|
|
/* Don't show the place object button when there are no objects to place. */
|
|
|
|
if (ObjectClass::GetCount() == 0) return;
|
2010-12-24 15:08:19 +00:00
|
|
|
if (HandlePlacePushButton(this, TTW_PLACE_OBJECT, SPR_CURSOR_TRANSMITTER, HT_RECT)) {
|
2010-12-24 15:06:18 +00:00
|
|
|
ShowBuildObjectPicker(this);
|
|
|
|
this->last_user_action = widget;
|
|
|
|
}
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
|
|
|
|
2010-12-19 13:44:09 +00:00
|
|
|
virtual void OnTimeout()
|
|
|
|
{
|
|
|
|
this->RaiseWidget(TTW_PLANT_TREES);
|
|
|
|
this->SetWidgetDirty(TTW_PLANT_TREES);
|
|
|
|
}
|
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
|
|
|
{
|
2010-07-03 13:28:48 +00:00
|
|
|
int num = CheckHotkeyMatch(terraform_hotkeys, keycode, this);
|
|
|
|
if (num == -1) return ES_NOT_HANDLED;
|
|
|
|
this->OnClick(Point(), num, 1);
|
|
|
|
return ES_HANDLED;
|
2005-11-14 19:48:04 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
|
|
|
{
|
2010-12-24 15:06:18 +00:00
|
|
|
switch (this->last_user_action) {
|
|
|
|
case TTW_LOWER_LAND: // Lower land button
|
2010-12-24 15:06:58 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LOWER_AND_LEVEL_AREA);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_RAISE_LAND: // Raise land button
|
2010-12-24 15:06:58 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_RAISE_AND_LEVEL_AREA);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_LEVEL_LAND: // Level land button
|
2010-12-24 15:06:58 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LEVEL_AREA);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_DEMOLISH: // Demolish aka dynamite button
|
|
|
|
PlaceProc_DemolishArea(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_BUY_LAND: // Buy land button
|
2010-12-24 15:06:58 +00:00
|
|
|
DoCommandP(tile, OBJECT_OWNED_LAND, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound1E);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_PLACE_SIGN: // Place sign button
|
|
|
|
PlaceProc_Sign(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TTW_PLACE_OBJECT: // Place object button
|
|
|
|
PlaceProc_Object(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
|
|
|
|
{
|
|
|
|
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-28 14:30:00 +00:00
|
|
|
virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
|
|
|
|
{
|
|
|
|
Point pt = GetToolbarAlignedWindowPosition(sm_width);
|
|
|
|
pt.y += sm_height;
|
|
|
|
return pt;
|
|
|
|
}
|
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
|
|
|
|
{
|
|
|
|
if (pt.x != -1) {
|
|
|
|
switch (select_proc) {
|
2008-05-18 12:40:38 +00:00
|
|
|
default: NOT_REACHED();
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_DEMOLISH_AREA:
|
2008-01-04 18:18:46 +00:00
|
|
|
case DDSP_RAISE_AND_LEVEL_AREA:
|
|
|
|
case DDSP_LOWER_AND_LEVEL_AREA:
|
2007-05-23 13:52:10 +00:00
|
|
|
case DDSP_LEVEL_AREA:
|
2008-05-18 21:53:45 +00:00
|
|
|
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
|
2007-05-23 13:52:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
|
{
|
2010-08-28 19:43:41 +00:00
|
|
|
DeleteWindowById(WC_BUILD_OBJECT, 0);
|
2008-05-18 21:53:45 +00:00
|
|
|
this->RaiseButtons();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2010-07-03 13:28:48 +00:00
|
|
|
|
|
|
|
static Hotkey<TerraformToolbarWindow> terraform_hotkeys[];
|
|
|
|
};
|
|
|
|
|
|
|
|
Hotkey<TerraformToolbarWindow> TerraformToolbarWindow::terraform_hotkeys[] = {
|
2010-07-03 21:43:44 +00:00
|
|
|
Hotkey<TerraformToolbarWindow>('Q' | WKC_GLOBAL_HOTKEY, "lower", TTW_LOWER_LAND),
|
|
|
|
Hotkey<TerraformToolbarWindow>('W' | WKC_GLOBAL_HOTKEY, "raise", TTW_RAISE_LAND),
|
|
|
|
Hotkey<TerraformToolbarWindow>('E' | WKC_GLOBAL_HOTKEY, "level", TTW_LEVEL_LAND),
|
|
|
|
Hotkey<TerraformToolbarWindow>('D' | WKC_GLOBAL_HOTKEY, "dynamite", TTW_DEMOLISH),
|
2010-07-03 13:28:48 +00:00
|
|
|
Hotkey<TerraformToolbarWindow>('U', "buyland", TTW_BUY_LAND),
|
|
|
|
Hotkey<TerraformToolbarWindow>('I', "trees", TTW_PLANT_TREES),
|
|
|
|
Hotkey<TerraformToolbarWindow>('O', "placesign", TTW_PLACE_SIGN),
|
2010-08-28 19:43:41 +00:00
|
|
|
Hotkey<TerraformToolbarWindow>('P', "placeobject", TTW_PLACE_OBJECT),
|
2010-07-03 13:28:48 +00:00
|
|
|
HOTKEY_LIST_END(TerraformToolbarWindow)
|
2008-05-18 21:53:45 +00:00
|
|
|
};
|
2010-07-03 13:28:48 +00:00
|
|
|
Hotkey<TerraformToolbarWindow> *_terraform_hotkeys = TerraformToolbarWindow::terraform_hotkeys;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-04-18 07:49:20 +00:00
|
|
|
static const NWidgetPart _nested_terraform_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_LANDSCAPING_TOOLBAR, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-04-18 07:49:20 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2010-08-01 19:01:09 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_LOWER_LAND), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_DOWN, STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND),
|
2010-08-01 19:01:09 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_RAISE_LAND), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_UP, STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND),
|
2010-08-01 19:01:09 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_LEVEL_LAND), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
|
2009-07-18 15:29:16 +00:00
|
|
|
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), EndContainer(),
|
2009-07-18 15:29:16 +00:00
|
|
|
|
2010-08-01 19:01:09 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_DEMOLISH), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
2010-08-01 19:01:09 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_BUY_LAND), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_BUY_LAND, STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND),
|
2010-08-01 19:01:09 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_PLANT_TREES), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
|
2010-08-01 19:01:09 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_PLACE_SIGN), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
|
2010-08-28 19:43:41 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, TTW_SHOW_PLACE_OBJECT),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_PLACE_OBJECT), SetMinimalSize(22, 22),
|
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT),
|
|
|
|
EndContainer(),
|
2009-04-18 07:49:20 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _terraform_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_MANUAL, 0, 0,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SCEN_LAND_GEN, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_terraform_widgets, lengthof(_nested_terraform_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-05-01 19:14:12 +00:00
|
|
|
/**
|
|
|
|
* Show the toolbar for terraforming in the game.
|
|
|
|
* @param link The toolbar we might want to link to.
|
|
|
|
* @return The allocated toolbar.
|
|
|
|
*/
|
2009-06-01 14:36:36 +00:00
|
|
|
Window *ShowTerraformToolbar(Window *link)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2009-06-01 14:36:36 +00:00
|
|
|
if (!Company::IsValidID(_local_company)) return NULL;
|
2009-01-02 21:01:13 +00:00
|
|
|
|
2010-04-22 19:41:36 +00:00
|
|
|
Window *w;
|
|
|
|
if (link == NULL) {
|
|
|
|
w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
|
|
|
|
return w;
|
2007-01-28 10:09:40 +00:00
|
|
|
}
|
2009-01-02 21:01:13 +00:00
|
|
|
|
2010-04-22 19:41:36 +00:00
|
|
|
/* Delete the terraform toolbar to place it again. */
|
|
|
|
DeleteWindowById(WC_SCEN_LAND_GEN, 0, true);
|
|
|
|
w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
|
|
|
|
/* Align the terraform toolbar under the main toolbar. */
|
|
|
|
w->top -= w->height;
|
|
|
|
w->SetDirty();
|
|
|
|
/* Put the linked toolbar to the left / right of it. */
|
2010-11-13 09:56:25 +00:00
|
|
|
link->left = w->left + (_current_text_dir == TD_RTL ? w->width : -link->width);
|
2009-01-02 21:01:13 +00:00
|
|
|
link->top = w->top;
|
|
|
|
link->SetDirty();
|
2009-06-01 14:36:36 +00:00
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
2010-07-03 21:43:44 +00:00
|
|
|
EventState TerraformToolbarGlobalHotkeys(uint16 key, uint16 keycode)
|
2009-06-01 14:36:36 +00:00
|
|
|
{
|
2010-07-03 21:43:44 +00:00
|
|
|
int num = CheckHotkeyMatch<TerraformToolbarWindow>(_terraform_hotkeys, keycode, NULL, true);
|
|
|
|
if (num == -1) return ES_NOT_HANDLED;
|
|
|
|
Window *w = ShowTerraformToolbar(NULL);
|
2010-07-04 09:27:15 +00:00
|
|
|
if (w == NULL) return ES_NOT_HANDLED;
|
2010-07-03 21:43:44 +00:00
|
|
|
return w->OnKeyPress(key, keycode);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
|
|
|
static byte _terraform_size = 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Raise/Lower a bigger chunk of land at the same time in the editor. When
|
|
|
|
* raising get the lowest point, when lowering the highest point, and set all
|
|
|
|
* tiles in the selection to that height.
|
|
|
|
* @todo : Incorporate into game itself to allow for ingame raising/lowering of
|
|
|
|
* larger chunks at the same time OR remove altogether, as we have 'level land' ?
|
|
|
|
* @param tile The top-left tile where the terraforming will start
|
|
|
|
* @param mode 1 for raising, 0 for lowering land
|
|
|
|
*/
|
|
|
|
static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
|
|
|
|
{
|
|
|
|
if (_terraform_size == 1) {
|
|
|
|
StringID msg =
|
2009-04-21 23:40:56 +00:00
|
|
|
mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE;
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-12-28 14:37:19 +00:00
|
|
|
DoCommandP(tile, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform);
|
2008-01-06 18:56:43 +00:00
|
|
|
} else {
|
|
|
|
assert(_terraform_size != 0);
|
2010-12-12 18:05:34 +00:00
|
|
|
TileArea ta(tile, _terraform_size, _terraform_size);
|
|
|
|
ta.ClampToMap();
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2010-12-12 18:05:34 +00:00
|
|
|
if (ta.w == 0 || ta.h == 0) return;
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-06-24 15:58:01 +00:00
|
|
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
|
|
|
|
2010-12-12 18:05:34 +00:00
|
|
|
uint h;
|
2008-01-06 18:56:43 +00:00
|
|
|
if (mode != 0) {
|
|
|
|
/* Raise land */
|
2010-12-12 18:05:34 +00:00
|
|
|
h = MAX_TILE_HEIGHT;
|
|
|
|
TILE_AREA_LOOP(tile2, ta) {
|
2008-01-06 18:56:43 +00:00
|
|
|
h = min(h, TileHeight(tile2));
|
2009-07-26 21:50:30 +00:00
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
} else {
|
|
|
|
/* Lower land */
|
|
|
|
h = 0;
|
2010-12-12 18:05:34 +00:00
|
|
|
TILE_AREA_LOOP(tile2, ta) {
|
2008-01-06 18:56:43 +00:00
|
|
|
h = max(h, TileHeight(tile2));
|
2009-07-26 21:50:30 +00:00
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
}
|
|
|
|
|
2010-12-12 18:05:34 +00:00
|
|
|
TILE_AREA_LOOP(tile2, ta) {
|
2008-01-06 18:56:43 +00:00
|
|
|
if (TileHeight(tile2) == h) {
|
2008-12-28 14:37:19 +00:00
|
|
|
DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND);
|
2008-01-06 18:56:43 +00:00
|
|
|
}
|
2009-07-26 21:50:30 +00:00
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const int8 _multi_terraform_coords[][2] = {
|
|
|
|
{ 0, -2},
|
|
|
|
{ 4, 0}, { -4, 0}, { 0, 2},
|
|
|
|
{ -8, 2}, { -4, 4}, { 0, 6}, { 4, 4}, { 8, 2},
|
|
|
|
{-12, 0}, { -8, -2}, { -4, -4}, { 0, -6}, { 4, -4}, { 8, -2}, { 12, 0},
|
|
|
|
{-16, 2}, {-12, 4}, { -8, 6}, { -4, 8}, { 0, 10}, { 4, 8}, { 8, 6}, { 12, 4}, { 16, 2},
|
|
|
|
{-20, 0}, {-16, -2}, {-12, -4}, { -8, -6}, { -4, -8}, { 0,-10}, { 4, -8}, { 8, -6}, { 12, -4}, { 16, -2}, { 20, 0},
|
|
|
|
{-24, 2}, {-20, 4}, {-16, 6}, {-12, 8}, { -8, 10}, { -4, 12}, { 0, 14}, { 4, 12}, { 8, 10}, { 12, 8}, { 16, 6}, { 20, 4}, { 24, 2},
|
|
|
|
{-28, 0}, {-24, -2}, {-20, -4}, {-16, -6}, {-12, -8}, { -8,-10}, { -4,-12}, { 0,-14}, { 4,-12}, { 8,-10}, { 12, -8}, { 16, -6}, { 20, -4}, { 24, -2}, { 28, 0},
|
|
|
|
};
|
|
|
|
|
2008-05-22 20:44:24 +00:00
|
|
|
/** Enum referring to the widgets of the editor terraform toolbar */
|
|
|
|
enum EditorTerraformToolbarWidgets {
|
2010-08-28 19:45:56 +00:00
|
|
|
ETTW_SHOW_PLACE_DESERT, ///< Should the place desert button be shown?
|
|
|
|
ETTW_START, ///< Used for iterations
|
2009-11-24 21:13:36 +00:00
|
|
|
ETTW_DOTS = ETTW_START, ///< Invisible widget for rendering the terraform size on.
|
2008-05-22 20:44:24 +00:00
|
|
|
ETTW_BUTTONS_START, ///< Start of pushable buttons
|
|
|
|
ETTW_DEMOLISH = ETTW_BUTTONS_START, ///< Demolish aka dynamite button
|
|
|
|
ETTW_LOWER_LAND, ///< Lower land button
|
|
|
|
ETTW_RAISE_LAND, ///< Raise land button
|
|
|
|
ETTW_LEVEL_LAND, ///< Level land button
|
|
|
|
ETTW_PLACE_ROCKS, ///< Place rocks button
|
2010-08-28 19:45:56 +00:00
|
|
|
ETTW_PLACE_DESERT, ///< Place desert button (in tropical climate)
|
|
|
|
ETTW_PLACE_OBJECT, ///< Place transmitter button
|
2008-05-22 20:44:24 +00:00
|
|
|
ETTW_BUTTONS_END, ///< End of pushable buttons
|
|
|
|
ETTW_INCREASE_SIZE = ETTW_BUTTONS_END, ///< Upwards arrow button to increase terraforming size
|
|
|
|
ETTW_DECREASE_SIZE, ///< Downwards arrow button to decrease terraforming size
|
|
|
|
ETTW_NEW_SCENARIO, ///< Button for generating a new scenario
|
2008-09-30 20:39:50 +00:00
|
|
|
ETTW_RESET_LANDSCAPE, ///< Button for removing all company-owned property
|
2008-05-22 20:44:24 +00:00
|
|
|
};
|
|
|
|
|
2009-04-18 07:49:20 +00:00
|
|
|
static const NWidgetPart _nested_scen_edit_land_gen_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TERRAFORM_TOOLBAR_LAND_GENERATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-04-18 07:49:20 +00:00
|
|
|
EndContainer(),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPadding(2, 2, 7, 2),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_DEMOLISH), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_LOWER_LAND), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_DOWN, STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_RAISE_LAND), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_UP, STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_LEVEL_LAND), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_PLACE_ROCKS), SetMinimalSize(22, 22),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_ROCKS, STR_TERRAFORM_TOOLTIP_PLACE_ROCKY_AREAS_ON_LANDSCAPE),
|
2010-08-28 19:45:56 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, ETTW_SHOW_PLACE_DESERT),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_PLACE_DESERT), SetMinimalSize(22, 22),
|
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_DESERT, STR_TERRAFORM_TOOLTIP_DEFINE_DESERT_AREA),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_PLACE_OBJECT), SetMinimalSize(23, 22),
|
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-04-18 07:49:20 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, ETTW_DOTS), SetMinimalSize(59, 31), SetDataTip(STR_EMPTY, STR_NULL),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-04-18 07:49:20 +00:00
|
|
|
NWidget(NWID_VERTICAL),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(0, 1),
|
2009-04-21 23:40:56 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_INCREASE_SIZE), SetMinimalSize(12, 12), SetDataTip(SPR_ARROW_UP, STR_TERRAFORM_TOOLTIP_INCREASE_SIZE_OF_LAND_AREA),
|
2009-04-18 07:49:20 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
|
2009-04-21 23:40:56 +00:00
|
|
|
NWidget(WWT_IMGBTN, COLOUR_GREY, ETTW_DECREASE_SIZE), SetMinimalSize(12, 12), SetDataTip(SPR_ARROW_DOWN, STR_TERRAFORM_TOOLTIP_DECREASE_SIZE_OF_LAND_AREA),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(0, 1),
|
2009-04-18 07:49:20 +00:00
|
|
|
EndContainer(),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(2, 0),
|
2009-04-18 07:49:20 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 6),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, ETTW_NEW_SCENARIO), SetMinimalSize(160, 12),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(1, 0), SetDataTip(STR_TERRAFORM_SE_NEW_WORLD, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetPadding(0, 2, 0, 2),
|
2009-07-18 15:29:16 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, ETTW_RESET_LANDSCAPE), SetMinimalSize(160, 12),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetFill(1, 0), SetDataTip(STR_TERRAFORM_RESET_LANDSCAPE, STR_TERRAFORM_RESET_LANDSCAPE_TOOLTIP), SetPadding(1, 2, 2, 2),
|
2009-04-18 07:49:20 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* Callback function for the scenario editor 'reset landscape' confirmation window
|
2008-01-06 18:56:43 +00:00
|
|
|
* @param w Window unused
|
2010-08-01 19:44:49 +00:00
|
|
|
* @param confirmed boolean value, true when yes was clicked, false otherwise
|
|
|
|
*/
|
2008-01-06 18:56:43 +00:00
|
|
|
static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
|
|
|
|
{
|
|
|
|
if (confirmed) {
|
|
|
|
/* Set generating_world to true to get instant-green grass after removing
|
2008-09-30 20:39:50 +00:00
|
|
|
* company property. */
|
2008-01-06 18:56:43 +00:00
|
|
|
_generating_world = true;
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
/* Delete all companies */
|
2009-05-11 18:17:21 +00:00
|
|
|
Company *c;
|
2008-09-30 20:39:50 +00:00
|
|
|
FOR_ALL_COMPANIES(c) {
|
|
|
|
ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
|
|
|
|
delete c;
|
2008-07-18 16:40:29 +00:00
|
|
|
}
|
2009-05-11 18:17:21 +00:00
|
|
|
|
2008-07-18 16:40:29 +00:00
|
|
|
_generating_world = false;
|
2009-05-11 18:17:21 +00:00
|
|
|
|
|
|
|
/* Delete all station signs */
|
2009-07-22 08:59:57 +00:00
|
|
|
BaseStation *st;
|
|
|
|
FOR_ALL_BASE_STATIONS(st) {
|
2009-05-11 18:17:21 +00:00
|
|
|
/* There can be buoys, remove them */
|
2009-07-22 08:59:57 +00:00
|
|
|
if (IsBuoyTile(st->xy)) DoCommand(st->xy, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
|
2009-07-24 07:38:10 +00:00
|
|
|
if (!st->IsInUse()) delete st;
|
2009-05-11 18:17:21 +00:00
|
|
|
}
|
|
|
|
|
2011-02-05 16:07:23 +00:00
|
|
|
/* Now that all vehicles are gone, we can reset the engine pool. Maybe it reduces some NewGRF changing-mess */
|
|
|
|
EngineOverrideManager::ResetToCurrentNewGRFConfig();
|
|
|
|
|
2009-05-11 18:17:21 +00:00
|
|
|
MarkWholeScreenDirty();
|
2008-01-06 18:56:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-24 15:06:18 +00:00
|
|
|
/** Landscape generation window handler in the scenario editor. */
|
2008-05-18 21:53:45 +00:00
|
|
|
struct ScenarioEditorLandscapeGenerationWindow : Window {
|
2010-12-24 15:06:18 +00:00
|
|
|
int last_user_action; ///< Last started user action.
|
|
|
|
|
2009-07-18 15:29:16 +00:00
|
|
|
ScenarioEditorLandscapeGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
2008-05-18 21:53:45 +00:00
|
|
|
{
|
2010-08-28 19:45:56 +00:00
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
NWidgetStacked *show_desert = this->GetWidget<NWidgetStacked>(ETTW_SHOW_PLACE_DESERT);
|
|
|
|
show_desert->SetDisplayedPlane(_settings_game.game_creation.landscape == LT_TROPIC ? 0 : SZSP_NONE);
|
|
|
|
this->FinishInitNested(desc, window_number);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = WIDGET_LIST_END;
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2009-10-04 17:10:57 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
2008-05-18 21:53:45 +00:00
|
|
|
this->DrawWidgets();
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2009-07-18 15:29:16 +00:00
|
|
|
if (this->IsWidgetLowered(ETTW_LOWER_LAND) || this->IsWidgetLowered(ETTW_RAISE_LAND)) { // change area-size if raise/lower corner is selected
|
|
|
|
SetTileSelectSize(_terraform_size, _terraform_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
|
|
|
if (widget != ETTW_DOTS) return;
|
|
|
|
|
2010-04-18 17:13:01 +00:00
|
|
|
int center_x = RoundDivSU(r.left + r.right, 2);
|
|
|
|
int center_y = RoundDivSU(r.top + r.bottom, 2);
|
2009-07-18 15:29:16 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
int n = _terraform_size * _terraform_size;
|
|
|
|
const int8 *coords = &_multi_terraform_coords[0][0];
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
assert(n != 0);
|
|
|
|
do {
|
2009-07-18 15:29:16 +00:00
|
|
|
DrawSprite(SPR_WHITE_POINT, PAL_NONE, center_x + coords[0], center_y + coords[1]);
|
2008-05-18 21:53:45 +00:00
|
|
|
coords += 2;
|
|
|
|
} while (--n);
|
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
|
|
|
{
|
2010-07-03 13:29:01 +00:00
|
|
|
int num = CheckHotkeyMatch(terraform_editor_hotkeys, keycode, this);
|
|
|
|
if (num == -1) return ES_NOT_HANDLED;
|
|
|
|
this->OnClick(Point(), num, 1);
|
|
|
|
return ES_HANDLED;
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-18 21:53:45 +00:00
|
|
|
{
|
2010-12-24 15:03:19 +00:00
|
|
|
if (widget < ETTW_BUTTONS_START) return;
|
|
|
|
|
|
|
|
switch (widget) {
|
|
|
|
case ETTW_DEMOLISH: // Demolish aka dynamite button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, ETTW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_LOWER_LAND: // Lower land button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, ETTW_LOWER_LAND, ANIMCURSOR_LOWERLAND, HT_POINT);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_RAISE_LAND: // Raise land button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, ETTW_RAISE_LAND, ANIMCURSOR_RAISELAND, HT_POINT);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_LEVEL_LAND: // Level land button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, ETTW_LEVEL_LAND, SPR_CURSOR_LEVEL_LAND, HT_POINT | HT_DIAGONAL);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_PLACE_ROCKS: // Place rocks button
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, ETTW_PLACE_ROCKS, SPR_CURSOR_ROCKY_AREA, HT_RECT);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_PLACE_DESERT: // Place desert button (in tropical climate)
|
2010-12-24 15:08:19 +00:00
|
|
|
HandlePlacePushButton(this, ETTW_PLACE_DESERT, SPR_CURSOR_DESERT, HT_RECT);
|
2010-12-24 15:06:18 +00:00
|
|
|
this->last_user_action = widget;
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_PLACE_OBJECT: // Place transmitter button
|
2010-12-24 15:08:19 +00:00
|
|
|
if (HandlePlacePushButton(this, ETTW_PLACE_OBJECT, SPR_CURSOR_TRANSMITTER, HT_RECT)) {
|
2010-12-24 15:06:18 +00:00
|
|
|
ShowBuildObjectPicker(this);
|
|
|
|
this->last_user_action = widget;
|
|
|
|
}
|
2010-12-24 15:03:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_INCREASE_SIZE:
|
|
|
|
case ETTW_DECREASE_SIZE: { // Increase/Decrease terraform size
|
|
|
|
int size = (widget == ETTW_INCREASE_SIZE) ? 1 : -1;
|
|
|
|
this->HandleButtonClick(widget);
|
|
|
|
size += _terraform_size;
|
|
|
|
|
|
|
|
if (!IsInsideMM(size, 1, 8 + 1)) return;
|
|
|
|
_terraform_size = size;
|
|
|
|
|
|
|
|
SndPlayFx(SND_15_BEEP);
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
2008-05-22 20:44:24 +00:00
|
|
|
}
|
2010-12-24 15:03:19 +00:00
|
|
|
|
|
|
|
case ETTW_NEW_SCENARIO: // gen random land
|
|
|
|
this->HandleButtonClick(widget);
|
|
|
|
ShowCreateScenario();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_RESET_LANDSCAPE: // Reset landscape
|
|
|
|
ShowQuery(STR_QUERY_RESET_LANDSCAPE_CAPTION, STR_RESET_LANDSCAPE_CONFIRMATION_TEXT, NULL, ResetLandscapeConfirmationCallback);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnTimeout()
|
|
|
|
{
|
2009-07-18 15:29:16 +00:00
|
|
|
for (uint i = ETTW_START; i < this->nested_array_size; i++) {
|
2008-05-22 20:44:24 +00:00
|
|
|
if (i == ETTW_BUTTONS_START) i = ETTW_BUTTONS_END; // skip the buttons
|
2008-05-18 21:53:45 +00:00
|
|
|
if (this->IsWidgetLowered(i)) {
|
|
|
|
this->RaiseWidget(i);
|
2009-09-13 19:15:59 +00:00
|
|
|
this->SetWidgetDirty(i);
|
2008-01-06 18:56:43 +00:00
|
|
|
}
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
|
|
|
{
|
2010-12-24 15:06:18 +00:00
|
|
|
switch (this->last_user_action) {
|
|
|
|
case ETTW_DEMOLISH: // Demolish aka dynamite button
|
|
|
|
PlaceProc_DemolishArea(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_LOWER_LAND: // Lower land button
|
2010-12-24 15:06:58 +00:00
|
|
|
CommonRaiseLowerBigLand(tile, 0);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_RAISE_LAND: // Raise land button
|
2010-12-24 15:06:58 +00:00
|
|
|
CommonRaiseLowerBigLand(tile, 1);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_LEVEL_LAND: // Level land button
|
2010-12-24 15:06:58 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LEVEL_AREA);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_PLACE_ROCKS: // Place rocks button
|
2010-12-24 15:06:58 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_ROCKS);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_PLACE_DESERT: // Place desert button (in tropical climate)
|
2010-12-24 15:06:58 +00:00
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CREATE_DESERT);
|
2010-12-24 15:06:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ETTW_PLACE_OBJECT: // Place transmitter button
|
|
|
|
PlaceProc_Object(tile);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
|
|
|
|
{
|
|
|
|
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
|
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
|
|
|
|
{
|
|
|
|
if (pt.x != -1) {
|
|
|
|
switch (select_proc) {
|
|
|
|
default: NOT_REACHED();
|
|
|
|
case DDSP_CREATE_ROCKS:
|
|
|
|
case DDSP_CREATE_DESERT:
|
|
|
|
case DDSP_RAISE_AND_LEVEL_AREA:
|
|
|
|
case DDSP_LOWER_AND_LEVEL_AREA:
|
|
|
|
case DDSP_LEVEL_AREA:
|
|
|
|
case DDSP_DEMOLISH_AREA:
|
|
|
|
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
|
|
|
|
break;
|
2008-01-06 18:56:43 +00:00
|
|
|
}
|
2008-05-18 21:53:45 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2008-05-18 21:53:45 +00:00
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
|
{
|
|
|
|
this->RaiseButtons();
|
|
|
|
this->SetDirty();
|
2010-08-28 19:45:56 +00:00
|
|
|
DeleteWindowById(WC_BUILD_OBJECT, 0);
|
2008-01-06 18:56:43 +00:00
|
|
|
}
|
2010-07-03 13:29:01 +00:00
|
|
|
|
|
|
|
static Hotkey<ScenarioEditorLandscapeGenerationWindow> terraform_editor_hotkeys[];
|
|
|
|
};
|
|
|
|
|
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow> ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys[] = {
|
2010-07-03 21:43:44 +00:00
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow>('D' | WKC_GLOBAL_HOTKEY, "dynamite", ETTW_DEMOLISH),
|
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow>('Q' | WKC_GLOBAL_HOTKEY, "lower", ETTW_LOWER_LAND),
|
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow>('W' | WKC_GLOBAL_HOTKEY, "raise", ETTW_RAISE_LAND),
|
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow>('E' | WKC_GLOBAL_HOTKEY, "level", ETTW_LEVEL_LAND),
|
2010-07-03 13:29:01 +00:00
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow>('R', "rocky", ETTW_PLACE_ROCKS),
|
2010-08-28 19:45:56 +00:00
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow>('T', "desert", ETTW_PLACE_DESERT),
|
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow>('O', "object", ETTW_PLACE_OBJECT),
|
2010-07-03 13:29:01 +00:00
|
|
|
HOTKEY_LIST_END(ScenarioEditorLandscapeGenerationWindow)
|
2008-05-18 21:53:45 +00:00
|
|
|
};
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2010-07-03 13:29:01 +00:00
|
|
|
Hotkey<ScenarioEditorLandscapeGenerationWindow> *_terraform_editor_hotkeys = ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys;
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _scen_edit_land_gen_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_AUTO, 0, 0,
|
2008-01-06 18:56:43 +00:00
|
|
|
WC_SCEN_LAND_GEN, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_scen_edit_land_gen_widgets, lengthof(_nested_scen_edit_land_gen_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2008-01-06 18:56:43 +00:00
|
|
|
|
2011-05-01 19:14:12 +00:00
|
|
|
/**
|
|
|
|
* Show the toolbar for terraforming in the scenario editor.
|
|
|
|
* @return The allocated toolbar.
|
|
|
|
*/
|
2009-06-01 14:36:36 +00:00
|
|
|
Window *ShowEditorTerraformToolbar()
|
|
|
|
{
|
|
|
|
return AllocateWindowDescFront<ScenarioEditorLandscapeGenerationWindow>(&_scen_edit_land_gen_desc, 0);
|
|
|
|
}
|
|
|
|
|
2010-07-03 21:43:44 +00:00
|
|
|
EventState TerraformToolbarEditorGlobalHotkeys(uint16 key, uint16 keycode)
|
2008-01-06 18:56:43 +00:00
|
|
|
{
|
2010-07-03 21:43:44 +00:00
|
|
|
int num = CheckHotkeyMatch<ScenarioEditorLandscapeGenerationWindow>(_terraform_editor_hotkeys, keycode, NULL, true);
|
|
|
|
if (num == -1) return ES_NOT_HANDLED;
|
|
|
|
Window *w = ShowEditorTerraformToolbar();
|
2010-07-04 09:27:15 +00:00
|
|
|
if (w == NULL) return ES_NOT_HANDLED;
|
2010-07-03 21:43:44 +00:00
|
|
|
return w->OnKeyPress(key, keycode);
|
2008-01-06 18:56:43 +00:00
|
|
|
}
|