mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #14373: [Plugin] Let ui.activateTool(...) return a Tool object
This commit is contained in:
parent
713bb09990
commit
8ae6d13fa4
|
@ -2327,11 +2327,11 @@ declare global {
|
|||
* The current tilt of the car in the X/Y axis.
|
||||
*/
|
||||
bankRotation: number;
|
||||
|
||||
/**
|
||||
* Whether the car sprite is reversed or not.
|
||||
*/
|
||||
isReversed: boolean;
|
||||
|
||||
/**
|
||||
* Whether the car sprite is reversed or not.
|
||||
*/
|
||||
isReversed: boolean;
|
||||
|
||||
/**
|
||||
* The colour of the car.
|
||||
|
@ -3511,8 +3511,9 @@ declare global {
|
|||
* Begins a new tool session. The cursor will change to the style specified by the
|
||||
* given tool descriptor and cursor events will be provided.
|
||||
* @param tool The properties and event handlers for the tool.
|
||||
* @returns The tool that was activated.
|
||||
*/
|
||||
activateTool(tool: ToolDesc): void;
|
||||
activateTool(tool: ToolDesc): Tool;
|
||||
|
||||
registerMenuItem(text: string, callback: () => void): void;
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
}
|
||||
|
||||
void InitialiseCustomTool(ScriptEngine& scriptEngine, const DukValue& dukValue)
|
||||
bool InitialiseCustomTool(ScriptEngine& scriptEngine, const DukValue& dukValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -271,6 +271,7 @@ namespace OpenRCT2::Scripting
|
|||
ToolSet(*toolbarWindow, widgetIndex, static_cast<Tool>(customTool.Cursor));
|
||||
ActiveCustomTool = std::move(customTool);
|
||||
ActiveCustomTool->Start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,6 +279,7 @@ namespace OpenRCT2::Scripting
|
|||
{
|
||||
duk_error(scriptEngine.GetContext(), DUK_ERR_ERROR, "Invalid parameters.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace OpenRCT2::Scripting
|
|||
extern std::vector<std::unique_ptr<CustomShortcut>> CustomShortcuts;
|
||||
|
||||
void InitialiseCustomMenuItems(ScriptEngine& scriptEngine);
|
||||
void InitialiseCustomTool(ScriptEngine& scriptEngine, const DukValue& dukValue);
|
||||
bool InitialiseCustomTool(ScriptEngine& scriptEngine, const DukValue& dukValue);
|
||||
|
||||
template<> DukValue ToDuk(duk_context* ctx, const CursorID& value);
|
||||
template<> CursorID FromDuk(const DukValue& s);
|
||||
|
|
|
@ -312,9 +312,12 @@ namespace OpenRCT2::Scripting
|
|||
false);
|
||||
}
|
||||
|
||||
void activateTool(const DukValue& desc)
|
||||
std::shared_ptr<ScTool> activateTool(const DukValue& desc)
|
||||
{
|
||||
InitialiseCustomTool(_scriptEngine, desc);
|
||||
if (InitialiseCustomTool(_scriptEngine, desc))
|
||||
return tool_get();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void registerMenuItem(std::string text, DukValue callback)
|
||||
|
|
Loading…
Reference in New Issue