OpenTTD
Data Structures | Functions | Variables
terraform_gui.cpp File Reference

GUI related to terraforming the map. More...

#include "stdafx.h"
#include "clear_map.h"
#include "company_func.h"
#include "company_base.h"
#include "gui.h"
#include "window_gui.h"
#include "window_func.h"
#include "viewport_func.h"
#include "command_func.h"
#include "signs_func.h"
#include "sound_func.h"
#include "base_station_base.h"
#include "textbuf_gui.h"
#include "genworld.h"
#include "tree_map.h"
#include "landscape_type.h"
#include "tilehighlight_func.h"
#include "strings_func.h"
#include "newgrf_object.h"
#include "object.h"
#include "hotkeys.h"
#include "engine_base.h"
#include "terraform_gui.h"
#include "zoom_func.h"
#include "widgets/terraform_widget.h"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  TerraformToolbarWindow
 Terra form toolbar managing class. More...
 
struct  ScenarioEditorLandscapeGenerationWindow
 Landscape generation window handler in the scenario editor. More...
 

Functions

void CcTerraform (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 
static void GenerateDesertArea (TileIndex end, TileIndex start)
 Scenario editor command that generates desert areas.
 
static void GenerateRockyArea (TileIndex end, TileIndex start)
 Scenario editor command that generates rocky areas.
 
bool GUIPlaceProcDragXY (ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
 A central place to handle all X_AND_Y dragged GUI functions. More...
 
void PlaceProc_DemolishArea (TileIndex tile)
 Start a drag for demolishing an area. More...
 
static EventState TerraformToolbarGlobalHotkeys (int hotkey)
 Handler for global hotkeys of the TerraformToolbarWindow. More...
 
WindowShowTerraformToolbar (Window *link)
 Show the toolbar for terraforming in the game. More...
 
static void CommonRaiseLowerBigLand (TileIndex tile, int mode)
 Raise/Lower a bigger chunk of land at the same time in the editor. More...
 
static void ResetLandscapeConfirmationCallback (Window *w, bool confirmed)
 Callback function for the scenario editor 'reset landscape' confirmation window. More...
 
static EventState TerraformToolbarEditorGlobalHotkeys (int hotkey)
 Handler for global hotkeys of the ScenarioEditorLandscapeGenerationWindow. More...
 
WindowShowEditorTerraformToolbar ()
 Show the toolbar for terraforming in the scenario editor. More...
 

Variables

static Hotkey terraform_hotkeys []
 
static const NWidgetPart _nested_terraform_widgets []
 
static WindowDesc _terraform_desc (WDP_MANUAL, "toolbar_landscape", 0, 0, WC_SCEN_LAND_GEN, WC_NONE, WDF_CONSTRUCTION, _nested_terraform_widgets, lengthof(_nested_terraform_widgets), &TerraformToolbarWindow::hotkeys)
 
static byte _terraform_size = 1
 
static const int8 _multi_terraform_coords [][2]
 
static const NWidgetPart _nested_scen_edit_land_gen_widgets []
 
static Hotkey terraform_editor_hotkeys []
 
static WindowDesc _scen_edit_land_gen_desc (WDP_AUTO, "toolbar_landscape_scen", 0, 0, WC_SCEN_LAND_GEN, WC_NONE, WDF_CONSTRUCTION, _nested_scen_edit_land_gen_widgets, lengthof(_nested_scen_edit_land_gen_widgets), &ScenarioEditorLandscapeGenerationWindow::hotkeys)
 

Detailed Description

GUI related to terraforming the map.

Definition in file terraform_gui.cpp.

Function Documentation

◆ CommonRaiseLowerBigLand()

static void CommonRaiseLowerBigLand ( TileIndex  tile,
int  mode 
)
static

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' ?
Parameters
tileThe top-left tile where the terraforming will start
mode1 for raising, 0 for lowering land

Definition at line 393 of file terraform_gui.cpp.

References CMD_MSG, CMD_TERRAFORM_LAND, DoCommandP(), and SLOPE_N.

Referenced by ScenarioEditorLandscapeGenerationWindow::OnPlaceObject().

◆ GUIPlaceProcDragXY()

bool GUIPlaceProcDragXY ( ViewportDragDropSelectionProcess  proc,
TileIndex  start_tile,
TileIndex  end_tile 
)

A central place to handle all X_AND_Y dragged GUI functions.

Parameters
procProcedure related to the dragging
start_tileBegin of the dragging
end_tileEnd of the dragging
Returns
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 of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp

Definition at line 108 of file terraform_gui.cpp.

References _ctrl_pressed, _settings_game, CMD_CLEAR_AREA, CMD_MSG, GameSettings::construction, DDSP_DEMOLISH_AREA, DoCommandP(), ConstructionSettings::freeform_edges, MapMaxX(), MapMaxY(), TileDiffXY(), TileX(), and TileY().

Referenced by BuildAirToolbarWindow::OnPlaceMouseUp(), and BuildDocksToolbarWindow::OnPlaceMouseUp().

◆ PlaceProc_DemolishArea()

void PlaceProc_DemolishArea ( TileIndex  tile)

◆ ResetLandscapeConfirmationCallback()

static void ResetLandscapeConfirmationCallback ( Window w,
bool  confirmed 
)
static

Callback function for the scenario editor 'reset landscape' confirmation window.

Parameters
wWindow unused
confirmedboolean value, true when yes was clicked, false otherwise

Definition at line 497 of file terraform_gui.cpp.

References _generating_world.

◆ ShowEditorTerraformToolbar()

Window* ShowEditorTerraformToolbar ( )

Show the toolbar for terraforming in the scenario editor.

Returns
The allocated toolbar if the window was newly opened, else NULL.

Definition at line 752 of file terraform_gui.cpp.

◆ ShowTerraformToolbar()

Window* ShowTerraformToolbar ( Window link)

Show the toolbar for terraforming in the game.

Parameters
linkThe toolbar we might want to link to.
Returns
The allocated toolbar if the window was newly opened, else NULL.

Definition at line 358 of file terraform_gui.cpp.

References _local_company, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID().

Referenced by MenuClickForest().

◆ TerraformToolbarEditorGlobalHotkeys()

static EventState TerraformToolbarEditorGlobalHotkeys ( int  hotkey)
static

Handler for global hotkeys of the ScenarioEditorLandscapeGenerationWindow.

Parameters
hotkeyHotkey
Returns
ES_HANDLED if hotkey was accepted.

Definition at line 719 of file terraform_gui.cpp.

◆ TerraformToolbarGlobalHotkeys()

static EventState TerraformToolbarGlobalHotkeys ( int  hotkey)
static

Handler for global hotkeys of the TerraformToolbarWindow.

Parameters
hotkeyHotkey
Returns
ES_HANDLED if hotkey was accepted.

Definition at line 293 of file terraform_gui.cpp.

Variable Documentation

◆ _multi_terraform_coords

const int8 _multi_terraform_coords[][2]
static
Initial value:
= {
{ 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},
}

Definition at line 432 of file terraform_gui.cpp.

◆ _nested_terraform_widgets

const NWidgetPart _nested_terraform_widgets[]
static
Initial value:
= {
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),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_LOWER_LAND), SetMinimalSize(22, 22),
SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_DOWN, STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_RAISE_LAND), SetMinimalSize(22, 22),
SetFill(0, 1), SetDataTip(SPR_IMG_TERRAFORM_UP, STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_LEVEL_LAND), SetMinimalSize(22, 22),
SetFill(0, 1), SetDataTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), EndContainer(),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_DEMOLISH), SetMinimalSize(22, 22),
SetFill(0, 1), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_BUY_LAND), SetMinimalSize(22, 22),
SetFill(0, 1), SetDataTip(SPR_IMG_BUY_LAND, STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND),
SetFill(0, 1), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_PLACE_SIGN), SetMinimalSize(22, 22),
SetFill(0, 1), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
SetFill(0, 1), SetDataTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT),
}
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
Horizontal container.
Definition: widget_type.h:75
Should the place object button be shown?
Close box (at top-left of a window)
Definition: widget_type.h:69
Buy land button.
Place sign button.
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Simple depressed panel.
Definition: widget_type.h:50
Demolish aka dynamite button.
Lower land button.
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Level land button.
Plant trees button (note: opens separate window, no place-push-button).
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Place object button.
Raise land button.
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
(Toggle) Button with image
Definition: widget_type.h:52
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:80

Definition at line 314 of file terraform_gui.cpp.

◆ terraform_editor_hotkeys

Hotkey terraform_editor_hotkeys[]
static
Initial value:
= {
Hotkey('R', "rocky", WID_ETT_PLACE_ROCKS),
Hotkey('T', "desert", WID_ETT_PLACE_DESERT),
Hotkey('O', "object", WID_ETT_PLACE_OBJECT),
HOTKEY_LIST_END
}
All data for a single hotkey.
Definition: hotkeys.h:24
Place rocks button.
Raise land button.
Level land button.
Demolish aka dynamite button.
Place desert button (in tropical climate).
Place transmitter button.
Fake keycode bit to indicate global hotkeys.
Definition: gfx_type.h:35
Lower land button.

Definition at line 727 of file terraform_gui.cpp.

◆ terraform_hotkeys

Hotkey terraform_hotkeys[]
static
Initial value:
= {
Hotkey('U', "buyland", WID_TT_BUY_LAND),
Hotkey('I', "trees", WID_TT_PLANT_TREES),
Hotkey('O', "placesign", WID_TT_PLACE_SIGN),
Hotkey('P', "placeobject", WID_TT_PLACE_OBJECT),
HOTKEY_LIST_END
}
All data for a single hotkey.
Definition: hotkeys.h:24
Buy land button.
Place sign button.
Demolish aka dynamite button.
Lower land button.
Level land button.
Plant trees button (note: opens separate window, no place-push-button).
Place object button.
Raise land button.
Fake keycode bit to indicate global hotkeys.
Definition: gfx_type.h:35

Definition at line 301 of file terraform_gui.cpp.