Class NWindowManagerComponent
- All Implemented Interfaces:
Component<Object>
,Fragment
,GuiViewPortFragment
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
closeAll()
void
void
int
int
getWidth()
void
onAttached
(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider) Called immediately when the component is attached to aComponentManager
and aRunner
.void
onDisable
(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider) Called when the component is disabled.void
onEnable
(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider, boolean firstTime, Object slot) Called when the component is enabled.void
Receive a GUI ViewPort instance as soon as it is available.void
<T> void
runInThread
(Callable<T> r, BiConsumer<T, Throwable> callback) void
showFatalError
(Throwable exc) void
showFatalError
(Throwable exc, BiConsumer<NErrorWindow, Throwable> callback) void
void
void
void
showToast
(Throwable exc, BiConsumer<NToast, Throwable> callback) void
showToast
(NToast.ToastType type, String message) void
showToast
(NToast.ToastType type, String message, Duration duration) void
showToast
(NToast.ToastType type, String message, Duration duration, BiConsumer<NToast, Throwable> callback) void
showToast
(NToast.ToastType type, String message, BiConsumer<NToast, Throwable> callback) showWindow
(Class<T> windowClass) Shows a window of the specified class with no arguments and no callback and returns a closer function.showWindow
(Class<T> windowClass, Object args) Shows a window of the specified class with the given arguments and returns a closer function.showWindow
(Class<T> windowClass, Object args, BiConsumer<T, Throwable> callback) Shows a window of the specified class with the given arguments and a callback and returns a closer function.showWindow
(Class<T> windowClass, BiConsumer<T, Throwable> callback) Shows a window of the specified class with the given arguments and a callback and returns a closer function.void
updateGuiViewPort
(ViewPort vp, float tpf) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ngengine.components.Component
getId, getSlot, onDetached, onNudge
Methods inherited from interface org.ngengine.components.fragments.GuiViewPortFragment
getGuiNode
-
Constructor Details
-
NWindowManagerComponent
public NWindowManagerComponent()
-
-
Method Details
-
onAttached
Description copied from interface:Component
Called immediately when the component is attached to aComponentManager
and aRunner
.This method can be overridden to perform initialization tasks when the component is attached.
- Specified by:
onAttached
in interfaceComponent<Object>
- Parameters:
mng
- the ComponentManager to which this component is attachedrunner
- the Runner associated with this componentdataStoreProvider
- the DataStoreProvider for accessing shared data
-
getDataStoreProvider
-
receiveGuiViewPort
Description copied from interface:GuiViewPortFragment
Receive a GUI ViewPort instance as soon as it is available. The reference to the GUI ViewPort can be stored and- Specified by:
receiveGuiViewPort
in interfaceGuiViewPortFragment
- Parameters:
vp
- the ViewPort instance
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
runInThread
-
runInThread
-
showWindow
Shows a window of the specified class with no arguments and no callback and returns a closer function.- Type Parameters:
T
- the class of the window- Parameters:
windowClass
- the class of the window to show- Returns:
- a Runnable that can be used to close the window
-
showWindow
public <T extends NWindow<?>> Runnable showWindow(Class<T> windowClass, BiConsumer<T, Throwable> callback) Shows a window of the specified class with the given arguments and a callback and returns a closer function.- Type Parameters:
T
- the class of the window- Parameters:
windowClass
- the class of the window to showcallback
- a callback to be called when the window is shown or if an error occurs, can be null- Returns:
- a Runnable that can be used to close the window
-
showWindow
Shows a window of the specified class with the given arguments and returns a closer function.- Type Parameters:
T
- the class of the window- Parameters:
windowClass
- the class of the window to showargs
- the arguments to pass to the window, can be null- Returns:
- a Runnable that can be used to close the window
-
showWindow
public <T extends NWindow> Runnable showWindow(Class<T> windowClass, Object args, BiConsumer<T, Throwable> callback) Shows a window of the specified class with the given arguments and a callback and returns a closer function.- Type Parameters:
T
- the class of the window- Parameters:
windowClass
- the class of the window to showargs
- the arguments to pass to the window, can be nullcallback
- a callback to be called when the window is shown or if an error occurs, can be null- Returns:
- a Runnable that can be used to close the window
-
showFatalError
-
showFatalError
-
showToast
-
showToast
-
showToast
-
showToast
-
showToast
-
showToast
-
showToast
-
showToast
public void showToast(NToast.ToastType type, String message, Duration duration, BiConsumer<NToast, Throwable> callback) -
closeAllWindows
public void closeAllWindows() -
closeAllToasts
public void closeAllToasts() -
closeAll
public void closeAll() -
onEnable
public void onEnable(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider, boolean firstTime, Object slot) Description copied from interface:Component
Called when the component is enabled. This is the most important method of the component lifecycle, where the component's main logic is implemented.This method is called when the component is enabled, all its dependencies are satisfied, the fragments are initialized, and the resources are loaded.
- Specified by:
onEnable
in interfaceComponent<Object>
- Parameters:
mng
- - the ComponentManager to which this component is attachedrunner
- - the Runner that executes the logicdataStoreProvider
- - the DataStoreProvider for storing and retrieving data and cachesfirstTime
- - whether this is the first time the component is being enabledslot
- - an argument that can be passed when enabling this component, can be null
-
onDisable
Description copied from interface:Component
Called when the component is disabled.This should undo anything that was done in
Component.onEnable(org.ngengine.components.ComponentManager, org.ngengine.runner.Runner, org.ngengine.store.DataStoreProvider, boolean, T)
and reset the component state to allow future re-enabling.This method is called when the component is explicitly disabled or when one of its dependencies is disabled.
If $
invalid reference
#onDetach
It is always called before an enabled component is detached from the
ComponentManager
. -
updateGuiViewPort
- Specified by:
updateGuiViewPort
in interfaceGuiViewPortFragment
-