BaseGameFeature::FocusManager Class Reference
#include <focusmanager.h>
Inheritance diagram for BaseGameFeature::FocusManager:
Detailed Description
The FocusManager singleton object manages the global input and camera focus entities. There may only be one input and camera focus entity at any time, the input focus entity can be different from the camera focus entity.The input focus entity will be the entity which receives input, the camera focus entity will be the entity which may manipulate the camera.
The FocusManager requires an EntityManager to iterate through existing entities, and works only on game entities, which have the InputProperty and/or CameraProperty (or a derived class thereof) attached.
Please note that an actual focus switch will happen only once per-frame. This is to avoid chain-reactions when 2 or more objects per frame think they currently have the input focus.
(C) 2007 Radon Labs GmbH
Public Member Functions | |
FocusManager () | |
constructor | |
virtual | ~FocusManager () |
destructor | |
virtual void | OnFrame () |
trigger the focus manager once a frame, actual focus switches will happen here | |
virtual void | SetFocusEntity (const Ptr< Game::Entity > &entity) |
set input and camera focus to entity, null ptr allowed | |
virtual const Ptr< Game::Entity > & | GetFocusEntity () const |
get common focus entity, will fail if input != camera focus entity | |
virtual void | SetFocusToNextEntity () |
switch input and camera focus to next entity | |
virtual void | SetInputFocusEntity (const Ptr< Game::Entity > &entity) |
set the current input focus entity, null ptr allowed | |
virtual const Ptr< Game::Entity > & | GetInputFocusEntity () const |
get the current input focus entity | |
virtual void | SetInputFocusToNextEntity () |
set input focus to next entity | |
virtual void | SetCameraFocusEntity (const Ptr< Game::Entity > &entity) |
set the current camera focus entity, null ptr allowed | |
virtual const Ptr< Game::Entity > & | GetCameraFocusEntity () const |
get the current camera focus entity | |
virtual void | SetCameraFocusToNextEntity () |
set camera focus to next entity | |
virtual void | OnActivate () |
called when attached to game server | |
virtual void | OnDeactivate () |
called when removed from game server | |
bool | IsActive () const |
return true if currently active | |
virtual void | OnBeginFrame () |
called before frame by the game server | |
virtual void | OnEndFrame () |
called after frame by the game server | |
virtual void | OnLoad () |
called after loading game state | |
virtual void | OnSave () |
called before saving game state | |
virtual void | OnStart () |
called by Game::Server::Start() when the world is started | |
virtual void | OnRenderDebug () |
render a debug visualization | |
virtual void | HandleMessage (const Ptr< Messaging::Message > &msg) |
handle a single message (distribute to ports which accept the message) | |
void | AttachPort (const Ptr< Port > &port) |
attach a message port | |
void | RemovePort (const Ptr< Port > &port) |
remove a message port | |
bool | HasPort (const Ptr< Port > &port) const |
return true if a port exists | |
virtual void | SetupAcceptedMessages () |
override to register accepted messages | |
void | AttachHandler (const Ptr< Handler > &h) |
attach a message handler to the port | |
void | RemoveHandler (const Ptr< Handler > &h) |
remove a message handler from the port | |
void | RemoveAllHandlers () |
remove all message handler from the port | |
SizeT | GetNumHandlers () const |
return number of handlers attached to the port | |
const Ptr< Handler > & | GetHandlerAtIndex (IndexT i) const |
get a message handler by index | |
virtual void | Send (const Ptr< Message > &msg) |
send a message to the port | |
const Util::Array< const Id * > & | GetAcceptedMessages () const |
get the array of accepted messages (sorted) | |
bool | AcceptsMessage (const Id &msgId) const |
return true if port accepts this msg | |
int | GetRefCount () const |
get the current refcount | |
void | AddRef () |
increment refcount by one | |
void | Release () |
decrement refcount and destroy object if refcount is zero | |
bool | IsInstanceOf (const Rtti &rtti) const |
return true if this object is instance of given class | |
bool | IsInstanceOf (const Util::String &className) const |
return true if this object is instance of given class by string | |
bool | IsInstanceOf (const Util::FourCC &classFourCC) const |
return true if this object is instance of given class by fourcc | |
bool | IsA (const Rtti &rtti) const |
return true if this object is instance of given class, or a derived class | |
bool | IsA (const Util::String &rttiName) const |
return true if this object is instance of given class, or a derived class, by string | |
bool | IsA (const Util::FourCC &rttiFourCC) const |
return true if this object is instance of given class, or a derived class, by fourcc | |
const Util::String & | GetClassName () const |
get the class name | |
Util::FourCC | GetClassFourCC () const |
get the class FourCC code | |
Static Public Member Functions | |
static void | DumpRefCountingLeaks () |
dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!) | |
Protected Member Functions | |
void | SwitchFocusEntities () |
actually switch focus entities | |
void | RegisterMessage (const Id &msgId) |
register a single accepted message |
Member Function Documentation
void BaseGameFeature::FocusManager::OnFrame | ( | ) | [virtual] |
trigger the focus manager once a frame, actual focus switches will happen here
This method is called once per frame.
Reimplemented from Game::Manager.
void BaseGameFeature::FocusManager::SetFocusEntity | ( | const Ptr< Game::Entity > & | entity | ) | [virtual] |
set input and camera focus to entity, null ptr allowed
Sets the input and camera focus to the given entity. The entity pointer may be 0 to clear the input and camera focus. The entity must have both a InputProperty and CameraProperty attached, otherwise the method will fail.
get common focus entity, will fail if input != camera focus entity
Returns the current common focus entity. This method will fail if the current input focus entity and camera focus entity are not the same. The method may return 0 if there is no current focus entity.
void BaseGameFeature::FocusManager::SetFocusToNextEntity | ( | ) | [virtual] |
switch input and camera focus to next entity
Set focus to next entity which has both an InputProperty and CameraProperty attached. If no current focus entity exists, the method will start to iterate with the first entity. The method will wrap around. The method will return false if no entities exist which have both an InputProperty and CameraProperty attached.
void BaseGameFeature::FocusManager::SetInputFocusEntity | ( | const Ptr< Game::Entity > & | entity | ) | [virtual] |
set the current input focus entity, null ptr allowed
Set input focus entity to the given entity. The entity pointer can be 0, this will clear the current input focus. The entity must have an InputProperty attached for this to work.
get the current input focus entity
Get current input focus entity. This method may return 0 if no input focus entity is set.
void BaseGameFeature::FocusManager::SetInputFocusToNextEntity | ( | ) | [virtual] |
set input focus to next entity
Set input focus to the next entity which has an InputProperty attached.
void BaseGameFeature::FocusManager::SetCameraFocusEntity | ( | const Ptr< Game::Entity > & | entity | ) | [virtual] |
set the current camera focus entity, null ptr allowed
Set camera focus entity to the given entity. The entity pointer can be 0, this will clear the current camera focus. The entity must have a CameraProperty attached for this to work.
get the current camera focus entity
Get current camera focus entity. This method may return 0 if no input focus entity is set.
void BaseGameFeature::FocusManager::SetCameraFocusToNextEntity | ( | ) | [virtual] |
set camera focus to next entity
Set camera focus to next entity which has a CameraProperty attached.
void BaseGameFeature::FocusManager::SwitchFocusEntities | ( | ) | [protected] |
actually switch focus entities
Actually switch focus entities. A focus entity switch doesn't happen immediately, but only once per frame. This is to prevent chain-reactions and circular reactions when 2 or more entities think they have the focus in a single frame.
void Game::Manager::OnActivate | ( | ) | [virtual, inherited] |
called when attached to game server
This method is called when the manager is attached to the game server. The manager base class will register its message port with the message server.
Reimplemented in BaseGameFeature::TimeManager, BaseGameFeature::CategoryManager, BaseGameFeature::EnvQueryManager, BaseGameFeature::GlobalAttrsManager, Script::DialogManager, and Script::ScriptManager.
void Game::Manager::OnDeactivate | ( | ) | [virtual, inherited] |
called when removed from game server
This method is called when the manager is removed from the game server. It will unregister its message port from the message server at this point.
Reimplemented in BaseGameFeature::TimeManager, BaseGameFeature::CategoryManager, BaseGameFeature::EntityManager, BaseGameFeature::EnvEntityManager, BaseGameFeature::EnvQueryManager, Script::DialogManager, and Script::ScriptManager.
void Game::Manager::OnBeginFrame | ( | ) | [virtual, inherited] |
called before frame by the game server
Called before frame, override in subclasses
Reimplemented in BaseGameFeature::EntityManager.
void Game::Manager::OnEndFrame | ( | ) | [virtual, inherited] |
called after frame by the game server
Called after frame, override in subclasses
Reimplemented in BaseGameFeature::EntityManager.
void Messaging::Dispatcher::HandleMessage | ( | const Ptr< Messaging::Message > & | msg | ) | [virtual, inherited] |
handle a single message (distribute to ports which accept the message)
Handle a message. The message will only be distributed to ports which accept the message.
Reimplemented from Messaging::Port.
Reimplemented in Script::DialogManager.
attach a message port
Attach a new message port.
- Parameters:
-
port pointer to a message port object
remove a message port
Remove a message port object.
- Parameters:
-
handler pointer to message port object to be removed
return true if a port exists
Return true if a port is already attached.
attach a message handler to the port
Attach a message handler to the port.
remove a message handler from the port
Remove a message handler from the port.
send a message to the port
Send a message to the port. This will immediately call the HandleMessage() method of all attached handlers. If the message has been handled by at least one of the handlers, the Handled() flag of the message will be set to true.
int Core::RefCounted::GetRefCount | ( | ) | const [inline, inherited] |
get the current refcount
Return the current refcount of the object.
void Core::RefCounted::AddRef | ( | ) | [inline, inherited] |
increment refcount by one
Increment the refcount of the object.
void Core::RefCounted::Release | ( | ) | [inline, inherited] |
decrement refcount and destroy object if refcount is zero
Decrement the refcount and destroy object if refcount is zero.
const Util::String & Core::RefCounted::GetClassName | ( | ) | const [inline, inherited] |
get the class name
Get the class name of the object.
Util::FourCC Core::RefCounted::GetClassFourCC | ( | ) | const [inline, inherited] |
get the class FourCC code
Get the class FourCC of the object.
void Core::RefCounted::DumpRefCountingLeaks | ( | ) | [static, inherited] |
dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)
This method should be called as the very last before an application exits.