29#include "table/strings.h"
78 if (s->company ==
this->window_number) {
141 default: NOT_REACHED();
160 if (s->company ==
this->window_number) num++;
164 if (num == 0) num = 1;
201 if (s->company ==
this->window_number) {
212 if (!s->progress.empty()) {
241 if (!s->progress.empty()) {
315 AllocateWindowDescFront<GoalListWindow>(_goals_list_desc, company);
337 assert(this->buttons < 4);
340 if (this->buttons == 0) {
407template <Colours bg_colour, Colours btn_colour, StringID caption>
409 static constexpr auto widgetparts = {
441static WindowDesc _goal_question_list_desc[] = {
446 _nested_goal_question_widgets_question,
452 _nested_goal_question_widgets_info,
458 _nested_goal_question_widgets_warning,
464 _nested_goal_question_widgets_error,
477 assert(type < GQT_END);
478 new GoalQuestionWindow(_goal_question_list_desc[type],
id, type == 3 ? TC_WHITE : TC_BLACK, button_mask, question);
Container for an encoded string, created by GetEncodedString.
std::string GetDecodedString() const
Decode the encoded string.
Functions related to commands.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
GUI Functions related to companies.
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
bool _ctrl_pressed
Is Ctrl pressed?
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
@ FS_NORMAL
Index of the normal font in the font tables.
@ SA_TOP
Top align the text.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_HOR_CENTER
Horizontally center the text.
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Command definitions related to goals.
void ShowGoalQuestion(uint16_t id, uint8_t type, uint32_t button_mask, const EncodedString &question)
Display a goal question.
void ShowGoalsList(CompanyID company)
Open a goal list window.
GoalColumn
Goal list columns.
@ GC_PROGRESS
Goal progress column.
@ GC_GOAL
Goal text column.
static constexpr NWidgetPart _nested_goals_list_widgets[]
Widgets of the GoalListWindow.
@ GT_INDUSTRY
Destination is an industry.
@ GT_STORY_PAGE
Destination is a story page.
@ GT_COMPANY
Destination is a company.
@ GT_NONE
Destination is not linked.
@ GT_TILE
Destination is a tile.
@ GT_TOWN
Destination is a town.
static const uint32_t GOAL_QUESTION_BUTTON_COUNT
Amount of buttons available.
GUI functions that shouldn't be here.
void ShowStoryBook(CompanyID company, StoryPageID page_id=StoryPageID::Invalid(), bool centered=false)
Raise or create the story book window for company, at page page_id.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
Functions related to low-level strings.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
Dimensions (a width and height) of a rectangle in 2D.
Window for displaying goals.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
void OnResize() override
Called after the window got resized.
uint CountLines()
Count the number of lines in this window.
void OnPaint() override
The window must be repainted.
void HandleClick(const Goal *s)
Handle clicking at a goal.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void DrawListColumn(GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
Draws a given column of the goal list.
Scrollbar * vscroll
Reference to the scrollbar widget.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
Ask a question about a goal.
std::array< int, 3 > button
Buttons to display.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
int buttons
Number of valid buttons in button.
EncodedString question
Question to ask (private copy).
TextColour colour
Colour of the question text.
Struct about goals, current and completed.
GoalType type
Type of the goal.
GoalTypeID dst
Index of type.
CompanyID company
Goal is for a specific company; CompanyID::Invalid() if it is global.
Coordinates of a point in 2D.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * Get(auto index)
Returns Titem with given index.
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
Iterable ensemble of each set bit in a value.
High level window description.
Number to differentiate different windows of the same class.
Data structure for an opened window.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void DrawWidgets() const
Paint all widgets of a window.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
ResizeInfo resize
Resize information.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
bool IsShaded() const
Is window shaded currently?
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
WindowNumber window_number
Window number within the window class.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to (drawing on) viewports.
Functions, definitions and such used only by the GUI.
@ Construction
This window is used for construction; close it whenever changing company.
@ WDP_CENTER
Center the window.
@ WDP_AUTO
Find a place automatically.
@ WC_GOAL_QUESTION
Popup with a set of buttons, designed to ask the user a question from a GameScript.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_GOALS_LIST
Goals list; Window numbers: