(svn r25342) -Add: StoryPage data structures and GS API
This commit is contained in:
39
src/script/api/game/game_story_page.hpp.sq
Normal file
39
src/script/api/game/game_story_page.hpp.sq
Normal file
@@ -0,0 +1,39 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
|
||||
|
||||
#include "../script_story_page.hpp"
|
||||
#include "../template/template_story_page.hpp.sq"
|
||||
|
||||
|
||||
template <> const char *GetClassName<ScriptStoryPage, ST_GS>() { return "GSStoryPage"; }
|
||||
|
||||
void SQGSStoryPage_Register(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptStoryPage, ST_GS> SQGSStoryPage("GSStoryPage");
|
||||
SQGSStoryPage.PreRegister(engine);
|
||||
SQGSStoryPage.AddConstructor<void (ScriptStoryPage::*)(), 1>(engine, "x");
|
||||
|
||||
SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::STORY_PAGE_INVALID, "STORY_PAGE_INVALID");
|
||||
SQGSStoryPage.DefSQConst(engine, ScriptStoryPage::STORY_PAGE_ELEMENT_INVALID, "STORY_PAGE_ELEMENT_INVALID");
|
||||
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.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::SetTitle, "SetTitle", 3, ".i.");
|
||||
SQGSStoryPage.DefSQStaticMethod(engine, &ScriptStoryPage::Remove, "Remove", 2, ".i");
|
||||
|
||||
SQGSStoryPage.PostRegister(engine);
|
||||
}
|
@@ -144,6 +144,8 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
SetNewSignID(_new_sign_id);
|
||||
SetNewGroupID(_new_group_id);
|
||||
SetNewGoalID(_new_goal_id);
|
||||
SetNewStoryPageID(_new_story_page_id);
|
||||
SetNewStoryPageElementID(_new_story_page_element_id);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptObject::GetLastCommandRes()
|
||||
@@ -191,6 +193,26 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
return GetStorage()->new_goal_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetNewStoryPageID(StoryPageID story_page_id)
|
||||
{
|
||||
GetStorage()->new_story_page_id = story_page_id;
|
||||
}
|
||||
|
||||
/* static */ GroupID ScriptObject::GetNewStoryPageID()
|
||||
{
|
||||
return GetStorage()->new_story_page_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetNewStoryPageElementID(StoryPageElementID story_page_element_id)
|
||||
{
|
||||
GetStorage()->new_story_page_element_id = story_page_element_id;
|
||||
}
|
||||
|
||||
/* static */ GroupID ScriptObject::GetNewStoryPageElementID()
|
||||
{
|
||||
return GetStorage()->new_story_page_element_id;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetAllowDoCommand(bool allow)
|
||||
{
|
||||
GetStorage()->allow_do_command = allow;
|
||||
|
@@ -166,6 +166,16 @@ protected:
|
||||
*/
|
||||
static GoalID GetNewGoalID();
|
||||
|
||||
/**
|
||||
* Get the latest stored new_story_page_id.
|
||||
*/
|
||||
static StoryPageID GetNewStoryPageID();
|
||||
|
||||
/**
|
||||
* Get the latest stored new_story_page_id.
|
||||
*/
|
||||
static StoryPageID GetNewStoryPageElementID();
|
||||
|
||||
/**
|
||||
* Store a allow_do_command per company.
|
||||
* @param allow The new allow.
|
||||
@@ -266,6 +276,18 @@ private:
|
||||
* @param goal_id The new GoalID.
|
||||
*/
|
||||
static void SetNewGoalID(GoalID goal_id);
|
||||
|
||||
/**
|
||||
* Store a new_story_page_id per company.
|
||||
* @param story_page_id The new StoryPageID.
|
||||
*/
|
||||
static void SetNewStoryPageID(StoryPageID story_page_id);
|
||||
|
||||
/**
|
||||
* Store a new_story_page_id per company.
|
||||
* @param story_page_id The new StoryPageID.
|
||||
*/
|
||||
static void SetNewStoryPageElementID(StoryPageElementID story_page_element_id);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_OBJECT_HPP */
|
||||
|
119
src/script/api/script_story_page.cpp
Normal file
119
src/script/api/script_story_page.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file script_story_page.cpp Implementation of ScriptStoryPage. */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_story_page.hpp"
|
||||
#include "script_error.hpp"
|
||||
#include "script_industry.hpp"
|
||||
#include "script_map.hpp"
|
||||
#include "script_town.hpp"
|
||||
#include "script_goal.hpp"
|
||||
#include "../script_instance.hpp"
|
||||
#include "../../story_base.h"
|
||||
#include "../../goal_base.h"
|
||||
#include "../../string_func.h"
|
||||
#include "../../tile_map.h"
|
||||
|
||||
/* static */ bool ScriptStoryPage::IsValidStoryPage(StoryPageID story_page_id)
|
||||
{
|
||||
return ::StoryPage::IsValidID(story_page_id);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::IsValidStoryPageElement(StoryPageElementID story_page_element_id)
|
||||
{
|
||||
return ::StoryPageElement::IsValidID(story_page_element_id);
|
||||
}
|
||||
|
||||
/* static */ ScriptStoryPage::StoryPageID ScriptStoryPage::New(ScriptCompany::CompanyID company, Text *title)
|
||||
{
|
||||
CCountedPtr<Text> counter(title);
|
||||
|
||||
EnforcePrecondition(STORY_PAGE_INVALID, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(STORY_PAGE_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
|
||||
|
||||
uint8 c = company;
|
||||
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
|
||||
|
||||
if (!ScriptObject::DoCommand(0,
|
||||
c,
|
||||
0,
|
||||
CMD_CREATE_STORY_PAGE,
|
||||
title != NULL? title->GetEncodedText() : NULL,
|
||||
&ScriptInstance::DoCommandReturnStoryPageID)) return STORY_PAGE_INVALID;
|
||||
|
||||
/* In case of test-mode, we return StoryPageID 0 */
|
||||
return (ScriptStoryPage::StoryPageID)0;
|
||||
}
|
||||
|
||||
/* static */ ScriptStoryPage::StoryPageElementID ScriptStoryPage::NewElement(StoryPageID story_page_id, StoryPageElementType type, uint32 reference, Text *text)
|
||||
{
|
||||
CCountedPtr<Text> counter(text);
|
||||
|
||||
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 != NULL && !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,
|
||||
story_page_id + (type << 16),
|
||||
type == SPET_GOAL ? reference : 0,
|
||||
CMD_CREATE_STORY_PAGE_ELEMENT,
|
||||
type == SPET_TEXT || type == SPET_LOCATION ? text->GetEncodedText() : NULL,
|
||||
&ScriptInstance::DoCommandReturnStoryPageElementID)) return STORY_PAGE_ELEMENT_INVALID;
|
||||
|
||||
/* In case of test-mode, we return StoryPageElementID 0 */
|
||||
return (ScriptStoryPage::StoryPageElementID)0;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::UpdateElement(StoryPageElementID story_page_element_id, uint32 reference, Text *text)
|
||||
{
|
||||
CCountedPtr<Text> counter(text);
|
||||
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(false, IsValidStoryPageElement(story_page_element_id));
|
||||
|
||||
StoryPageElement *pe = StoryPageElement::Get(story_page_element_id);
|
||||
StoryPage *p = StoryPage::Get(pe->page);
|
||||
::StoryPageElementType type = pe->type;
|
||||
|
||||
EnforcePrecondition(false, (type != SPET_TEXT && type != SPET_LOCATION) || (text != NULL && !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,
|
||||
pe->page,
|
||||
type == SPET_GOAL ? reference : 0,
|
||||
CMD_UPDATE_STORY_PAGE_ELEMENT,
|
||||
type == SPET_TEXT || type == SPET_LOCATION ? text->GetEncodedText() : NULL,
|
||||
&ScriptInstance::DoCommandReturnStoryPageElementID);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::SetTitle(StoryPageID story_page_id, Text *title)
|
||||
{
|
||||
CCountedPtr<Text> counter(title);
|
||||
|
||||
EnforcePrecondition(false, IsValidStoryPage(story_page_id));
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
|
||||
return ScriptObject::DoCommand(0, story_page_id, 0, CMD_SET_STORY_PAGE_TITLE, title != NULL? title->GetEncodedText() : NULL);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::Remove(StoryPageID story_page_id)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(false, IsValidStoryPage(story_page_id));
|
||||
|
||||
return ScriptObject::DoCommand(0, story_page_id, 0, CMD_REMOVE_STORY_PAGE);
|
||||
}
|
||||
|
142
src/script/api/script_story_page.hpp
Normal file
142
src/script/api/script_story_page.hpp
Normal file
@@ -0,0 +1,142 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file script_story_page.hpp Everything to manipulate a story page. */
|
||||
|
||||
#ifndef SCRIPT_STORY_HPP
|
||||
#define SCRIPT_STORY_HPP
|
||||
|
||||
#include "script_company.hpp"
|
||||
#include "../../story_type.h"
|
||||
#include "../../story_base.h"
|
||||
|
||||
/**
|
||||
* Class that handles story page related functions.
|
||||
*
|
||||
* To create a page:
|
||||
* 1. Create the page
|
||||
* 2. Create page elements that will be appended to the page in the order which they are created.
|
||||
*
|
||||
* Pages can be either global or company specific. It is possible to mix, but the only mixed solution
|
||||
* that will work is to have all global pages first. Once you create the first company specific page,
|
||||
* it is not recommended to add additional global pages unless you clear up all pages first.
|
||||
*
|
||||
* Page elements are stacked vertically on a page. If goal elements are used, the element will
|
||||
* become empty if the goal is removed while the page still exist. Instead of removing the goal,
|
||||
* you can mark it as complete and the Story Book will show that the goal is completed.
|
||||
*
|
||||
* Mind that users might want to go back to old pages later on. Thus do not remove pages in
|
||||
* the story book unless you really need to.
|
||||
*
|
||||
* @api game
|
||||
*/
|
||||
class ScriptStoryPage : public ScriptObject {
|
||||
public:
|
||||
/**
|
||||
* The story page IDs.
|
||||
*/
|
||||
enum StoryPageID {
|
||||
/* Note: these values represent part of the in-game StoryPageID enum */
|
||||
STORY_PAGE_INVALID = ::INVALID_STORY_PAGE, ///< An invalid story page id.
|
||||
};
|
||||
|
||||
/**
|
||||
* The story page element IDs.
|
||||
*/
|
||||
enum StoryPageElementID {
|
||||
/* Note: these values represent part of the in-game StoryPageElementID enum */
|
||||
STORY_PAGE_ELEMENT_INVALID = ::INVALID_STORY_PAGE_ELEMENT, ///< An invalid story page element id.
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether this is a valid story page ID.
|
||||
* @param story_page_id The StoryPageID to check.
|
||||
* @return True if and only if this story page is valid.
|
||||
*/
|
||||
static bool IsValidStoryPage(StoryPageID story_page_id);
|
||||
|
||||
/**
|
||||
* Check whether this is a valid story page element ID.
|
||||
* @param story_page_element_id The StoryPageElementID to check.
|
||||
* @return True if and only if this story page element is valid.
|
||||
*/
|
||||
static bool IsValidStoryPageElement(StoryPageElementID story_page_element_id);
|
||||
|
||||
/**
|
||||
* Create a new story page.
|
||||
* @param company The company to create the story page for, or ScriptCompany::COMPANY_INVALID for all.
|
||||
* @param title Page title (can be either a raw string, a ScriptText object, or null).
|
||||
* @return The new StoryPageID, or STORY_INVALID if it failed.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
|
||||
*/
|
||||
static StoryPageID New(ScriptCompany::CompanyID company, Text *title);
|
||||
|
||||
/**
|
||||
* 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 refered 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 text The body text of page elements that allow custom text. (SPET_TEXT and SPET_LOCATION)
|
||||
* @return The new StoryPageID, or STORY_INVALID if it failed.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre IsValidStoryPage(story_page).
|
||||
* @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != NULL && len(text) != 0).
|
||||
* @pre type != SPET_LOCATION || ScriptMap::IsValidTile(reference).
|
||||
* @pre type != SPET_GOAL || ScriptGoal::IsValidGoal(reference).
|
||||
* @pre if type is SPET_GOAL and story_page is a global page, then referenced goal must be global.
|
||||
*/
|
||||
static StoryPageElementID NewElement(StoryPageID story_page_id, StoryPageElementType type, uint32 reference, Text *text);
|
||||
|
||||
/**
|
||||
* Update the content of a page element
|
||||
* @param story_page_element_id The page id of the story page which the page element should be appended to.
|
||||
* @param reference A reference value to the object that is refered to by some page element types. See also NewElement.
|
||||
* @param text The body text of page elements that allow custom text. See also NewElement.
|
||||
* @return The new StoryPageID, or STORY_INVALID if it failed.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre IsValidStoryPage(story_page).
|
||||
* @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != NULL && len(text) != 0).
|
||||
* @pre type != SPET_LOCATION || ScriptMap::IsValidTile(reference).
|
||||
* @pre type != SPET_GOAL || ScriptGoal::IsValidGoal(reference).
|
||||
* @pre if type is SPET_GOAL and story_page is a global page, then referenced goal must be global.
|
||||
*/
|
||||
static bool UpdateElement(StoryPageElementID story_page_element_id, uint32 reference, Text *text);
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* @return True if the action succeeded.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre IsValidStoryPage(story_page_id).
|
||||
*/
|
||||
static bool SetTitle(StoryPageID story_page_id, Text *title);
|
||||
|
||||
/**
|
||||
* Remove a story page from the list.
|
||||
* @param story_page_id The story page to remove.
|
||||
* @return True if the action succeeded.
|
||||
* @pre No ScriptCompanyMode may be in scope.
|
||||
* @pre IsValidStoryPage(story_page_id).
|
||||
*/
|
||||
static bool Remove(StoryPageID story_page_id);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_STORY_HPP */
|
||||
|
@@ -100,6 +100,8 @@ typedef uint16 SignID; ///< The ID of a sign.
|
||||
typedef uint16 StationID; ///< The ID of a station.
|
||||
typedef uint16 StringID; ///< The ID of a string.
|
||||
typedef uint16 SubsidyID; ///< The ID of a subsidy.
|
||||
typedef uint16 StoryPageID; ///< The ID of a story page.
|
||||
typedef uint16 StoryPageElementID; ///< The ID of a story page element.
|
||||
typedef uint32 TileIndex; ///< The ID of a tile (just named differently).
|
||||
typedef uint16 TownID; ///< The ID of a town.
|
||||
typedef uint32 VehicleID; ///< The ID of a vehicle.
|
||||
|
29
src/script/api/template/template_story_page.hpp.sq
Normal file
29
src/script/api/template/template_story_page.hpp.sq
Normal file
@@ -0,0 +1,29 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
|
||||
|
||||
#include "../script_story_page.hpp"
|
||||
|
||||
namespace SQConvert {
|
||||
/* Allow enums to be used as Squirrel parameters */
|
||||
template <> inline ScriptStoryPage::StoryPageID GetParam(ForceType<ScriptStoryPage::StoryPageID>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStoryPage::StoryPageID)tmp; }
|
||||
template <> inline int Return<ScriptStoryPage::StoryPageID>(HSQUIRRELVM vm, ScriptStoryPage::StoryPageID res) { sq_pushinteger(vm, (int32)res); return 1; }
|
||||
template <> inline ScriptStoryPage::StoryPageElementID GetParam(ForceType<ScriptStoryPage::StoryPageElementID>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStoryPage::StoryPageElementID)tmp; }
|
||||
template <> inline int Return<ScriptStoryPage::StoryPageElementID>(HSQUIRRELVM vm, ScriptStoryPage::StoryPageElementID res) { sq_pushinteger(vm, (int32)res); return 1; }
|
||||
template <> inline ScriptStoryPage::StoryPageElementType GetParam(ForceType<ScriptStoryPage::StoryPageElementType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptStoryPage::StoryPageElementType)tmp; }
|
||||
template <> inline int Return<ScriptStoryPage::StoryPageElementType>(HSQUIRRELVM vm, ScriptStoryPage::StoryPageElementType res) { sq_pushinteger(vm, (int32)res); return 1; }
|
||||
|
||||
/* Allow ScriptStoryPage to be used as Squirrel parameter */
|
||||
template <> inline ScriptStoryPage *GetParam(ForceType<ScriptStoryPage *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStoryPage *)instance; }
|
||||
template <> inline ScriptStoryPage &GetParam(ForceType<ScriptStoryPage &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStoryPage *)instance; }
|
||||
template <> inline const ScriptStoryPage *GetParam(ForceType<const ScriptStoryPage *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptStoryPage *)instance; }
|
||||
template <> inline const ScriptStoryPage &GetParam(ForceType<const ScriptStoryPage &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptStoryPage *)instance; }
|
||||
template <> inline int Return<ScriptStoryPage *>(HSQUIRRELVM vm, ScriptStoryPage *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "StoryPage", res, NULL, DefSQDestructorCallback<ScriptStoryPage>, true); return 1; }
|
||||
} // namespace SQConvert
|
@@ -275,6 +275,16 @@ void ScriptInstance::CollectGarbage() const
|
||||
instance->engine->InsertResult(ScriptObject::GetNewGoalID());
|
||||
}
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturnStoryPageID(ScriptInstance *instance)
|
||||
{
|
||||
instance->engine->InsertResult(ScriptObject::GetNewStoryPageID());
|
||||
}
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturnStoryPageElementID(ScriptInstance *instance)
|
||||
{
|
||||
instance->engine->InsertResult(ScriptObject::GetNewStoryPageElementID());
|
||||
}
|
||||
|
||||
ScriptStorage *ScriptInstance::GetStorage()
|
||||
{
|
||||
return this->storage;
|
||||
|
@@ -107,6 +107,16 @@ public:
|
||||
*/
|
||||
static void DoCommandReturnGoalID(ScriptInstance *instance);
|
||||
|
||||
/**
|
||||
* Return a StoryPageID reply for a DoCommand.
|
||||
*/
|
||||
static void DoCommandReturnStoryPageID(ScriptInstance *instance);
|
||||
|
||||
/**
|
||||
* Return a StoryPageElementID reply for a DoCommand.
|
||||
*/
|
||||
static void DoCommandReturnStoryPageElementID(ScriptInstance *instance);
|
||||
|
||||
/**
|
||||
* Get the controller attached to the instance.
|
||||
*/
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include "../road_type.h"
|
||||
#include "../group.h"
|
||||
#include "../goal_type.h"
|
||||
#include "../story_type.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
#include <vector>
|
||||
@@ -49,6 +50,8 @@ private:
|
||||
SignID new_sign_id; ///< The ID of the new Sign.
|
||||
GroupID new_group_id; ///< The ID of the new Group.
|
||||
GoalID new_goal_id; ///< The ID of the new Goal.
|
||||
StoryPageID new_story_page_id; ///< The ID of the new StoryPage.
|
||||
StoryPageID new_story_page_element_id; ///< The ID of the new StoryPageElement.
|
||||
|
||||
std::vector<int> callback_value; ///< The values which need to survive a callback.
|
||||
|
||||
|
Reference in New Issue
Block a user