|
@@ -19,19 +19,20 @@
|
|
|
#include "viewport_func.h"
|
|
|
#include "command_func.h"
|
|
|
#include "signs_func.h"
|
|
|
#include "functions.h"
|
|
|
#include "sound_func.h"
|
|
|
#include "base_station_base.h"
|
|
|
#include "object_type.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 "table/strings.h"
|
|
|
|
|
|
void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
|
|
{
|
|
@@ -156,20 +157,22 @@ static void PlaceProc_LevelLand(TileInde
|
|
|
{
|
|
|
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LEVEL_AREA);
|
|
|
}
|
|
|
|
|
|
/** Enum referring to the widgets of the terraform toolbar */
|
|
|
enum TerraformToolbarWidgets {
|
|
|
TTW_SHOW_PLACE_OBJECT, ///< Should the place object button be shown?
|
|
|
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
|
|
|
TTW_PLACE_OBJECT, ///< Place object button
|
|
|
};
|
|
|
|
|
|
static void TerraformClick_Lower(Window *w)
|
|
|
{
|
|
|
HandlePlacePushButton(w, TTW_LOWER_LAND, ANIMCURSOR_LOWERLAND, HT_POINT, PlaceProc_LowerLand);
|
|
|
}
|
|
@@ -202,32 +205,50 @@ static void TerraformClick_Trees(Window
|
|
|
|
|
|
static void TerraformClick_PlaceSign(Window *w)
|
|
|
{
|
|
|
HandlePlacePushButton(w, TTW_PLACE_SIGN, SPR_CURSOR_SIGN, HT_RECT, PlaceProc_Sign);
|
|
|
}
|
|
|
|
|
|
static void TerraformClick_PlaceObject(Window *w)
|
|
|
{
|
|
|
/* Don't show the place object button when there are no objects to place. */
|
|
|
if (ObjectClass::GetCount() == 0) return;
|
|
|
if (HandlePlacePushButton(w, TTW_PLACE_OBJECT, SPR_CURSOR_TRANSMITTER, HT_RECT, PlaceProc_Object)) ShowBuildObjectPicker(w);
|
|
|
}
|
|
|
|
|
|
static OnButtonClick * const _terraform_button_proc[] = {
|
|
|
TerraformClick_Lower,
|
|
|
TerraformClick_Raise,
|
|
|
TerraformClick_Level,
|
|
|
TerraformClick_Dynamite,
|
|
|
TerraformClick_BuyLand,
|
|
|
TerraformClick_Trees,
|
|
|
TerraformClick_PlaceSign,
|
|
|
TerraformClick_PlaceObject,
|
|
|
};
|
|
|
|
|
|
struct TerraformToolbarWindow : Window {
|
|
|
TerraformToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
|
|
{
|
|
|
this->InitNested(desc, window_number);
|
|
|
/* This is needed as we like to have the tree available on OnInit. */
|
|
|
this->CreateNestedTree(desc);
|
|
|
this->FinishInitNested(desc, window_number);
|
|
|
}
|
|
|
|
|
|
~TerraformToolbarWindow()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
this->DrawWidgets();
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
@@ -274,12 +295,13 @@ struct TerraformToolbarWindow : Window {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
{
|
|
|
DeleteWindowById(WC_BUILD_OBJECT, 0);
|
|
|
this->RaiseButtons();
|
|
|
}
|
|
|
|
|
|
static Hotkey<TerraformToolbarWindow> terraform_hotkeys[];
|
|
|
};
|
|
|
|
|
@@ -288,12 +310,13 @@ Hotkey<TerraformToolbarWindow> Terraform
|
|
|
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),
|
|
|
Hotkey<TerraformToolbarWindow>('U', "buyland", TTW_BUY_LAND),
|
|
|
Hotkey<TerraformToolbarWindow>('I', "trees", TTW_PLANT_TREES),
|
|
|
Hotkey<TerraformToolbarWindow>('O', "placesign", TTW_PLACE_SIGN),
|
|
|
Hotkey<TerraformToolbarWindow>('P', "placeobject", TTW_PLACE_OBJECT),
|
|
|
HOTKEY_LIST_END(TerraformToolbarWindow)
|
|
|
};
|
|
|
Hotkey<TerraformToolbarWindow> *_terraform_hotkeys = TerraformToolbarWindow::terraform_hotkeys;
|
|
|
|
|
|
static const NWidgetPart _nested_terraform_widgets[] = {
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
@@ -316,12 +339,16 @@ static const NWidgetPart _nested_terrafo
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_BUY_LAND), SetMinimalSize(22, 22),
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_BUY_LAND, STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND),
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_PLANT_TREES), SetMinimalSize(22, 22),
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
|
|
|
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_PLACE_SIGN), SetMinimalSize(22, 22),
|
|
|
SetFill(0, 1), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
|
|
|
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(),
|
|
|
EndContainer(),
|
|
|
};
|
|
|
|
|
|
static const WindowDesc _terraform_desc(
|
|
|
WDP_MANUAL, 0, 0,
|
|
|
WC_SCEN_LAND_GEN, WC_NONE,
|