OpenTTD Source 20250312-master-gcdcc6b491d
StoryPageElement Struct Reference

Struct about story page elements. More...

#include <story_base.h>

Inheritance diagram for StoryPageElement:
Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_story_page_element_pool >

Public Member Functions

 StoryPageElement ()
 We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
 
 StoryPageElement (uint32_t sort_value, StoryPageElementType type, StoryPageID page)
 
 ~StoryPageElement ()
 (Empty) destructor has to be defined else operator delete might be called with nullptr parameter
 
- Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_story_page_element_pool >
void * operator new (size_t size)
 Allocates space for new Titem.
 
void * operator new (size_t size, Tindex index)
 Allocates space for new Titem with given index.
 
void * operator new (size_t, void *ptr)
 Allocates space for new Titem at given memory address.
 
void operator delete (void *p, size_t size)
 Marks Titem as free.
 

Data Fields

uint32_t sort_value = 0
 A number that increases for every created story page element. Used for sorting. The id of a story page element is the pool index.
 
StoryPageID page {}
 Id of the page which the page element belongs to.
 
StoryPageElementType type {}
 Type of page element.
 
uint32_t referenced_id = 0
 Id of referenced object (location, goal etc.)
 
EncodedString text {}
 Static content text of page element.
 
- Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_story_page_element_pool >
Tindex index
 Index of this pool item.
 

Additional Inherited Members

- Public Types inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_story_page_element_pool >
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache > Pool
 Type of the pool this item is going to be part of.
 
- Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_story_page_element_pool >
static bool CanAllocateItem (size_t n=1)
 Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
 
static bool CleaningPool ()
 Returns current state of pool cleaning - yes or no.
 
static bool IsValidID (auto index)
 Tests whether given index can be used to get valid (non-nullptr) Titem.
 
static Titem * Get (auto index)
 Returns Titem with given index.
 
static Titem * GetIfValid (auto index)
 Returns Titem with given index.
 
static size_t GetPoolSize ()
 Returns first unused index.
 
static size_t GetNumItems ()
 Returns number of valid items in the pool.
 
static void PostDestructor (size_t index)
 Dummy function called after destructor of each member.
 
static Pool::IterateWrapper< Titem > Iterate (size_t from=0)
 Returns an iterable ensemble of all valid Titem.
 

Detailed Description

Struct about story page elements.

Each StoryPage is composed of one or more page elements that provide page content. Each element only contain one type of content.

Definition at line 145 of file story_base.h.

Constructor & Destructor Documentation

◆ StoryPageElement() [1/2]

StoryPageElement::StoryPageElement ( )
inline

We need an (empty) constructor so struct isn't zeroed (as C++ standard states)

Definition at line 156 of file story_base.h.

◆ StoryPageElement() [2/2]

StoryPageElement::StoryPageElement ( uint32_t  sort_value,
StoryPageElementType  type,
StoryPageID  page 
)
inline

Definition at line 157 of file story_base.h.

◆ ~StoryPageElement()

StoryPageElement::~StoryPageElement ( )
inline

(Empty) destructor has to be defined else operator delete might be called with nullptr parameter

Definition at line 163 of file story_base.h.

Field Documentation

◆ page

StoryPageID StoryPageElement::page {}

Id of the page which the page element belongs to.

Definition at line 147 of file story_base.h.

Referenced by CmdRemoveStoryPageElement(), CmdStoryPageButton(), and CmdUpdateStoryPageElement().

◆ referenced_id

uint32_t StoryPageElement::referenced_id = 0

Id of referenced object (location, goal etc.)

Definition at line 150 of file story_base.h.

Referenced by StoryBookWindow::GetPageElementFloat(), StoryBookWindow::GetPageElementSprite(), StoryBookWindow::OnPageElementClick(), and UpdateElement().

◆ sort_value

uint32_t StoryPageElement::sort_value = 0

A number that increases for every created story page element. Used for sorting. The id of a story page element is the pool index.

Definition at line 146 of file story_base.h.

Referenced by STPEChunkHandler::Load(), and StoryBookWindow::PageElementOrderSorter().

◆ text

EncodedString StoryPageElement::text {}

Static content text of page element.

Definition at line 151 of file story_base.h.

Referenced by StoryBookWindow::GetPageElementFloatWidth(), StoryBookWindow::GetPageElementHeight(), and UpdateElement().

◆ type


The documentation for this struct was generated from the following file: