OpenTTD Source: src/story_cmd.h File Reference

OpenTTD Source 14.1

Functions
story_cmd.h File Reference
`#include "command_type.h"`
`#include "company_type.h"`
`#include "story_type.h"`
`#include "vehicle_type.h"`

Go to the source code of this file.

## Functions
std::tuple< CommandCost, StoryPageID > | CmdCreateStoryPage (DoCommandFlag flags, CompanyID company, const std::string &text)
| Create a new story page. More...
std::tuple< CommandCost, StoryPageElementID > | CmdCreateStoryPageElement (DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const std::string &text)
| Create a new story page element. More...
CommandCost | CmdUpdateStoryPageElement (DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const std::string &text)
| Update a new story page element. More...
CommandCost | CmdSetStoryPageTitle (DoCommandFlag flags, StoryPageID page_id, const std::string &text)
| Update title of a story page. More...
CommandCost | CmdSetStoryPageDate (DoCommandFlag flags, StoryPageID page_id, TimerGameCalendar::Date date)
| Update date of a story page. More...
CommandCost | CmdShowStoryPage (DoCommandFlag flags, StoryPageID page_id)
| Display a story page for all clients that are allowed to view the story page. More...
CommandCost | CmdRemoveStoryPage (DoCommandFlag flags, StoryPageID page_id)
| Remove a story page and associated story page elements. More...
CommandCost | CmdRemoveStoryPageElement (DoCommandFlag flags, StoryPageElementID page_element_id)
| Remove a story page element. More...
CommandCost | CmdStoryPageButton (DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, VehicleID reference)
| Clicked/used a button on a story page. More...

## Detailed Description

Command definitions related to stories.

Definition in file story_cmd.h.

## Function Documentation

## ◆ CmdCreateStoryPage()

std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage | ( | DoCommandFlag | flags,
|  | CompanyID | company,
|  | const std::string & | text
| ) |  |

Create a new story page.

Parameters

  flags | type of operation
  company | Company for which this story page belongs to.
  text | Title of the story page. Null is allowed in which case a generic page title is provided by OpenTTD.

Returns
  the cost of this operation or an error

Definition at line 209 of file story.cpp.

References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::CanAllocateItem(), CMD_ERROR, DC_EXEC, INVALID_COMPANY, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and OWNER_DEITY.

## ◆ CmdCreateStoryPageElement()

std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement | ( | DoCommandFlag | flags,
|  | TileIndex | tile,
|  | StoryPageID | page_id,
|  | StoryPageElementType | type,
|  | uint32_t | reference,
|  | const std::string & | text
| ) |  |

Create a new story page element.

Parameters

  flags | type of operation
  tile | Tile location if it is a location page element, otherwise unused.
  page_id | The page which the element belongs to.
  type | Page element type
  reference | Id of referenced object
  text | Text content in case it is a text or location page element

Returns
  the cost of this operation or an error

Definition at line 248 of file story.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >::CanAllocateItem(), and CMD_ERROR.

## ◆ CmdRemoveStoryPage()

CommandCost CmdRemoveStoryPage | ( | DoCommandFlag | flags,
|  | StoryPageID | page_id
| ) |  |

Remove a story page and associated story page elements.

Parameters

  flags | type of operation
  page_id | StoryPageID to remove.

Returns
  the cost of this operation or an error

Definition at line 382 of file story.cpp.

References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >::Iterate(), OWNER_DEITY, WC_MAIN_TOOLBAR, and WC_STORY_BOOK.

## ◆ CmdRemoveStoryPageElement()

CommandCost CmdRemoveStoryPageElement | ( | DoCommandFlag | flags,
|  | StoryPageElementID | page_element_id
| ) |  |

Remove a story page element.

Parameters

  flags | type of operation
  page_element_id | StoryPageElementID to remove.

Returns
  the cost of this operation or an error

Definition at line 411 of file story.cpp.

References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >::Get(), InvalidateWindowClassesData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >::IsValidID(), OWNER_DEITY, StoryPageElement::page, and WC_STORY_BOOK.

## ◆ CmdSetStoryPageDate()

CommandCost CmdSetStoryPageDate | ( | DoCommandFlag | flags,
|  | StoryPageID | page_id,
|  | TimerGameCalendar::Date | date
| ) |  |

Update date of a story page.

Parameters

  flags | type of operation
  page_id | StoryPageID to update.
  date | date

Returns
  the cost of this operation or an error

Definition at line 342 of file story.cpp.

References _current_company, CMD_ERROR, StoryPage::date, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::Get(), InvalidateWindowClassesData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::IsValidID(), OWNER_DEITY, and WC_STORY_BOOK.

## ◆ CmdSetStoryPageTitle()

CommandCost CmdSetStoryPageTitle | ( | DoCommandFlag | flags,
|  | StoryPageID | page_id,
|  | const std::string & | text
| ) |  |

Update title of a story page.

Parameters

  flags | type of operation
  page_id | StoryPageID to update.
  text | title text of the story page.

Returns
  the cost of this operation or an error

Definition at line 320 of file story.cpp.

References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::Get(), InvalidateWindowClassesData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::IsValidID(), OWNER_DEITY, StoryPage::title, and WC_STORY_BOOK.

## ◆ CmdShowStoryPage()

CommandCost CmdShowStoryPage | ( | DoCommandFlag | flags,
|  | StoryPageID | page_id
| ) |  |

Display a story page for all clients that are allowed to view the story page.

Parameters

  flags | type of operation
  page_id | StoryPageID to show.

Returns
  the cost of this operation or an error

Definition at line 364 of file story.cpp.

References _current_company, _local_company, CMD_ERROR, StoryPage::company, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::Get(), INVALID_COMPANY, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), OWNER_DEITY, and ShowStoryBook().

## ◆ CmdStoryPageButton()

CommandCost CmdStoryPageButton | ( | DoCommandFlag | flags,
|  | TileIndex | tile,
|  | StoryPageElementID | page_element_id,
|  | VehicleID | reference
| ) |  |

Clicked/used a button on a story page.

Parameters

  flags | Type of operation.
  tile | Tile selected, for tile selection buttons, otherwise unused.
  page_element_id | story page element id of button.
  reference | ID of selected item for buttons that select an item (e.g. vehicle), otherwise unused.

Returns
  The cost of the operation, or an error.

Definition at line 436 of file story.cpp.

References _current_company, CMD_ERROR, StoryPage::company, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >::Get(), INVALID_COMPANY, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::IsValidID(), IsValidTile(), Game::NewEvent(), StoryPageElement::page, SPET_BUTTON_PUSH, SPET_BUTTON_TILE, SPET_BUTTON_VEHICLE, and StoryPageElement::type.

## ◆ CmdUpdateStoryPageElement()

CommandCost CmdUpdateStoryPageElement | ( | DoCommandFlag | flags,
|  | TileIndex | tile,
|  | StoryPageElementID | page_element_id,
|  | uint32_t | reference,
|  | const std::string & | text
| ) |  |

Update a new story page element.

Parameters

  flags | type of operation
  tile | Tile location if it is a location page element, otherwise unused.
  page_element_id | The page element to update.
  reference | Id of referenced object
  text | Text content in case it is a text or location page element

Returns
  the cost of this operation or an error

Definition at line 294 of file story.cpp.

References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >::Get(), InvalidateWindowClassesData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_element_pool >::IsValidID(), OWNER_DEITY, StoryPageElement::page, StoryPageElement::type, UpdateElement(), VerifyElementContentParameters(), and WC_STORY_BOOK.