From 33ad9774fb7c51f1ec706851c7a96a7ced5ff622 Mon Sep 17 00:00:00 2001 From: zuu Date: Sun, 9 Jun 2013 12:57:22 +0000 Subject: (svn r25352) -Feature: GameScript API for selecting a story page to view --- src/script/api/game/game_story_page.hpp.sq | 1 + src/script/api/script_story_page.cpp | 8 ++++++++ src/script/api/script_story_page.hpp | 11 +++++++++++ 3 files changed, 20 insertions(+) (limited to 'src/script/api') diff --git a/src/script/api/game/game_story_page.hpp.sq b/src/script/api/game/game_story_page.hpp.sq index abc9500d1..1d0fe6ced 100644 --- a/src/script/api/game/game_story_page.hpp.sq +++ b/src/script/api/game/game_story_page.hpp.sq @@ -33,6 +33,7 @@ void SQGSStoryPage_Register(Squirrel *engine) SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::NewElement, "NewElement", 5, ".iii."); SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::UpdateElement, "UpdateElement", 4, ".ii."); SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::SetTitle, "SetTitle", 3, ".i."); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::Show, "Show", 2, ".i"); SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::Remove, "Remove", 2, ".i"); SQGSStoryPage.PostRegister(engine); diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp index e94bc0017..8d6253b3c 100644 --- a/src/script/api/script_story_page.cpp +++ b/src/script/api/script_story_page.cpp @@ -109,6 +109,14 @@ return ScriptObject::DoCommand(0, story_page_id, 0, CMD_SET_STORY_PAGE_TITLE, title != NULL? title->GetEncodedText() : NULL); } +/* static */ bool ScriptStoryPage::Show(StoryPageID story_page_id) +{ + EnforcePrecondition(false, IsValidStoryPage(story_page_id)); + EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); + + return ScriptObject::DoCommand(0, story_page_id, 0, CMD_SHOW_STORY_PAGE); +} + /* static */ bool ScriptStoryPage::Remove(StoryPageID story_page_id) { EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); diff --git a/src/script/api/script_story_page.hpp b/src/script/api/script_story_page.hpp index b013f2515..d026650be 100644 --- a/src/script/api/script_story_page.hpp +++ b/src/script/api/script_story_page.hpp @@ -128,6 +128,17 @@ public: */ static bool SetTitle(StoryPageID story_page_id, Text *title); + /** + * Opens the Story Book if not yet open and selects the given page. + * @param 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. + * @return True if the action succeeded. + * @pre No ScriptCompanyMode may be in scope. + * @pre IsValidStoryPage(story_page_id). + */ + static bool Show(StoryPageID story_page_id); + /** * Remove a story page from the list. * @param story_page_id The story page to remove. -- cgit v1.2.3-70-g09d2