Tweak the mechanics for showing and rendering lua screens.

- Place new screens below any dismissed ones on top.
- When asked to render a dismissed lua screen, call render() on its
  parent to avoid producing a black screen frame when unlucky.
develop
Alexander Gavrilov 2012-10-25 12:09:39 +04:00
parent 2d83b4fa39
commit a1dd31aab3
3 changed files with 13 additions and 9 deletions

@ -513,17 +513,18 @@ function Screen:sendInputToParent(...)
end
end
function Screen:show(below)
function Screen:show(parent)
if self._native then
error("This screen is already on display")
end
self:onAboutToShow(below)
if not dscreen.show(self, below) then
parent = parent or dfhack.gui.getCurViewscreen(true)
self:onAboutToShow(parent)
if not dscreen.show(self, parent.child) then
error('Could not show screen')
end
end
function Screen:onAboutToShow()
function Screen:onAboutToShow(parent)
end
function Screen:onShow()

@ -373,10 +373,8 @@ function DwarfOverlay:simulateCursorMovement(keys, anchor)
end
end
function DwarfOverlay:onAboutToShow(below)
local screen = dfhack.gui.getCurViewscreen()
if below then screen = below.parent end
if not df.viewscreen_dwarfmodest:is_instance(screen) then
function DwarfOverlay:onAboutToShow(parent)
if not df.viewscreen_dwarfmodest:is_instance(parent) then
error("This screen requires the main dwarfmode view")
end
end

@ -639,7 +639,12 @@ dfhack_lua_viewscreen::~dfhack_lua_viewscreen()
void dfhack_lua_viewscreen::render()
{
if (Screen::isDismissed(this)) return;
if (Screen::isDismissed(this))
{
if (parent)
parent->render();
return;
}
dfhack_viewscreen::render();