28 #include "table/strings.h" 56 SetDParam(0, STR_GOALS_SPECTATOR_CAPTION);
89 if (s->company == this->window_number) {
141 default: NOT_REACHED();
159 uint num_company = 0;
163 }
else if (s->company == this->window_number) {
169 if (num_global == 0) num_global = 1;
170 if (num_company == 0) num_company = 1;
173 return 3 + num_global + num_company;
181 resize->height = d.height;
216 DrawString(x + (rtl ? width_reduction : 0), right - (rtl ? 0 : width_reduction), y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_TEXT);
221 if (s->progress !=
nullptr) {
223 StringID str = s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS;
225 int progress_right = rtl ? x + progress_col_width : right;
239 DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, str);
279 if (s->progress !=
nullptr) {
281 StringID str = s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS;
283 if (str_width > max_width) max_width = str_width;
288 uint progress_col_width =
min(max_width, wid->
current_x);
308 if (!gui_scope)
return;
325 NWidget(
WWT_EMPTY, COLOUR_GREY,
WID_GOAL_LIST),
SetResize(1, 1),
SetMinimalTextLines(2, 0),
SetFill(1, 1),
SetPadding(
WD_FRAMERECT_TOP, 2,
WD_FRAMETEXT_BOTTOM, 2),
338 _nested_goals_list_widgets,
lengthof(_nested_goals_list_widgets)
349 AllocateWindowDescFront<GoalListWindow>(&_goals_list_desc, company);
362 this->question =
stredup(question);
369 this->button[n++] = bit;
373 assert(this->buttons > 0 && this->buttons < 4);
376 this->GetWidget<NWidgetStacked>(
WID_GQ_BUTTONS)->SetDisplayedPlane(this->buttons - 1);
382 free(this->question);
389 SetDParam(0, STR_GOAL_QUESTION_CAPTION_QUESTION + this->type);
393 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]);
397 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[1]);
401 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]);
450 NWidget(
WWT_EMPTY, INVALID_COLOUR,
WID_GQ_QUESTION),
SetMinimalSize(300, 0),
SetPadding(8, 8, 8, 8),
SetFill(1, 0),
473 _nested_goal_question_widgets,
lengthof(_nested_goal_question_widgets)
Functions related to OTTD's strings.
Owner
Enum for all companies/owners.
Destination is an industry.
Definition of stuff that is very close to a company, like the company struct itself.
Horizontally center the text.
ResizeInfo resize
Resize information.
High level window description.
static const NWidgetPart _nested_goal_question_widgets[]
Widgets of the goal question window.
void DrawWidgets() const
Paint all widgets of a window.
static Titem * Get(size_t index)
Returns Titem with given index.
Functions related to dates.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Offset at top to draw the frame rectangular area.
Popup with a set of buttons, designed to ask the user a question from a GameScript.
void DrawPartialGoalList(int &pos, const int cap, int x, int y, int right, uint progress_col_width, bool global_section, GoalColumn column) const
Draws either the global goals or the company goal section.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
char * question
Question to ask (private copy).
Window for displaying goals.
Struct about goals, current and completed.
Goals list; Window numbers:
void ShowGoalsList(CompanyID company)
Open a goal list window.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Ask a question about a goal.
#define FOR_EACH_SET_BIT(bitpos_var, bitset_value)
Do an operation for each set set bit in a value.
byte type
Type of question.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Large amount of vertical space between two paragraphs of text.
void OnResize() override
Called after the window got resized.
Functions, definitions and such used only by the GUI.
Force the alignment, i.e. don't swap for RTL languages.
Functions related to (drawing on) viewports.
GoalTypeID dst
Index of type.
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.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Bottom offset of the text of the frame.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Functions related to low-level strings.
This window is used for construction; close it whenever changing company.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition of base types and functions in a cross-platform compatible way.
static const NWidgetPart _nested_goals_list_widgets[]
Widgets of the GoalListWindow.
A number of safeguards to prevent using unsafe methods.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Offset at bottom to draw the frame rectangular area.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
#define lengthof(x)
Return the length of an fixed size array.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
static T min(const T a, const T b)
Returns the minimum of two values.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Destination is not linked.
void ShowExtraViewPortWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Scrollbar * vscroll
Reference to the scrollbar widget.
void OnPaint() override
The window must be repainted.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
Functions related to companies.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
uint32 TileIndex
The index/ID of a Tile.
TextDirection _current_text_dir
Text direction of the currently selected language.
void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const char *question)
Display a goal question.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to commands.
void ShowStoryBook(CompanyID company, uint16 page_id=INVALID_STORY_PAGE)
Raise or create the story book window for company, at page page_id.
Coordinates of a point in 2D.
Destination is a company.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Destination is a story page.
uint CountLines()
Count the number of lines in this window.
void HandleClick(const Goal *s)
Handle clicking at a goal.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable...
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
CompanyID company
Goal is for a specific company; INVALID_COMPANY if it is global.
Offset at right to draw the frame rectangular area.
static const uint32 GOAL_QUESTION_BUTTON_COUNT
Amount of buttons available.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
GoalColumn
Goal list columns.
answer(s) to CMD_GOAL_QUESTION
int32 WindowNumber
Number to differentiate different windows of the same class.
Specification of a rectangle with absolute coordinates of all edges.
bool IsShaded() const
Is window shaded currently?
Text is written right-to-left by default.
Right align the text (must be a single bit).
WindowNumber window_number
Window number within the window class.
static const byte GOAL_QUESTION_TYPE_COUNT
Amount of question types.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Find a place automatically.
GUI functions that shouldn't be here.
int buttons
Number of valid buttons in button.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
GoalType type
Type of the goal.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
void DrawListColumn(GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
Draws a given column of the goal list.