Rebel Fork Framework
Urho3D::ApplicationState Class Reference

Base class for an application state. Examples of a state would be a loading screen, a menu or a game screen. More...

#include <Urho3D/Engine/StateManager.h>

Inheritance diagram for Urho3D::ApplicationState:
Urho3D::Object Urho3D::RefCounted Urho3D::SplashScreen

Public Member Functions

 ApplicationState (Context *context)
 Construct.
 
virtual ~ApplicationState () override
 Destruct.
 
virtual void Activate (StringVariantMap &bundle)
 Activate game state. Executed by StateManager. More...
 
virtual void TransitionComplete ()
 Transition into the state complete. Executed by StateManager.
 
virtual bool CanLeaveState () const
 Return true if state is ready to be deactivated. Executed by StateManager.
 
virtual void TransitionStarted ()
 Transition out of the state started. Executed by StateManager.
 
virtual void Deactivate ()
 Deactivate game state. Executed by StateManager. More...
 
virtual void Update (float timeStep)
 Handle the logic update event.
 
bool IsActive () const
 Get activation flag. Returns true if game screen is active.
 
void SetMouseVisible (bool enable)
 Set whether the operating system mouse cursor is visible.
 
void SetMouseGrabbed (bool grab)
 Set whether the mouse is currently being grabbed by an operation.
 
void SetMouseMode (MouseMode mode)
 Set the mouse mode.
 
void SetCursor (Cursor *cursor)
 Set cursor UI element.
 
CursorGetCursor () const
 Return cursor.
 
bool IsMouseVisible () const
 
bool IsMouseGrabbed () const
 
MouseMode GetMouseMode () const
 
UIElementGetUIRoot () const
 
void SetUICustomSize (const IntVector2 &size)
 
void SetUICustomSize (int width, int height)
 Set custom size of the root element.
 
const IntVector2GetUICustomSize () const
 
void SetNumViewports (unsigned num)
 
void SetViewport (unsigned index, Viewport *viewport)
 
void SetDefaultFogColor (const Color &color)
 Set default zone fog color.
 
ViewportGetViewport (unsigned index) const
 
ViewportGetViewportForScene (Scene *scene, unsigned index) const
 Return nth backbuffer viewport associated to a scene. Index 0 returns the first.
 
const ColorGetDefaultFogColor () const
 Get default zone fog color.
 
- Public Member Functions inherited from Urho3D::Object
 Object (Context *context)
 Construct.
 
 ~Object () override
 Destruct. Clean up self from event sender & receiver structures.
 
virtual StringHash GetType () const =0
 
virtual const ea::string & GetTypeName () const =0
 
virtual const TypeInfoGetTypeInfo () const =0
 Return type info.
 
virtual void OnEvent (Object *sender, StringHash eventType, VariantMap &eventData)
 Handle event.
 
virtual void SerializeInBlock (Archive &archive)
 Serialize content from/to archive. May throw ArchiveException.
 
bool IsInstanceOf (StringHash type) const
 Check current instance is type of specified type.
 
bool IsInstanceOf (const TypeInfo *typeInfo) const
 Check current instance is type of specified type.
 
template<typename T >
bool IsInstanceOf () const
 Check current instance is type of specified class.
 
template<typename T >
T * Cast ()
 Cast the object to specified most derived class.
 
template<typename T >
const T * Cast () const
 Cast the object to specified most derived class.
 
void SubscribeToEventManual (StringHash eventType, EventHandler *handler)
 Subscribe to an event that can be sent by any sender.
 
void SubscribeToEventManual (Object *sender, StringHash eventType, EventHandler *handler)
 Subscribe to a specific sender's event.
 
template<class T >
void SubscribeToEvent (StringHash eventType, T handler)
 Subscribe to an event that can be sent by any sender.
 
template<class T >
void SubscribeToEvent (Object *sender, StringHash eventType, T handler)
 Subscribe to a specific sender's event.
 
void UnsubscribeFromEvent (StringHash eventType)
 Unsubscribe from an event.
 
void UnsubscribeFromEvent (Object *sender, StringHash eventType)
 Unsubscribe from a specific sender's event.
 
void UnsubscribeFromEvents (Object *sender)
 Unsubscribe from a specific sender's events.
 
void UnsubscribeFromAllEvents ()
 Unsubscribe from all events.
 
void UnsubscribeFromAllEventsExcept (const ea::vector< StringHash > &exceptions)
 Unsubscribe from all events except those listed.
 
void UnsubscribeFromAllEventsExcept (const ea::vector< Object * > &exceptions)
 Unsubscribe from all events except those with listed senders.
 
void SendEvent (StringHash eventType)
 Send event to all subscribers.
 
void SendEvent (StringHash eventType, VariantMap &eventData)
 Send event with parameters to all subscribers.
 
VariantMapGetEventDataMap () const
 Return a preallocated map for event data. Used for optimization to avoid constant re-allocation of event data maps.
 
template<typename... Args>
void SendEvent (StringHash eventType, const Args &... args)
 Send event with variadic parameter pairs to all subscribers. The parameters are (paramID, paramValue) pairs.
 
ContextGetContext () const
 Return execution context.
 
const VariantGetGlobalVar (StringHash key) const
 
const VariantMapGetGlobalVars () const
 
void SetGlobalVar (StringHash key, const Variant &value)
 
ObjectGetSubsystem (StringHash type) const
 Return subsystem by type.
 
ObjectGetEventSender () const
 Return active event sender. Null outside event handling.
 
EventHandlerGetEventHandler () const
 Return active event handler. Null outside event handling.
 
bool HasSubscribedToEvent (StringHash eventType) const
 Return whether has subscribed to an event without specific sender.
 
bool HasSubscribedToEvent (Object *sender, StringHash eventType) const
 Return whether has subscribed to a specific sender's event.
 
bool HasEventHandlers () const
 Return whether has subscribed to any event.
 
template<class T >
T * GetSubsystem () const
 Template version of returning a subsystem.
 
const ea::string & GetCategory () const
 
void SendEvent (StringHash eventType, const VariantMap &eventData)
 Send event with parameters to all subscribers.
 
void SetBlockEvents (bool block)
 Block object from sending and receiving events.
 
bool GetBlockEvents () const
 Return sending and receiving events blocking status.
 
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
 
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
 
 RefCounted (const RefCounted &rhs)=delete
 Prevent copy construction.
 
RefCountedoperator= (const RefCounted &rhs)=delete
 Prevent assignment.
 
int AddRef ()
 
int ReleaseRef ()
 
int Refs () const
 
int WeakRefs () const
 
RefCountRefCountPtr () const
 Return pointer to the reference count structure.
 
bool HasScriptObject () const
 Return true if script runtime object wrapping this native object exists.
 
bool IsScriptStrongRef () const
 Return true if script reference is strong.
 

Static Public Member Functions

static void RegisterObject (Context *context)
 Register object factory.
 
- Static Public Member Functions inherited from Urho3D::Object
static const TypeInfoGetTypeInfoStatic ()
 Return type info static.
 

Private Member Functions

void InitMouseMode ()
 Initialize mouse mode on non-web platform.
 
void HandleMouseModeRequest (StringHash eventType, VariantMap &eventData)
 Handle request for mouse mode on web platform.
 
void HandleMouseModeChange (StringHash eventType, VariantMap &eventData)
 Handle request for mouse mode change on web platform.
 
void HandleUpdate (StringHash eventType, VariantMap &eventData)
 Handle the logic update event.
 

Private Attributes

bool active_ {false}
 Is the game screen active.
 
SharedPtr< UIElementrootElement_ {}
 UI root element.
 
SharedPtr< UIElementsavedRootElement_ {}
 UI root element saved upon activation to be restored at deactivation.
 
SharedPtr< Cursorcursor_ {}
 UI cursor.
 
SharedPtr< CursorsavedCursor_ {}
 UI cursor saved from previous state.
 
IntVector2 rootCustomSize_ {}
 UI root element custom size.
 
IntVector2 savedRootCustomSize_ {}
 UI root element custom size saved upon activation to be restored at deactivation.
 
ea::vector< SharedPtr< Viewport > > viewports_
 Backbuffer viewports.
 
bool mouseVisible_ {true}
 Operating system mouse cursor visible flag.
 
bool mouseGrabbed_ {false}
 
MouseMode mouseMode_ {MM_FREE}
 Determines the mode of mouse behaviour.
 
Color fogColor_ {0.0f, 0.0f, 0.0f}
 Fog color.
 
Color savedFogColor_ {}
 Saved fog color to be restored at deactivation.
 

Additional Inherited Members

- Protected Attributes inherited from Urho3D::Object
WeakPtr< Contextcontext_
 Execution context.
 

Detailed Description

Base class for an application state. Examples of a state would be a loading screen, a menu or a game screen.

Member Function Documentation

◆ Activate()

void Urho3D::ApplicationState::Activate ( StringVariantMap bundle)
virtual

Activate game state. Executed by StateManager.

Activate game screen. Executed by Application.

Reimplemented in Urho3D::SplashScreen.

◆ Deactivate()

void Urho3D::ApplicationState::Deactivate ( )
virtual

Deactivate game state. Executed by StateManager.

Deactivate game screen. Executed by Application.

Reimplemented in Urho3D::SplashScreen.

◆ GetMouseMode()

MouseMode Urho3D::ApplicationState::GetMouseMode ( ) const
inline

Return the mouse mode.

◆ GetUICustomSize()

const IntVector2& Urho3D::ApplicationState::GetUICustomSize ( ) const
inline

Return root element custom size. Returns 0,0 when custom size is not being used and automatic resizing according to window size is in use instead (default).

◆ GetUIRoot()

UIElement* Urho3D::ApplicationState::GetUIRoot ( ) const
inline

Return root UI element.

◆ GetViewport()

Viewport * Urho3D::ApplicationState::GetViewport ( unsigned  index) const

Return backbuffer viewport by index.

◆ IsMouseGrabbed()

bool Urho3D::ApplicationState::IsMouseGrabbed ( ) const
inline

Return whether the mouse is currently being grabbed by an operation.

◆ IsMouseVisible()

bool Urho3D::ApplicationState::IsMouseVisible ( ) const
inline

Return whether the operating system mouse cursor is visible.

◆ SetNumViewports()

void Urho3D::ApplicationState::SetNumViewports ( unsigned  num)

Set number of backbuffer viewports to render.

◆ SetUICustomSize()

void Urho3D::ApplicationState::SetUICustomSize ( const IntVector2 size)

Set custom size of the root element. This disables automatic resizing of the root element according to window size. Set custom size 0,0 to return to automatic resizing.

◆ SetViewport()

void Urho3D::ApplicationState::SetViewport ( unsigned  index,
Viewport viewport 
)

Set a backbuffer viewport.

Member Data Documentation

◆ mouseGrabbed_

bool Urho3D::ApplicationState::mouseGrabbed_ {false}
private

Flag to indicate the mouse is being grabbed by an operation. Subsystems like UI that uses mouse should temporarily ignore the mouse hover or click events.


The documentation for this class was generated from the following files: