diff --git a/LUA_API.rst b/LUA_API.rst index 76f6454f4..49e205235 100644 --- a/LUA_API.rst +++ b/LUA_API.rst @@ -724,15 +724,20 @@ can be omitted. Gui module ---------- -* ``dfhack.gui.getCurViewscreen()`` +* ``dfhack.gui.getCurViewscreen([skip_dismissed])`` - Returns the viewscreen that is current in the core. + Returns the topmost viewscreen. If ``skip_dismissed`` is *true*, + ignores screens already marked to be removed. * ``dfhack.gui.getFocusString(viewscreen)`` Returns a string representation of the current focus position in the ui. The string has a "screen/foo/bar/baz..." format. +* ``dfhack.gui.getCurFocus([skip_dismissed])`` + + Returns the focus string of the current viewscreen. + * ``dfhack.gui.getSelectedWorkshopJob([silent])`` When a job is selected in *'q'* mode, returns the job, else @@ -1291,9 +1296,10 @@ Screens are managed with the following functions: Displays the given screen, possibly placing it below a different one. The screen must not be already shown. Returns *true* if success. -* ``dfhack.screen.dismiss(screen)`` +* ``dfhack.screen.dismiss(screen[,to_first])`` Marks the screen to be removed when the game enters its event loop. + If ``to_first`` is *true*, all screens up to the first one will be deleted. * ``dfhack.screen.isDismissed(screen)`` @@ -1312,10 +1318,22 @@ Supported callbacks and fields are: Initialized by ``show`` with a reference to the backing viewscreen object, and removed again when the object is deleted. +* ``function screen:onShow()`` + + Called by ``dfhack.screen.show`` if successful. + +* ``function screen:onDismiss()`` + + Called by ``dfhack.screen.dismiss`` if successful. + * ``function screen:onDestroy()`` Called from the destructor when the viewscreen is deleted. +* ``function screen:onResize(w, h)`` + + Called before ``onRender`` or ``onIdle`` when the window size has changed. + * ``function screen:onRender()`` Called when the viewscreen should paint itself. This is the only context diff --git a/Lua API.html b/Lua API.html index c4ab9c8c4..15f1d89cb 100644 --- a/Lua API.html +++ b/Lua API.html @@ -987,13 +987,17 @@ can be omitted.
dfhack.gui.getCurViewscreen()
-Returns the viewscreen that is current in the core.
+dfhack.gui.getCurViewscreen([skip_dismissed])
+Returns the topmost viewscreen. If skip_dismissed is true, +ignores screens already marked to be removed.
dfhack.gui.getFocusString(viewscreen)
Returns a string representation of the current focus position in the ui. The string has a "screen/foo/bar/baz..." format.
dfhack.gui.getCurFocus([skip_dismissed])
+Returns the focus string of the current viewscreen.
+dfhack.gui.getSelectedWorkshopJob([silent])
When a job is selected in 'q' mode, returns the job, else prints error unless silent and returns nil.
@@ -1465,8 +1469,9 @@ interface screens added by dfhack should bear the "DFHack" signature.<Displays the given screen, possibly placing it below a different one. The screen must not be already shown. Returns true if success.
dfhack.screen.dismiss(screen)
-Marks the screen to be removed when the game enters its event loop.
+dfhack.screen.dismiss(screen[,to_first])
+Marks the screen to be removed when the game enters its event loop. +If to_first is true, all screens up to the first one will be deleted.
dfhack.screen.isDismissed(screen)
Checks if the screen is already marked for removal.
@@ -1482,9 +1487,18 @@ that delegates all processing to methods stored in that table.Initialized by show with a reference to the backing viewscreen object, and removed again when the object is deleted.
function screen:onShow()
+Called by dfhack.screen.show if successful.
+function screen:onDismiss()
+Called by dfhack.screen.dismiss if successful.
+function screen:onDestroy()
Called from the destructor when the viewscreen is deleted.
function screen:onResize(w, h)
+Called before onRender or onIdle when the window size has changed.
+function screen:onRender()
Called when the viewscreen should paint itself. This is the only context where the above painting functions work correctly.
diff --git a/library/Core.cpp b/library/Core.cpp index a61fef4e9..6a0dea7c2 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1260,7 +1260,7 @@ bool Core::ncurses_wgetch(int in, int & out) // FIXME: copypasta, push into a method! if(df::global::ui && df::global::gview) { - df::viewscreen * ws = Gui::GetCurrentScreen(); + df::viewscreen * ws = Gui::getCurViewscreen(); if (strict_virtual_cast