|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
31 #include "table/strings.h"
47 typedef std::vector<LayoutCacheElement> LayoutCache;
49 enum class ElementFloat {
72 this->story_pages.clear();
75 if (this->IsPageAvailable(p)) {
76 this->story_pages.push_back(p);
80 this->story_pages.shrink_to_fit();
84 this->story_pages.
Sort();
97 this->story_page_elements.clear();
102 if (pe->page == p->
index) {
103 this->story_page_elements.push_back(pe);
108 this->story_page_elements.shrink_to_fit();
112 this->story_page_elements.
Sort();
127 bool IsPageAvailable(
const StoryPage *page)
const
149 for (
const StoryPage *p : this->story_pages) {
150 if (p->index == this->selected_page_id) {
164 if (!_story_page_pool.
IsValidID(this->selected_page_id))
return false;
175 if (!_story_page_pool.
IsValidID(this->selected_page_id))
return false;
177 if (this->story_pages.size() <= 1)
return true;
178 const StoryPage *last = this->story_pages.back();
189 if (page !=
nullptr && page->
title.empty()) {
210 if (!_story_page_pool.
IsValidID(this->selected_page_id))
return;
214 last_available =
nullptr;
215 for (
const StoryPage *p : this->story_pages) {
216 if (p->index == this->selected_page_id) {
217 if (last_available ==
nullptr)
return;
230 if (!_story_page_pool.
IsValidID(this->selected_page_id))
return;
233 for (
auto iter = this->story_pages.begin(); iter != this->story_pages.end(); iter++) {
235 if (p->
index == this->selected_page_id) {
238 if (iter != this->story_pages.end()) {
252 uint16_t page_num = 1;
253 for (
const StoryPage *p : this->story_pages) {
255 if (!p->title.empty()) {
256 list.push_back(std::make_unique<DropDownListStringItem>(p->title, p->index, current_page));
260 list.push_back(std::make_unique<DropDownListStringItem>(STR_STORY_BOOK_GENERIC_PAGE_ITEM, p->index, current_page));
286 if (page ==
nullptr)
return 0;
308 if (g ==
nullptr)
return SPR_IMG_GOAL_BROKEN_REF;
309 return g->
completed ? SPR_IMG_GOAL_COMPLETED : SPR_IMG_GOAL;
312 return SPR_IMG_VIEW_LOCATION;
334 return sprite_dim.height;
362 if (
flags & SPBF_FLOAT_LEFT)
return ElementFloat::Left;
363 if (
flags & SPBF_FLOAT_RIGHT)
return ElementFloat::Right;
364 return ElementFloat::None;
368 return ElementFloat::None;
395 this->layout_cache.clear();
402 if (!this->layout_cache.empty())
return;
405 if (page ==
nullptr)
return;
414 int right_y = main_y;
419 std::vector<size_t> left_floats;
420 std::vector<size_t> right_floats;
426 if (fl == ElementFloat::None) {
429 int left_offset = (left_width == 0) ? 0 : (left_width + element_dist);
430 int right_offset = (right_width == 0) ? 0 : (right_width + element_dist);
431 if (left_offset + right_offset + min_required_width >= max_width) {
433 main_y = std::max(main_y, left_y);
434 main_y = std::max(main_y, right_y);
435 left_width = right_width = 0;
436 left_offset = right_offset = 0;
440 const int available_width = max_width - left_offset - right_offset;
443 if (left_offset == 0 && right_offset == 0) {
448 left_offset = right_offset = available_width / 5;
456 ce.bounds.left = left_offset;
457 ce.bounds.right = max_width - right_offset;
458 ce.bounds.top = main_y;
460 ce.bounds.bottom = main_y;
461 this->layout_cache.push_back(ce);
462 main_y += element_dist;
464 left_width = right_width = 0;
465 left_y = right_y = main_y = std::max({main_y, left_y, right_y});
467 right_floats.clear();
470 int &cur_width = (fl == ElementFloat::Left) ? left_width : right_width;
471 int &cur_y = (fl == ElementFloat::Left) ? left_y : right_y;
472 std::vector<size_t> &cur_floats = (fl == ElementFloat::Left) ? left_floats : right_floats;
476 ce.bounds.left = (fl == ElementFloat::Left) ? 0 : (max_width - cur_width);
477 ce.bounds.right = (fl == ElementFloat::Left) ? cur_width : max_width;
478 ce.bounds.top = cur_y;
480 ce.bounds.bottom = cur_y;
481 cur_floats.push_back(this->layout_cache.size());
482 this->layout_cache.push_back(ce);
483 cur_y += element_dist;
485 for (
size_t index : cur_floats) {
487 ce.bounds.left = (fl == ElementFloat::Left) ? 0 : (max_width - cur_width);
488 ce.bounds.right = (fl == ElementFloat::Left) ? cur_width : max_width;
503 uint max_y = std::accumulate(this->layout_cache.begin(), this->layout_cache.end(), 0, [](uint max_y,
const LayoutCacheElement &ce) -> uint { return std::max<uint>(max_y, ce.bounds.bottom); });
522 uint element_height = std::max(sprite_dim.height, (uint)line_height);
524 uint sprite_top = y_offset + (element_height - sprite_dim.height) / 2;
525 uint text_top = y_offset + (element_height - line_height) / 2;
527 DrawSprite(action_sprite, PAL_NONE, 0, sprite_top);
530 y_offset += element_height;
558 this->active_button_id = pe.
index;
566 if (this->active_button_id == pe.
index) {
568 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
572 this->active_button_id = pe.
index;
578 if (this->active_button_id == pe.
index) {
580 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
584 this->active_button_id = pe.
index;
602 this->story_pages.
SetSortFuncs(StoryBookWindow::page_sorter_funcs);
605 this->story_page_elements.
SetSortFuncs(StoryBookWindow::page_element_sorter_funcs);
612 this->selected_generic_title.clear();
613 this->selected_page_id = INVALID_STORY_PAGE;
615 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
637 if (this->selected_page_id != page_index) {
639 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
640 this->selected_page_id = page_index;
646 void SetStringParameters(
WidgetID widget)
const override
656 SetDParam(0, STR_STORY_BOOK_SPECTATOR_CAPTION);
671 if (this->vscroll->
GetCount() != this->GetContentHeight()) {
680 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
685 if (page ==
nullptr)
return;
698 const int scrollpos = this->vscroll->
GetPosition();
699 int y_offset = -scrollpos;
704 DrawString(0, fr.right, y_offset, STR_JUST_DATE_LONG, TC_BLACK);
706 y_offset += line_height;
714 for (
const LayoutCacheElement &ce : this->layout_cache) {
715 y_offset = ce.bounds.top - scrollpos;
716 switch (ce.pe->type) {
719 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);
724 StringID string_id = g ==
nullptr ? STR_STORY_BOOK_INVALID_GOAL_REF : STR_JUST_RAW_STRING;
742 DrawFrameRect(ce.bounds.left, ce.bounds.top - scrollpos, ce.bounds.right, ce.bounds.bottom - scrollpos - 1, bgcolour, frame);
749 default: NOT_REACHED();
766 for (
size_t i = 0; i < this->story_pages.size(); i++) {
767 const StoryPage *s = this->story_pages[i];
769 if (!s->
title.empty()) {
776 if (title_d.width > d.width) {
777 d.width = title_d.width;
781 d.width += padding.width;
782 d.height += padding.height;
804 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
812 for (
size_t i = 0; i < this->story_pages.size(); i++) {
813 const StoryPage *p = this->story_pages[i];
814 if (p->
index == this->selected_page_id)
break;
835 for (
const LayoutCacheElement &ce : this->layout_cache) {
836 if (clicked_y >= ce.bounds.top && clicked_y < ce.bounds.bottom && pt.x >= ce.bounds.left && pt.x < ce.bounds.right) {
845 void OnDropdownSelect(
WidgetID widget,
int index)
override
860 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
862 if (!gui_scope)
return;
872 if (this->story_pages.empty()) {
873 this->selected_generic_title.clear();
877 if (!_story_page_pool.
IsValidID(this->selected_page_id)) {
878 this->selected_page_id = INVALID_STORY_PAGE;
880 if (this->selected_page_id == INVALID_STORY_PAGE && !this->story_pages.empty()) {
890 }
else if (data >= 0 && this->selected_page_id == data) {
897 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
901 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
906 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
915 bool OnVehicleSelect(
const Vehicle *v)
override
920 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
927 VehicleType wanted_vehtype = data.GetVehicleType();
928 if (wanted_vehtype !=
VEH_INVALID && wanted_vehtype != v->
type)
return false;
937 this->active_button_id = INVALID_STORY_PAGE_ELEMENT;
947 &PageElementOrderSorter,
950 static constexpr
NWidgetPart _nested_story_book_widgets[] = {
971 static WindowDesc _story_book_desc(__FILE__, __LINE__,
975 std::begin(_nested_story_book_widgets), std::end(_nested_story_book_widgets)
978 static WindowDesc _story_book_gs_desc(__FILE__, __LINE__,
982 std::begin(_nested_story_book_widgets), std::end(_nested_story_book_widgets)
989 case SPBC_ZZZ:
return SPR_CURSOR_ZZZ;
990 case SPBC_BUOY:
return SPR_CURSOR_BUOY;
991 case SPBC_QUERY:
return SPR_CURSOR_QUERY;
992 case SPBC_HQ:
return SPR_CURSOR_HQ;
993 case SPBC_SHIP_DEPOT:
return SPR_CURSOR_SHIP_DEPOT;
994 case SPBC_SIGN:
return SPR_CURSOR_SIGN;
995 case SPBC_TREE:
return SPR_CURSOR_TREE;
996 case SPBC_BUY_LAND:
return SPR_CURSOR_BUY_LAND;
997 case SPBC_LEVEL_LAND:
return SPR_CURSOR_LEVEL_LAND;
998 case SPBC_TOWN:
return SPR_CURSOR_TOWN;
999 case SPBC_INDUSTRY:
return SPR_CURSOR_INDUSTRY;
1000 case SPBC_ROCKY_AREA:
return SPR_CURSOR_ROCKY_AREA;
1001 case SPBC_DESERT:
return SPR_CURSOR_DESERT;
1002 case SPBC_TRANSMITTER:
return SPR_CURSOR_TRANSMITTER;
1003 case SPBC_AIRPORT:
return SPR_CURSOR_AIRPORT;
1004 case SPBC_DOCK:
return SPR_CURSOR_DOCK;
1005 case SPBC_CANAL:
return SPR_CURSOR_CANAL;
1006 case SPBC_LOCK:
return SPR_CURSOR_LOCK;
1007 case SPBC_RIVER:
return SPR_CURSOR_RIVER;
1008 case SPBC_AQUEDUCT:
return SPR_CURSOR_AQUEDUCT;
1009 case SPBC_BRIDGE:
return SPR_CURSOR_BRIDGE;
1010 case SPBC_RAIL_STATION:
return SPR_CURSOR_RAIL_STATION;
1011 case SPBC_TUNNEL_RAIL:
return SPR_CURSOR_TUNNEL_RAIL;
1012 case SPBC_TUNNEL_ELRAIL:
return SPR_CURSOR_TUNNEL_ELRAIL;
1013 case SPBC_TUNNEL_MONO:
return SPR_CURSOR_TUNNEL_MONO;
1014 case SPBC_TUNNEL_MAGLEV:
return SPR_CURSOR_TUNNEL_MAGLEV;
1015 case SPBC_AUTORAIL:
return SPR_CURSOR_AUTORAIL;
1016 case SPBC_AUTOELRAIL:
return SPR_CURSOR_AUTOELRAIL;
1017 case SPBC_AUTOMONO:
return SPR_CURSOR_AUTOMONO;
1018 case SPBC_AUTOMAGLEV:
return SPR_CURSOR_AUTOMAGLEV;
1019 case SPBC_WAYPOINT:
return SPR_CURSOR_WAYPOINT;
1020 case SPBC_RAIL_DEPOT:
return SPR_CURSOR_RAIL_DEPOT;
1021 case SPBC_ELRAIL_DEPOT:
return SPR_CURSOR_ELRAIL_DEPOT;
1022 case SPBC_MONO_DEPOT:
return SPR_CURSOR_MONO_DEPOT;
1023 case SPBC_MAGLEV_DEPOT:
return SPR_CURSOR_MAGLEV_DEPOT;
1024 case SPBC_CONVERT_RAIL:
return SPR_CURSOR_CONVERT_RAIL;
1025 case SPBC_CONVERT_ELRAIL:
return SPR_CURSOR_CONVERT_ELRAIL;
1026 case SPBC_CONVERT_MONO:
return SPR_CURSOR_CONVERT_MONO;
1027 case SPBC_CONVERT_MAGLEV:
return SPR_CURSOR_CONVERT_MAGLEV;
1028 case SPBC_AUTOROAD:
return SPR_CURSOR_AUTOROAD;
1029 case SPBC_AUTOTRAM:
return SPR_CURSOR_AUTOTRAM;
1030 case SPBC_ROAD_DEPOT:
return SPR_CURSOR_ROAD_DEPOT;
1031 case SPBC_BUS_STATION:
return SPR_CURSOR_BUS_STATION;
1032 case SPBC_TRUCK_STATION:
return SPR_CURSOR_TRUCK_STATION;
1033 case SPBC_ROAD_TUNNEL:
return SPR_CURSOR_ROAD_TUNNEL;
1034 case SPBC_CLONE_TRAIN:
return SPR_CURSOR_CLONE_TRAIN;
1035 case SPBC_CLONE_ROADVEH:
return SPR_CURSOR_CLONE_ROADVEH;
1036 case SPBC_CLONE_SHIP:
return SPR_CURSOR_CLONE_SHIP;
1037 case SPBC_CLONE_AIRPLANE:
return SPR_CURSOR_CLONE_AIRPLANE;
1043 default:
return SPR_CURSOR_QUERY;
1057 StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(centered ? &_story_book_gs_desc : &_story_book_desc, company,
true);
bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
void ShowStoryBook(CompanyID company, uint16_t page_id, bool centered)
Raise or create the story book window for company, at page page_id.
@ SPET_TEXT
A text element.
Struct about goals, current and completed.
int GetSelPageNum() const
Get the page number of selected page.
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.
std::string title
Title of story page.
void ShowGoalsList(CompanyID company)
Open a goal list window.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
@ WID_SB_PAGE_PANEL
Page body.
Dimensions (a width and height) of a rectangle in 2D.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
TimerGameCalendar::Date date
Date when the page was created.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
static const CursorID ANIMCURSOR_RAISELAND
696 - 698 - raise land tool
StoryPageButtonFlags
Flags available for buttons.
int GetPageElementFloatWidth(const StoryPageElement &pe) const
Get the width a page element would use if it was floating left or right.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
SpriteID GetPageElementSprite(const StoryPageElement &pe) const
Decides which sprite to display for a given page element.
uint GetAvailablePageContentWidth() const
Get the width available for displaying content on the page panel.
DropDownList BuildDropDownList() const
Builds the page selector drop down list.
FrameFlags
Flags to describe the look of the frame.
Tindex index
Index of this pool item.
@ WID_SB_PREV_PAGE
Prev button.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
@ SPET_BUTTON_PUSH
A push button that triggers an immediate event.
uint16_t StoryPageElementID
ID of a story page element.
LayoutCache layout_cache
Cached element layout.
bool _ctrl_pressed
Is Ctrl pressed?
void SelectNextPage()
Selects the next available page after the currently selected page.
@ SPET_GOAL
An element that references a goal.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Owner
Enum for all companies/owners.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
void OnTimeout() override
Called when this window's timeout has been reached.
bool NeedRebuild() const
Check if a rebuild is needed.
@ SPET_BUTTON_VEHICLE
A button that allows the player to select a vehicle, and triggers an event wih the vehicle.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
@ WC_STORY_BOOK
Story book; Window numbers:
static const CursorID ANIMCURSOR_PICKSTATION
716 - 718 - goto-order icon
Scrollbar * vscroll
Scrollbar of the page text.
@ SPET_BUTTON_TILE
A button that allows the player to select a tile, and triggers an event with the tile.
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
StoryPageElementType type
Type of page element.
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.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
GUIStoryPageElementList story_page_elements
Sorted list of page elements that belong to the current page.
int height
Height of the window (number of pixels down in y direction)
std::conditional_t< std::is_same_v< std::nullptr_t, std::nullptr_t >, bool(const const StoryPage * &, const const StoryPage * &), bool(const const StoryPage * &, const const StoryPage * &, const std::nullptr_t)> SortFunction
Signature of sort function.
void SelectPrevPage()
Selects the previous available page before the currently selected page.
StoryPage * GetSelPage() const
Get instance of selected page.
void InvalidateStoryPageElementLayout()
Invalidate the current page layout.
Struct about stories, current and completed.
void RefreshSelectedPage()
Updates the content of selected page.
uint GetHeadHeight(int max_width) const
Counts how many pixels of height that are used by Date and Title (excluding marginal after Title,...
void OnPageElementClick(const StoryPageElement &pe)
Internal event handler for when a page element is clicked.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
WindowFlags flags
Window flags.
@ VEH_INVALID
Non-existing type of vehicle.
uint32_t CursorID
The number of the cursor (sprite)
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
StoryPageID selected_page_id
Pool index of selected page.
@ SPET_LOCATION
An element that references a tile along with a one-line text.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Coordinates of a point in 2D.
StoryPageButtonCursor
Mouse cursors usable by story page buttons.
uint GetPageElementHeight(const StoryPageElement &pe, int max_width) const
Get the height in pixels used by a page element.
uint16_t GoalID
ID of a goal.
WindowNumber window_number
Window number within the window class.
VehicleType
Available vehicle types.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Titem * Get(size_t index)
Returns Titem with given index.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ SA_HOR_CENTER
Horizontally center the text.
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
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 SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
bool IsFirstPageSelected()
Check if the selected page is also the first available 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.
@ WID_SB_SEL_PAGE
Page selector.
void ForceRebuild()
Force that a rebuild is needed.
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.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close)
Show a drop down list.
@ WID_SB_CAPTION
Caption of the window.
static bool PageElementOrderSorter(const StoryPageElement *const &a, const StoryPageElement *const &b)
Sort story page elements by order value.
@ WID_SB_SCROLLBAR
Scrollbar of the goal list.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
bool completed
Is the goal completed or not?
void OnResize() override
Called after the window got resized.
uint32_t referenced_id
Id of referenced object (location, goal etc.)
uint32_t sort_value
A number that increases for every created story page. Used for sorting. The id of a story page is the...
GUIStoryPageList story_pages
Sorted list of pages.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
static constexpr TimerGame< struct Calendar >::Date INVALID_DATE
Representation of an invalid date.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
@ HT_RECT
rectangle (stations, depots, ...)
std::string text
Static content text of page element.
Struct about story page elements.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
@ SA_LEFT
Left align the text.
@ SA_CENTER
Center both horizontally and vertically.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
int width
width of the window (number of pixels to the right in x direction)
void SetSelectedPage(uint16_t page_index)
Sets the selected page.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
void RebuildDone()
Notify the sortlist that the rebuild is done.
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.
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...
@ INVALID_COMPANY
An invalid company.
std::string text
Text of the goal.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Helper to construct packed "id" values for button-type StoryPageElement.
static bool PageOrderSorter(const StoryPage *const &a, const StoryPage *const &b)
Sort story pages by order value.
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.
VehicleType type
Type of vehicle.
void DrawWidgets() const
Paint all widgets of a window.
void UpdatePrevNextDisabledState()
Updates the disabled state of the prev/next buttons.
@ WID_SB_NEXT_PAGE
Next button.
void BuildStoryPageList()
(Re)Build story page list.
uint16_t StoryPageID
ID of a story page.
Specification of a rectangle with absolute coordinates of all edges.
uint32_t sort_value
A number that increases for every created story page element. Used for sorting. The id of a story pag...
bool Sort(Comp compare)
Sort the list.
uint GetContentHeight()
Get the total height of the content displayed in this window.
CompanyID company
StoryPage is for a specific company; INVALID_COMPANY if it is global.
bool IsLastPageSelected()
Check if the selected page is also the last available page.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
@ WDP_CENTER
Center the window.
void OnPaint() override
The window must be repainted.
ElementFloat GetPageElementFloat(const StoryPageElement &pe) const
Get the float style of a page element.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
void BuildStoryPageElementList()
(Re)Build story page element list.
Data about how and where to blit pixels.
void EnsureStoryPageElementLayout() const
Create the page layout if it is missing.
StoryPageElementID active_button_id
Which button element the player is currently using.
static const CursorID ANIMCURSOR_LOWERLAND
699 - 701 - lower land tool