30 #include "table/strings.h" 58 SetDParam(0, STR_GOALS_SPECTATOR_CAPTION);
92 if (s->
company == this->window_number) {
144 default: NOT_REACHED();
162 uint num_company = 0;
167 }
else if (s->
company == this->window_number) {
173 if (num_global == 0) num_global = 1;
174 if (num_company == 0) num_company = 1;
177 return 3 + num_global + num_company;
185 resize->height = d.height;
221 DrawString(x + (rtl ? width_reduction : 0), right - (rtl ? 0 : width_reduction), y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_TEXT);
230 int progress_right = rtl ? x + progress_col_width : right;
244 DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, str);
289 if (str_width > max_width) max_width = str_width;
294 uint progress_col_width =
min(max_width, wid->
current_x);
314 if (!gui_scope)
return;
331 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),
344 _nested_goals_list_widgets,
lengthof(_nested_goals_list_widgets)
355 AllocateWindowDescFront<GoalListWindow>(&_goals_list_desc, company);
368 this->question =
stredup(question);
375 this->button[n++] = bit;
379 assert(this->buttons > 0 && this->buttons < 4);
382 this->GetWidget<NWidgetStacked>(
WID_GQ_BUTTONS)->SetDisplayedPlane(this->buttons - 1);
388 free(this->question);
395 SetDParam(0, STR_GOAL_QUESTION_CAPTION_QUESTION + this->type);
399 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]);
403 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[1]);
407 SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]);
456 NWidget(
WWT_EMPTY, INVALID_COLOUR,
WID_GQ_QUESTION),
SetMinimalSize(300, 0),
SetPadding(8, 8, 8, 8),
SetFill(1, 0),
479 _nested_goal_question_widgets,
lengthof(_nested_goal_question_widgets)
Functions related to OTTD's strings.
Definition of stuff that is very close to a company, like the company struct itself.
Horizontally center the text.
ResizeInfo resize
Resize information.
Destination is a story page.
High level window description.
static const NWidgetPart _nested_goal_question_widgets[]
Widgets of the goal question window.
void SetStringParameters(int widget) const
Initialize string parameters for a widget.
void DrawWidgets() const
Paint all widgets of a window.
static Titem * Get(size_t index)
Returns Titem with given index.
Destination is a company.
Functions related to dates.
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.
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.
char * question
Question to ask (private copy).
Window for displaying goals.
Destination is not linked.
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.
void OnPaint()
The window must be repainted.
byte type
Type of question.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Large amount of vertical space between two paragraphs of text.
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.
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.
void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Destination is an industry.
#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.
void SetStringParameters(int widget) const
Initialize string parameters for a widget.
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.
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.
void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
GoalTypeByte type
Type of the goal.
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.
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.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
CompanyByte company
Goal is for a specific company; INVALID_COMPANY if it is global.
char * progress
Progress text of the goal.
uint32 TileIndex
The index/ID of a Tile.
TextDirection _current_text_dir
Text direction of the currently selected language.
bool completed
Is the goal completed or not?
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 UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
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.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
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.
Offset at right to draw the frame rectangular area.
static const uint32 GOAL_QUESTION_BUTTON_COUNT
Amount of buttons available.
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.
char * text
Text of the goal.
static const byte GOAL_QUESTION_TYPE_COUNT
Amount of question types.
Owner
Enum for all companies/owners.
void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Find a place automatically.
GUI functions that shouldn't be here.
int buttons
Number of valid buttons in button.
void OnResize()
Called after the window got resized.
void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
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.