summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzuu <zuu@openttd.org>2014-02-06 19:25:39 +0000
committerzuu <zuu@openttd.org>2014-02-06 19:25:39 +0000
commit5165be2698a9d92de4b675b0dece9057e92484bf (patch)
tree2939c724ef744237783100bf3368f03a195ed572
parentebcc8462b7d09d36ff74843748ab5277a81bc409 (diff)
downloadopenttd-5165be2698a9d92de4b675b0dece9057e92484bf.tar.xz
(svn r26303) -Add: [nogo] ScriptStoryPageList() - a list of all story pages
-rw-r--r--projects/openttd_vs100.vcxproj2
-rw-r--r--projects/openttd_vs100.vcxproj.filters6
-rw-r--r--projects/openttd_vs80.vcproj8
-rw-r--r--projects/openttd_vs90.vcproj8
-rw-r--r--source.list2
-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
10 files changed, 47 insertions, 0 deletions
diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj
index d93f31927..d2282cc7b 100644
--- a/projects/openttd_vs100.vcxproj
+++ b/projects/openttd_vs100.vcxproj
@@ -1036,6 +1036,7 @@
<ClInclude Include="..\src\script\api\script_station.hpp" />
<ClInclude Include="..\src\script\api\script_stationlist.hpp" />
<ClInclude Include="..\src\script\api\script_story_page.hpp" />
+ <ClInclude Include="..\src\script\api\script_storypagelist.hpp" />
<ClInclude Include="..\src\script\api\script_subsidy.hpp" />
<ClInclude Include="..\src\script\api\script_subsidylist.hpp" />
<ClInclude Include="..\src\script\api\script_testmode.hpp" />
@@ -1098,6 +1099,7 @@
<ClCompile Include="..\src\script\api\script_station.cpp" />
<ClCompile Include="..\src\script\api\script_stationlist.cpp" />
<ClCompile Include="..\src\script\api\script_story_page.cpp" />
+ <ClCompile Include="..\src\script\api\script_storypagelist.cpp" />
<ClCompile Include="..\src\script\api\script_subsidy.cpp" />
<ClCompile Include="..\src\script\api\script_subsidylist.cpp" />
<ClCompile Include="..\src\script\api\script_testmode.cpp" />
diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters
index 8cce80374..c884307f5 100644
--- a/projects/openttd_vs100.vcxproj.filters
+++ b/projects/openttd_vs100.vcxproj.filters
@@ -2337,6 +2337,9 @@
<ClInclude Include="..\src\script\api\script_story_page.hpp">
<Filter>Script API</Filter>
</ClInclude>
+ <ClInclude Include="..\src\script\api\script_storypagelist.hpp">
+ <Filter>Script API</Filter>
+ </ClInclude>
<ClInclude Include="..\src\script\api\script_subsidy.hpp">
<Filter>Script API</Filter>
</ClInclude>
@@ -2523,6 +2526,9 @@
<ClCompile Include="..\src\script\api\script_story_page.cpp">
<Filter>Script API Implementation</Filter>
</ClCompile>
+ <ClCompile Include="..\src\script\api\script_storypagelist.cpp">
+ <Filter>Script API Implementation</Filter>
+ </ClCompile>
<ClCompile Include="..\src\script\api\script_subsidy.cpp">
<Filter>Script API Implementation</Filter>
</ClCompile>
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 787f3a4e0..b18d71ca7 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -3479,6 +3479,10 @@
>
</File>
<File
+ RelativePath=".\..\src\script\api\script_storypagelist.hpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\script\api\script_subsidy.hpp"
>
</File>
@@ -3731,6 +3735,10 @@
>
</File>
<File
+ RelativePath=".\..\src\script\api\script_storypagelist.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\script\api\script_subsidy.cpp"
>
</File>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index a433653a1..fcf2adc30 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -3476,6 +3476,10 @@
>
</File>
<File
+ RelativePath=".\..\src\script\api\script_storypagelist.hpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\script\api\script_subsidy.hpp"
>
</File>
@@ -3728,6 +3732,10 @@
>
</File>
<File
+ RelativePath=".\..\src\script\api\script_storypagelist.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\script\api\script_subsidy.cpp"
>
</File>
diff --git a/source.list b/source.list
index c8aa11bf3..430a76cf5 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 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).