From 1dbd59e6ab9a917214d98c53a8ab8ca5b0d47223 Mon Sep 17 00:00:00 2001 From: zuu Date: Thu, 6 Feb 2014 19:48:19 +0000 Subject: (svn r26306) -Add: [nogo] More story APIs: RemovePageElement, GetCompany, GetDate, SetDate --- src/story.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/story.cpp') diff --git a/src/story.cpp b/src/story.cpp index e60eaadec..da44c2743 100644 --- a/src/story.cpp +++ b/src/story.cpp @@ -250,6 +250,32 @@ CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, return CommandCost(); } +/** + * Update date of a story page. + * @param tile unused. + * @param flags type of operation + * @param p1 = (bit 0 - 15) - StoryPageID to update. + * @param p2 = (bit 0 - 31) - date + * @param text unused + * @return the cost of this operation or an error + */ +CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +{ + if (_current_company != OWNER_DEITY) return CMD_ERROR; + StoryPageID page_id = (StoryPageID)GB(p1, 0, 16); + if (!StoryPage::IsValidID(page_id)) return CMD_ERROR; + Date date = (Date)p2; + + if (flags & DC_EXEC) { + StoryPage *p = StoryPage::Get(page_id); + p->date = date; + + InvalidateWindowClassesData(WC_STORY_BOOK, page_id); + } + + return CommandCost(); +} + /** * Display a story page for all clients that are allowed to * view the story page. @@ -307,3 +333,30 @@ CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, u return CommandCost(); } +/** + * Remove a story page element + * @param tile unused. + * @param flags type of operation + * @param p1 = (bit 0 - 15) - StoryPageElementID to remove. + * @param p2 unused. + * @param text unused. + * @return the cost of this operation or an error + */ +CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +{ + if (_current_company != OWNER_DEITY) return CMD_ERROR; + StoryPageElementID page_element_id = (StoryPageElementID)p1; + if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR; + + if (flags & DC_EXEC) { + StoryPageElement *pe = StoryPageElement::Get(page_element_id); + StoryPageID page_id = pe->page; + + delete pe; + + InvalidateWindowClassesData(WC_STORY_BOOK, page_id); + } + + return CommandCost(); +} + -- cgit v1.2.3-54-g00ecf