From ec06a9ca4b4e96d45c0be8847c2b8a538827d020 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 10 May 2020 18:06:31 +0100 Subject: [PATCH] Add plugin API for showing an error message (#11706) --- distribution/openrct2.d.ts | 7 +++++++ src/openrct2-ui/scripting/ScUi.hpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index d8f8380026..5350003619 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -945,6 +945,13 @@ declare global { closeWindows(classification: string, id?: number): void; closeAllWindows(): void; + /** + * Show a red error box. + * @param title The title / first line of the box. + * @param message The message / second line of the box. + */ + showError(title: string, message: string): void; + /** * Shows a text input prompt and calls the given callback when entered. * @param desc The parameters for the text input window. diff --git a/src/openrct2-ui/scripting/ScUi.hpp b/src/openrct2-ui/scripting/ScUi.hpp index 2c7c2b6653..931037a23e 100644 --- a/src/openrct2-ui/scripting/ScUi.hpp +++ b/src/openrct2-ui/scripting/ScUi.hpp @@ -181,6 +181,11 @@ namespace OpenRCT2::Scripting return {}; } + void showError(const std::string& title, const std::string& message) + { + window_error_open(title, message); + } + void showTextInput(const DukValue& desc) { try @@ -230,6 +235,7 @@ namespace OpenRCT2::Scripting dukglue_register_method(ctx, &ScUi::closeWindows, "closeWindows"); dukglue_register_method(ctx, &ScUi::closeAllWindows, "closeAllWindows"); dukglue_register_method(ctx, &ScUi::getWindow, "getWindow"); + dukglue_register_method(ctx, &ScUi::showError, "showError"); dukglue_register_method(ctx, &ScUi::showTextInput, "showTextInput"); dukglue_register_method(ctx, &ScUi::activateTool, "activateTool"); dukglue_register_method(ctx, &ScUi::registerMenuItem, "registerMenuItem");