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 | MemoryLevel { MemoryLevel::Moderate, MemoryLevel::Low, MemoryLevel::Critical } |
Public Attributes | |
CYISignal< int32_t, int32_t, int32_t, int32_t > | SurfaceSizeChanged |
CYISignal | ForegroundEntered |
CYISignal | BackgroundEntered |
Protected Member Functions | |
CYIApp (CYIAppPriv *pPriv) | |
virtual bool | UserInit ()=0 |
virtual bool | UserStart ()=0 |
virtual void | UserUpdate () |
virtual void | OnSurfaceSizeChanged (int32_t width, int32_t height, int32_t xDensity, int32_t yDensity) |
Protected Attributes | |
CYIAppPriv * | m_pPriv |
Friends | |
class | CYIAppPriv |
|
strong |
CYIApp::CYIApp | ( | ) |
|
virtual |
|
protected |
void CYIApp::DestroyDevPanel | ( | ) |
Destroys the dev panel, if one exists.
debug-tools
optional module be included in the app.
|
virtual |
This function draws the results of the previous Update() to the screen. If nothing has been updated, the screen buffer will not be drawn.
Returns true if a draw occurred.
const CYIString& CYIApp::GetAssetsPath | ( | ) | const |
Retrieve the asset location. The data within this path should be considered read-only.
const CYIColor& CYIApp::GetBackgroundColor | ( | ) |
Returns the current app background color.
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. Frequent writes to this location are permitted.
CYIScreenProperty::NavigationBar CYIApp::GetDefaultNavigationBarVisibility | ( | ) | const |
CYIScreenProperty::Orientation CYIApp::GetDefaultOrientation | ( | ) | const |
CYIScreenProperty::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.
debug-tools
optional module be included in the app. const CYIString& CYIApp::GetExternalPath | ( | ) | const |
Get the external storage location. This location generally persists beyond the install life of the application.
WRITE_EXTERNAL_STORAGE
permission is required to read or write to this path on Android.CYIHud& CYIApp::GetHUD | ( | ) |
Returns the CYIHud instance used by this app.
debug-tools
optional module be included in the app. const CYIHud& CYIApp::GetHUD | ( | ) | const |
Returns the CYIHud instance used by this app.
debug-tools
optional module be included in the app. const CYIString& CYIApp::GetPersistentPath | ( | ) | const |
Retrieve the data location. This location generally persists for the install life of the application.
CYIRenderingSurfaceInfo* CYIApp::GetRenderingSurfaceInfo | ( | ) |
Returns the rendering surface info object owned by this app.
const CYIRenderingSurfaceInfo* CYIApp::GetRenderingSurfaceInfo | ( | ) | const |
|
virtual |
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.
|
virtual |
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: CYIEvent::Type::ActionDown CYIEvent::Type::ActionMove CYIEvent::Type::ActionUp CYIEvent::Type::ActionWheel CYIEvent::Type::ActionWheelHorizontal CYIEvent::Type::ActionWheelVertical
void CYIApp::HandleGraphicsContextGained | ( | ) |
Updates the app in response to a new graphics context. Must be called by the platform implementation when the graphics context is gained and the application can begin rendering, such as when a window has been created.
void CYIApp::HandleGraphicsContextLost | ( | ) |
Updates the app in response to the loss of the graphics context. Must be called by the platform implementation when the graphics context is lost and the application can no longer render, such as in the case of the window being closed or when notified by the operating system.
|
virtual |
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 | ( | IYIRenderer::Type | rendererType = IYIRenderer::Type::Default | ) |
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.
bool CYIApp::Init | ( | std::unique_ptr< CYIFocusEngine > | pFocusEngine, |
IYIRenderer::Type | rendererType = IYIRenderer::Type::Default |
||
) |
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.
debug-tools
optional module be included in the app. bool CYIApp::IsHUDVisible | ( | ) | const |
Returns true if the HUD is visible, false otherwise.
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::IsRenderingThrottled | ( | ) | const |
Returns true if rendering is throttled.
Load a font, located at the specified URI into the text engine. The font's id will be stored in pFontID. local indicates whether the path is a local path
bool CYIApp::LoadFont | ( | const uint8_t * | pFontData, |
uint32_t | dataSize, | ||
ssize_t * | pFontID | ||
) |
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.
void CYIApp::OnBackgroundEntered | ( | ) |
Indicates that the application has entered the background. Causes the CYIApp::BackgroundEntered CYISignal to be emitted.
void CYIApp::OnForegroundEntered | ( | ) |
Indicates that the application has entered the foreground. Causes the CYIApp::ForegroundEntered CYISignal to be emitted.
|
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, |
CYIEvent::Priority | priority = CYIEvent::Priority::Default , |
||
bool | bump = false |
||
) |
Posts an event to the event dispatcher with priority priority. If bump 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, | ||
CYIEvent::Priority | priority = CYIEvent::Priority::Default , |
||
bool | bump = 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::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. The data written to the specified path must persistent as long as the application is running, but may be deleted between launches if necessary. Frequent writes to this location must be permitted.
void CYIApp::SetDefaultNavigationBarVisibility | ( | CYIScreenProperty::NavigationBar | navigationBar | ) |
void CYIApp::SetDefaultOrientation | ( | CYIScreenProperty::Orientation | orientation | ) |
void CYIApp::SetDefaultStatusBarVisibility | ( | CYIScreenProperty::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::SetHUDVisibility | ( | bool | visible | ) |
Sets the visibility of the HUD.
debug-tools
optional module be included in the app.void CYIApp::SetMultiTouchEnabled | ( | bool | enabled | ) |
Specify if the application will be notified of multi-touch events. Multi touch events are disabled by default.
void CYIApp::SetPersistentPath | ( | 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. The data written to the specified path should persist between app launches. Applications will minimize writes to this location.
void CYIApp::SetRenderingThrottling | ( | bool | throttle | ) |
Sets whether rendering should be throttled. When throttled, the renderer will sleep to avoid exceeding 60fps.
void CYIApp::SetShowFPS | ( | bool | show | ) |
Enable FPS rendering
debug-tools
optional module be included in the app. void CYIApp::SetVersion | ( | const CYIString & | version | ) |
Sets the application version string for this application object.
void CYIApp::SurfaceWasResized | ( | int32_t | width, |
int32_t | height, | ||
int32_t | xDensity, | ||
int32_t | yDensity | ||
) |
Handles available suface size changed notification. This will update the CYIRenderingSurfaceInfo and pass the notification along to the user.
void CYIApp::SurfaceWasResized | ( | int32_t | width, |
int32_t | height | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
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.
void CYIApp::Update | ( | bool | forceDirty = false , |
bool | updateTime = true |
||
) |
This function updates all of the application logic and the scene tree. Rendering occurs in Draw().
forceDirty can be set to true to force a draw. This should only be done when absolutely necessary updateTime 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 |
CYISignal CYIApp::BackgroundEntered |
Emitted when the app is no longer visible to the user, generally this occurs when the user has selected another application. On most platforms after this signal is emitted the application processing is paused and no further event processing or signals will be provided to the application until it comes back in the foreground.
CYISignal CYIApp::ForegroundEntered |
Emitted when the app has come into the foreground, generally this occurs when the user has selected this application after using another. On most platforms after this signal is emitted application processing is resumed and any queued events or signals will be provided to the application.
|
protected |
CYISignal<int32_t , int32_t , int32_t , int32_t > CYIApp::SurfaceSizeChanged |