Skylicht Engine
Loading...
Searching...
No Matches
CApplication.h
1/*
2!@
3MIT License
4
5Copyright (c) 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "pch.h"
28#include "CBaseApp.h"
29#include <functional>
30
31namespace Skylicht
32{
40 public IEventReceiver,
41 public CBaseApp
42 {
43 public:
45 unsigned long m_lastUpdateTime;
46
48 int m_fps;
49
51 std::function<void()> OnExitApplication;
52
53 protected:
54 int m_width;
55 int m_height;
56
59
61 std::vector<std::string> m_argv;
62
63 public:
68
72 virtual ~CApplication();
73
79 virtual bool OnEvent(const SEvent& event);
80
86 {
87 return static_cast<CBaseApp*>(this);
88 }
89
94 void setParams(const std::vector<std::string>& argv);
95
100 const std::vector<std::string>& getParams();
101
107
112
117
122
126 void mainLoop();
127
131 void onInit();
132
137 bool onClose();
138
143 int back();
144
148 void pause();
149
154 void resume(int showConnecting = 1);
155
160
166 void notifyResizeWin(int w, int h);
167
175 void updateTouch(long touchID, int x, int y, int action);
176
183 void updateJoystick(int deviceID, int key, int action);
184
192 void updateAnalog(int deviceID, int id, float x, float y);
193
200 void updateAccelerometer(float x, float y, float z);
201
207
213
219
224 void setDeviceID(const wchar_t* string);
225
230 void setDeviceID(const char* string);
231
236 void enableWriteLog(bool b);
237 };
238
239}
CApplication()
Constructor for CApplication.
bool m_runGame
Flag indicating whether the application is running.
Definition CApplication.h:58
void initApplication(IrrlichtDevice *device)
Initialize the application with an Irrlicht device.
void resume(int showConnecting=1)
Resume the application after pause.
std::vector< std::string > m_argv
Command line arguments for the application.
Definition CApplication.h:61
void updateAccelerometer(float x, float y, float z)
Update accelerometer values (motion sensor).
int back()
Handle Back event (commonly used on mobile).
void onInit()
Send initialization event to application receivers.
void destroyApplication()
Destroy the application and release resources.
const std::vector< std::string > & getParams()
Get the list of command line parameters passed to the application.
bool isAccelerometerEnable()
Check if accelerometer is enabled.
void updateAnalog(int deviceID, int id, float x, float y)
Update analog event from joystick.
virtual bool OnEvent(const SEvent &event)
Handle input events.
void updateJoystick(int deviceID, int key, int action)
Update joystick event (game controller).
void updateTouch(long touchID, int x, int y, int action)
Update touch event (screen interaction).
void setDeviceID(const wchar_t *string)
Set device ID (unicode string).
void pause()
Pause the application.
void notifyResizeWin(int w, int h)
Notify window size change.
virtual ~CApplication()
Destructor for CApplication, releases resources.
void mainLoop()
Main loop of the application. Calls update, render, and handles events.
void setParams(const std::vector< std::string > &argv)
Set command line parameters for the application.
void setAccelerometerSupport(bool b)
Set accelerometer support.
void setAccelerometerEnable(bool b)
Enable/disable accelerometer.
bool onClose()
Handle application close event.
void setDeviceID(const char *string)
Set device ID (ansi string).
void resetTouch()
Reset touch (screen touch) state.
int m_fps
Current limit FPS value.
Definition CApplication.h:48
void releasePlugin()
Release the application external plugin.
CBaseApp * getBaseApp()
Returns a pointer to CBaseApp (for multiple inheritance).
Definition CApplication.h:85
void enableWriteLog(bool b)
Enable/disable console logging.
std::function< void()> OnExitApplication
Callback for application exit (use on MacOS).
Definition CApplication.h:51
void initPlugin()
Initialize the application external plugin.
unsigned long m_lastUpdateTime
Last update time(milliseconds).
Definition CApplication.h:45
CBaseApp()
Default constructor for CBaseApp.
Interface of an object which can receive events.
Definition IEventReceiver.h:474
The Irrlicht device. You can create it with createDevice() or createDeviceEx().
Definition IrrlichtDevice.h:44
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
Definition IEventReceiver.h:273