Public Types | |
enum | StoryPageID { STORY_PAGE_INVALID } |
The story page IDs. More... | |
enum | StoryPageElementID { STORY_PAGE_ELEMENT_INVALID } |
The story page element IDs. More... | |
enum | StoryPageElementType { SPET_TEXT, SPET_LOCATION, SPET_GOAL } |
Story page element types. More... | |
Static Public Member Functions | |
static bool | IsValidStoryPage (StoryPageID story_page_id) |
Check whether this is a valid story page ID. | |
static bool | IsValidStoryPageElement (StoryPageElementID story_page_element_id) |
Check whether this is a valid story page element ID. | |
static StoryPageID | New (GSCompany::CompanyID company, Text *title) |
Create a new story page. | |
static StoryPageElementID | NewElement (StoryPageID story_page_id, StoryPageElementType type, uint32 reference, Text *text) |
Create a new story page element. | |
static bool | UpdateElement (StoryPageElementID story_page_element_id, uint32 reference, Text *text) |
Update the content of a page element. | |
static uint32 | GetPageSortValue (StoryPageID story_page_id) |
Get story page sort value. | |
static uint32 | GetPageElementSortValue (StoryPageElementID story_page_element_id) |
Get story page element sort value. | |
static GSCompany::CompanyID | GetCompany (StoryPageID story_page_id) |
Get the company which the page belongs to. | |
static GSDate::Date | GetDate (StoryPageID story_page_id) |
Get the page date which is displayed at the top of each page. | |
static bool | SetDate (StoryPageID story_page_id, GSDate::Date date) |
Update date of a story page. | |
static bool | SetTitle (StoryPageID story_page_id, Text *title) |
Update title of a story page. | |
static bool | Show (StoryPageID story_page_id) |
Opens the Story Book if not yet open and selects the given page. | |
static bool | Remove (StoryPageID story_page_id) |
Remove a story page and all the page elements associated with it. | |
static bool | RemoveElement (StoryPageElementID story_page_element_id) |
Removes a story page element. |
To create a page: 1. Create the page 2. Create page elements that will be appended to the page in the order which they are created.
Pages can be either global or company specific. It is possible to mix, but the only mixed solution that will work is to have all global pages first. Once you create the first company specific page, it is not recommended to add additional global pages unless you clear up all pages first.
Page elements are stacked vertically on a page. If goal elements are used, the element will become empty if the goal is removed while the page still exist. Instead of removing the goal, you can mark it as complete and the Story Book will show that the goal is completed.
Mind that users might want to go back to old pages later on. Thus do not remove pages in the story book unless you really need to.
static bool GSStoryPage::IsValidStoryPage | ( | StoryPageID | story_page_id | ) | [static] |
Check whether this is a valid story page ID.
story_page_id | The StoryPageID to check. |
static bool GSStoryPage::IsValidStoryPageElement | ( | StoryPageElementID | story_page_element_id | ) | [static] |
Check whether this is a valid story page element ID.
story_page_element_id | The StoryPageElementID to check. |
static StoryPageID GSStoryPage::New | ( | GSCompany::CompanyID | company, | |
Text * | title | |||
) | [static] |
Create a new story page.
company | The company to create the story page for, or GSCompany::COMPANY_INVALID for all. | |
title | Page title (can be either a raw string, a GSText object, or null). |
company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
static StoryPageElementID GSStoryPage::NewElement | ( | StoryPageID | story_page_id, | |
StoryPageElementType | type, | |||
uint32 | reference, | |||
Text * | text | |||
) | [static] |
Create a new story page element.
story_page_id | The page id of the story page which the page element should be appended to. | |
type | Which page element type to create. | |
reference | A reference value to the object that is refered to by some page element types. When type is SPET_GOAL, this is the goal ID. When type is SPET_LOCATION, this is the TileIndex. | |
text | The body text of page elements that allow custom text. (SPET_TEXT and SPET_LOCATION) |
IsValidStoryPage(story_page).
(type != SPET_TEXT && type != SPET_LOCATION) || (text != NULL && len(text) != 0).
type != SPET_LOCATION || GSMap::IsValidTile(reference).
type != SPET_GOAL || GSGoal::IsValidGoal(reference).
if type is SPET_GOAL and story_page is a global page, then referenced goal must be global.
static bool GSStoryPage::UpdateElement | ( | StoryPageElementID | story_page_element_id, | |
uint32 | reference, | |||
Text * | text | |||
) | [static] |
Update the content of a page element.
story_page_element_id | The page id of the story page which the page element should be appended to. | |
reference | A reference value to the object that is refered to by some page element types. See also NewElement. | |
text | The body text of page elements that allow custom text. See also NewElement. |
IsValidStoryPage(story_page).
(type != SPET_TEXT && type != SPET_LOCATION) || (text != NULL && len(text) != 0).
type != SPET_LOCATION || GSMap::IsValidTile(reference).
type != SPET_GOAL || GSGoal::IsValidGoal(reference).
if type is SPET_GOAL and story_page is a global page, then referenced goal must be global.
static uint32 GSStoryPage::GetPageSortValue | ( | StoryPageID | story_page_id | ) | [static] |
Get story page sort value.
Each page has a sort value that is internally assigned and used to sort the pages in the story book. OpenTTD maintains this number so that the sort order is perceived. This API exist only so that you can sort GSStoryPageList the same order as in GUI. You should not use this number for anything else.
story_page_id | The story page to get the sort value of. |
static uint32 GSStoryPage::GetPageElementSortValue | ( | StoryPageElementID | story_page_element_id | ) | [static] |
Get story page element sort value.
Each page element has a sort value that is internally assigned and used to sort the page elements within a page of the story book. OpenTTD maintains this number so that the sort order is perceived. This API exist only so that you can sort GSStoryPageList the same order as in GUI. You should not use this number for anything else.
story_page_element_id | The story page element to get the sort value of. |
static GSCompany::CompanyID GSStoryPage::GetCompany | ( | StoryPageID | story_page_id | ) | [static] |
Get the company which the page belongs to.
If the page is global, GSCompany::COMPANY_INVALID is returned.
story_page_id | The story page to get the company for. |
static GSDate::Date GSStoryPage::GetDate | ( | StoryPageID | story_page_id | ) | [static] |
Get the page date which is displayed at the top of each page.
story_page_id | The story page to get the date of. |
static bool GSStoryPage::SetDate | ( | StoryPageID | story_page_id, | |
GSDate::Date | date | |||
) | [static] |
Update date of a story page.
The date is shown in the top left of the page
story_page_id | The story page to set the date for. | |
date | Date to display at the top of story page or GSDate::DATE_INVALID to disable showing date on this page. (also, |
IsValidStoryPage(story_page_id).
static bool GSStoryPage::SetTitle | ( | StoryPageID | story_page_id, | |
Text * | title | |||
) | [static] |
Update title of a story page.
The title is shown in the page selector drop down.
story_page_id | The story page to update. | |
title | Page title (can be either a raw string, a GSText object, or null). |
IsValidStoryPage(story_page_id).
static bool GSStoryPage::Show | ( | StoryPageID | story_page_id | ) | [static] |
Opens the Story Book if not yet open and selects the given page.
story_page_id | The story page to update. If it is a global page, clients of all companies are affecetd. Otherwise only the clients of the company which the page belongs to are affected. |
IsValidStoryPage(story_page_id).
static bool GSStoryPage::Remove | ( | StoryPageID | story_page_id | ) | [static] |
Remove a story page and all the page elements associated with it.
story_page_id | The story page to remove. |
IsValidStoryPage(story_page_id).
static bool GSStoryPage::RemoveElement | ( | StoryPageElementID | story_page_element_id | ) | [static] |
Removes a story page element.
story_page_element_id | The story page element to remove. |
IsValidStoryPageElement(story_page_element_id).