Rewrite showInteractiveMessage to be more future proof, and hide it behind the UI interface.

This commit is contained in:
Mads Buvik Sandvei 2025-03-19 22:15:05 +01:00
parent 525aac7a15
commit 7943d1147f
3 changed files with 9 additions and 20 deletions

View File

@ -109,13 +109,8 @@ namespace MWLua
luaManager->addUIMessage(message, mode);
};
api["showInteractiveMessage"] = [windowManager](std::string_view message, sol::optional<sol::table> options) {
std::string buttonText = "#{Interface:OK}";
if (options)
{
buttonText = options->get_or<std::string>("buttonText", buttonText);
}
windowManager->interactiveMessageBox(message, { buttonText });
api["_showInteractiveMessage"] = [windowManager](std::string_view message, sol::optional<sol::table>) {
windowManager->interactiveMessageBox(message, { "#{Interface:OK}" });
};
api["CONSOLE_COLOR"] = LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string, Misc::Color>(lua,
{

View File

@ -254,6 +254,13 @@ return {
-- @return #boolean
isWindowVisible = isWindowVisible,
---
-- Shows a message as an interactive message box pausing the game, with a single button with the localized text OK.
-- @function [parent=#UI] showInteractiveMessage
-- @param #string message Message to display
-- @param #table options Options (none yet)
showInteractiveMessage = ui._showInteractiveMessage
-- TODO
-- registerHudElement = function(name, showFn, hideFn) end,
-- showHudElement = function(name, bool) end,

View File

@ -35,19 +35,6 @@
-- @field Flex Aligns widgets in a row or column
-- @field Container Automatically wraps around its contents
---
-- Shows given message as a message box
-- @function [parent=#ui] showInteractiveMessage
-- @param #string msg
-- @param #table options An optional table with additional optional arguments. Can contain:
--
-- * `buttonText` - Changes the text of the button (default: OK (localized))
-- @usage local params = {
-- buttonText="Bene"
-- };
-- ui.showInteractiveMessage("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque quis justo in orci pharetra semper in lobortis tortor. Suspendisse et sapien sapien.", params)
---
-- Shows given message at the bottom of the screen.
-- @function [parent=#ui] showMessage