diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj
index d93f319273..d2282cc7b0 100644
--- a/projects/openttd_vs100.vcxproj
+++ b/projects/openttd_vs100.vcxproj
@@ -1036,6 +1036,7 @@
+
@@ -1098,6 +1099,7 @@
+
diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters
index 8cce803742..c884307f5e 100644
--- a/projects/openttd_vs100.vcxproj.filters
+++ b/projects/openttd_vs100.vcxproj.filters
@@ -2337,6 +2337,9 @@
Script API
+
+ Script API
+
Script API
@@ -2523,6 +2526,9 @@
Script API Implementation
+
+ Script API Implementation
+
Script API Implementation
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 787f3a4e09..b18d71ca74 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -3478,6 +3478,10 @@
RelativePath=".\..\src\script\api\script_story_page.hpp"
>
+
+
@@ -3730,6 +3734,10 @@
RelativePath=".\..\src\script\api\script_story_page.cpp"
>
+
+
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index a433653a1a..fcf2adc302 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -3475,6 +3475,10 @@
RelativePath=".\..\src\script\api\script_story_page.hpp"
>
+
+
@@ -3727,6 +3731,10 @@
RelativePath=".\..\src\script\api\script_story_page.cpp"
>
+
+
diff --git a/source.list b/source.list
index c8aa11bf33..430a76cf55 100644
--- a/source.list
+++ b/source.list
@@ -816,6 +816,7 @@ script/api/script_signlist.hpp
script/api/script_station.hpp
script/api/script_stationlist.hpp
script/api/script_story_page.hpp
+script/api/script_storypagelist.hpp
script/api/script_subsidy.hpp
script/api/script_subsidylist.hpp
script/api/script_testmode.hpp
@@ -880,6 +881,7 @@ script/api/script_signlist.cpp
script/api/script_station.cpp
script/api/script_stationlist.cpp
script/api/script_story_page.cpp
+script/api/script_storypagelist.cpp
script/api/script_subsidy.cpp
script/api/script_subsidylist.cpp
script/api/script_testmode.cpp
diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp
index bd588e0392..c61fb26f26 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 1d0fe6cedf..dba324eaa9 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 e55d8c214c..0bca404011 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 c6d4582a5c..8382d43d73 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 counter(title);
diff --git a/src/script/api/script_story_page.hpp b/src/script/api/script_story_page.hpp
index 149ac55b84..2ce74dcbc9 100644
--- a/src/script/api/script_story_page.hpp
+++ b/src/script/api/script_story_page.hpp
@@ -118,6 +118,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.