OpenTTD Source 20241224-master-gee860a5c8e
StoryPageElement Struct Reference

Struct about story page elements. More...

#include <story_base.h>

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

Public Member Functions

 StoryPageElement ()
 We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
 
 ~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, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >
void * operator new (size_t size)
 Allocates space for new Titem.
 
void * operator new (size_t size, size_t 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)
 Marks Titem as free.
 

Data Fields

uint32_t sort_value
 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
 Id of referenced object (location, goal etc.)
 
std::string text
 Static content text of page element.
 
- Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >
Tindex index
 Index of this pool item.
 

Additional Inherited Members

- Public Types inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero > Pool
 Type of the pool this item is going to be part of.
 
- Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::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 (size_t index)
 Tests whether given index can be used to get valid (non-nullptr) Titem.
 
static Titem * Get (size_t index)
 Returns Titem with given index.
 
static Titem * GetIfValid (size_t 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 144 of file story_base.h.

Constructor & Destructor Documentation

◆ StoryPageElement()

StoryPageElement::StoryPageElement ( )
inline

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

Definition at line 155 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 146 of file story_base.h.

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

◆ referenced_id

uint32_t StoryPageElement::referenced_id

Id of referenced object (location, goal etc.)

Definition at line 149 of file story_base.h.

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

◆ sort_value

uint32_t StoryPageElement::sort_value

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 145 of file story_base.h.

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

◆ text

std::string StoryPageElement::text

Static content text of page element.

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