OpenTTD Source: src/object_gui.cpp File Reference

OpenTTD Source 15.0-beta1

Data Structures | Functions | Variables
object_gui.cpp File Reference

The GUI for objects. More...

`#include "stdafx.h"`
`#include "command_func.h"`
`#include "company_func.h"`
`#include "hotkeys.h"`
`#include "newgrf.h"`
`#include "newgrf_object.h"`
`#include "newgrf_text.h"`
`#include "object.h"`
`#include "object_base.h"`
`#include "picker_gui.h"`
`#include "sound_func.h"`
`#include "strings_func.h"`
`#include "viewport_func.h"`
`#include "tilehighlight_func.h"`
`#include "window_gui.h"`
`#include "window_func.h"`
`#include "zoom_func.h"`
`#include "terraform_cmd.h"`
`#include "object_cmd.h"`
`#include "road_cmd.h"`
`#include "widgets/object_widget.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | ObjectPickerSelection
class | ObjectPickerCallbacks
class | BuildObjectWindow
| The window used for building objects. More...

## Functions
Window * | ShowBuildObjectPicker ()
| Show our object picker.
void | InitializeObjectGui ()
| Reset all data of the object GUI.

## Variables
static ObjectPickerSelection | _object_gui
| Settings of the object picker.
static constexpr NWidgetPart | _nested_build_object_widgets []
static WindowDesc | _build_object_desc (WDP_AUTO, "build_object", 0, 0, WC_BUILD_OBJECT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_object_widgets, &BuildObjectWindow::hotkeys)

## Detailed Description

The GUI for objects.

Definition in file object_gui.cpp.

## Function Documentation

## ◆ InitializeObjectGui()

void InitializeObjectGui | ( |  | ) |

Reset all data of the object GUI.

Definition at line 419 of file object_gui.cpp.

References _object_gui, OBJECT_CLASS_BEGIN, and ObjectPickerSelection::sel_class.

## ◆ ShowBuildObjectPicker()

Window * ShowBuildObjectPicker | ( |  | ) |

Show our object picker.

Definition at line 409 of file object_gui.cpp.

Referenced by BuildObjectWindow::BuildObjectGlobalHotkeys(), TerraformToolbarWindow::OnClick(), and ScenarioEditorLandscapeGenerationWindow::OnClick().

## Variable Documentation

## ◆ _nested_build_object_widgets

constexpr NWidgetPart _nested_build_object_widgets[]
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_OBJECT_BUILD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_VERTICAL),
NWidgetFunction(MakePickerClassWidgets),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0), SetPadding(WidgetDimensions::unscaled.picker),
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_OBJECT_MATRIX), SetPIP(0, 2, 0),
NWidget(WWT_PANEL, COLOUR_GREY, WID_BO_OBJECT_SPRITE), SetDataTip(0x0, STR_OBJECT_BUILD_PREVIEW_TOOLTIP), EndContainer(),
EndContainer(),
EndContainer(),
NWidget(WWT_TEXT, COLOUR_DARK_GREEN, WID_BO_OBJECT_SIZE), SetDataTip(STR_OBJECT_BUILD_SIZE, STR_NULL), SetAlignment(SA_CENTER),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BO_INFO), SetFill(1, 0), SetResize(1, 0),
EndContainer(),
EndContainer(),
EndContainer(),
NWidgetFunction(MakePickerTypeWidgets),
EndContainer(),
}
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:96
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition gfx_type.h:353
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition widget_type.h:1341
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1181
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1271
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1228
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition widget_type.h:1202
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1320
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1191
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition widget_type.h:1170
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition widget_type.h:1126
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition widget_type.h:1283
WID_BO_OBJECT_SIZE
@ WID_BO_OBJECT_SIZE
The size of the selected object.
Definition object_widget.h:17
WID_BO_INFO
@ WID_BO_INFO
Other information about the object (from the NewGRF).
Definition object_widget.h:18
WID_BO_OBJECT_SPRITE
@ WID_BO_OBJECT_SPRITE
A preview sprite of the object.
Definition object_widget.h:16
WID_BO_OBJECT_MATRIX
@ WID_BO_OBJECT_MATRIX
The matrix with preview sprites.
Definition object_widget.h:15
MakePickerClassWidgets
std::unique_ptr< NWidgetBase > MakePickerClassWidgets()
Create nested widgets for the class picker widgets.
Definition picker_gui.cpp:623
MakePickerTypeWidgets
std::unique_ptr< NWidgetBase > MakePickerTypeWidgets()
Create nested widgets for the type picker widgets.
Definition picker_gui.cpp:646
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition widget_type.h:57
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:75
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:50
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:66
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition widget_type.h:64
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:61
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:77
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:69
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:48
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition widget_type.h:65
NWID_MATRIX
@ NWID_MATRIX
Matrix container.
Definition widget_type.h:78
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition widget_type.h:58

Definition at line 372 of file object_gui.cpp.

## ◆ _object_gui

ObjectPickerSelection _object_gui
| static

Settings of the object picker.

Definition at line 42 of file object_gui.cpp.

Referenced by ObjectPickerCallbacks::DrawType(), BuildObjectWindow::DrawWidget(), ObjectPickerCallbacks::GetSelectedClass(), ObjectPickerCallbacks::GetSelectedType(), InitializeObjectGui(), BuildObjectWindow::OnClick(), BuildObjectWindow::OnInvalidateData(), BuildObjectWindow::OnPlaceMouseUp(), BuildObjectWindow::OnPlaceObject(), ObjectPickerCallbacks::SetSelectedClass(), ObjectPickerCallbacks::SetSelectedType(), BuildObjectWindow::SetStringParameters(), and BuildObjectWindow::UpdateWidgetSize().