CRM64Pro GDK v0.11.0
A free cross-platform game development kit built on top of SDL 3.0
|
v2.00 (23 June 2023)
The Main module manages and provides access to the rest of modules.
The CRM64Pro::Main represents a starting point for the client application and also manages some important tasks:
Using this module, the application can gain access to the rest of modules:
There are two kinds of interfaces:
Regarding managers, there are three categorized types based on how they handle its objects:
Acts as a hub from which all other interfaces can be reached. Main is designed as a singleton and only one instance will exists.
It is automatically created the first time Main::Instance() is called. This creation process is not thread-safe.
Once the instance is created, it is accessible throughout the life of client application using Main::Instance().
Main singleton is using explicit destruction so do not forget to call Main::Terminate() before exiting from the application.
Namespaces | |
namespace | CRM64Pro::CMem |
CMem: CRM64Pro Memory Manager. | |
Classes | |
class | CRM64Pro::Main |
CRM64Pro GDK Main class. More... | |
Macros | |
#define | C64_EVENT 0xEC64 |
#define | C64_EVENT_LOGIC 1 |
#define | C64_EVENT_RENDER 2 |
#define | C64_EVENT_WIDGET 4 |
#define | C64_EVENT_WIDGET_MOUSEOVER 8 |
#define | C64_EVENT_WIDGET_LOSTFOCUS 16 |
#define | C64_STATUS_DISABLED 0 |
#define | C64_STATUS_ENABLED 1 |
#define | C64_STATUS_PAUSED 2 |
#define | C64_STATUS_HIDDEN 5 |
#define | C64_STATUS_SHOWN 9 |
#define | C64_STATUS_END 16 |
#define | C64_ERR_INTER 0xFFFFFF00 |
#define | C64_ERR_PARAM 0xFFFFFE00 |
#define | C64_ERR_FILOP 0xFFFFFD00 |
#define | C64_ERR_FILWR 0xFFFFFC00 |
#define | C64_ERR_FILRE 0xFFFFFB00 |
#define | C64_ERR_ALLOC 0xFFFFFA00 |
#define | C64_ERR_OBJNF 0xFFFFF900 |
Enumerations | |
enum | CRM64Pro::ePositionHelpers { CRM64Pro::PH_END = 0x60000000 , CRM64Pro::PH_CENTER = 0x61000000 , CRM64Pro::PH_CENTERD = 0x71000000 , CRM64Pro::PH_TOP = 0x62000000 , CRM64Pro::PH_TOPD = 0x72000000 , CRM64Pro::PH_BOTTOM = 0x63000000 , CRM64Pro::PH_BOTTOMD = 0x73000000 , CRM64Pro::PH_LEFT = 0x65000000 , CRM64Pro::PH_LEFTD = 0x75000000 , CRM64Pro::PH_RIGHT = 0x66000000 , CRM64Pro::PH_RIGHTD = 0x76000000 } |
Position helpers used by Cursor, Sprite, Font and GUI Widgets. More... | |
Functions | |
static Main & | CRM64Pro::Main::Instance () |
Creates the Main instance. | |
static void | CRM64Pro::Main::Terminate () |
Main explicit destructor. | |
Sint32 | CRM64Pro::Main::info (Sint32 iMode=0) |
Request Main Interface information. | |
static Sint32 | CRM64Pro::Main::isInit () |
Check if the GDK is initialized. | |
const string & | CRM64Pro::Main::getCopyright () |
Get copyright string. | |
void | CRM64Pro::Main::printVersion () |
Print version and compiled date to our default log object. | |
const string & | CRM64Pro::Main::getVersion () |
Get version string. | |
Sint32 | CRM64Pro::Main::requireVersion (Uint8 iMajor, Uint8 iMinor) |
Check given version against GDK version. | |
Sint32 | CRM64Pro::Main::update (SDL_Event *evUser=nullptr) |
Main application update governor. | |
float | CRM64Pro::Main::getLogicTime () |
Get logic time. | |
Sint32 | CRM64Pro::Main::getKeyState (SDL_Keycode keycode) |
Get the state of a key. | |
const char * | CRM64Pro::Main::getKeyName (SDL_Keycode keycode) |
Get a human-readable name for a key. | |
Sint32 | CRM64Pro::Main::getKeyboardFocus () |
Get the Screen id which currently has keyboard focus. | |
ConfigMgr & | CRM64Pro::Main::IConfigMgr () |
Get the reference to the Config Manager. | |
Tool & | CRM64Pro::Main::ITool () |
Get the reference to the Tool Interface. | |
LogMgr & | CRM64Pro::Main::ILogMgr () |
Get the reference to the Log Manager. | |
Timer & | CRM64Pro::Main::ITimer () |
Get the reference to the Timer Interface. | |
ArchiveMgr & | CRM64Pro::Main::IArchiveMgr () |
Get the reference to the Archive Manager. | |
XMLMgr & | CRM64Pro::Main::IXMLMgr () |
Get the reference to the XML Manager. | |
MusicMgr & | CRM64Pro::Main::IMusicMgr () |
Get the reference to the Music Manager. | |
SoundMgr & | CRM64Pro::Main::ISoundMgr () |
Get the reference to the Sound Manager. | |
ImageMgr & | CRM64Pro::Main::IImageMgr () |
Get the reference to the Image Manager. | |
CursorMgr & | CRM64Pro::Main::ICursorMgr () |
Get the reference to the Cursor Manager. | |
TileMgr & | CRM64Pro::Main::ITileMgr () |
Get the reference to the Tile Manager. | |
SpriteMgr & | CRM64Pro::Main::ISpriteMgr () |
Get the reference to the Sprite Manager. | |
FontMgr & | CRM64Pro::Main::IFontMgr () |
Get the reference to the Font Manager. | |
GFX & | CRM64Pro::Main::IGFX () |
Get the reference to the GFX Interface. | |
GUIMgr & | CRM64Pro::Main::IGUIMgr () |
Get the reference to the GUI Manager. | |
TileEngineMgr & | CRM64Pro::Main::ITileEngineMgr () |
Get the reference to the TileEngine Manager. | |
NetTCP & | CRM64Pro::Main::INetTCP () |
Get the reference to the NetTCP Interface. | |
#define C64_EVENT 0xEC64 |
Event type returned by Main::update() setting one of available codes.
#define C64_EVENT_LOGIC 1 |
event.user.code returned by Main::update() with C64_EVENT event type. A logic frame occurred.
#define C64_EVENT_RENDER 2 |
event.user.code returned by Main::update() with C64_EVENT event type. A render frame occurred.
#define C64_EVENT_WIDGET 4 |
event.user.code returned by Main::update() with C64_EVENT event type. A GUI Widget triggered an WS_ACTION event.
#define C64_EVENT_WIDGET_MOUSEOVER 8 |
event.user.code returned by Main::update() with C64_EVENT event type. The mouse pointer is over a GUI Widget.
#define C64_EVENT_WIDGET_LOSTFOCUS 16 |
event.user.code returned by Main::update() with C64_EVENT event type. The GUI Widget lost the focus.
#define C64_STATUS_DISABLED 0 |
General Status: disabled.
#define C64_STATUS_ENABLED 1 |
General Status: enabled.
#define C64_STATUS_PAUSED 2 |
General Status: paused.
#define C64_STATUS_HIDDEN 5 |
General Status: enabled but hidden.
#define C64_STATUS_SHOWN 9 |
General Status: enabled and shown.
#define C64_STATUS_END 16 |
General Status: end.
#define C64_ERR_INTER 0xFFFFFF00 |
Error code: Internal error.
#define C64_ERR_PARAM 0xFFFFFE00 |
Error code: Invalid parameter.
#define C64_ERR_FILOP 0xFFFFFD00 |
Error code: Could not open/create a file.
#define C64_ERR_FILWR 0xFFFFFC00 |
Error code: Could not write to a file.
#define C64_ERR_FILRE 0xFFFFFB00 |
Error code: Could not read from a file.
#define C64_ERR_ALLOC 0xFFFFFA00 |
Error code: Could not allocate memory.
#define C64_ERR_OBJNF 0xFFFFF900 |
Error code: Object not found.
Position helpers used by Cursor, Sprite, Font and GUI Widgets.
Enumerator | |
---|---|
PH_END | Used with Cursor::setHotSpot() to set as hotspot the cursor_size. |
PH_CENTER | Used with Cursor::setHotSpot() to set as hotspot the cursor_size/2. |
PH_CENTERD | Widget and Font relative position: center with optional decrement. |
PH_TOP | Widget and Font relative position: top with optional increment. Valid for Y axis. |
PH_TOPD | Widget and Font relative position: top with optional decrement. Valid for Y axis. |
PH_BOTTOM | Widget and Font relative position: bottom with optional increment. Valid for Y axis. |
PH_BOTTOMD | Widget and Font relative position: bottom with optional decrement. Valid for Y axis. |
PH_LEFT | Widget and Font relative position: left with optional increment. Valid for X axis. |
PH_LEFTD | Widget and Font relative position: left with optional decrement. Valid for X axis. |
PH_RIGHT | Widget and Font relative position: right with optional increment. Valid for X axis. |
PH_RIGHTD | Widget and Font relative position: right with optional decrement. Valid for X axis. |
|
static |
Creates the Main instance.
Main automatically performs these tasks:
|
static |
Sint32 CRM64Pro::Main::info | ( | Sint32 | iMode = 0 | ) |
Request Main Interface information.
For displaying the information, it uses the default log.
iMode | unused for the time being. |
|
static |
Check if the GDK is initialized.
const string & CRM64Pro::Main::getCopyright | ( | ) |
Get copyright string.
void CRM64Pro::Main::printVersion | ( | ) |
Print version and compiled date to our default log object.
Does not return any value, just print the version.
const string & CRM64Pro::Main::getVersion | ( | ) |
Get version string.
Sint32 CRM64Pro::Main::requireVersion | ( | Uint8 | iMajor, |
Uint8 | iMinor | ||
) |
Check given version against GDK version.
iMajor | required major version. |
iMinor | required minor version. |
Sint32 CRM64Pro::Main::update | ( | SDL_Event * | evUser = nullptr | ) |
Main application update governor.
This method is very important and replaces some SDL functions as SDL_PollEvent() or SDL_RenderPresent() and update other internal system as GUI or Timer.
It also provides an important feature of the GDK, the fixed virtual logic frame rate with interpolation feature.
As there are some ways to use it which target different application behaviours, it is recommended to read and understand this extended information page.
The workflow for every call to this method follow below priority steps:
evUser | SDL_Event pointer, by default is nullptr. |
float CRM64Pro::Main::getLogicTime | ( | ) |
Get logic time.
Sint32 CRM64Pro::Main::getKeyState | ( | SDL_Keycode | keycode | ) |
Get the state of a key.
From the two different types of values to represent keys on the SDL system, we are using the keycode approach.
Keycode type is character-dependent and keyboard layout-independent.
keycode | SDL_Keycode key to get its state. |
const char * CRM64Pro::Main::getKeyName | ( | SDL_Keycode | keycode | ) |
Get a human-readable name for a key.
keycode | SDL_Keycode key to get its human-readable name. |
Sint32 CRM64Pro::Main::getKeyboardFocus | ( | ) |
Get the Screen id which currently has keyboard focus.
ConfigMgr & CRM64Pro::Main::IConfigMgr | ( | ) |
Get the reference to the Config Manager.
Tool & CRM64Pro::Main::ITool | ( | ) |
Get the reference to the Tool Interface.
LogMgr & CRM64Pro::Main::ILogMgr | ( | ) |
Get the reference to the Log Manager.
Timer & CRM64Pro::Main::ITimer | ( | ) |
Get the reference to the Timer Interface.
ArchiveMgr & CRM64Pro::Main::IArchiveMgr | ( | ) |
Get the reference to the Archive Manager.
XMLMgr & CRM64Pro::Main::IXMLMgr | ( | ) |
Get the reference to the XML Manager.
MusicMgr & CRM64Pro::Main::IMusicMgr | ( | ) |
Get the reference to the Music Manager.
SoundMgr & CRM64Pro::Main::ISoundMgr | ( | ) |
Get the reference to the Sound Manager.
ImageMgr & CRM64Pro::Main::IImageMgr | ( | ) |
Get the reference to the Image Manager.
CursorMgr & CRM64Pro::Main::ICursorMgr | ( | ) |
Get the reference to the Cursor Manager.
TileMgr & CRM64Pro::Main::ITileMgr | ( | ) |
Get the reference to the Tile Manager.
SpriteMgr & CRM64Pro::Main::ISpriteMgr | ( | ) |
Get the reference to the Sprite Manager.
FontMgr & CRM64Pro::Main::IFontMgr | ( | ) |
Get the reference to the Font Manager.
GFX & CRM64Pro::Main::IGFX | ( | ) |
Get the reference to the GFX Interface.
GUIMgr & CRM64Pro::Main::IGUIMgr | ( | ) |
Get the reference to the GUI Manager.
TileEngineMgr & CRM64Pro::Main::ITileEngineMgr | ( | ) |
Get the reference to the TileEngine Manager.
NetTCP & CRM64Pro::Main::INetTCP | ( | ) |
Get the reference to the NetTCP Interface.