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) |
| CYIFramework * | GetMainFramework () |
| CYIRenderSystem * | GetMainRenderSystem () |
| CYISceneManager * | GetSceneManager () 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 |
| CYIDevPanel * | GetDevPanel () const |
| void | InitializeDevPanel () |
| void | DestroyDevPanel () |
| void | SetAssetsPath (const CYIString &assetsPath) |
| const CYIString & | GetAssetsPath () const |
| void | SetCachePath (const CYIString &cachePath) |
| const CYIString & | GetCachePath () const |
| void | SetDataPath (const CYIString &dataPath) |
| const CYIString & | GetDataPath () const |
| void | SetExternalPath (const CYIString &externalPath) |
| const CYIString & | GetExternalPath () const |
| void | SetVersion (const CYIString &version) |
| const CYIString & | GetVersion () const |
| void | SetMultiTouchEnabled (bool bEnabled) |
| bool | IsMultiTouchEnabled () const |
| void | SetBindingContext (std::unique_ptr< CYIBindingContext > pBindingContext) |
| CYIBindingContext * | GetBindingContext () |
| void | SetBackgroundColor (const CYIColor &color) |
| const CYIColor & | GetBackgroundColor () |
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 | |
| CYIAppPriv * | m_pPriv |
Friends | |
| class | CYIFPSWidget |
| class | CYIAppPriv |
| enum CYIApp::MEMORY_LEVEL |
| CYIApp::CYIApp | ( | ) |
|
virtual |
|
protected |
| void CYIApp::DestroyDevPanel | ( | ) |
Destroys the dev panel, if one exists.
|
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.
| 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.
| const CYIString& CYIApp::GetExternalPath | ( | ) | const |
Get the external storage location. This location generally persists beyond the install life of the application. See also SetExternalPath
| 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 |
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.
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.
|
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()
|
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.
|
protectedvirtual |
Function will be called when the surface size changes. Subclasses can use this to update their views based on the new size.
| 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.
|
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 |
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.
|
protectedpure virtual |
This function will be called during app initialization.
|
protectedpure virtual |
This is guaranteed to execute as the last component after all initializations are complete, including UserInit().
|
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.
|
friend |
|
friend |
|
protected |
| CYISignal<int32_t , int32_t > CYIApp::SurfaceSizeChanged |