You.i Engine
CYIApp Class Referenceabstract

Detailed Description

The base class for all applications.

Typically, applications derive from the CYIApp base class and implement key methods. These methods are then called by the platform, which controls the lifecycle, timing and input for applications.

CYIApp::Init() is the entry point for the initialization process, this will trigger calls to UserInit() and UserStart() in which users can specify custom initialization steps.

CYIApp::UserUpdate() will be triggered on each application tick

#include <framework/YiApp.h>

Public Types

enum  MEMORY_LEVEL {
  MEMORY_LEVEL_MODERATE,
  MEMORY_LEVEL_LOW,
  MEMORY_LEVEL_CRITICAL
}
 

Public Member Functions

 CYIApp ()
 
virtual ~CYIApp ()
 
bool Init ()
 
bool IsInitialized () const
 
void SetDefaultOrientation (YIViewProperty::Orientation orientation)
 
YIViewProperty::Orientation GetDefaultOrientation () const
 
void SetDefaultStatusBarVisibility (YIViewProperty::StatusBar statusbar)
 
YIViewProperty::StatusBar GetDefaultStatusBarVisibility () const
 
void SetDefaultNavigationBarVisibility (YIViewProperty::NavigationBar navigationBar)
 
YIViewProperty::NavigationBar GetDefaultNavigationBarVisibility () const
 
bool SetScreenProperties (int screenSizeX, int screenSizeY, int screenDensityX, int screenDensityY)
 
bool SetSurface (CYISurface *pSurface)
 
void SurfaceWasResized (int32_t nWidth, int32_t nHeight)
 
virtual CYIFrameworkConfiguration UserConfiguration ()
 
void HandleKeyInputs (const CYIKeyEvent &keyEvent)
 
void HandleActionInputs (int32_t nX, int32_t nY, YI_EVENT_TYPE eEventType, uint8_t uPointerID=0, bool bHover=false)
 
void HandleActionInputs (int32_t nX, int32_t nY, int32_t nWheelDelta, uint8_t uButton, YI_EVENT_TYPE eEventType, uint8_t uPointerID=0, bool bHover=false)
 
virtual void HandleLowMemory (MEMORY_LEVEL eMemoryLevel)
 
bool LoadFont (const CYIString &URI, ssize_t *pnFontID, bool bLocal=false)
 
bool LoadFont (const uint8_t *pFontData, uint32_t nDataSize, ssize_t *pnFontID)
 
CYIFrameworkGetMainFramework ()
 
CYIRenderSystemGetMainRenderSystem ()
 
CYISceneManagerGetSceneManager () const
 
bool PostEvent (std::unique_ptr< CYIEvent > pEvent, YI_EVENT_PRIORITY priority=YI_EVENT_PRIORITY_DEFAULT, bool bBump=false)
 
bool PostEvent (std::unique_ptr< CYIEvent > pEvent, CYIEventHandler *pDestination, YI_EVENT_PRIORITY priority=YI_EVENT_PRIORITY_DEFAULT, bool bBump=false)
 
bool SendEvent (std::unique_ptr< CYIEvent > pEvent)
 
bool SendEvent (std::unique_ptr< CYIEvent > pEvent, CYIEventHandler *pDestination)
 
bool Update (bool bForceDirty=false, bool bUpdateTime=true)
 
virtual void Draw ()
 
virtual void OnPreDraw ()
 
virtual void OnPostDraw ()
 
virtual void Swap ()
 
void SetShowFPS (bool bShow)
 
bool GetShowFPS () const
 
CYIDevPanelGetDevPanel () const
 
void InitializeDevPanel ()
 
void DestroyDevPanel ()
 
void SetAssetsPath (const CYIString &assetsPath)
 
const CYIStringGetAssetsPath () const
 
void SetCachePath (const CYIString &cachePath)
 
const CYIStringGetCachePath () const
 
void SetDataPath (const CYIString &dataPath)
 
const CYIStringGetDataPath () const
 
void SetExternalPath (const CYIString &externalPath)
 
const CYIStringGetExternalPath () const
 
void SetVersion (const CYIString &version)
 
const CYIStringGetVersion () const
 
void SetMultiTouchEnabled (bool bEnabled)
 
bool IsMultiTouchEnabled () const
 
void SetBindingContext (std::unique_ptr< CYIBindingContext > pBindingContext)
 
CYIBindingContextGetBindingContext ()
 
void SetBackgroundColor (const CYIColor &color)
 
const CYIColorGetBackgroundColor ()
 

Public Attributes

CYISignal< int32_t, int32_t > SurfaceSizeChanged
 

Protected Member Functions

 CYIApp (CYIAppPriv *pPriv)
 
virtual bool UserInit ()=0
 
virtual bool UserStart ()=0
 
virtual void UserUpdate ()
 
virtual void OnSurfaceSizeChanged (int32_t nWidth, int32_t nHeight)
 

Protected Attributes

CYIAppPrivm_pPriv
 

Friends

class CYIFPSWidget
 
class CYIAppPriv
 

Member Enumeration Documentation

Enumerator
MEMORY_LEVEL_MODERATE 
MEMORY_LEVEL_LOW 
MEMORY_LEVEL_CRITICAL 

Constructor & Destructor Documentation

CYIApp::CYIApp ( )
virtual CYIApp::~CYIApp ( )
virtual
CYIApp::CYIApp ( CYIAppPriv pPriv)
protected

Member Function Documentation

void CYIApp::DestroyDevPanel ( )

Destroys the dev panel, if one exists.

virtual void CYIApp::Draw ( )
virtual

This function draws the results of the previous Update() to the screen. If nothing has been updated, the screen buffer will not be re-drawn.

const CYIString& CYIApp::GetAssetsPath ( ) const

Retrieve the asset location. This location is generally read-only. See also SetAssetsPath

const CYIColor& CYIApp::GetBackgroundColor ( )

Returns the current app background color.

See also
SetBackgroundColor
CYIBindingContext* CYIApp::GetBindingContext ( )

Returns the current binding context. Or nullptr if no binding context has been set.

const CYIString& CYIApp::GetCachePath ( ) const

Retrieve the cache location. This location generally persists for the install life of the application, but the data may be cleared between application launches. The data path will be returned if no cache path has been set, or has been set to an empty string. See also SetCachePath and SetDataPath.

const CYIString& CYIApp::GetDataPath ( ) const

Retrieve the data location. This location generally persists for the install life of the application. See also SetDataPath

YIViewProperty::NavigationBar CYIApp::GetDefaultNavigationBarVisibility ( ) const
YIViewProperty::Orientation CYIApp::GetDefaultOrientation ( ) const
YIViewProperty::StatusBar CYIApp::GetDefaultStatusBarVisibility ( ) const
CYIDevPanel* CYIApp::GetDevPanel ( ) const

Returns the instance of the dev panel. May return null if such an instance doesn't exist.

Note
This function typically returns nullptr for Release builds, unless the InitializeDevPanel function has explicitly been called.
const CYIString& CYIApp::GetExternalPath ( ) const

Get the external storage location. This location generally persists beyond the install life of the application. See also SetExternalPath

Note
The "WRITE_EXTERNAL_STORAGE" permission is required to read or write to this path on Android.
CYIFramework* CYIApp::GetMainFramework ( )

Returns the main application framework, equivalent to CYIFramework::GetInstance()

CYIRenderSystem* CYIApp::GetMainRenderSystem ( )

Returns the main application render system, equivalent to CYIRenderSystem::GetInstance()

CYISceneManager* CYIApp::GetSceneManager ( ) const

Returns the scene manager for this application. The scene manager is the entry point for interacting with a 3D scene

bool CYIApp::GetShowFPS ( ) const

Returns true if FPS rendering is enabled, false otherwise

const CYIString& CYIApp::GetVersion ( ) const

Returns the application version string for this application object.

void CYIApp::HandleActionInputs ( int32_t  nX,
int32_t  nY,
YI_EVENT_TYPE  eEventType,
uint8_t  uPointerID = 0,
bool  bHover = false 
)

Handles action input events, posting them to the event queue to be processed. If the surface is not available, no event will be posted.

Pass in the x and y coordinates of the event along with the event type, the pointer id (if applicable) and the hover flag (if applicable).

Applicable event types are: YI_ACTION_DOWN YI_ACTION_MOVE YI_ACTION_UP YI_ACTION_WHEEL

void CYIApp::HandleActionInputs ( int32_t  nX,
int32_t  nY,
int32_t  nWheelDelta,
uint8_t  uButton,
YI_EVENT_TYPE  eEventType,
uint8_t  uPointerID = 0,
bool  bHover = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void CYIApp::HandleKeyInputs ( const CYIKeyEvent keyEvent)

Handles key input events, posting them to the event queue to be processed.

virtual void CYIApp::HandleLowMemory ( MEMORY_LEVEL  eMemoryLevel)
virtual

This may be called by the platform during low-memory conditions.

bool CYIApp::Init ( )

This function must be called by the user in the Drawing context. This function will Initialize the user application along with the You.i Engine framework. This functions has hooks to UserInit() and UserStart() to allow the user insert application specific behaviour.

void CYIApp::InitializeDevPanel ( )

Constructs an instance of the dev panel, if one doesn't exist already.

bool CYIApp::IsInitialized ( ) const

Returns true if the application has already been initialized. On some platforms, and application can receive an event prior to You.i Engine being initialized.

bool CYIApp::IsMultiTouchEnabled ( ) const

Return true if multi-touch events are being sent to the application.

bool CYIApp::LoadFont ( const CYIString URI,
ssize_t pnFontID,
bool  bLocal = false 
)

Load a font, located at the specified URI into the text engine. The font's id will be stored in pnFontID. bLocal indicates whether the path is a local path

bool CYIApp::LoadFont ( const uint8_t *  pFontData,
uint32_t  nDataSize,
ssize_t pnFontID 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This function loads binary font data into the text engine.

virtual void CYIApp::OnPostDraw ( )
inlinevirtual

Optional method to allow the app to draw things after You.i Engine renders, but before it swaps. This can be used to render debug information on top of everything.

This is called right after Draw()

virtual void CYIApp::OnPreDraw ( )
inlinevirtual

Optional method to allow the app to prepare or render things before You.i Engine renders. This could be useful for example on platforms that need to render a video before everything else.

This is called before CYISceneManager::Draw(). Event processing will be complete prior to this call.

virtual void CYIApp::OnSurfaceSizeChanged ( int32_t  nWidth,
int32_t  nHeight 
)
protectedvirtual

Function will be called when the surface size changes. Subclasses can use this to update their views based on the new size.

Note
Overriding without calling the base implementation will prevent the scene manager from updating for the surface size change. When the scene manager does not update for a surface size change scenes in the scene manager and the scene manager background will not ube updated to be consistent with the new surface size.
See also
CYISceneManager::OnSurfaceSizeChanged
CYISceneManager::UpdateAllScenes
CYISceneManager::UpdateBackground
bool CYIApp::PostEvent ( std::unique_ptr< CYIEvent pEvent,
YI_EVENT_PRIORITY  priority = YI_EVENT_PRIORITY_DEFAULT,
bool  bBump = false 
)

Posts an event to the event dispatcher with priority priority. If bBump is true, then the event will be pushed to the top of the event queue.

bool CYIApp::PostEvent ( std::unique_ptr< CYIEvent pEvent,
CYIEventHandler pDestination,
YI_EVENT_PRIORITY  priority = YI_EVENT_PRIORITY_DEFAULT,
bool  bBump = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool CYIApp::SendEvent ( std::unique_ptr< CYIEvent pEvent)

Immediately dispatch an event

bool CYIApp::SendEvent ( std::unique_ptr< CYIEvent pEvent,
CYIEventHandler pDestination 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void CYIApp::SetAssetsPath ( const CYIString assetsPath)

Specify the location from which application assets will be loaded, this is generally a read-only location and will be treated as such.

void CYIApp::SetBackgroundColor ( const CYIColor color)

Sets the background color for the app which will be visible behind the bottom-most scene if it has a transparent background.

The default app background color is CYIColor::Named().Black.

void CYIApp::SetBindingContext ( std::unique_ptr< CYIBindingContext pBindingContext)

Set binding context.

void CYIApp::SetCachePath ( const CYIString cachePath)

Specify the location to which the application can cache files, the app needs write permissions to this location. The path should point to a directory that will be destroyed upon uninstallation.

void CYIApp::SetDataPath ( const CYIString dataPath)

Specify the location to which the application can store files, the app needs write permissions to this location. The path should point to a directory that will be destroyed upon uninstallation.

void CYIApp::SetDefaultNavigationBarVisibility ( YIViewProperty::NavigationBar  navigationBar)
void CYIApp::SetDefaultOrientation ( YIViewProperty::Orientation  orientation)
void CYIApp::SetDefaultStatusBarVisibility ( YIViewProperty::StatusBar  statusbar)
void CYIApp::SetExternalPath ( const CYIString externalPath)

Specify the location to which the application can place persistent files. The path should point to a directory that is not destroyed upon uninstallation.

void CYIApp::SetMultiTouchEnabled ( bool  bEnabled)

Specify if the application will be notified of multi-touch events. Multi touch events are disabled by default.

bool CYIApp::SetScreenProperties ( int  screenSizeX,
int  screenSizeY,
int  screenDensityX,
int  screenDensityY 
)
void CYIApp::SetShowFPS ( bool  bShow)

Enable FPS rendering

bool CYIApp::SetSurface ( CYISurface pSurface)
void CYIApp::SetVersion ( const CYIString version)

Sets the application version string for this application object.

void CYIApp::SurfaceWasResized ( int32_t  nWidth,
int32_t  nHeight 
)

Handles available suface size changed notification. This will update the CYISurface and pass the notification along to the user.

See also
OnSurfaceSizeChanged
virtual void CYIApp::Swap ( )
virtual

This function will swap the contents of the back and front buffers and throttle the application's rendering to 60 frames per second. For double buffered rendering, this operation must be performed after drawing is complete. A typical frame will consist of an Update(), a Draw(), and a Swap() in that order.

bool CYIApp::Update ( bool  bForceDirty = false,
bool  bUpdateTime = true 
)

This function updates all of the application logic and the scene tree. Rendering occurs in Draw(). Returns true if a redraw is required following the update.

bForceDirty can be set to true to force a re-draw. This should only be done when absolutely necessary bUpdateTime can be set to false to avoid a time update; this can be useful when an update cycle is desirable, but a time advance is not.

virtual CYIFrameworkConfiguration CYIApp::UserConfiguration ( )
virtual

Function will be called before initialization.

The user must implement the UserConfiguration() function and return a CYIFrameworkConfiguration object in order to set any configurable pre-initialization settings.

virtual bool CYIApp::UserInit ( )
protectedpure virtual

This function will be called during app initialization.

virtual bool CYIApp::UserStart ( )
protectedpure virtual

This is guaranteed to execute as the last component after all initializations are complete, including UserInit().

virtual void CYIApp::UserUpdate ( )
inlineprotectedvirtual

Can be overridden by the user that will be called every time the application is updating its internal timers, animations and the scene tree.

Friends And Related Function Documentation

friend class CYIAppPriv
friend
friend class CYIFPSWidget
friend

Member Data Documentation

CYIAppPriv* CYIApp::m_pPriv
protected
CYISignal<int32_t , int32_t > CYIApp::SurfaceSizeChanged

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