Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CApplication Class Reference

Class that manages the lifecycle and events of the application in Skylicht Engine. More...

#include <CApplication.h>

Inheritance diagram for Skylicht::CApplication:
irr::IEventReceiver Skylicht::CBaseApp

Public Member Functions

 CApplication ()
 Constructor for CApplication.
virtual ~CApplication ()
 Destructor for CApplication, releases resources.
virtual bool OnEvent (const SEvent &event)
 Handle input events.
CBaseAppgetBaseApp ()
 Returns a pointer to CBaseApp (for multiple inheritance).
void setParams (const std::vector< std::string > &argv)
 Set command line parameters for the application.
const std::vector< std::string > & getParams ()
 Get the list of command line parameters passed to the application.
void initApplication (IrrlichtDevice *device)
 Initialize the application with an Irrlicht device.
void initPlugin ()
 Initialize the application external plugin.
void releasePlugin ()
 Release the application external plugin.
void destroyApplication ()
 Destroy the application and release resources.
void mainLoop ()
 Main loop of the application. Calls update, render, and handles events.
void onInit ()
 Send initialization event to application receivers.
bool onClose ()
 Handle application close event.
int back ()
 Handle Back event (commonly used on mobile).
void pause ()
 Pause the application.
void resume (int showConnecting=1)
 Resume the application after pause.
void resetTouch ()
 Reset touch (screen touch) state.
void notifyResizeWin (int w, int h)
 Notify window size change.
void updateTouch (long touchID, int x, int y, int action)
 Update touch event (screen interaction).
void updateJoystick (int deviceID, int key, int action)
 Update joystick event (game controller).
void updateAnalog (int deviceID, int id, float x, float y)
 Update analog event from joystick.
void updateAccelerometer (float x, float y, float z)
 Update accelerometer values (motion sensor).
void setAccelerometerSupport (bool b)
 Set accelerometer support.
void setAccelerometerEnable (bool b)
 Enable/disable accelerometer.
bool isAccelerometerEnable ()
 Check if accelerometer is enabled.
void setDeviceID (const wchar_t *string)
 Set device ID (unicode string).
void setDeviceID (const char *string)
 Set device ID (ansi string).
void enableWriteLog (bool b)
 Enable/disable console logging.
Public Member Functions inherited from irr::IEventReceiver
virtual ~IEventReceiver ()
 Destructor.
Public Member Functions inherited from Skylicht::CBaseApp
 CBaseApp ()
 Default constructor for CBaseApp.
virtual ~CBaseApp ()
 Destructor for CBaseApp.
const char * getAppName ()
 Get the name of the application.
void showDebugConsole ()
 Show debug console (Windows only).
IrrlichtDevicegetDevice ()
 Get the Irrlicht device.
IVideoDrivergetDriver ()
 Get the Irrlicht video driver.
io::IFileSystemgetFileSystem ()
 Get the Irrlicht file system.
void setClearColor (const video::SColor &c)
 Set the color used to clear the screen before rendering.
SExposedVideoDatagetVideoData ()
 Get exposed video data for rendering pipeline.
float getTimeStep ()
 Get the time step for the current frame.
io::path getBuiltInPath (const char *name)
 Get built-in asset path based on platform.
std::string getTexturePackageName (const char *name, const char *ext=".zip")
 Get texture package name based on platform and compression support.
void showFPS (bool b)
 Show or hide FPS in window caption.
int getWidth ()
 Get the screen width.
int getHeight ()
 Get the screen height.
float getSizeRatio ()
 Get the screen aspect ratio (width/height).
bool isWideScreen ()
 Check if screen is widescreen format.
void clearScreenTime (float t)
 Set the duration to clear the screen before rendering.
void enableRender (bool b)
 Enable or disable rendering.
bool isRenderEnabled ()
 Check if rendering is enabled.
void registerAppEvent (const std::string &name, IApplicationEventReceiver *pEvent)
 Register a new application event receiver.
void unRegisterAppEvent (IApplicationEventReceiver *pEvent)
 Unregister an application event receiver.
void sendEventToAppReceiver (int eventID, int param1=0, int param2=0)
 Send an event to all registered application event receivers.
void setLimitFPS (int fps)
 Set the FPS limit for the application.
int getLimitFPS ()
 Get the FPS limit.
void enableRunWhenPause (bool b)
 Enable or disable running logic when the application is paused.
void openURL (const char *url)
 Open browse with url.
bool isNetworkAvailable ()
 Check network available or not?

Public Attributes

unsigned long m_lastUpdateTime
 Last update time(milliseconds).
int m_fps
 Current limit FPS value.
std::function< void()> OnExitApplication
 Callback for application exit (use on MacOS).
Public Attributes inherited from Skylicht::CBaseApp
std::vector< appEventTypem_appEventReceivers
 List of registered application event receivers.

Protected Attributes

int m_width
int m_height
bool m_runGame
 Flag indicating whether the application is running.
std::vector< std::string > m_argv
 Command line arguments for the application.
Protected Attributes inherited from Skylicht::CBaseApp
IrrlichtDevicem_device
 Irrlicht device pointer.
IVideoDriverm_driver
 Video driver pointer.
io::IFileSystemm_fileSystem
 File system pointer.
SExposedVideoData m_videoData
float m_timeStep
 Time step for each frame(ms).
float m_totalTime
 Total elapsed time since app started(ms).
int m_limitFPS
 FPS limit(-1 for unlimited).
bool m_showFPS
 Flag to display FPS in window caption.
float m_clearScreenTime
 Time to clear screen before rendering.
bool m_renderEnabled
 Flag to enable / disable rendering.
bool m_enableRunWhenPause
video::SColor m_clearColor
 Color used to clear the screen.
std::string m_appName
 Application name.

Additional Inherited Members

Public Types inherited from Skylicht::CBaseApp
typedef std::pair< std::string, IApplicationEventReceiver * > appEventType
 Type for mapping application event receivers by name.
Static Public Member Functions inherited from Skylicht::CBaseApp
static void reportLeakMemory ()
 Report memory leaks (Visual Leak Detector, debug only).

Detailed Description

Class that manages the lifecycle and events of the application in Skylicht Engine.

CApplication inherits from IEventReceiver and CBaseApp. It is responsible for initialization, main loop management, event processing, input device management (touch, joystick, accelerometer), and system operations related to the application.

Member Function Documentation

◆ back()

int Skylicht::CApplication::back ( )

Handle Back event (commonly used on mobile).

Returns
Returns 1 if handled, or value from receivers.

◆ enableWriteLog()

void Skylicht::CApplication::enableWriteLog ( bool b)

Enable/disable console logging.

Parameters
btrue to enable, false to disable.

◆ getBaseApp()

CBaseApp * Skylicht::CApplication::getBaseApp ( )
inline

Returns a pointer to CBaseApp (for multiple inheritance).

Returns
Pointer to CBaseApp.

◆ getParams()

const std::vector< std::string > & Skylicht::CApplication::getParams ( )

Get the list of command line parameters passed to the application.

Returns
List of parameters.

◆ initApplication()

void Skylicht::CApplication::initApplication ( IrrlichtDevice * device)

Initialize the application with an Irrlicht device.

Parameters
devicePointer to IrrlichtDevice.

◆ isAccelerometerEnable()

bool Skylicht::CApplication::isAccelerometerEnable ( )

Check if accelerometer is enabled.

Returns
true if enabled, false if disabled.

◆ notifyResizeWin()

void Skylicht::CApplication::notifyResizeWin ( int w,
int h )

Notify window size change.

Parameters
wNew width.
hNew height.

◆ onClose()

bool Skylicht::CApplication::onClose ( )

Handle application close event.

Returns
Return true if can close, false if should keep running.

◆ OnEvent()

virtual bool Skylicht::CApplication::OnEvent ( const SEvent & event)
virtual

Handle input events.

Parameters
eventThe incoming event.
Returns
Return true if the event is handled, otherwise false.

Implements irr::IEventReceiver.

◆ resume()

void Skylicht::CApplication::resume ( int showConnecting = 1)

Resume the application after pause.

Parameters
showConnectingIndicates whether to show reconnecting UI.

◆ setAccelerometerEnable()

void Skylicht::CApplication::setAccelerometerEnable ( bool b)

Enable/disable accelerometer.

Parameters
btrue to enable, false to disable.

◆ setAccelerometerSupport()

void Skylicht::CApplication::setAccelerometerSupport ( bool b)

Set accelerometer support.

Parameters
btrue to support, false otherwise.

◆ setDeviceID() [1/2]

void Skylicht::CApplication::setDeviceID ( const char * string)

Set device ID (ansi string).

Parameters
stringDevice ID as char string.

◆ setDeviceID() [2/2]

void Skylicht::CApplication::setDeviceID ( const wchar_t * string)

Set device ID (unicode string).

Parameters
stringDevice ID as wchar_t string.

◆ setParams()

void Skylicht::CApplication::setParams ( const std::vector< std::string > & argv)

Set command line parameters for the application.

Parameters
argvList of parameters.

◆ updateAccelerometer()

void Skylicht::CApplication::updateAccelerometer ( float x,
float y,
float z )

Update accelerometer values (motion sensor).

Parameters
xX axis.
yY axis.
zZ axis.

◆ updateAnalog()

void Skylicht::CApplication::updateAnalog ( int deviceID,
int id,
float x,
float y )

Update analog event from joystick.

Parameters
deviceIDDevice ID.
idAnalog ID.
xX axis value.
yY axis value.

◆ updateJoystick()

void Skylicht::CApplication::updateJoystick ( int deviceID,
int key,
int action )

Update joystick event (game controller).

Parameters
deviceIDDevice ID.
keyKey pressed/released.
actionEvent type: 0 = Press, 1 = Release.

◆ updateTouch()

void Skylicht::CApplication::updateTouch ( long touchID,
int x,
int y,
int action )

Update touch event (screen interaction).

Parameters
touchIDTouch ID.
xX coordinate.
yY coordinate.
actionEvent type: 0 = TouchDown, 1 = TouchUp, 2 = TouchMove.

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