31 #include "table/strings.h"
47 typedef std::vector<LayoutCacheElement> LayoutCache;
49 enum class ElementFloat {
65 static const std::initializer_list<GUIStoryPageList::SortFunction * const> page_sorter_funcs;
66 static const std::initializer_list<GUIStoryPageElementList::SortFunction * const> page_element_sorter_funcs;
72 this->story_pages.clear();
75 if (this->IsPageAvailable(p)) {
76 this->story_pages.push_back(p);
83 this->story_pages.
Sort();
96 this->story_page_elements.clear();
101 if (pe->page == p->
index) {
102 this->story_page_elements.push_back(pe);
110 this->story_page_elements.
Sort();
125 bool IsPageAvailable(
const StoryPage *page)
const
147 for (
const StoryPage *p : this->story_pages) {
148 if (p->index == this->selected_page_id) {
162 if (!_story_page_pool.
IsValidID(this->selected_page_id))
return false;
173 if (!_story_page_pool.
IsValidID(this->selected_page_id))
return false;
175 if (this->story_pages.size() <= 1)
return true;
176 const StoryPage *last = this->story_pages.back();
187 if (page !=
nullptr && page->
title.empty()) {
208 if (!_story_page_pool.
IsValidID(this->selected_page_id))
return;
212 last_available =
nullptr;
213 for (
const StoryPage *p : this->story_pages) {
214 if (p->index == this->selected_page_id) {
215 if (last_available ==
nullptr)
return;
228 if (!_story_page_pool.
IsValidID(this->selected_page_id))
return;
231 for (
auto iter = this->story_pages.begin(); iter != this->story_pages.end(); iter++) {
233 if (p->
index == this->selected_page_id) {
236 if (iter != this->story_pages.end()) {
250 uint16_t page_num = 1;
251 for (
const StoryPage *p : this->story_pages) {
253 if (!p->title.empty()) {
254 list.push_back(MakeDropDownListStringItem(p->title, p->index, current_page));
258 list.push_back(MakeDropDownListStringItem(STR_STORY_BOOK_GENERIC_PAGE_ITEM, p->index, current_page));
284 if (page ==
nullptr)
return 0;
306 if (g ==
nullptr)
return SPR_IMG_GOAL_BROKEN_REF;
307 return g->
completed ? SPR_IMG_GOAL_COMPLETED : SPR_IMG_GOAL;
310 return SPR_IMG_VIEW_LOCATION;
332 return sprite_dim.height;
360 if (
flags & SPBF_FLOAT_LEFT)
return ElementFloat::Left;
361 if (
flags & SPBF_FLOAT_RIGHT)
return ElementFloat::Right;
362 return ElementFloat::None;
366 return ElementFloat::None;
393 this->layout_cache.clear();
400 if (!this->layout_cache.empty())
return;
403 if (page ==
nullptr)
return;
412 int right_y = main_y;
417 std::vector<size_t> left_floats;
418 std::vector<size_t> right_floats;
424 if (fl == ElementFloat::None) {
427 int left_offset = (left_width == 0) ? 0 : (left_width + element_dist);
428 int right_offset = (right_width == 0) ? 0 : (right_width + element_dist);
429 if (left_offset + right_offset + min_required_width >= max_width) {
431 main_y = std::max(main_y, left_y);
432 main_y = std::max(main_y, right_y);
433 left_width = right_width = 0;
434 left_offset = right_offset = 0;
438 const int available_width = max_width - left_offset - right_offset;
441 if (left_offset == 0 && right_offset == 0) {
446 left_offset = right_offset = available_width / 5;
454 ce.bounds.left = left_offset;
455 ce.bounds.right = max_width - right_offset;
456 ce.bounds.top = main_y;
458 ce.bounds.bottom = main_y;
459 this->layout_cache.push_back(ce);
460 main_y += element_dist;
462 left_width = right_width = 0;
463 left_y = right_y = main_y = std::max({main_y, left_y, right_y});
465 right_floats.clear();
468 int &cur_width = (fl == ElementFloat::Left) ? left_width : right_width;
469 int &cur_y = (fl == ElementFloat::Left) ? left_y : right_y;
470 std::vector<size_t> &cur_floats = (fl == ElementFloat::Left) ? left_floats : right_floats;
474 ce.bounds.left = (fl == ElementFloat::Left) ? 0 : (max_width - cur_width);
475 ce.bounds.right = (fl == ElementFloat::Left) ? cur_width : max_width;
476 ce.bounds.top = cur_y;
478 ce.bounds.bottom = cur_y;
479 cur_floats.push_back(this->layout_cache.size());
480 this->layout_cache.push_back(ce);
481 cur_y += element_dist;
483 for (
size_t index : cur_floats) {
485 ce.bounds.left = (fl == ElementFloat::Left) ? 0 : (max_width - cur_width);
486 ce.bounds.right = (fl == ElementFloat::Left) ? cur_width : max_width;
501 int32_t max_y = std::accumulate(this->layout_cache.begin(), this->layout_cache.end(), 0, [](int32_t max_y,
const LayoutCacheElement &ce) -> int32_t { return std::max<int32_t>(max_y, ce.bounds.bottom); });
520 uint element_height = std::max(sprite_dim.height, (uint)line_height);
522 uint sprite_top = y_offset + (element_height - sprite_dim.height) / 2;
523 uint text_top = y_offset + (element_height - line_height) / 2;
525 DrawSprite(action_sprite, PAL_NONE, 0, sprite_top);
528 y_offset += element_height;
556 this->active_button_id = pe.
index;
564 if (this->active_button_id == pe.
index) {
566 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
570 this->active_button_id = pe.
index;
576 if (this->active_button_id == pe.
index) {
578 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
582 this->active_button_id = pe.
index;
600 this->story_pages.
SetSortFuncs(StoryBookWindow::page_sorter_funcs);
603 this->story_page_elements.
SetSortFuncs(StoryBookWindow::page_element_sorter_funcs);
610 this->selected_generic_title.clear();
611 this->selected_page_id = INVALID_STORY_PAGE;
613 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
635 if (this->selected_page_id != page_index) {
637 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
638 this->selected_page_id = page_index;
644 void SetStringParameters(
WidgetID widget)
const override
654 SetDParam(0, STR_STORY_BOOK_SPECTATOR_CAPTION);
669 if (this->vscroll->
GetCount() != this->GetContentHeight()) {
678 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
683 if (page ==
nullptr)
return;
696 const int scrollpos = this->vscroll->
GetPosition();
697 int y_offset = -scrollpos;
702 DrawString(0, fr.right, y_offset, STR_JUST_DATE_LONG, TC_BLACK);
704 y_offset += line_height;
712 for (
const LayoutCacheElement &ce : this->layout_cache) {
713 y_offset = ce.bounds.top - scrollpos;
714 switch (ce.pe->type) {
717 y_offset =
DrawStringMultiLine(ce.bounds.left, ce.bounds.right, ce.bounds.top - scrollpos, ce.bounds.bottom - scrollpos, STR_JUST_RAW_STRING, TC_BLACK,
SA_TOP |
SA_LEFT);
722 StringID string_id = g ==
nullptr ? STR_STORY_BOOK_INVALID_GOAL_REF : STR_JUST_RAW_STRING;
740 DrawFrameRect(ce.bounds.left, ce.bounds.top - scrollpos, ce.bounds.right, ce.bounds.bottom - scrollpos - 1, bgcolour, frame);
747 default: NOT_REACHED();
764 for (
size_t i = 0; i < this->story_pages.size(); i++) {
765 const StoryPage *s = this->story_pages[i];
767 if (!s->
title.empty()) {
774 if (title_d.width > d.width) {
775 d.width = title_d.width;
779 d.width += padding.width;
780 d.height += padding.height;
802 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
810 for (
size_t i = 0; i < this->story_pages.size(); i++) {
811 const StoryPage *p = this->story_pages[i];
812 if (p->
index == this->selected_page_id)
break;
833 for (
const LayoutCacheElement &ce : this->layout_cache) {
834 if (clicked_y >= ce.bounds.top && clicked_y < ce.bounds.bottom && pt.x >= ce.bounds.left && pt.x < ce.bounds.right) {
843 void OnDropdownSelect(
WidgetID widget,
int index)
override
858 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
860 if (!gui_scope)
return;
870 if (this->story_pages.empty()) {
871 this->selected_generic_title.clear();
875 if (!_story_page_pool.
IsValidID(this->selected_page_id)) {
876 this->selected_page_id = INVALID_STORY_PAGE;
878 if (this->selected_page_id == INVALID_STORY_PAGE && !this->story_pages.empty()) {
888 }
else if (data >= 0 && this->selected_page_id == data) {
895 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
899 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
904 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
913 bool OnVehicleSelect(
const Vehicle *v)
override
918 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
925 VehicleType wanted_vehtype = data.GetVehicleType();
926 if (wanted_vehtype !=
VEH_INVALID && wanted_vehtype != v->
type)
return false;
935 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
940 const std::initializer_list<GUIStoryPageList::SortFunction * const> StoryBookWindow::page_sorter_funcs = {
944 const std::initializer_list<GUIStoryPageElementList::SortFunction * const> StoryBookWindow::page_element_sorter_funcs = {
945 &PageElementOrderSorter,
948 static constexpr
NWidgetPart _nested_story_book_widgets[] = {
973 _nested_story_book_widgets
980 _nested_story_book_widgets
987 case SPBC_ZZZ:
return SPR_CURSOR_ZZZ;
988 case SPBC_BUOY:
return SPR_CURSOR_BUOY;
989 case SPBC_QUERY:
return SPR_CURSOR_QUERY;
990 case SPBC_HQ:
return SPR_CURSOR_HQ;
991 case SPBC_SHIP_DEPOT:
return SPR_CURSOR_SHIP_DEPOT;
992 case SPBC_SIGN:
return SPR_CURSOR_SIGN;
993 case SPBC_TREE:
return SPR_CURSOR_TREE;
994 case SPBC_BUY_LAND:
return SPR_CURSOR_BUY_LAND;
995 case SPBC_LEVEL_LAND:
return SPR_CURSOR_LEVEL_LAND;
996 case SPBC_TOWN:
return SPR_CURSOR_TOWN;
997 case SPBC_INDUSTRY:
return SPR_CURSOR_INDUSTRY;
998 case SPBC_ROCKY_AREA:
return SPR_CURSOR_ROCKY_AREA;
999 case SPBC_DESERT:
return SPR_CURSOR_DESERT;
1000 case SPBC_TRANSMITTER:
return SPR_CURSOR_TRANSMITTER;
1001 case SPBC_AIRPORT:
return SPR_CURSOR_AIRPORT;
1002 case SPBC_DOCK:
return SPR_CURSOR_DOCK;
1003 case SPBC_CANAL:
return SPR_CURSOR_CANAL;
1004 case SPBC_LOCK:
return SPR_CURSOR_LOCK;
1005 case SPBC_RIVER:
return SPR_CURSOR_RIVER;
1006 case SPBC_AQUEDUCT:
return SPR_CURSOR_AQUEDUCT;
1007 case SPBC_BRIDGE:
return SPR_CURSOR_BRIDGE;
1008 case SPBC_RAIL_STATION:
return SPR_CURSOR_RAIL_STATION;
1009 case SPBC_TUNNEL_RAIL:
return SPR_CURSOR_TUNNEL_RAIL;
1010 case SPBC_TUNNEL_ELRAIL:
return SPR_CURSOR_TUNNEL_ELRAIL;
1011 case SPBC_TUNNEL_MONO:
return SPR_CURSOR_TUNNEL_MONO;
1012 case SPBC_TUNNEL_MAGLEV:
return SPR_CURSOR_TUNNEL_MAGLEV;
1013 case SPBC_AUTORAIL:
return SPR_CURSOR_AUTORAIL;
1014 case SPBC_AUTOELRAIL:
return SPR_CURSOR_AUTOELRAIL;
1015 case SPBC_AUTOMONO:
return SPR_CURSOR_AUTOMONO;
1016 case SPBC_AUTOMAGLEV:
return SPR_CURSOR_AUTOMAGLEV;
1017 case SPBC_WAYPOINT:
return SPR_CURSOR_WAYPOINT;
1018 case SPBC_RAIL_DEPOT:
return SPR_CURSOR_RAIL_DEPOT;
1019 case SPBC_ELRAIL_DEPOT:
return SPR_CURSOR_ELRAIL_DEPOT;
1020 case SPBC_MONO_DEPOT:
return SPR_CURSOR_MONO_DEPOT;
1021 case SPBC_MAGLEV_DEPOT:
return SPR_CURSOR_MAGLEV_DEPOT;
1022 case SPBC_CONVERT_RAIL:
return SPR_CURSOR_CONVERT_RAIL;
1023 case SPBC_CONVERT_ELRAIL:
return SPR_CURSOR_CONVERT_ELRAIL;
1024 case SPBC_CONVERT_MONO:
return SPR_CURSOR_CONVERT_MONO;
1025 case SPBC_CONVERT_MAGLEV:
return SPR_CURSOR_CONVERT_MAGLEV;
1026 case SPBC_AUTOROAD:
return SPR_CURSOR_AUTOROAD;
1027 case SPBC_AUTOTRAM:
return SPR_CURSOR_AUTOTRAM;
1028 case SPBC_ROAD_DEPOT:
return SPR_CURSOR_ROAD_DEPOT;
1029 case SPBC_BUS_STATION:
return SPR_CURSOR_BUS_STATION;
1030 case SPBC_TRUCK_STATION:
return SPR_CURSOR_TRUCK_STATION;
1031 case SPBC_ROAD_TUNNEL:
return SPR_CURSOR_ROAD_TUNNEL;
1032 case SPBC_CLONE_TRAIN:
return SPR_CURSOR_CLONE_TRAIN;
1033 case SPBC_CLONE_ROADVEH:
return SPR_CURSOR_CLONE_ROADVEH;
1034 case SPBC_CLONE_SHIP:
return SPR_CURSOR_CLONE_SHIP;
1035 case SPBC_CLONE_AIRPLANE:
return SPR_CURSOR_CLONE_AIRPLANE;
1041 default:
return SPR_CURSOR_QUERY;
1055 StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(centered ? _story_book_gs_desc : _story_book_desc, company,
true);
void RebuildDone()
Notify the sortlist that the rebuild is done.
bool NeedRebuild() const
Check if a rebuild is needed.
void ForceRebuild()
Force that a rebuild is needed.
bool Sort(Comp compare)
Sort the list.
void SetSortFuncs(std::span< SortFunction *const > n_funcs)
Hand the sort function pointers to the GUIList.
static constexpr TimerGame< struct Calendar >::Date INVALID_DATE
Representation of an invalid date.
Functions related to commands.
Definition of stuff that is very close to a company, like the company struct itself.
Functions related to companies.
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
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 GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
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?
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
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.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ SA_TOP
Top align the text.
@ SA_LEFT
Left align the text.
@ SA_HOR_CENTER
Horizontally center the text.
@ SA_CENTER
Center both horizontally and vertically.
uint32_t CursorID
The number of the cursor (sprite)
@ FS_NORMAL
Index of the normal font in the font tables.
void ShowGoalsList(CompanyID company)
Open a goal list window.
uint16_t GoalID
ID of a goal.
GUI functions that shouldn't be here.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
A number of safeguards to prevent using unsafe methods.
Base types for having sorted lists in GUIs.
This file contains all sprite-related enums and defines.
static const CursorID ANIMCURSOR_PICKSTATION
716 - 718 - goto-order icon
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
static const CursorID ANIMCURSOR_LOWERLAND
699 - 701 - lower land tool
static const CursorID ANIMCURSOR_RAISELAND
696 - 698 - raise land tool
Definition of base types and functions in a cross-platform compatible way.
StoryPageButtonFlags
Flags available for buttons.
@ SPET_LOCATION
An element that references a tile along with a one-line text.
@ SPET_GOAL
An element that references a goal.
@ SPET_BUTTON_PUSH
A push button that triggers an immediate event.
@ SPET_BUTTON_TILE
A button that allows the player to select a tile, and triggers an event with the tile.
@ SPET_TEXT
A text element.
@ SPET_BUTTON_VEHICLE
A button that allows the player to select a vehicle, and triggers an event wih the vehicle.
StoryPageButtonCursor
Mouse cursors usable by story page buttons.
Command definitions related to stories.
void ShowStoryBook(CompanyID company, uint16_t page_id, bool centered)
Raise or create the story book window for company, at page page_id.
uint16_t StoryPageID
ID of a story page.
uint16_t StoryPageElementID
ID of a story page element.
Types related to the story widgets.
@ WID_SB_PAGE_PANEL
Page body.
@ WID_SB_SEL_PAGE
Page selector.
@ WID_SB_SCROLLBAR
Scrollbar of the goal list.
@ WID_SB_CAPTION
Caption of the window.
@ WID_SB_PREV_PAGE
Prev button.
@ WID_SB_NEXT_PAGE
Next button.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
VehicleType type
Type of vehicle.
Dimensions (a width and height) of a rectangle in 2D.
Data about how and where to blit pixels.
Struct about goals, current and completed.
bool completed
Is the goal completed or not?
std::string text
Text of the goal.
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Titem * Get(size_t index)
Returns Titem with given index.
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 Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
void OnTimeout() override
Called when this window's timeout has been reached.
void BuildStoryPageList()
(Re)Build story page list.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
std::string selected_generic_title
If the selected page doesn't have a custom title, this buffer is used to store a generic page title.
void OnPageElementClick(const StoryPageElement &pe)
Internal event handler for when a page element is clicked.
void OnResize() override
Called after the window got resized.
static bool PageElementOrderSorter(const StoryPageElement *const &a, const StoryPageElement *const &b)
Sort story page elements by order value.
uint GetAvailablePageContentWidth() const
Get the width available for displaying content on the page panel.
void OnPaint() override
The window must be repainted.
StoryPage * GetSelPage() const
Get instance of selected page.
bool IsFirstPageSelected()
Check if the selected page is also the first available page.
DropDownList BuildDropDownList() const
Builds the page selector drop down list.
int GetPageElementFloatWidth(const StoryPageElement &pe) const
Get the width a page element would use if it was floating left or right.
LayoutCache layout_cache
Cached element layout.
void UpdatePrevNextDisabledState()
Updates the disabled state of the prev/next buttons.
Scrollbar * vscroll
Scrollbar of the page text.
void SelectNextPage()
Selects the next available page after the currently selected page.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void SelectPrevPage()
Selects the previous available page before the currently selected page.
void DrawActionElement(int &y_offset, int width, int line_height, SpriteID action_sprite, StringID string_id=STR_JUST_RAW_STRING) const
Draws a page element that is composed of a sprite to the left and a single line of text after that.
void RefreshSelectedPage()
Updates the content of selected page.
StoryPageID selected_page_id
Pool index of selected page.
bool IsLastPageSelected()
Check if the selected page is also the last available page.
GUIStoryPageList story_pages
Sorted list of pages.
void InvalidateStoryPageElementLayout()
Invalidate the current page layout.
void BuildStoryPageElementList()
(Re)Build story page element list.
static bool PageOrderSorter(const StoryPage *const &a, const StoryPage *const &b)
Sort story pages by order value.
StoryPageElementID active_button_id
Which button element the player is currently using.
int32_t GetContentHeight()
Get the total height of the content displayed in this window.
uint GetHeadHeight(int max_width) const
Counts how many pixels of height that are used by Date and Title (excluding marginal after Title,...
uint GetPageElementHeight(const StoryPageElement &pe, int max_width) const
Get the height in pixels used by a page element.
int GetSelPageNum() const
Get the page number of selected page.
void SetSelectedPage(uint16_t page_index)
Sets the selected page.
SpriteID GetPageElementSprite(const StoryPageElement &pe) const
Decides which sprite to display for a given page element.
void EnsureStoryPageElementLayout() const
Create the page layout if it is missing.
GUIStoryPageElementList story_page_elements
Sorted list of page elements that belong to the current page.
ElementFloat GetPageElementFloat(const StoryPageElement &pe) const
Get the float style of a page element.
Helper to construct packed "id" values for button-type StoryPageElement.
Struct about story page elements.
uint32_t referenced_id
Id of referenced object (location, goal etc.)
std::string text
Static content text of page element.
uint32_t sort_value
A number that increases for every created story page element. Used for sorting. The id of a story pag...
StoryPageElementType type
Type of page element.
Struct about stories, current and completed.
uint32_t sort_value
A number that increases for every created story page. Used for sorting. The id of a story page is the...
CompanyID company
StoryPage is for a specific company; INVALID_COMPANY if it is global.
std::string title
Title of story page.
TimerGameCalendar::Date date
Date when the page was created.
High level window description.
Data structure for an opened window.
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.
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.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
WindowFlags flags
Window flags.
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.
int height
Height of the window (number of pixels down in y direction)
int width
width of the window (number of pixels to the right in x direction)
WindowNumber window_number
Window number within the window class.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
@ HT_RECT
rectangle (stations, depots, ...)
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
Base class for all vehicles.
VehicleType
Available vehicle types.
@ VEH_INVALID
Non-existing type of vehicle.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to (drawing on) viewports.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
FrameFlags
Flags to describe the look of the frame.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ WDP_CENTER
Center the window.
@ WDP_AUTO
Find a place automatically.
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_STORY_BOOK
Story book; Window numbers: