![]() |
Gorgon Game Engine
|
This class is a Window that manages scenes, allowing swapping, handling input and game loop. More...
Public Member Functions | |
SceneManager () | |
SceneManager (SceneManager &&)=default | |
~SceneManager () | |
void | ActivateKeyboard () |
Moves keyboard input event to the top if there is a layer that accepts keyboard input. More... | |
void | Assume (Scene &scene) |
Assumes the ownership of the the given scene, adding it to the list of scenes. More... | |
auto | begin () |
Returns iterator to the first scene. More... | |
auto | begin () const |
Returns iterator to the first scene. More... | |
void | Deactivate () |
Deactivates all scenes. More... | |
void | DeleteScene (SceneID scene) |
Deletes the given scene, nothing is done if the scene is not found. More... | |
auto | end () |
Returns iterator to the end of scenes. More... | |
auto | end () const |
Returns iterator to the end of scenes. More... | |
Scene & | GetScene (SceneID scene) |
Returns the requested scene. More... | |
int | GetSceneCount () const |
Returns the number of scenes registered. More... | |
template<class S_ , class ... P_> | |
S_ & | NewScene (SceneID id, P_ &&... params) |
Creates a new scene using the given type and parameters. More... | |
SceneManager & | operator= (SceneManager &&)=default |
void | Quit () override |
Quits the scene manager, returning the execution to the point where Run function is called. More... | |
Scene & | Release (SceneID id) |
Releases the ownership of the scene with the given ID, removing it from the manager. More... | |
void | Run () override |
Runs the application by running the active scene, progressing OS events and rendering mechanism. More... | |
bool | SceneExists (SceneID id) const |
Returns if the given scene exists. More... | |
void | Step () override |
Steps the application by running the active scene, progressing OS events and rendering mechanism. More... | |
void | SwitchScene (SceneID scene) |
Switches the current scene to the scene with the given id. More... | |
Window () | |
Empty constructor creates a non-initialized window. More... | |
Window (const FullscreenTag &, const WindowManager::Monitor &monitor, const std::string &name, const std::string &title="") | |
Creates a fullscreen window. More... | |
Window (const FullscreenTag &tag, const std::string &name, const std::string &title="") | |
Creates a fullscreen window. More... | |
Window (const Geometry::Size &size, const char *name, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const Geometry::Size &size, const char *name, const char *title, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const Geometry::Size &size, const std::string &name, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const Geometry::Size &size, const std::string &name, const std::string &title, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const Window &)=delete | |
Copy constructor is not allowed. More... | |
Window (const WindowManager::Monitor &monitor, const Geometry::Size &size, const char *name, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const WindowManager::Monitor &monitor, const Geometry::Size &size, const std::string &name, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const WindowManager::Monitor &monitor, Geometry::Rectangle rect, const std::string &name, const std::string &title, bool allowresize, bool visible) | |
Window (Geometry::Rectangle rect, const char *name, bool allowresize=false, bool visible=true) | |
Creates a new window. More... | |
Window (Geometry::Rectangle rect, const std::string &name, bool allowresize=false, bool visible=true) | |
Creates a new window. More... | |
Window (Window &&other) | |
Move constructor. More... | |
![]() | |
Window () | |
Empty constructor creates a non-initialized window. More... | |
Window (const FullscreenTag &, const WindowManager::Monitor &monitor, const std::string &name, const std::string &title="") | |
Creates a fullscreen window. More... | |
Window (const FullscreenTag &tag, const std::string &name, const std::string &title="") | |
Creates a fullscreen window. More... | |
Window (const Geometry::Size &size, const char *name, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const Geometry::Size &size, const char *name, const char *title, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const Geometry::Size &size, const std::string &name, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const Geometry::Size &size, const std::string &name, const std::string &title, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const Window &)=delete | |
Copy constructor is not allowed. More... | |
Window (const WindowManager::Monitor &monitor, const Geometry::Size &size, const char *name, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (const WindowManager::Monitor &monitor, const Geometry::Size &size, const std::string &name, bool allowresize=false, bool visible=true) | |
Creates a new window at the center of the screen. More... | |
Window (Geometry::Rectangle rect, const char *name, bool allowresize=false, bool visible=true) | |
Creates a new window. More... | |
Window (Geometry::Rectangle rect, const std::string &name, bool allowresize=false, bool visible=true) | |
Creates a new window. More... | |
Window (Window &&other) | |
Move constructor. More... | |
~Window () | |
Destroys this window. More... | |
void | activatecontext () |
Activates the GL context of the window. More... | |
void | AllowResize () |
Allows window to be resized by the user. More... | |
void | Center () |
Centers the window to the default monitor. More... | |
void | Center (const WindowManager::Monitor &monitor) |
Centers the window to the given monitor. More... | |
void | Close () |
Closes the window. After this function, any use of this object might fail. More... | |
void | Destroy () |
Destroys this window. More... | |
void | Focus () |
Focuses this window. More... | |
Geometry::Bounds | GetExteriorBounds () const |
Returns the exterior bounding box of the window. More... | |
const WindowManager::Monitor & | GetMonitor () const |
Returns the monitor that the window is currently on. More... | |
Geometry::Point | GetMouseLocation () const |
Returns the mouse location on the window. More... | |
std::string | GetName () const |
Returns the name of the window that is set at creation time. More... | |
Geometry::Point | GetPosition () const |
Returns the current position of the window. More... | |
std::string | GetTitle () const |
Returns the current title of the window. More... | |
virtual void | Hide () override |
Hides this window, may generate Deactivated event. More... | |
void | HidePointer () |
Hides the pointer. More... | |
bool | IsClosed () const |
Whether the window is currently closed and cannot be acted on. More... | |
bool | IsFocused () const |
Returns if this window has the focus. More... | |
bool | IsLeftButtonPressed () const |
Query whether the left mouse button is pressed. More... | |
bool | IsLocalPointer () const |
Returns whether the current pointer is a local pointer. More... | |
bool | IsMaximized () const |
Returns if the window is maximized. More... | |
bool | IsMiddleButtonPressed () const |
Query whether the middle mouse button is pressed. More... | |
bool | IsMinimized () const |
Returns if the window is minimized. More... | |
bool | IsPointerVisible () const |
Returns whether the pointer is visible. More... | |
bool | IsRightButtonPressed () const |
Query whether the right mouse button is pressed. More... | |
virtual bool | IsVisible () const override |
Returns whether this layer is effectively visible. More... | |
bool | IsX1ButtonPressed () const |
Query whether the X1 mouse button is pressed. More... | |
bool | IsX2ButtonPressed () const |
Query whether the X2 mouse button is pressed. More... | |
void | Maximize () |
Maximizes the window to cover the usable area of the screen. More... | |
void | Minimize () |
Minimizes the window. More... | |
void | mouse_down (Geometry::Point location, Input::Mouse::Button button) |
These functions are used internally. More... | |
void | mouse_event (Input::Mouse::EventType event, Geometry::Point location, Input::Mouse::Button button, float amount) |
These functions are used internally. More... | |
void | mouse_location () |
These functions are used internally. More... | |
void | mouse_up (Geometry::Point location, Input::Mouse::Button button) |
These functions are used internally. More... | |
virtual void | Move (const Geometry::Point &position) override |
Moves the window to the given position. More... | |
virtual void | Move (int x, int y) override |
Moves the window to the given position. More... | |
Window & | operator= (Window &&other) |
Moves another window into this one. More... | |
Input::Mouse::Button | PressedButtons () const |
Returns currently pressed buttons. More... | |
void | PreventResize () |
Prevents window to be resized by the user. More... | |
void | processmessages () |
This method is automatically called by the system.Unless its necessary, do not use it. More... | |
virtual void | Render () override |
Renders the contents of the window. More... | |
virtual void | Resize (const Geometry::Size &size) override |
Resizes the window to the given size. More... | |
virtual void | Resize (int width, int height) override |
Resizes the window to the given size. More... | |
void | Restore () |
Restores a minimized or maximized window. More... | |
void | SetIcon (const WindowManager::Icon &icon) |
Changes the icon of the window. More... | |
void | SetTitle (const std::string &title) |
Changes the title of the window to the specified string. More... | |
virtual void | Show () override |
Displays this window, may generate Activated event. More... | |
void | ShowPointer () |
Displays the pointer. More... | |
void | Swap (Window &other) |
Used for move semantics. More... | |
void | SwitchToLocalPointers () |
Removes the operating system pointer and starts using Locally defined pointers. More... | |
void | SwitchToWMPointers () |
Stops showing local pointers and makes window manager pointer visible. More... | |
![]() | |
Layer () | |
Constructor that sets the layer to cover entire parent, no matter how big it is. More... | |
Layer (const Geometry::Bounds &bounds) | |
Initializing constructor. More... | |
Layer (const Geometry::Point &location) | |
Constructor that places the layer to the given location. More... | |
Layer (const Layer &)=delete | |
Copy constructor is disabled. More... | |
Layer (Layer &&other) | |
Move constructor. More... | |
virtual | ~Layer () |
Destructor. More... | |
Layer & | operator= (const Layer &)=delete |
Copy assignment is deleted. More... | |
Layer & | operator= (Layer &&other) |
Move assignment. More... | |
virtual bool | propagate_mouseevent (Input::Mouse::EventType evet, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers) |
Propagates a mouse event. More... | |
void | Swap (Layer &other) |
Swaps two layers, mostly used for move semantics. More... | |
void | Add (Layer &layer) |
Adds the given layer as a child. More... | |
void | Add (Layer *layer) |
Adds the given layer as a child. More... | |
void | setname (std::string value) |
For debugging. More... | |
void | Insert (Layer &layer, long under) |
Inserts the given layer before the given index. More... | |
void | Insert (Layer *layer, long under) |
Inserts the given layer before the given index. More... | |
void | Remove (Layer &layer) |
Removes the given layer. More... | |
void | Remove (Layer *layer) |
Removes the given layer. More... | |
bool | HasParent () const |
Returns whether this layer has a parent. More... | |
virtual Layer & | GetParent () const |
Returns the parent of this layer. More... | |
Layer & | GetTopLevel () const |
Returns the top level layer that contains this layer. More... | |
virtual Geometry::Point | TranslateToTopLevel (Geometry::Point location={0, 0}) const |
Translates the given location to the top level. More... | |
Layer & | GetTopLevel () |
Containers::Collection< Layer >::ConstIterator | begin () const |
An iterator pointing to the start of the children. More... | |
Containers::Collection< Layer >::ConstIterator | end () const |
An iterator pointing to the end of the children. More... | |
Containers::Collection< Layer >::ConstIterator | First () const |
An iterator pointing to the start of the children. More... | |
Containers::Collection< Layer >::ConstIterator | Last () const |
An iterator pointing to the last item of the children. More... | |
void | PlaceBefore (int before) |
Places this layer before the given index. More... | |
void | PlaceToTop () |
Places this layer to the top of the layer stack its in. More... | |
void | PlaceToBottom () |
Places this layer to the bottom of the layer stack. More... | |
int | GetOrder () const |
Gets the current order of the stack. More... | |
void | SetWidth (int width) |
Resizes the layer to the given size. More... | |
void | SetHeight (int height) |
Resizes the layer to the given size. More... | |
void | SetBounds (const Geometry::Bounds &bounds) |
Sets the boundaries of this layer. More... | |
Geometry::Size | GetSize () const |
Returns the size of the layer. More... | |
Geometry::Size | GetCalculatedSize () const |
Returns the size of the layer. More... | |
int | GetWidth () const |
Returns the width of the layer. More... | |
int | GetHeight () const |
Returns the height of the layer. More... | |
Geometry::Point | GetLocation () const |
Returns the current location of the layer. More... | |
int | GetLeft () const |
Returns the current location of the layer. More... | |
int | GetTop () const |
Returns the current location of the layer. More... | |
Geometry::Bounds | GetBounds () const |
Returns the boundaries of the layer. More... | |
Geometry::Bounds | GetEffectiveBounds () const |
Returns the effective boundaries of the layer. More... | |
Public Attributes | |
Gorgon::Event< SceneManager, Scene & > | ActivatedEvent |
This event will be fired whenever a scene is activated. More... | |
![]() | |
Graphics::PointerStack | Pointers |
Pointer system to be used within the window. More... | |
Event< Window > | FocusedEvent |
Called when this window is focused. More... | |
Event< Window > | LostFocusEvent |
Called when this window is deactivated. More... | |
Event< Window > | DestroyedEvent |
Called when this window is destroyed. More... | |
Event< Window, bool & > | ClosingEvent |
Called when user tries to close the window. More... | |
Event< Window > | MovedEvent |
Called after the window is moved, either by the user or programmatically. More... | |
Event< Window > | ResizedEvent |
Called after the window is resized, either by the user or programmatically. More... | |
Event< Window > | MinimizedEvent |
Called after the window is minimized, either by the user or programmatically. More... | |
Event< Window > | RestoredEvent |
Called after the window is restored from minimized state, either by the user or programmatically. More... | |
ConsumableEvent< Window, Input::Key, float > | KeyEvent |
Called when a key is pressed or released. More... | |
ConsumableEvent< Window, Input::Keyboard::Char > | CharacterEvent |
Called when a character is received. More... | |
![]() | |
const Containers::Collection< Layer > & | Children |
Sub-layers that this layer holds, all the sub-layers are considered to be above current layer. More... | |
Protected Member Functions | |
decltype(KeyEvent) ::Token | init () |
![]() | |
Window (const WindowManager::Monitor &monitor, Geometry::Rectangle rect, const std::string &name, const std::string &title, bool allowresize, bool visible) | |
virtual void | added (Layer &layer) override |
Will be called when a layer is added. More... | |
void | deleting (Layer *layer) |
virtual void | located (Layer *) override |
A window cannot be placed in another layer. This function always fails. More... | |
![]() | |
void | dotransformandclip (bool inverse=false) |
Performs transformation and clipping. Use inverse for reverse mapping for mouse events. More... | |
virtual void | removed (Layer &layer) |
Will be called when a layer is removed. More... | |
void | reverttransformandclip () |
Reverts previously done transformation. More... | |
Protected Attributes | |
Scene * | active |
decltype(KeyEvent) ::Token | inputtoken |
bool | quiting |
Gorgon::Containers::Hashmap< SceneID, Scene > | scenes |
![]() | |
Geometry::Bounds | bounds |
Bounds of this layer. More... | |
Containers::Collection< Layer > | children |
Child layers that this layer holds, all child layers are considered to be above current layer. More... | |
bool | isvisible |
Whether this layer is visible, invisible layers will not be drawn or receive any events. More... | |
std::string | name |
For debugging. More... | |
Layer * | parent |
Parent layer, could be nullptr. More... | |
Additional Inherited Members | |
![]() | |
static Geometry::Size | GetMinimumRequiredSize () |
Returns the minimum size required to fit any window inside. More... | |
![]() | |
static const struct Gorgon::Window::FullscreenTag | Fullscreen |
static const Containers::Collection< Window > & | Windows |
List of currently created windows. More... | |
![]() | |
static const Geometry::Bounds | EntireRegion |
When used as layer bounds, represents the entire region its placed in. More... | |
This class is a Window that manages scenes, allowing swapping, handling input and game loop.
This runner is most suitable for games where there would be multiple scenes (intro, how to play, game, pause screen, etc...) that compete with each other for input and rendering.
SceneManager | ( | ) |
|
default |
~SceneManager | ( | ) |
References SceneManager::scenes.
void ActivateKeyboard | ( | ) |
Moves keyboard input event to the top if there is a layer that accepts keyboard input.
References SceneManager::active, SceneManager::inputtoken, Window::KeyEvent, and Scene::RequiresKeyInput().
void Assume | ( | Scene & | scene | ) |
Assumes the ownership of the the given scene, adding it to the list of scenes.
References Scene::id, Scene::parent, and SceneManager::scenes.
auto begin | ( | ) |
Returns iterator to the first scene.
References SceneManager::scenes.
auto begin | ( | ) | const |
Returns iterator to the first scene.
References SceneManager::scenes.
void Deactivate | ( | ) |
Deactivates all scenes.
References SceneManager::active, SceneManager::inputtoken, and Window::KeyEvent.
void DeleteScene | ( | SceneID | scene | ) |
Deletes the given scene, nothing is done if the scene is not found.
References SceneManager::scenes.
auto end | ( | ) |
Returns iterator to the end of scenes.
References SceneManager::scenes.
auto end | ( | ) | const |
Returns iterator to the end of scenes.
References SceneManager::scenes.
Returns the requested scene.
If it does not exist, this function will throw runtime error.
References SceneManager::scenes.
int GetSceneCount | ( | ) | const |
Returns the number of scenes registered.
References SceneManager::scenes.
|
protected |
S_& NewScene | ( | SceneID | id, |
P_ &&... | params | ||
) |
Creates a new scene using the given type and parameters.
Scene class should always take parent layer first, then id and then the other parameters if they exists. When using this function, only specify the class as template parameter, the others will be resolved. If a scene with the same id exists, it will be deleted. It is advisable to add new scenes at the start without activating any scene.
References SceneManager::scenes.
|
default |
|
overridevirtual |
Quits the scene manager, returning the execution to the point where Run function is called.
It allows current frame to be completed before quiting. It also deactives the current scene.
Implements Runner.
References SceneManager::quiting.
Releases the ownership of the scene with the given ID, removing it from the manager.
Using scene while it does not have parent might cause problems.
References SceneManager::scenes.
|
overridevirtual |
Runs the application by running the active scene, progressing OS events and rendering mechanism.
This function will run until Quit is called.
Implements Runner.
References SceneManager::active, Gorgon::Time::DeltaTime(), Scene::doframe(), Gorgon::NextFrame(), SceneManager::quiting, Scene::render(), and SceneManager::SwitchScene().
bool SceneExists | ( | SceneID | id | ) | const |
Returns if the given scene exists.
References SceneManager::scenes.
|
overridevirtual |
Steps the application by running the active scene, progressing OS events and rendering mechanism.
Implements Runner.
References SceneManager::active, Gorgon::Time::DeltaTime(), Scene::doframe(), Gorgon::NextFrame(), and Scene::render().
void SwitchScene | ( | SceneID | scene | ) |
Switches the current scene to the scene with the given id.
Will throw std::runtime_error if scene is not found. If given id is NoSceneID, all scenes will be deactivated.
References SceneManager::ActivatedEvent, SceneManager::active, SceneManager::Deactivate(), Scene::GetID(), SceneManager::inputtoken, Window::KeyEvent, Scene::RequiresKeyInput(), and SceneManager::scenes.
Creates a fullscreen window.
Fullscreen windows do not have chrome and covers entire screen, including any panels it contains.
Creates a fullscreen window.
Fullscreen windows do not have chrome and covers entire screen, including any panels it contains.
Creates a new window at the center of the screen.
size | of the window |
name | of the window |
visible | after creation, window will be visible or invisible depending on this value. |
Creates a new window at the center of the screen.
size | of the window |
name | of the window |
title | of the window |
visible | after creation, window will be visible or invisible depending on this value. |
Creates a new window at the center of the screen.
size | of the window |
name | of the window |
visible | after creation, window will be visible or invisible depending on this value. |
Creates a new window at the center of the screen.
size | of the window |
name | of the window |
title | of the window |
visible | after creation, window will be visible or invisible depending on this value. |
|
delete |
Copy constructor is not allowed.
Creates a new window at the center of the screen.
monitor | that the window will be centered on |
size | of the window |
name | of the window |
visible | after creation, window will be visible or invisible depending on this value. |
Creates a new window at the center of the screen.
monitor | that the window will be centered on |
size | of the window |
name | of the window |
visible | after creation, window will be visible or invisible depending on this value. |
Creates a new window.
rect | the position and the interior size of the window unless use outer metrics is set to true |
name | of the window |
visible | after creation, window will be visible or invisible depending on this value. |
Creates a new window.
rect | the position and the interior size of the window unless use outer metrics is set to true |
name | of the window |
visible | after creation, window will be visible or invisible depending on this value. |
Move constructor.
References Window::Swap().
Gorgon::Event<SceneManager, Scene&> ActivatedEvent |
This event will be fired whenever a scene is activated.
|
protected |
|
protected |
|
protected |
|
protected |