39 #include "table/strings.h" 57 if (_game_mode != GM_EDITOR)
return;
74 if (_game_mode != GM_EDITOR)
return;
182 this->last_user_action = widget;
187 this->last_user_action = widget;
192 this->last_user_action = widget;
197 this->last_user_action = widget;
202 this->last_user_action = widget;
206 ShowBuildTreesToolbar();
211 this->last_user_action = widget;
218 default: NOT_REACHED();
224 switch (this->last_user_action) {
249 default: NOT_REACHED();
268 switch (select_proc) {
269 default: NOT_REACHED();
301 static Hotkey terraform_hotkeys[] = {
314 static const NWidgetPart _nested_terraform_widgets[] = {
322 SetFill(0, 1),
SetDataTip(SPR_IMG_TERRAFORM_DOWN, STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND),
324 SetFill(0, 1),
SetDataTip(SPR_IMG_TERRAFORM_UP, STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND),
326 SetFill(0, 1),
SetDataTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
333 SetFill(0, 1),
SetDataTip(SPR_IMG_BUY_LAND, STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND),
340 SetFill(0, 1),
SetDataTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT),
349 _nested_terraform_widgets,
lengthof(_nested_terraform_widgets),
350 &TerraformToolbarWindow::hotkeys
364 w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
370 w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
382 static byte _terraform_size = 1;
395 if (_terraform_size == 1) {
397 mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE;
401 assert(_terraform_size != 0);
402 TileArea ta(tile, _terraform_size, _terraform_size);
405 if (ta.
w == 0 || ta.
h == 0)
return;
432 static const int8 _multi_terraform_coords[][2] = {
434 { 4, 0}, { -4, 0}, { 0, 2},
435 { -8, 2}, { -4, 4}, { 0, 6}, { 4, 4}, { 8, 2},
436 {-12, 0}, { -8, -2}, { -4, -4}, { 0, -6}, { 4, -4}, { 8, -2}, { 12, 0},
437 {-16, 2}, {-12, 4}, { -8, 6}, { -4, 8}, { 0, 10}, { 4, 8}, { 8, 6}, { 12, 4}, { 16, 2},
438 {-20, 0}, {-16, -2}, {-12, -4}, { -8, -6}, { -4, -8}, { 0,-10}, { 4, -8}, { 8, -6}, { 12, -4}, { 16, -2}, { 20, 0},
439 {-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},
440 {-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},
443 static const NWidgetPart _nested_scen_edit_land_gen_widgets[] = {
456 SetFill(0, 1),
SetDataTip(SPR_IMG_TERRAFORM_DOWN, STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND),
458 SetFill(0, 1),
SetDataTip(SPR_IMG_TERRAFORM_UP, STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND),
460 SetFill(0, 1),
SetDataTip(SPR_IMG_LEVEL_LAND, STR_LANDSCAPING_LEVEL_LAND_TOOLTIP),
462 SetFill(0, 1),
SetDataTip(SPR_IMG_ROCKS, STR_TERRAFORM_TOOLTIP_PLACE_ROCKY_AREAS_ON_LANDSCAPE),
465 SetFill(0, 1),
SetDataTip(SPR_IMG_DESERT, STR_TERRAFORM_TOOLTIP_DEFINE_DESERT_AREA),
468 SetFill(0, 1),
SetDataTip(SPR_IMG_TRANSMITTER, STR_SCENEDIT_TOOLBAR_PLACE_OBJECT),
506 FOR_ALL_COMPANIES(c) {
515 FOR_ALL_BASE_STATIONS(st) {
555 size->height = max<uint>(size->height,
ScaleGUITrad(31));
562 int center_x =
RoundDivSU(r.left + r.right, 2);
563 int center_y =
RoundDivSU(r.top + r.bottom, 2);
565 int n = _terraform_size * _terraform_size;
566 const int8 *coords = &_multi_terraform_coords[0][0];
582 this->last_user_action = widget;
587 this->last_user_action = widget;
592 this->last_user_action = widget;
597 this->last_user_action = widget;
602 this->last_user_action = widget;
607 this->last_user_action = widget;
618 size += _terraform_size;
621 _terraform_size = size;
637 default: NOT_REACHED();
654 switch (this->last_user_action) {
679 default: NOT_REACHED();
691 switch (select_proc) {
692 default: NOT_REACHED();
727 static Hotkey terraform_editor_hotkeys[] = {
741 WDP_AUTO,
"toolbar_landscape_scen", 0, 0,
744 _nested_scen_edit_land_gen_widgets,
lengthof(_nested_scen_edit_land_gen_widgets),
745 &ScenarioEditorLandscapeGenerationWindow::hotkeys
754 return AllocateWindowDescFront<ScenarioEditorLandscapeGenerationWindow>(&_scen_edit_land_gen_desc, 0);
EventState
State of handling an event.
Functions related to OTTD's strings.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it...
the north corner of the tile is raised
void ClampToMap()
Clamp the tile area to map borders.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
ResizeInfo resize
Resize information.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
static const CursorID ANIMCURSOR_RAISELAND
696 - 698 - raise land tool
byte landscape
the landscape we're currently in
static const uint MAX_TILE_HEIGHT
Maximum allowed tile height.
All data for a single hotkey.
High level window description.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Landscape generation (in Scenario Editor); Window numbers:
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
int left
x position of left edge of the window
void DrawWidgets() const
Paint all widgets of a window.
Hotkey related functions.
virtual void OnPaint()
The window must be repainted.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
static const CursorID ANIMCURSOR_LOWERLAND
699 - 701 - lower land tool
The passed event is not handled.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
bool IsInUse() const
Check whether the base station currently is in use; in use means that it is not scheduled for deletio...
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
virtual void OnTimeout()
Called when this window's timeout has been reached.
static uint TileX(TileIndex tile)
Get the X component of a tile.
int top
y position of top edge of the window
Tindex index
Index of this pool item.
Map accessors for tree tiles.
Functions related to world/map generation.
Stuff related to the text buffer GUI.
Common return value for all commands.
Functions related to signs.
static T max(const T a, const T b)
Returns the maximum of two values.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
uint16 w
The width of the area.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
static int RoundDivSU(int a, uint b)
Computes round(a / b) for signed a and unsigned b.
Functions, definitions and such used only by the GUI.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
company bankrupts, skip money check, skip vehicle on tile check in some cases
Functions related to (drawing on) viewports.
Functions related to NewGRF objects.
bool freeform_edges
allow terraforming the tiles at the map edges
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
This window is used for construction; close it whenever changing company.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
SoundSettings sound
sound effect settings
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Point GetToolbarAlignedWindowPosition(int window_width)
Computer the position of the top-left corner of a window to be opened right under the toolbar...
ClientSettings _settings_client
The current settings for this game.
bool Succeeded() const
Did this command succeed?
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
List of hotkeys for a window.
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
The user is dragging over the map when the tile highlight mode has been set.
rectangle (stations, depots, ...)
Landscape generation window handler in the scenario editor.
uint nested_array_size
Size of the nested array.
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
Represents the covered area of e.g.
static const ObjectType OBJECT_OWNED_LAND
Owned land 'flag'.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
#define lengthof(x)
Return the length of an fixed size array.
static T min(const T a, const T b)
Returns the minimum of two values.
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Functions related to sound.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
virtual void OnPlaceObject(Point pt, TileIndex tile)
The user clicked some place on the map when a tile highlight mode has been set.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
point (lower land, raise land, level land, ...)
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
execute the given command
Functions related to companies.
int last_user_action
Last started user action.
bool _generating_world
Whether we are generating the map or not.
area of land in X and Y directions
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Types related to the landscape.
uint32 TileIndex
The index/ID of a Tile.
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Functions related to objects.
Map accessors for 'clear' tiles.
void ShowCreateScenario()
Show the window to create a scenario.
TextDirection _current_text_dir
Text direction of the currently selected language.
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static void MakeClear(TileIndex t, ClearGround g, uint density)
Make a clear tile.
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
TileIndex xy
Base tile of the station.
Functions related to zooming.
Town view; Window numbers:
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
bool confirm
Play sound effect on succesful constructions or other actions.
Non-water non-rail construction.
Functions related to commands.
Coordinates of a point in 2D.
Base classes/functions for base stations.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
ConstructionSettings construction
construction of things in-game
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
int width
width of the window (number of pixels to the right in x direction)
#define CMD_MSG(x)
Used to combine a StringID with the command.
void ShowBuildObjectPicker()
Show our object picker.
int32 WindowNumber
Number to differentiate different windows of the same class.
GameCreationSettings game_creation
settings used during the creation of a game (map)
A tile without any structures, i.e. grass, rocks, farm fields etc.
Specification of a rectangle with absolute coordinates of all edges.
Text is written right-to-left by default.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
WindowNumber window_number
Window number within the window class.
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
Find a place automatically.
Manually align the window (so no automatic location finding)
GUI functions that shouldn't be here.
void PlaceProc_Sign(TileIndex tile)
PlaceProc function, called when someone pressed the button if the sign-tool is selected.
uint16 h
The height of the area.
Fake keycode bit to indicate global hotkeys.
Dimensions (a width and height) of a rectangle in 2D.
bool click_beep
Beep on a random selection of buttons.
Base class for all station-ish types.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
static void SetTropicZone(TileIndex tile, TropicZone type)
Set the tropic zone.
int height
Height of the window (number of pixels down in y direction)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.