mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-14 01:19:59 +00:00
Merge branch 'windowvisiblelua' into 'master'
lua - add binding to check window visibility Closes #8355 See merge request OpenMW/openmw!4543
This commit is contained in:
commit
3dd5d83865
@ -384,6 +384,7 @@ namespace MWBase
|
||||
// Used in Lua bindings
|
||||
virtual const std::vector<MWGui::GuiMode>& getGuiModeStack() const = 0;
|
||||
virtual void setDisabledByLua(std::string_view windowId, bool disabled) = 0;
|
||||
virtual bool isWindowVisible(std::string_view windowId) const = 0;
|
||||
virtual std::vector<std::string_view> getAllWindowIds() const = 0;
|
||||
virtual std::vector<std::string_view> getAllowedWindowIds(MWGui::GuiMode mode) const = 0;
|
||||
};
|
||||
|
@ -2402,6 +2402,14 @@ namespace MWGui
|
||||
updateVisible();
|
||||
}
|
||||
|
||||
bool WindowManager::isWindowVisible(std::string_view windowId) const
|
||||
{
|
||||
auto it = mLuaIdToWindow.find(windowId);
|
||||
if (it == mLuaIdToWindow.end())
|
||||
throw std::logic_error("Invalid window name: " + std::string(windowId));
|
||||
return it->second->isVisible();
|
||||
}
|
||||
|
||||
std::vector<std::string_view> WindowManager::getAllWindowIds() const
|
||||
{
|
||||
std::vector<std::string_view> res;
|
||||
|
@ -390,6 +390,7 @@ namespace MWGui
|
||||
// Used in Lua bindings
|
||||
const std::vector<GuiMode>& getGuiModeStack() const override { return mGuiModes; }
|
||||
void setDisabledByLua(std::string_view windowId, bool disabled) override;
|
||||
bool isWindowVisible(std::string_view windowId) const override;
|
||||
std::vector<std::string_view> getAllWindowIds() const override;
|
||||
std::vector<std::string_view> getAllowedWindowIds(GuiMode mode) const override;
|
||||
|
||||
|
@ -291,6 +291,8 @@ namespace MWLua
|
||||
luaManager->addAction(
|
||||
[=, window = std::move(window)]() { windowManager->setDisabledByLua(window, disabled); });
|
||||
};
|
||||
api["_isWindowVisible"]
|
||||
= [windowManager](std::string_view window) { return windowManager->isWindowVisible(window); };
|
||||
|
||||
// TODO
|
||||
// api["_showMouseCursor"] = [](bool) {};
|
||||
|
@ -155,6 +155,13 @@ local function onUiModeChangedEvent(data)
|
||||
end
|
||||
end
|
||||
|
||||
local function isWindowVisible(windowName)
|
||||
if replacedWindows[windowName] then
|
||||
return replacedWindows[windowName].visible
|
||||
end
|
||||
return ui._isWindowVisible(windowName)
|
||||
end
|
||||
|
||||
return {
|
||||
interfaceName = 'UI',
|
||||
---
|
||||
@ -239,6 +246,13 @@ return {
|
||||
-- @return #boolean
|
||||
isHudVisible = function() return ui._isHudVisible() end,
|
||||
|
||||
---
|
||||
-- Returns if the given window is visible or not
|
||||
-- @function [parent=#UI] isWindowVisible
|
||||
-- @param #string windowName
|
||||
-- @return #boolean
|
||||
isWindowVisible = isWindowVisible,
|
||||
|
||||
-- TODO
|
||||
-- registerHudElement = function(name, showFn, hideFn) end,
|
||||
-- showHudElement = function(name, bool) end,
|
||||
|
Loading…
x
Reference in New Issue
Block a user