|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
29 #include "table/strings.h"
54 void SetStringParameters(
WidgetID widget)
const override
59 SetDParam(0, STR_GOALS_SPECTATOR_CAPTION);
66 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
80 if (s->company == this->window_number) {
143 default: NOT_REACHED();
162 if (s->company == this->window_number) num++;
166 if (num == 0) num = 1;
177 resize->height = d.height;
203 if (s->company == this->window_number) {
215 if (!s->progress.empty()) {
217 StringID str = s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS;
245 if (!s->progress.empty()) {
247 StringID str = s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS;
249 if (str_width > max_width) max_width = str_width;
254 uint progress_col_width = std::min(max_width, wid->
current_x);
272 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
274 if (!gui_scope)
return;
296 NWidget(
WWT_PANEL, COLOUR_BROWN,
WID_GOAL_LIST),
SetDataTip(0x0, STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER),
SetScrollbar(
WID_GOAL_SCROLLBAR),
SetResize(1, 1),
SetMinimalTextLines(2, 0),
305 static WindowDesc _goals_list_desc(__FILE__, __LINE__,
320 AllocateWindowDescFront<GoalListWindow>(&_goals_list_desc, company);
338 this->button[n++] = bit;
342 assert(this->buttons < 4);
345 if (this->buttons == 0) {
348 this->GetWidget<NWidgetStacked>(
WID_GQ_BUTTONS)->SetDisplayedPlane(this->buttons - 1);
354 void SetStringParameters(
WidgetID widget)
const override
358 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]);
362 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[1]);
366 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]);
371 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
399 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
414 template <Colours bg_colour, Colours btn_colour, StringID caption>
416 static constexpr
auto widgetparts = {
448 static WindowDesc _goal_question_list_desc[] = {
454 std::begin(_nested_goal_question_widgets_question), std::end(_nested_goal_question_widgets_question),
461 std::begin(_nested_goal_question_widgets_info), std::end(_nested_goal_question_widgets_info),
468 std::begin(_nested_goal_question_widgets_warning), std::end(_nested_goal_question_widgets_warning),
475 std::begin(_nested_goal_question_widgets_error), std::end(_nested_goal_question_widgets_error),
486 void ShowGoalQuestion(uint16_t
id,
byte type, uint32_t button_mask,
const std::string &question)
488 assert(type < GQT_END);
489 new GoalQuestionWindow(&_goal_question_list_desc[type],
id, type == 3 ? TC_WHITE : TC_BLACK, button_mask, question);
Window for displaying goals.
Struct about goals, current and completed.
static Titem * Get(size_t index)
Returns Titem with given index.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
void ShowGoalsList(CompanyID company)
Open a goal list window.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
GoalColumn
Goal list columns.
Dimensions (a width and height) of a rectangle in 2D.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
@ GT_INDUSTRY
Destination is an industry.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
void OnPaint() override
The window must be repainted.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
@ GT_TILE
Destination is a tile.
void HandleClick(const Goal *s)
Handle clicking at a goal.
bool _ctrl_pressed
Is Ctrl pressed?
@ GC_PROGRESS
Goal progress column.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
GoalTypeID dst
Index of type.
@ SA_RIGHT
Right align the text (must be a single bit).
@ WC_GOALS_LIST
Goals list; Window numbers:
Ask a question about a goal.
Owner
Enum for all companies/owners.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
@ GT_TOWN
Destination is a town.
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
int button[3]
Buttons to display.
@ GC_GOAL
Goal text column.
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Iterable ensemble of each set bit in a value.
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ FS_NORMAL
Index of the normal font in the font tables.
@ SA_TOP
Top align the text.
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Coordinates of a point in 2D.
Scrollbar * vscroll
Reference to the scrollbar widget.
WindowNumber window_number
Window number within the window class.
uint CountLines()
Count the number of lines in this window.
@ GT_NONE
Destination is not linked.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ SA_HOR_CENTER
Horizontally center the text.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
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.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
bool IsShaded() const
Is window shaded currently?
void DrawListColumn(GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
Draws a given column of the goal list.
static constexpr NWidgetPart _nested_goals_list_widgets[]
Widgets of the GoalListWindow.
@ GT_COMPANY
Destination is a company.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
@ COMPANY_SPECTATOR
The client is spectating.
CompanyID company
Goal is for a specific company; INVALID_COMPANY if it is global.
int buttons
Number of valid buttons in button.
@ WC_GOAL_QUESTION
Popup with a set of buttons, designed to ask the user a question from a GameScript.
@ GT_STORY_PAGE
Destination is a story page.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void ShowStoryBook(CompanyID company, uint16_t page_id=INVALID_STORY_PAGE, bool centered=false)
Raise or create the story book window for company, at page page_id.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
static const uint32_t GOAL_QUESTION_BUTTON_COUNT
Amount of buttons available.
void OnResize() override
Called after the window got resized.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
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.
@ INVALID_COMPANY
An invalid company.
std::string question
Question to ask (private copy).
Data structure for an opened window.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void DrawWidgets() const
Paint all widgets of a window.
void ShowGoalQuestion(uint16_t id, byte type, uint32_t button_mask, const std::string &question)
Display a goal question.
TextColour colour
Colour of the question text.
void ShowCompany(CompanyID company)
Show the window with the overview of the company.
Specification of a rectangle with absolute coordinates of all edges.
GoalType type
Type of the goal.
@ WDP_CENTER
Center the window.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.