mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-29 09:44:52 +01:00
Move ClearAction, GameAction, ScenarioSetSettingAction into GameActions (#25045)
This commit is contained in:
@@ -1195,7 +1195,7 @@ ExpenditureType ScriptEngine::StringToExpenditureType(std::string_view expenditu
|
||||
return ExpenditureType::count;
|
||||
}
|
||||
|
||||
DukValue ScriptEngine::GameActionResultToDuk(const GameAction& action, const GameActions::Result& result)
|
||||
DukValue ScriptEngine::GameActionResultToDuk(const GameActions::GameAction& action, const GameActions::Result& result)
|
||||
{
|
||||
DukStackFrame frame(_context);
|
||||
DukObject obj(_context);
|
||||
@@ -1298,7 +1298,7 @@ void ScriptEngine::RemoveCustomGameActions(const std::shared_ptr<Plugin>& plugin
|
||||
}
|
||||
}
|
||||
|
||||
class DukToGameActionParameterVisitor : public GameActionParameterVisitor
|
||||
class DukToGameActionParameterVisitor : public GameActions::GameActionParameterVisitor
|
||||
{
|
||||
private:
|
||||
DukValue _dukValue;
|
||||
@@ -1325,7 +1325,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class DukFromGameActionParameterVisitor : public GameActionParameterVisitor
|
||||
class DukFromGameActionParameterVisitor : public GameActions::GameActionParameterVisitor
|
||||
{
|
||||
private:
|
||||
DukObject& _dukObject;
|
||||
@@ -1451,7 +1451,7 @@ static std::string GetActionName(GameCommand commandId)
|
||||
return {};
|
||||
}
|
||||
|
||||
static std::unique_ptr<GameAction> CreateGameActionFromActionId(const std::string& name)
|
||||
static std::unique_ptr<GameActions::GameAction> CreateGameActionFromActionId(const std::string& name)
|
||||
{
|
||||
auto result = ActionNameToType.find(name);
|
||||
if (result != ActionNameToType.end())
|
||||
@@ -1461,7 +1461,7 @@ static std::unique_ptr<GameAction> CreateGameActionFromActionId(const std::strin
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ScriptEngine::RunGameActionHooks(const GameAction& action, GameActions::Result& result, bool isExecute)
|
||||
void ScriptEngine::RunGameActionHooks(const GameActions::GameAction& action, GameActions::Result& result, bool isExecute)
|
||||
{
|
||||
DukStackFrame frame(_context);
|
||||
|
||||
@@ -1497,8 +1497,8 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, GameActions::Res
|
||||
|
||||
DukObject args(_context);
|
||||
DukFromGameActionParameterVisitor visitor(args);
|
||||
const_cast<GameAction&>(action).AcceptParameters(visitor);
|
||||
const_cast<GameAction&>(action).AcceptFlags(visitor);
|
||||
const_cast<GameActions::GameAction&>(action).AcceptParameters(visitor);
|
||||
const_cast<GameActions::GameAction&>(action).AcceptFlags(visitor);
|
||||
obj.Set("args", args.Take());
|
||||
}
|
||||
|
||||
@@ -1530,7 +1530,7 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, GameActions::Res
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<GameAction> ScriptEngine::CreateGameAction(
|
||||
std::unique_ptr<GameActions::GameAction> ScriptEngine::CreateGameAction(
|
||||
const std::string& actionid, const DukValue& args, const std::string& pluginName)
|
||||
{
|
||||
auto action = CreateGameActionFromActionId(actionid);
|
||||
|
||||
@@ -31,11 +31,12 @@
|
||||
struct duk_hthread;
|
||||
typedef struct duk_hthread duk_context;
|
||||
|
||||
class GameAction;
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
class GameAction;
|
||||
class Result;
|
||||
}
|
||||
} // namespace OpenRCT2::GameActions
|
||||
|
||||
class FileWatcher;
|
||||
class InteractiveConsole;
|
||||
|
||||
@@ -252,10 +253,10 @@ namespace OpenRCT2::Scripting
|
||||
const GameActions::CustomAction& action, bool isExecute);
|
||||
bool RegisterCustomAction(
|
||||
const std::shared_ptr<Plugin>& plugin, std::string_view action, const DukValue& query, const DukValue& execute);
|
||||
void RunGameActionHooks(const GameAction& action, GameActions::Result& result, bool isExecute);
|
||||
[[nodiscard]] std::unique_ptr<GameAction> CreateGameAction(
|
||||
void RunGameActionHooks(const GameActions::GameAction& action, GameActions::Result& result, bool isExecute);
|
||||
[[nodiscard]] std::unique_ptr<GameActions::GameAction> CreateGameAction(
|
||||
const std::string& actionid, const DukValue& args, const std::string& pluginName);
|
||||
[[nodiscard]] DukValue GameActionResultToDuk(const GameAction& action, const GameActions::Result& result);
|
||||
[[nodiscard]] DukValue GameActionResultToDuk(const GameActions::GameAction& action, const GameActions::Result& result);
|
||||
|
||||
void SaveSharedStorage();
|
||||
|
||||
|
||||
@@ -334,7 +334,8 @@ namespace OpenRCT2::Scripting
|
||||
if (isExecute)
|
||||
{
|
||||
action->SetCallback(
|
||||
[this, plugin, callback](const GameAction* act, const GameActions::Result* res) -> void {
|
||||
[this, plugin,
|
||||
callback](const GameActions::GameAction* act, const GameActions::Result* res) -> void {
|
||||
HandleGameActionResult(plugin, *act, *res, callback);
|
||||
});
|
||||
GameActions::Execute(action.get());
|
||||
@@ -357,7 +358,7 @@ namespace OpenRCT2::Scripting
|
||||
}
|
||||
|
||||
void HandleGameActionResult(
|
||||
const std::shared_ptr<Plugin>& plugin, const GameAction& action, const GameActions::Result& res,
|
||||
const std::shared_ptr<Plugin>& plugin, const GameActions::GameAction& action, const GameActions::Result& res,
|
||||
const DukValue& callback)
|
||||
{
|
||||
if (callback.is_function())
|
||||
|
||||
Reference in New Issue
Block a user