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
end end
function Screen:show(below) function Screen:show(parent)
if self._native then if self._native then
error("This screen is already on display") error("This screen is already on display")
end end
self:onAboutToShow(below) parent = parent or dfhack.gui.getCurViewscreen(true)
if not dscreen.show(self, below) then self:onAboutToShow(parent)
if not dscreen.show(self, parent.child) then
error('Could not show screen') error('Could not show screen')
end end
end end
function Screen:onAboutToShow() function Screen:onAboutToShow(parent)
end end
function Screen:onShow() function Screen:onShow()

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

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