Class NWindowManagerComponent

java.lang.Object
org.ngengine.gui.win.NWindowManagerComponent
All Implemented Interfaces:
Component<Object>, Fragment, GuiViewPortFragment

public class NWindowManagerComponent extends Object implements Component<Object>, GuiViewPortFragment
  • Constructor Details

    • NWindowManagerComponent

      public NWindowManagerComponent()
  • Method Details

    • onAttached

      public void onAttached(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider)
      Description copied from interface: Component
      Called immediately when the component is attached to a ComponentManager and a Runner.

      This method can be overridden to perform initialization tasks when the component is attached.

      Specified by:
      onAttached in interface Component<Object>
      Parameters:
      mng - the ComponentManager to which this component is attached
      runner - the Runner associated with this component
      dataStoreProvider - the DataStoreProvider for accessing shared data
    • getDataStoreProvider

      public DataStoreProvider getDataStoreProvider()
    • receiveGuiViewPort

      public void receiveGuiViewPort(ViewPort vp)
      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 interface GuiViewPortFragment
      Parameters:
      vp - the ViewPort instance
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • runInThread

      public <T> void runInThread(Callable<T> r, BiConsumer<T,Throwable> callback)
    • runInThread

      public void runInThread(Runnable r)
    • showWindow

      public <T extends NWindow<?>> Runnable showWindow(Class<T> windowClass)
      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 show
      callback - 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

      public <T extends NWindow<?>> Runnable showWindow(Class<T> windowClass, Object args)
      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 show
      args - 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 show
      args - the arguments to pass to the window, can be null
      callback - 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

      public void showFatalError(Throwable exc)
    • showFatalError

      public void showFatalError(Throwable exc, BiConsumer<NErrorWindow,Throwable> callback)
    • showToast

      public void showToast(Throwable exc)
    • showToast

      public void showToast(Throwable exc, BiConsumer<NToast,Throwable> callback)
    • showToast

      public void showToast(Throwable exc, Duration duration)
    • showToast

      public void showToast(Throwable exc, Duration duration, BiConsumer<NToast,Throwable> callback)
    • showToast

      public void showToast(NToast.ToastType type, String message)
    • showToast

      public void showToast(NToast.ToastType type, String message, BiConsumer<NToast,Throwable> callback)
    • showToast

      public void showToast(NToast.ToastType type, String message, Duration duration)
    • 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 interface Component<Object>
      Parameters:
      mng - - the ComponentManager to which this component is attached
      runner - - the Runner that executes the logic
      dataStoreProvider - - the DataStoreProvider for storing and retrieving data and caches
      firstTime - - whether this is the first time the component is being enabled
      slot - - an argument that can be passed when enabling this component, can be null
    • onDisable

      public void onDisable(ComponentManager mng, Runner runner, DataStoreProvider dataStoreProvider)
      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
      is not implemented, this method should take care of cleaning up all resources to prevent leaks.

      It is always called before an enabled component is detached from the ComponentManager.

      Specified by:
      onDisable in interface Component<Object>
      Parameters:
      mng -
      runner -
      dataStoreProvider -
    • updateGuiViewPort

      public void updateGuiViewPort(ViewPort vp, float tpf)
      Specified by:
      updateGuiViewPort in interface GuiViewPortFragment