Class SceneManager

java.lang.Object
com.victorvalentim.zividomelive.SceneManager

public class SceneManager extends Object
Maintains an identity-ordered collection of scenes and switches their activation.

A detached manager selects its first registered scene but does not invoke lifecycle methods. Attaching it through ziviDomeLive.setSceneManager(SceneManager) installs the facade lifecycle and activates the selection with fresh SceneServices. Scene membership uses Java object identity (==), not Object.equals(Object).

Mutation methods are intended for the Processing thread and are not thread-safe.

API stability: Stable.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty, detached scene manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Activates a scene by instance; registers it first if it is not in the manager yet.
    void
    Disposes the active scene, clears all registrations, and resets the manager.
    boolean
    Returns true when the manager already contains the provided scene instance.
    Returns the current scene.
    int
    Returns the total number of registered scenes.
    void
    Switches to the next scene in registration order, wrapping at the end.
    void
    Switches to the previous scene in registration order, wrapping at the beginning.
    void
    Registers a scene by instance identity.
    boolean
    Performs one complete dispose/setup cycle for the active scene.
    void
    Selects and activates the scene at the supplied registration index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SceneManager

      public SceneManager()
      Creates an empty, detached scene manager.
  • Method Details

    • registerScene

      public void registerScene(Scene scene)
      Registers a scene by instance identity.

      The first registration becomes the selected scene. It is set up immediately only when this manager is already attached to a facade; otherwise setup begins when attached.

      Parameters:
      scene - scene to register; null and duplicate instances are ignored
    • activateScene

      public void activateScene(Scene scene)
      Activates a scene by instance; registers it first if it is not in the manager yet.
      Parameters:
      scene - scene instance to activate; null is ignored
    • containsScene

      public boolean containsScene(Scene scene)
      Returns true when the manager already contains the provided scene instance.
      Parameters:
      scene - scene to check
      Returns:
      true if that exact scene instance is already managed
    • getSceneCount

      public int getSceneCount()
      Returns the total number of registered scenes.
      Returns:
      the number of scenes
    • nextScene

      public void nextScene()
      Switches to the next scene in registration order, wrapping at the end.
    • previousScene

      public void previousScene()
      Switches to the previous scene in registration order, wrapping at the beginning.
    • getCurrentScene

      public Scene getCurrentScene()
      Returns the current scene.
      Returns:
      selected scene, or null when no scene is registered
    • setCurrentSceneIndex

      public void setCurrentSceneIndex(int index)
      Selects and activates the scene at the supplied registration index.
      Parameters:
      index - zero-based registration index; invalid values are ignored
    • reloadCurrentScene

      public boolean reloadCurrentScene()
      Performs one complete dispose/setup cycle for the active scene.

      This method does not defer work. From scene code, prefer SceneServices.requestReload(), which schedules the cycle at a safe frame boundary.

      Returns:
      true when an attached, active scene was reloaded
    • clearScenes

      public void clearScenes()
      Disposes the active scene, clears all registrations, and resets the manager.

      Inactive scenes have already been disposed when they were deactivated. Scenes that were only registered and never activated have not entered their setup/dispose lifecycle.