summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/game_instance.cpp2
-rw-r--r--src/script/api/game/game_story_page.hpp.sq1
-rw-r--r--src/script/api/game_changelog.hpp1
-rw-r--r--src/script/api/script_story_page.cpp7
-rw-r--r--src/script/api/script_story_page.hpp10
5 files changed, 21 insertions, 0 deletions
diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp
index bd588e039..c61fb26f2 100644
--- a/src/game/game_instance.cpp
+++ b/src/game/game_instance.cpp
@@ -67,6 +67,7 @@
#include "../script/api/game/game_station.hpp.sq"
#include "../script/api/game/game_stationlist.hpp.sq"
#include "../script/api/game/game_story_page.hpp.sq"
+#include "../script/api/game/game_storypagelist.hpp.sq"
#include "../script/api/game/game_subsidy.hpp.sq"
#include "../script/api/game/game_subsidylist.hpp.sq"
#include "../script/api/game/game_testmode.hpp.sq"
@@ -171,6 +172,7 @@ void GameInstance::RegisterAPI()
SQGSStationList_Register(this->engine);
SQGSStationList_Vehicle_Register(this->engine);
SQGSStoryPage_Register(this->engine);
+ SQGSStoryPageList_Register(this->engine);
SQGSSubsidy_Register(this->engine);
SQGSSubsidyList_Register(this->engine);
SQGSTestMode_Register(this->engine);
diff --git a/src/script/api/game/game_story_page.hpp.sq b/src/script/api/game/game_story_page.hpp.sq
index 1d0fe6ced..dba324eaa 100644
--- a/src/script/api/game/game_story_page.hpp.sq
+++ b/src/script/api/game/game_story_page.hpp.sq
@@ -32,6 +32,7 @@ void SQGSStoryPage_Register(Squirrel *engine)
SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::New, "New", 3, ".i.");
SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::NewElement, "NewElement", 5, ".iii.");
SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::UpdateElement, "UpdateElement", 4, ".ii.");
+ SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::GetPageSort, "GetPageSort", 2, ".i");
SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::SetTitle, "SetTitle", 3, ".i.");
SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::Show, "Show", 2, ".i");
SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::Remove, "Remove", 2, ".i");
diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp
index e55d8c214..0bca40401 100644
--- a/src/script/api/game_changelog.hpp
+++ b/src/script/api/game_changelog.hpp
@@ -28,6 +28,7 @@
* \li GSGoal::SetText
* \li GSStation::HasCargoRating
* \li GSStoryPage
+ * \li GSStoryPageList
* \li GSTile::GetTerrainType
* \li GSTown::FoundTown
* \li GSTown::GetFundBuildingsDuration
diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp
index c6d4582a5..8382d43d7 100644
--- a/src/script/api/script_story_page.cpp
+++ b/src/script/api/script_story_page.cpp
@@ -98,6 +98,13 @@
type == ::SPET_TEXT || type == ::SPET_LOCATION ? text->GetEncodedText() : NULL);
}
+/* static */ uint32 ScriptStoryPage::GetPageSort(StoryPageID story_page_id)
+{
+ EnforcePrecondition(false, IsValidStoryPage(story_page_id));
+
+ return StoryPage::Get(story_page_id)->sort_value;
+}
+
/* static */ bool ScriptStoryPage::SetTitle(StoryPageID story_page_id, Text *title)
{
CCountedPtr<Text> counter(title);
diff --git a/src/script/api/script_story_page.hpp b/src/script/api/script_story_page.hpp
index 149ac55b8..2ce74dcbc 100644
--- a/src/script/api/script_story_page.hpp
+++ b/src/script/api/script_story_page.hpp
@@ -119,6 +119,16 @@ public:
static bool UpdateElement(StoryPageElementID story_page_element_id, uint32 reference, Text *text);
/**
+ * 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 ScriptStoryPageList the same order
+ * as in GUI. You should not use this number for anything else.
+ * @param story_page_id The story page to get the sort value of.
+ * @return Page sort value.
+ */
+ static uint32 GetPageSort(StoryPageID story_page_id);
+
+ /**
* Update title of a story page. The title is shown in the page selector drop down.
* @param story_page_id The story page to update.
* @param title Page title (can be either a raw string, a ScriptText object, or null).