From 800ade77021b34adf8daa5ca5de0efaa8df24152 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Fri, 22 May 2020 22:22:55 +0200 Subject: Feature: Push-buttons on storybook pages (#7896) Allow more direct player-initiated interaction for Game Scripts, by letting the GS put push-buttons on storybook pages. These buttons can either trigger an immediate event, or require the player to first select a tile on the map, or a vehicle. Additionally this reworks how the storybook pages are layouted and rendered, to allow for slightly more complex layouts, and maybe speeding drawing up a bit. --- src/script/api/ai/ai_event.hpp.sq | 3 + src/script/api/game/game_event.hpp.sq | 3 + src/script/api/game/game_event_types.hpp.sq | 53 ++++++++ src/script/api/game/game_story_page.hpp.sq | 108 +++++++++++++--- src/script/api/game_changelog.hpp | 8 ++ src/script/api/script_event.hpp | 3 + src/script/api/script_event_types.hpp | 132 +++++++++++++++++++ src/script/api/script_story_page.cpp | 87 +++++++++++-- src/script/api/script_story_page.hpp | 139 ++++++++++++++++++++- .../api/template/template_event_types.hpp.sq | 27 ++++ src/script/api/template/template_story_page.hpp.sq | 6 + 11 files changed, 543 insertions(+), 26 deletions(-) (limited to 'src/script/api') diff --git a/src/script/api/ai/ai_event.hpp.sq b/src/script/api/ai/ai_event.hpp.sq index 6061eeed5..1290008c7 100644 --- a/src/script/api/ai/ai_event.hpp.sq +++ b/src/script/api/ai/ai_event.hpp.sq @@ -49,6 +49,9 @@ void SQAIEvent_Register(Squirrel *engine) SQAIEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS"); SQAIEvent.DefSQConst(engine, ScriptEvent::ET_ROAD_RECONSTRUCTION, "ET_ROAD_RECONSTRUCTION"); SQAIEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_AUTOREPLACED, "ET_VEHICLE_AUTOREPLACED"); + SQAIEvent.DefSQConst(engine, ScriptEvent::ET_STORYPAGE_BUTTON_CLICK, "ET_STORYPAGE_BUTTON_CLICK"); + SQAIEvent.DefSQConst(engine, ScriptEvent::ET_STORYPAGE_TILE_SELECT, "ET_STORYPAGE_TILE_SELECT"); + SQAIEvent.DefSQConst(engine, ScriptEvent::ET_STORYPAGE_VEHICLE_SELECT, "ET_STORYPAGE_VEHICLE_SELECT"); SQAIEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x"); diff --git a/src/script/api/game/game_event.hpp.sq b/src/script/api/game/game_event.hpp.sq index 42ea11b8b..2be056cd8 100644 --- a/src/script/api/game/game_event.hpp.sq +++ b/src/script/api/game/game_event.hpp.sq @@ -49,6 +49,9 @@ void SQGSEvent_Register(Squirrel *engine) SQGSEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS"); SQGSEvent.DefSQConst(engine, ScriptEvent::ET_ROAD_RECONSTRUCTION, "ET_ROAD_RECONSTRUCTION"); SQGSEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_AUTOREPLACED, "ET_VEHICLE_AUTOREPLACED"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_STORYPAGE_BUTTON_CLICK, "ET_STORYPAGE_BUTTON_CLICK"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_STORYPAGE_TILE_SELECT, "ET_STORYPAGE_TILE_SELECT"); + SQGSEvent.DefSQConst(engine, ScriptEvent::ET_STORYPAGE_VEHICLE_SELECT, "ET_STORYPAGE_VEHICLE_SELECT"); SQGSEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x"); diff --git a/src/script/api/game/game_event_types.hpp.sq b/src/script/api/game/game_event_types.hpp.sq index 62e4f6a08..6a0e89b49 100644 --- a/src/script/api/game/game_event_types.hpp.sq +++ b/src/script/api/game/game_event_types.hpp.sq @@ -308,3 +308,56 @@ void SQGSEventRoadReconstruction_Register(Squirrel *engine) SQGSEventRoadReconstruction.PostRegister(engine); } + + +template <> const char *GetClassName() { return "GSEventStoryPageButtonClick"; } + +void SQGSEventStoryPageButtonClick_Register(Squirrel *engine) +{ + DefSQClass SQGSEventStoryPageButtonClick("GSEventStoryPageButtonClick"); + SQGSEventStoryPageButtonClick.PreRegister(engine, "GSEvent"); + + SQGSEventStoryPageButtonClick.DefSQStaticMethod(engine, &ScriptEventStoryPageButtonClick::Convert, "Convert", 2, ".x"); + + SQGSEventStoryPageButtonClick.DefSQMethod(engine, &ScriptEventStoryPageButtonClick::GetCompanyID, "GetCompanyID", 1, "x"); + SQGSEventStoryPageButtonClick.DefSQMethod(engine, &ScriptEventStoryPageButtonClick::GetStoryPageID, "GetStoryPageID", 1, "x"); + SQGSEventStoryPageButtonClick.DefSQMethod(engine, &ScriptEventStoryPageButtonClick::GetElementID, "GetElementID", 1, "x"); + + SQGSEventStoryPageButtonClick.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSEventStoryPageTileSelect"; } + +void SQGSEventStoryPageTileSelect_Register(Squirrel *engine) +{ + DefSQClass SQGSEventStoryPageTileSelect("GSEventStoryPageTileSelect"); + SQGSEventStoryPageTileSelect.PreRegister(engine, "GSEvent"); + + SQGSEventStoryPageTileSelect.DefSQStaticMethod(engine, &ScriptEventStoryPageTileSelect::Convert, "Convert", 2, ".x"); + + SQGSEventStoryPageTileSelect.DefSQMethod(engine, &ScriptEventStoryPageTileSelect::GetCompanyID, "GetCompanyID", 1, "x"); + SQGSEventStoryPageTileSelect.DefSQMethod(engine, &ScriptEventStoryPageTileSelect::GetStoryPageID, "GetStoryPageID", 1, "x"); + SQGSEventStoryPageTileSelect.DefSQMethod(engine, &ScriptEventStoryPageTileSelect::GetElementID, "GetElementID", 1, "x"); + SQGSEventStoryPageTileSelect.DefSQMethod(engine, &ScriptEventStoryPageTileSelect::GetTile, "GetTile", 1, "x"); + + SQGSEventStoryPageTileSelect.PostRegister(engine); +} + + +template <> const char *GetClassName() { return "GSEventStoryPageVehicleSelect"; } + +void SQGSEventStoryPageVehicleSelect_Register(Squirrel *engine) +{ + DefSQClass SQGSEventStoryPageVehicleSelect("GSEventStoryPageVehicleSelect"); + SQGSEventStoryPageVehicleSelect.PreRegister(engine, "GSEvent"); + + SQGSEventStoryPageVehicleSelect.DefSQStaticMethod(engine, &ScriptEventStoryPageVehicleSelect::Convert, "Convert", 2, ".x"); + + SQGSEventStoryPageVehicleSelect.DefSQMethod(engine, &ScriptEventStoryPageVehicleSelect::GetCompanyID, "GetCompanyID", 1, "x"); + SQGSEventStoryPageVehicleSelect.DefSQMethod(engine, &ScriptEventStoryPageVehicleSelect::GetStoryPageID, "GetStoryPageID", 1, "x"); + SQGSEventStoryPageVehicleSelect.DefSQMethod(engine, &ScriptEventStoryPageVehicleSelect::GetElementID, "GetElementID", 1, "x"); + SQGSEventStoryPageVehicleSelect.DefSQMethod(engine, &ScriptEventStoryPageVehicleSelect::GetVehicleID, "GetVehicleID", 1, "x"); + + SQGSEventStoryPageVehicleSelect.PostRegister(engine); +} diff --git a/src/script/api/game/game_story_page.hpp.sq b/src/script/api/game/game_story_page.hpp.sq index 99bc237bf..b9fbf6026 100644 --- a/src/script/api/game/game_story_page.hpp.sq +++ b/src/script/api/game/game_story_page.hpp.sq @@ -24,21 +24,101 @@ void SQGSStoryPage_Register(Squirrel *engine) SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPET_TEXT, "SPET_TEXT"); SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPET_LOCATION, "SPET_LOCATION"); SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPET_GOAL, "SPET_GOAL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPET_BUTTON_PUSH, "SPET_BUTTON_PUSH"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPET_BUTTON_TILE, "SPET_BUTTON_TILE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPET_BUTTON_VEHICLE, "SPET_BUTTON_VEHICLE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBF_NONE, "SPBF_NONE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBF_FLOAT_LEFT, "SPBF_FLOAT_LEFT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBF_FLOAT_RIGHT, "SPBF_FLOAT_RIGHT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_MOUSE, "SPBC_MOUSE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_ZZZ, "SPBC_ZZZ"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_BUOY, "SPBC_BUOY"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_QUERY, "SPBC_QUERY"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_HQ, "SPBC_HQ"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_SHIP_DEPOT, "SPBC_SHIP_DEPOT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_SIGN, "SPBC_SIGN"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_TREE, "SPBC_TREE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_BUY_LAND, "SPBC_BUY_LAND"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_LEVEL_LAND, "SPBC_LEVEL_LAND"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_TOWN, "SPBC_TOWN"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_INDUSTRY, "SPBC_INDUSTRY"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_ROCKY_AREA, "SPBC_ROCKY_AREA"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_DESERT, "SPBC_DESERT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_TRANSMITTER, "SPBC_TRANSMITTER"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_AIRPORT, "SPBC_AIRPORT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_DOCK, "SPBC_DOCK"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CANAL, "SPBC_CANAL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_LOCK, "SPBC_LOCK"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_RIVER, "SPBC_RIVER"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_AQUEDUCT, "SPBC_AQUEDUCT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_BRIDGE, "SPBC_BRIDGE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_RAIL_STATION, "SPBC_RAIL_STATION"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_TUNNEL_RAIL, "SPBC_TUNNEL_RAIL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_TUNNEL_ELRAIL, "SPBC_TUNNEL_ELRAIL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_TUNNEL_MONO, "SPBC_TUNNEL_MONO"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_TUNNEL_MAGLEV, "SPBC_TUNNEL_MAGLEV"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_AUTORAIL, "SPBC_AUTORAIL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_AUTOELRAIL, "SPBC_AUTOELRAIL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_AUTOMONO, "SPBC_AUTOMONO"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_AUTOMAGLEV, "SPBC_AUTOMAGLEV"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_WAYPOINT, "SPBC_WAYPOINT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_RAIL_DEPOT, "SPBC_RAIL_DEPOT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_ELRAIL_DEPOT, "SPBC_ELRAIL_DEPOT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_MONO_DEPOT, "SPBC_MONO_DEPOT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_MAGLEV_DEPOT, "SPBC_MAGLEV_DEPOT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CONVERT_RAIL, "SPBC_CONVERT_RAIL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CONVERT_ELRAIL, "SPBC_CONVERT_ELRAIL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CONVERT_MONO, "SPBC_CONVERT_MONO"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CONVERT_MAGLEV, "SPBC_CONVERT_MAGLEV"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_AUTOROAD, "SPBC_AUTOROAD"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_AUTOTRAM, "SPBC_AUTOTRAM"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_ROAD_DEPOT, "SPBC_ROAD_DEPOT"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_BUS_STATION, "SPBC_BUS_STATION"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_TRUCK_STATION, "SPBC_TRUCK_STATION"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_ROAD_TUNNEL, "SPBC_ROAD_TUNNEL"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CLONE_TRAIN, "SPBC_CLONE_TRAIN"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CLONE_ROADVEH, "SPBC_CLONE_ROADVEH"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CLONE_SHIP, "SPBC_CLONE_SHIP"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CLONE_AIRPLANE, "SPBC_CLONE_AIRPLANE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_DEMOLISH, "SPBC_DEMOLISH"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_LOWERLAND, "SPBC_LOWERLAND"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_RAISELAND, "SPBC_RAISELAND"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_PICKSTATION, "SPBC_PICKSTATION"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_BUILDSIGNALS, "SPBC_BUILDSIGNALS"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_DARK_BLUE, "SPBC_DARK_BLUE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_PALE_GREEN, "SPBC_PALE_GREEN"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_PINK, "SPBC_PINK"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_YELLOW, "SPBC_YELLOW"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_RED, "SPBC_RED"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_LIGHT_BLUE, "SPBC_LIGHT_BLUE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_GREEN, "SPBC_GREEN"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_DARK_GREEN, "SPBC_DARK_GREEN"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_BLUE, "SPBC_BLUE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_CREAM, "SPBC_CREAM"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_MAUVE, "SPBC_MAUVE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_PURPLE, "SPBC_PURPLE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_ORANGE, "SPBC_ORANGE"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_BROWN, "SPBC_BROWN"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_GREY, "SPBC_GREY"); + SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::SPBC_WHITE, "SPBC_WHITE"); - SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::IsValidStoryPage, "IsValidStoryPage", 2, ".i"); - SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::IsValidStoryPageElement, "IsValidStoryPageElement", 2, ".i"); - 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::GetPageSortValue, "GetPageSortValue", 2, ".i"); - SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::GetPageElementSortValue, "GetPageElementSortValue", 2, ".i"); - SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::GetCompany, "GetCompany", 2, ".i"); - SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::GetDate, "GetDate", 2, ".i"); - SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::SetDate, "SetDate", 3, ".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.DefSQStaticMethod(engine, &ScriptStoryPage::RemoveElement, "RemoveElement", 2, ".i"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::IsValidStoryPage, "IsValidStoryPage", 2, ".i"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::IsValidStoryPageElement, "IsValidStoryPageElement", 2, ".i"); + 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::GetPageSortValue, "GetPageSortValue", 2, ".i"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::GetPageElementSortValue, "GetPageElementSortValue", 2, ".i"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::GetCompany, "GetCompany", 2, ".i"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::GetDate, "GetDate", 2, ".i"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::SetDate, "SetDate", 3, ".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.DefSQStaticMethod(engine, &ScriptStoryPage::RemoveElement, "RemoveElement", 2, ".i"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::MakePushButtonReference, "MakePushButtonReference", 3, ".ii"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::MakeTileButtonReference, "MakeTileButtonReference", 4, ".iii"); + SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::MakeVehicleButtonReference, "MakeVehicleButtonReference", 5, ".iiii"); SQGSStoryPage.PostRegister(engine); } diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index df8c663a0..69c4d971a 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -17,6 +17,14 @@ * * This version is not yet released. The following changes are not set in stone yet. * + * API additions: + * \li GSEventStoryPageButtonClick + * \li GSEventStoryPageTileSelect + * \li GSEventStoryPageVehicleSelect + * \li GSStoryPage::MakePushButtonReference + * \li GSStoryPage::MakeTileButtonReference + * \li GSStoryPage::MakeVehicleButtonReference + * * \b 1.10.0 * * API additions: diff --git a/src/script/api/script_event.hpp b/src/script/api/script_event.hpp index 886e4f1db..8e8f18170 100644 --- a/src/script/api/script_event.hpp +++ b/src/script/api/script_event.hpp @@ -54,6 +54,9 @@ public: ET_EXCLUSIVE_TRANSPORT_RIGHTS, ET_ROAD_RECONSTRUCTION, ET_VEHICLE_AUTOREPLACED, + ET_STORYPAGE_BUTTON_CLICK, + ET_STORYPAGE_TILE_SELECT, + ET_STORYPAGE_VEHICLE_SELECT, }; /** diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index 98cca7f50..f0487f48a 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -1098,4 +1098,136 @@ private: VehicleID new_id; ///< The vehicle that has been created in replacement. }; +/** + * Event StoryPageButtonClick, indicating a player clicked a push button on a storybook page. + * @api game + */ +class ScriptEventStoryPageButtonClick : public ScriptEvent { +public: + /** + * @param company_id Which company triggered the event. + * @param page_id Which page was the clicked button on. + * @param element_id Which button element was clicked. + */ + ScriptEventStoryPageButtonClick(CompanyID company_id, StoryPageID page_id, StoryPageElementID element_id) : + ScriptEvent(ET_STORYPAGE_BUTTON_CLICK), + company_id((ScriptCompany::CompanyID)company_id), + page_id(page_id), + element_id(element_id) + { } + + /** + * Convert an ScriptEvent to the real instance. + * @param instance The instance to convert. + * @return The converted instance. + */ + static ScriptEventStoryPageButtonClick *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageButtonClick *)instance; } + + /** Get the CompanyID of the player that selected a tile. */ + ScriptCompany::CompanyID GetCompanyID() { return this->company_id; } + + /** Get the StoryPageID of the storybook page the clicked button is located on. */ + StoryPageID GetStoryPageID() { return this->page_id; } + + /** Get the StoryPageElementID of the button element that was clicked. */ + StoryPageElementID GetElementID() { return this->element_id; } + +private: + ScriptCompany::CompanyID company_id; + StoryPageID page_id; + StoryPageElementID element_id; +}; + +/** + * Event StoryPageTileSelect, indicating a player clicked a tile selection button on a storybook page, and selected a tile. + * @api game + */ +class ScriptEventStoryPageTileSelect : public ScriptEvent { +public: + /** + * @param company_id Which company triggered the event. + * @param page_id Which page is the used selection button on. + * @param element_id Which button element was used to select the tile. + * @param tile_index Which tile was selected by the player. + */ + ScriptEventStoryPageTileSelect(CompanyID company_id, StoryPageID page_id, StoryPageElementID element_id, TileIndex tile_index) : + ScriptEvent(ET_STORYPAGE_TILE_SELECT), + company_id((ScriptCompany::CompanyID)company_id), + page_id(page_id), + element_id(element_id), + tile_index(tile_index) + { } + + /** + * Convert an ScriptEvent to the real instance. + * @param instance The instance to convert. + * @return The converted instance. + */ + static ScriptEventStoryPageTileSelect *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageTileSelect *)instance; } + + /** Get the CompanyID of the player that selected a tile. */ + ScriptCompany::CompanyID GetCompanyID() { return this->company_id; } + + /** Get the StoryPageID of the storybook page the used selection button is located on. */ + StoryPageID GetStoryPageID() { return this->page_id; } + + /** Get the StoryPageElementID of the selection button used to select the tile. */ + StoryPageElementID GetElementID() { return this->element_id; } + + /** Get the TileIndex of the tile the player selected */ + TileIndex GetTile() { return this->tile_index; } + +private: + ScriptCompany::CompanyID company_id; + StoryPageID page_id; + StoryPageElementID element_id; + TileIndex tile_index; +}; + +/** + * Event StoryPageTileSelect, indicating a player clicked a tile selection button on a storybook page, and selected a tile. + * @api game + */ +class ScriptEventStoryPageVehicleSelect : public ScriptEvent { +public: + /** + * @param company_id Which company triggered the event. + * @param page_id Which page is the used selection button on. + * @param element_id Which button element was used to select the tile. + * @param vehicle_id Which vehicle was selected by the player. + */ + ScriptEventStoryPageVehicleSelect(CompanyID company_id, StoryPageID page_id, StoryPageElementID element_id, VehicleID vehicle_id) : + ScriptEvent(ET_STORYPAGE_VEHICLE_SELECT), + company_id((ScriptCompany::CompanyID)company_id), + page_id(page_id), + element_id(element_id), + vehicle_id(vehicle_id) + { } + + /** + * Convert an ScriptEvent to the real instance. + * @param instance The instance to convert. + * @return The converted instance. + */ + static ScriptEventStoryPageVehicleSelect *Convert(ScriptEvent *instance) { return (ScriptEventStoryPageVehicleSelect *)instance; } + + /** Get the CompanyID of the player that selected a tile. */ + ScriptCompany::CompanyID GetCompanyID() { return this->company_id; } + + /** Get the StoryPageID of the storybook page the used selection button is located on. */ + StoryPageID GetStoryPageID() { return this->page_id; } + + /** Get the StoryPageElementID of the selection button used to select the vehicle. */ + StoryPageElementID GetElementID() { return this->element_id; } + + /** Get the VehicleID of the vehicle the player selected */ + VehicleID GetVehicleID() { return this->vehicle_id; } + +private: + ScriptCompany::CompanyID company_id; + StoryPageID page_id; + StoryPageElementID element_id; + VehicleID vehicle_id; +}; + #endif /* SCRIPT_EVENT_TYPES_HPP */ diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp index 87b81268c..39ae3d53f 100644 --- a/src/script/api/script_story_page.cpp +++ b/src/script/api/script_story_page.cpp @@ -22,6 +22,11 @@ #include "../../safeguards.h" +static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) +{ + return type == SPET_TEXT || type == SPET_LOCATION || type == SPET_BUTTON_PUSH || type == SPET_BUTTON_TILE || type == SPET_BUTTON_VEHICLE; +} + /* static */ bool ScriptStoryPage::IsValidStoryPage(StoryPageID story_page_id) { return ::StoryPage::IsValidID(story_page_id); @@ -57,18 +62,34 @@ { CCountedPtr counter(text); + ::StoryPageElementType btype = static_cast<::StoryPageElementType>(type); + EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, IsValidStoryPage(story_page_id)); - EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, (type != SPET_TEXT && type != SPET_LOCATION) || (text != nullptr && !StrEmpty(text->GetEncodedText()))); + EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, !StoryPageElementTypeRequiresText(btype) || (text != nullptr && !StrEmpty(text->GetEncodedText()))); EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_LOCATION || ::IsValidTile(reference)); EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference)); EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || !(StoryPage::Get(story_page_id)->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY)); - if (!ScriptObject::DoCommand(type == SPET_LOCATION ? reference : 0, + uint32 refid = 0; + TileIndex reftile = 0; + switch (type) { + case SPET_LOCATION: + reftile = reference; + break; + case SPET_GOAL: + case SPET_BUTTON_PUSH: + case SPET_BUTTON_TILE: + case SPET_BUTTON_VEHICLE: + refid = reference; + break; + } + + if (!ScriptObject::DoCommand(reftile, story_page_id + (type << 16), - type == SPET_GOAL ? reference : 0, + refid, CMD_CREATE_STORY_PAGE_ELEMENT, - type == SPET_TEXT || type == SPET_LOCATION ? text->GetEncodedText() : nullptr, + StoryPageElementTypeRequiresText(btype) ? text->GetEncodedText() : nullptr, &ScriptInstance::DoCommandReturnStoryPageElementID)) return STORY_PAGE_ELEMENT_INVALID; /* In case of test-mode, we return StoryPageElementID 0 */ @@ -86,16 +107,30 @@ StoryPage *p = StoryPage::Get(pe->page); ::StoryPageElementType type = pe->type; - EnforcePrecondition(false, (type != ::SPET_TEXT && type != ::SPET_LOCATION) || (text != nullptr && !StrEmpty(text->GetEncodedText()))); + EnforcePrecondition(false, !StoryPageElementTypeRequiresText(type) || (text != nullptr && !StrEmpty(text->GetEncodedText()))); EnforcePrecondition(false, type != ::SPET_LOCATION || ::IsValidTile(reference)); EnforcePrecondition(false, type != ::SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference)); EnforcePrecondition(false, type != ::SPET_GOAL || !(p->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY)); - return ScriptObject::DoCommand(type == ::SPET_LOCATION ? reference : 0, + uint32 refid = 0; + TileIndex reftile = 0; + switch (type) { + case SPET_LOCATION: + reftile = reference; + break; + case SPET_GOAL: + case SPET_BUTTON_PUSH: + case SPET_BUTTON_TILE: + case SPET_BUTTON_VEHICLE: + refid = reference; + break; + } + + return ScriptObject::DoCommand(reftile, story_page_element_id, - type == ::SPET_GOAL ? reference : 0, + refid, CMD_UPDATE_STORY_PAGE_ELEMENT, - type == ::SPET_TEXT || type == ::SPET_LOCATION ? text->GetEncodedText() : nullptr); + StoryPageElementTypeRequiresText(type) ? text->GetEncodedText() : nullptr); } /* static */ uint32 ScriptStoryPage::GetPageSortValue(StoryPageID story_page_id) @@ -173,3 +208,39 @@ return ScriptObject::DoCommand(0, story_page_element_id, 0, CMD_REMOVE_STORY_PAGE_ELEMENT); } +/* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags) +{ + StoryPageButtonData data; + data.SetColour((Colours)colour); + data.SetFlags((::StoryPageButtonFlags)flags); + if (!data.ValidateColour()) return UINT32_MAX; + if (!data.ValidateFlags()) return UINT32_MAX; + return data.referenced_id; +} + +/* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakeTileButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags, StoryPageButtonCursor cursor) +{ + StoryPageButtonData data; + data.SetColour((Colours)colour); + data.SetFlags((::StoryPageButtonFlags)flags); + data.SetCursor((::StoryPageButtonCursor)cursor); + if (!data.ValidateColour()) return UINT32_MAX; + if (!data.ValidateFlags()) return UINT32_MAX; + if (!data.ValidateCursor()) return UINT32_MAX; + return data.referenced_id; +} + +/* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakeVehicleButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags, StoryPageButtonCursor cursor, ScriptVehicle::VehicleType vehtype) +{ + StoryPageButtonData data; + data.SetColour((Colours)colour); + data.SetFlags((::StoryPageButtonFlags)flags); + data.SetCursor((::StoryPageButtonCursor)cursor); + data.SetVehicleType((::VehicleType)vehtype); + if (!data.ValidateColour()) return UINT32_MAX; + if (!data.ValidateFlags()) return UINT32_MAX; + if (!data.ValidateCursor()) return UINT32_MAX; + if (!data.ValidateVehicleType()) return UINT32_MAX; + return data.referenced_id; +} + diff --git a/src/script/api/script_story_page.hpp b/src/script/api/script_story_page.hpp index d7e44fee4..23e4e03b1 100644 --- a/src/script/api/script_story_page.hpp +++ b/src/script/api/script_story_page.hpp @@ -12,6 +12,7 @@ #include "script_company.hpp" #include "script_date.hpp" +#include "script_vehicle.hpp" #include "../../story_type.h" #include "../../story_base.h" @@ -57,9 +58,111 @@ public: * Story page element types. */ enum StoryPageElementType { - SPET_TEXT = ::SPET_TEXT, ///< An element that displays a block of text. - SPET_LOCATION = ::SPET_LOCATION, ///< An element that displays a single line of text along with a button to view the referenced location. - SPET_GOAL = ::SPET_GOAL, ///< An element that displays a goal. + SPET_TEXT = ::SPET_TEXT, ///< An element that displays a block of text. + SPET_LOCATION = ::SPET_LOCATION, ///< An element that displays a single line of text along with a button to view the referenced location. + SPET_GOAL = ::SPET_GOAL, ///< An element that displays a goal. + SPET_BUTTON_PUSH = ::SPET_BUTTON_PUSH, ///< A push button that triggers an immediate event. + SPET_BUTTON_TILE = ::SPET_BUTTON_TILE, ///< A button that allows the player to select a tile, and triggers an event with the tile. + SPET_BUTTON_VEHICLE = ::SPET_BUTTON_VEHICLE, ///< A button that allows the player to select a vehicle, and triggers an event wih the vehicle. + }; + + /** + * Formatting data for button page elements. + */ + typedef uint32 StoryPageButtonFormatting; + + /** + * Formatting and layout flags for story page buttons. + * The SPBF_FLOAT_LEFT and SPBF_FLOAT_RIGHT flags can not be combined. + */ + enum StoryPageButtonFlags { + SPBF_NONE = ::SPBF_NONE, ///< No special formatting for button. + SPBF_FLOAT_LEFT = ::SPBF_FLOAT_LEFT, ///< Button is placed to the left of the following paragraph. + SPBF_FLOAT_RIGHT = ::SPBF_FLOAT_RIGHT, ///< Button is placed to the right of the following paragraph. + }; + + /** + * Mouse cursors usable by story page buttons. + */ + enum StoryPageButtonCursor { + SPBC_MOUSE = ::SPBC_MOUSE, + SPBC_ZZZ = ::SPBC_ZZZ, + SPBC_BUOY = ::SPBC_BUOY, + SPBC_QUERY = ::SPBC_QUERY, + SPBC_HQ = ::SPBC_HQ, + SPBC_SHIP_DEPOT = ::SPBC_SHIP_DEPOT, + SPBC_SIGN = ::SPBC_SIGN, + SPBC_TREE = ::SPBC_TREE, + SPBC_BUY_LAND = ::SPBC_BUY_LAND, + SPBC_LEVEL_LAND = ::SPBC_LEVEL_LAND, + SPBC_TOWN = ::SPBC_TOWN, + SPBC_INDUSTRY = ::SPBC_INDUSTRY, + SPBC_ROCKY_AREA = ::SPBC_ROCKY_AREA, + SPBC_DESERT = ::SPBC_DESERT, + SPBC_TRANSMITTER = ::SPBC_TRANSMITTER, + SPBC_AIRPORT = ::SPBC_AIRPORT, + SPBC_DOCK = ::SPBC_DOCK, + SPBC_CANAL = ::SPBC_CANAL, + SPBC_LOCK = ::SPBC_LOCK, + SPBC_RIVER = ::SPBC_RIVER, + SPBC_AQUEDUCT = ::SPBC_AQUEDUCT, + SPBC_BRIDGE = ::SPBC_BRIDGE, + SPBC_RAIL_STATION = ::SPBC_RAIL_STATION, + SPBC_TUNNEL_RAIL = ::SPBC_TUNNEL_RAIL, + SPBC_TUNNEL_ELRAIL = ::SPBC_TUNNEL_ELRAIL, + SPBC_TUNNEL_MONO = ::SPBC_TUNNEL_MONO, + SPBC_TUNNEL_MAGLEV = ::SPBC_TUNNEL_MAGLEV, + SPBC_AUTORAIL = ::SPBC_AUTORAIL, + SPBC_AUTOELRAIL = ::SPBC_AUTOELRAIL, + SPBC_AUTOMONO = ::SPBC_AUTOMONO, + SPBC_AUTOMAGLEV = ::SPBC_AUTOMAGLEV, + SPBC_WAYPOINT = ::SPBC_WAYPOINT, + SPBC_RAIL_DEPOT = ::SPBC_RAIL_DEPOT, + SPBC_ELRAIL_DEPOT = ::SPBC_ELRAIL_DEPOT, + SPBC_MONO_DEPOT = ::SPBC_MONO_DEPOT, + SPBC_MAGLEV_DEPOT = ::SPBC_MAGLEV_DEPOT, + SPBC_CONVERT_RAIL = ::SPBC_CONVERT_RAIL, + SPBC_CONVERT_ELRAIL = ::SPBC_CONVERT_ELRAIL, + SPBC_CONVERT_MONO = ::SPBC_CONVERT_MONO, + SPBC_CONVERT_MAGLEV = ::SPBC_CONVERT_MAGLEV, + SPBC_AUTOROAD = ::SPBC_AUTOROAD, + SPBC_AUTOTRAM = ::SPBC_AUTOTRAM, + SPBC_ROAD_DEPOT = ::SPBC_ROAD_DEPOT, + SPBC_BUS_STATION = ::SPBC_BUS_STATION, + SPBC_TRUCK_STATION = ::SPBC_TRUCK_STATION, + SPBC_ROAD_TUNNEL = ::SPBC_ROAD_TUNNEL, + SPBC_CLONE_TRAIN = ::SPBC_CLONE_TRAIN, + SPBC_CLONE_ROADVEH = ::SPBC_CLONE_ROADVEH, + SPBC_CLONE_SHIP = ::SPBC_CLONE_SHIP, + SPBC_CLONE_AIRPLANE = ::SPBC_CLONE_AIRPLANE, + SPBC_DEMOLISH = ::SPBC_DEMOLISH, + SPBC_LOWERLAND = ::SPBC_LOWERLAND, + SPBC_RAISELAND = ::SPBC_RAISELAND, + SPBC_PICKSTATION = ::SPBC_PICKSTATION, + SPBC_BUILDSIGNALS = ::SPBC_BUILDSIGNALS, + }; + + /** + * Colour codes usable for story page button elements. + * Place a colour value in the lowest 8 bits of the \c reference parameter to the button. + */ + enum StoryPageButtonColour { + SPBC_DARK_BLUE = ::COLOUR_DARK_BLUE, + SPBC_PALE_GREEN = ::COLOUR_PALE_GREEN, + SPBC_PINK = ::COLOUR_PINK, + SPBC_YELLOW = ::COLOUR_YELLOW, + SPBC_RED = ::COLOUR_RED, + SPBC_LIGHT_BLUE = ::COLOUR_LIGHT_BLUE, + SPBC_GREEN = ::COLOUR_GREEN, + SPBC_DARK_GREEN = ::COLOUR_DARK_GREEN, + SPBC_BLUE = ::COLOUR_BLUE, + SPBC_CREAM = ::COLOUR_CREAM, + SPBC_MAUVE = ::COLOUR_MAUVE, + SPBC_PURPLE = ::COLOUR_PURPLE, + SPBC_ORANGE = ::COLOUR_ORANGE, + SPBC_BROWN = ::COLOUR_BROWN, + SPBC_GREY = ::COLOUR_GREY, + SPBC_WHITE = ::COLOUR_WHITE, }; /** @@ -90,7 +193,11 @@ public: * Create a new story page element. * @param story_page_id The page id of the story page which the page element should be appended to. * @param type Which page element type to create. - * @param reference A reference value to the object that is referred to by some page element types. When type is SPET_GOAL, this is the goal ID. When type is SPET_LOCATION, this is the TileIndex. + * @param reference A reference value to the object that is referred to by some page element types. + * When type is SPET_GOAL, this is the goal ID. + * When type is SPET_LOCATION, this is the TileIndex. + * When type is a button, this is additional parameters for the button, + * use the #BuildPushButtonReference, #BuildTileButtonReference, or #BuildVehicleButtonReference functions to make the values. * @param text The body text of page elements that allow custom text. (SPET_TEXT and SPET_LOCATION) * @return The new StoryPageElementID, or STORY_PAGE_ELEMENT_INVALID if it failed. * @pre No ScriptCompanyMode may be in scope. @@ -204,6 +311,30 @@ public: * @pre IsValidStoryPageElement(story_page_element_id). */ static bool RemoveElement(StoryPageElementID story_page_element_id); + + /** + * Create a reference value for SPET_BUTTON_PUSH element parameters. + * @param colour The colour for the face of the button. + * @return A reference value usable with the #NewElement and #UpdateElement functions. + */ + static StoryPageButtonFormatting MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags); + + /** + * Create a reference value for SPET_BUTTON_TILE element parameters. + * @param colour The colour for the face of the button. + * @param cursor The mouse cursor to use when the player clicks the button and the game is ready for the player to select a tile. + * @return A reference value usable with the #NewElement and #UpdateElement functions. + */ + static StoryPageButtonFormatting MakeTileButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags, StoryPageButtonCursor cursor); + + /** + * Create a reference value for SPET_BUTTON_VEHICLE element parameters. + * @param colour The colour for the face of the button. + * @param cursor The mouse cursor to use when the player clicks the button and the game is ready for the player to select a vehicle. + * @param vehtype The type of vehicle that will be selectable, or \c VT_INVALID to allow all types. + * @return A reference value usable with the #NewElement and #UpdateElement functions. + */ + static StoryPageButtonFormatting MakeVehicleButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags, StoryPageButtonCursor cursor, ScriptVehicle::VehicleType vehtype); }; #endif /* SCRIPT_STORY_HPP */ diff --git a/src/script/api/template/template_event_types.hpp.sq b/src/script/api/template/template_event_types.hpp.sq index 09cbe43f3..4e82de63c 100644 --- a/src/script/api/template/template_event_types.hpp.sq +++ b/src/script/api/template/template_event_types.hpp.sq @@ -273,3 +273,30 @@ namespace SQConvert { template <> inline const ScriptEventVehicleAutoReplaced &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventVehicleAutoReplaced *)instance; } template <> inline int Return(HSQUIRRELVM vm, ScriptEventVehicleAutoReplaced *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventVehicleAutoReplaced", res, nullptr, DefSQDestructorCallback, true); return 1; } } // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptEventStoryPageButtonClick to be used as Squirrel parameter */ + template <> inline ScriptEventStoryPageButtonClick *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventStoryPageButtonClick *)instance; } + template <> inline ScriptEventStoryPageButtonClick &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventStoryPageButtonClick *)instance; } + template <> inline const ScriptEventStoryPageButtonClick *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventStoryPageButtonClick *)instance; } + template <> inline const ScriptEventStoryPageButtonClick &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventStoryPageButtonClick *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptEventStoryPageButtonClick *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventStoryPageButtonClick", res, nullptr, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptEventStoryPageTileSelect to be used as Squirrel parameter */ + template <> inline ScriptEventStoryPageTileSelect *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventStoryPageTileSelect *)instance; } + template <> inline ScriptEventStoryPageTileSelect &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventStoryPageTileSelect *)instance; } + template <> inline const ScriptEventStoryPageTileSelect *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventStoryPageTileSelect *)instance; } + template <> inline const ScriptEventStoryPageTileSelect &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventStoryPageTileSelect *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptEventStoryPageTileSelect *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventStoryPageTileSelect", res, nullptr, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert + +namespace SQConvert { + /* Allow ScriptEventStoryPageVehicleSelect to be used as Squirrel parameter */ + template <> inline ScriptEventStoryPageVehicleSelect *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventStoryPageVehicleSelect *)instance; } + template <> inline ScriptEventStoryPageVehicleSelect &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventStoryPageVehicleSelect *)instance; } + template <> inline const ScriptEventStoryPageVehicleSelect *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventStoryPageVehicleSelect *)instance; } + template <> inline const ScriptEventStoryPageVehicleSelect &GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventStoryPageVehicleSelect *)instance; } + template <> inline int Return(HSQUIRRELVM vm, ScriptEventStoryPageVehicleSelect *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventStoryPageVehicleSelect", res, nullptr, DefSQDestructorCallback, true); return 1; } +} // namespace SQConvert diff --git a/src/script/api/template/template_story_page.hpp.sq b/src/script/api/template/template_story_page.hpp.sq index 106f9a623..f06d53138 100644 --- a/src/script/api/template/template_story_page.hpp.sq +++ b/src/script/api/template/template_story_page.hpp.sq @@ -17,6 +17,12 @@ namespace SQConvert { template <> inline int Return(HSQUIRRELVM vm, ScriptStoryPage::StoryPageElementID res) { sq_pushinteger(vm, (int32)res); return 1; } template <> inline ScriptStoryPage::StoryPageElementType GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStoryPage::StoryPageElementType)tmp; } template <> inline int Return(HSQUIRRELVM vm, ScriptStoryPage::StoryPageElementType res) { sq_pushinteger(vm, (int32)res); return 1; } + template <> inline ScriptStoryPage::StoryPageButtonFlags GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStoryPage::StoryPageButtonFlags)tmp; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStoryPage::StoryPageButtonFlags res) { sq_pushinteger(vm, (int32)res); return 1; } + template <> inline ScriptStoryPage::StoryPageButtonCursor GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStoryPage::StoryPageButtonCursor)tmp; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStoryPage::StoryPageButtonCursor res) { sq_pushinteger(vm, (int32)res); return 1; } + template <> inline ScriptStoryPage::StoryPageButtonColour GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStoryPage::StoryPageButtonColour)tmp; } + template <> inline int Return(HSQUIRRELVM vm, ScriptStoryPage::StoryPageButtonColour res) { sq_pushinteger(vm, (int32)res); return 1; } /* Allow ScriptStoryPage to be used as Squirrel parameter */ template <> inline ScriptStoryPage *GetParam(ForceType, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStoryPage *)instance; } -- cgit v1.2.3-54-g00ecf