OpenTTD Source 20260108-master-g8ba1860eaa
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 (StoryPageElementID index)
 
 StoryPageElement (StoryPageElementID index, 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 >
 PoolItem (Tindex index)
 Construct the item.
 
void * operator new (size_t)=delete
 Do not use new PoolItem, but rather PoolItem::Create.
 
void * operator new (size_t size, Tindex index)=delete
 Do not use new (index) PoolItem(...), but rather PoolItem::CreateAtIndex(index, ...).
 
void * operator new (size_t, void *ptr)=delete
 Do not use new (address) PoolItem(...).
 
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 >
const 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 T * Create (Targs &&... args)
 Creates a new T-object in the associated pool.
 
static T * CreateAtIndex (Tindex index, Targs &&... args)
 Creates a new T-object in the associated 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 ( StoryPageElementID  index)
inline

Definition at line 153 of file story_base.h.

◆ StoryPageElement() [2/2]

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

Definition at line 154 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 160 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: