![]() |
CRM64Pro GDK
v0.94
A free cross-platform game development kit built on top of SDL 2.0
|
Classes | |
class | CRM64Pro::CursorObj |
class | CRM64Pro::CursorMgr |
Macros | |
#define | CUR_HOTSPOT_CENTER 0x0A000000 |
#define | CUR_HOTSPOT_END 0x0B000000 |
This system is build over the SDL cursor and always has the 12 SDL system cursors available for selecting:
SDL_SYSTEM_CURSOR_ARROW - Arrow
SDL_SYSTEM_CURSOR_IBEAM - I-beam
SDL_SYSTEM_CURSOR_WAIT - Wait
SDL_SYSTEM_CURSOR_CROSSHAIR - Crosshair
SDL_SYSTEM_CURSOR_WAITARROW - Small wait cursor (or Wait if not available)
SDL_SYSTEM_CURSOR_SIZENWSE - Double arrow pointing northwest and southeast
SDL_SYSTEM_CURSOR_SIZENESW - Double arrow pointing northeast and southwest
SDL_SYSTEM_CURSOR_SIZEWE - Double arrow pointing west and east
SDL_SYSTEM_CURSOR_SIZENS - Double arrow pointing north and south
SDL_SYSTEM_CURSOR_SIZEALL - Four pointed arrow pointing north, south, east, and west
SDL_SYSTEM_CURSOR_NO - Slashed circle or crossbones
SDL_SYSTEM_CURSOR_HAND - Hand
Before to create/load cursors, a valid screen must exist or these methods will fail.
Each cursor (but SDL system cursors) owns an Image id. Although there is a method for getting this Image id, it only should be used for showing image info, saving it or changing the image name. Other attributes like color modulation, alpha modulation and blend modes dont work with the cursor. Only colorkey works but as it needs a cursor rebuild, CursorMgr has its own setColorKey() that does this task.
The storage layer(CursorMgr::load() and CursorObj::save() methods) are using the CDC v1.x specification.
Internally, Main::update() call to CursorMgr::update() for updating the cursor status (buttons and position).
This is an advance "cloning" manager: when loading from a CDC file a cursor which is already loaded/created (using the name as the key), it will create a new child cursor.
Only a single instance of the Cursor Manager exists which is created once Main is instantiated.
You can get a reference to this manager using Main::ICursorMgr() method.
#define CUR_HOTSPOT_CENTER 0x0A000000 |
Used with CursorObj::setHotSpot() to set as hotspot the cursor_size/2.
#define CUR_HOTSPOT_END 0x0B000000 |
Used with CursorObj::setHotSpot() to set as hotspot the cursor_size.
Sint32 CRM64Pro::CursorObj::info | ( | Sint32 | iMode = 0 | ) |
Request Cursor object information.
For displaying the information, it uses the default log.
iMode | unused for the time being. |
Sint32 CRM64Pro::CursorObj::getName | ( | string & | sName | ) |
Get the name.
sName | a string containing the cursor name. |
Uint32 CRM64Pro::CursorObj::getID | ( | ) |
Get the ID.
Sint32 CRM64Pro::CursorObj::assignImage | ( | Sint32 | idImage, |
Sint32 | iOwnership = 0 |
||
) |
Assign an Image to this cursor.
It is mainly used for associating an Image to the cursor when it is created via CursorMgr::create().
idImage | Image id. |
iOwnership | 0 for creating our own copy of the image or any other integer for taking the ownership of the image, in this case, the image can not be already owned by other item. By default it is set to 0. |
Sint32 CRM64Pro::CursorObj::getImage | ( | ) |
Get the assigned Image of this cursor.
Sint32 CRM64Pro::CursorObj::build | ( | ) |
Build the cursor.
If the assigned Image colorkey is modified, a call to this method will re-build the cursor to reflect the changes.
Other Image attributes as color and alpha modulation will not have any effect with the cursors.
Sint32 CRM64Pro::CursorObj::setHotSpot | ( | Sint32 | iHotX, |
Sint32 | iHotY | ||
) |
Set the cursor hotspots.
iHotX | the x hotspot position of the cursor. You can set any value or CUR_HOTSPOT_CENTER and CUR_HOTSPOT_END defines. |
iHotY | the y hotspot position of the cursor. You can set any value or CUR_HOTSPOT_CENTER and CUR_HOTSPOT_END defines. |
Sint32 CRM64Pro::CursorObj::getHotSpot | ( | Sint32 * | iHotX, |
Sint32 * | iHotY | ||
) |
Get the cursor hotspots.
iHotX | an integer pointer filled in with x hotspot position of the cursor. If nullptr is passed, the method ignores the retrieving of this value. |
iHotY | an integer pointer filled in with y hotspot position of the cursor. If nullptr is passed, the method ignores the retrieving of this value. |
Sint32 CRM64Pro::CursorObj::save | ( | const string & | sFileCDC | ) |
Save the cursor to a CDC file.
The associated image will also be saved in to the same CDC file.
sFileCDC | string containing the [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
Sint32 CRM64Pro::CursorObj::save | ( | Sint32 | idCDC | ) |
Save the cursor to a CDC file.
The associated image will also be saved in to the same CDC file.
idCDC | CDC id. |
Sint32 CRM64Pro::CursorMgr::info | ( | Sint32 | iMode = 0 | ) |
Request Cursor Manager information.
For displaying the information, it uses the default log.
iMode | -1 for displaying only Manager information. 0 for displaying Manager and all Objects information. This is the default value. idCursor for displaying Manager and given Cursor id information. |
Sint32 CRM64Pro::CursorMgr::create | ( | const string & | sName, |
Uint32 | iVersion = 10 |
||
) |
Create a new cursor.
This method will create an empty cursor (no image assigned), use CursorObj::assignImage() method for assigning the image.
sName | The name to give to the cursor e.g. 'myCursor'. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
iVersion | Cursor version. 10 means 1.0 which is the only version supported (as of now). v1.0 is set by default. |
Sint32 CRM64Pro::CursorMgr::close | ( | Sint32 | idCur | ) |
Close and destroy a cursor.
idCur | 0 for closing all cursors or the Cursor id. Stand-alone and child cursors can be closed but parent ones, can not as they have at least one dependency(a child). |
Sint32 CRM64Pro::CursorMgr::getNum | ( | ) |
Get number of loaded objects.
Sint32 CRM64Pro::CursorMgr::setName | ( | Sint32 | idCur, |
const string & | sName | ||
) |
Change the object name.
idCur | Cursor id. |
sName | The name to give to the cursor e.g. 'myCursor'. The object name must be unique and with a maximum size of 64 characters or will be truncated. |
CursorObj * CRM64Pro::CursorMgr::get | ( | Sint32 | idCur | ) |
Get a pointer to the cursor using its handler.
idCur | Cursor id. |
Sint32 CRM64Pro::CursorMgr::select | ( | Sint32 | idCur | ) |
Select a mouse cursor.
idCur | Cursor id. It also supports any SDL_SystemCursor. |
Sint32 CRM64Pro::CursorMgr::getSelect | ( | ) |
Get selected mouse cursor.
Sint32 CRM64Pro::CursorMgr::show | ( | ) |
Make visible the selected mouse cursor.
Sint32 CRM64Pro::CursorMgr::hide | ( | ) |
Hide the mouse cursor.
Sint32 CRM64Pro::CursorMgr::setPosition | ( | Sint32 | iX, |
Sint32 | iY, | ||
Sint32 | idScreen = 0 |
||
) |
Set the mouse cursor position.
iX | integer with x position. |
iY | integer with y position. |
idScreen | Screen id. By default it is set to 0 for using the screen with the mouse focus. |
Sint32 CRM64Pro::CursorMgr::getPosition | ( | Sint32 * | iX, |
Sint32 * | iY | ||
) |
Get the mouse cursor position.
iX | an integer pointer filled in with X mouse position. If nullptr is passed, the method ignores the retrieving of this value. |
iY | an integer pointer filled in with Y mouse position. If nullptr is passed, the method ignores the retrieving of this value. |
Sint32 CRM64Pro::CursorMgr::getButtons | ( | ) |
Get the mouse buttons.
Sint32 CRM64Pro::CursorMgr::getButtonsPrev | ( | ) |
Get the previous mouse buttons.
Sint32 CRM64Pro::CursorMgr::getFocus | ( | ) |
Get the Screen id which currently has mouse focus.
Sint32 CRM64Pro::CursorMgr::child | ( | Sint32 | idCur | ) |
Create a child cursor dependant on the provided one(the parent).
A child cursor uses the attributes of the parent and creates also a parent child image for having different attributes, for the time being, only different Hotspots as the colorkey can not be modified on child images and other image attributes are not supported on the SDL cursors system.
idCur | parent Cursor id. If the provided cursor is a child, internally it will redirect this request to the parent in order to create the new child. |
Sint32 CRM64Pro::CursorMgr::load | ( | const string & | sFileCDC, |
const string & | sName | ||
) |
Load a cursor stored in a CDC file.
sFileCDC | string containing the [directory]+filename. Directory separators '\' and '/' are supported. |
sName | string with the cursor name (maximum size of 64 characters). If the Cursor is already created, this method will call child() for creating a child. |
Sint32 CRM64Pro::CursorMgr::load | ( | const Sint32 | idCDC, |
const string & | sName | ||
) |
Load a cursor stored in a CDC file.
idCDC | CDC id. |
sName | string with the cursor name (maximum size of 64 characters). If the Cursor is already created, this method will call child() for creating a child. |
Sint32 CRM64Pro::CursorMgr::remove | ( | Sint32 | idCDC, |
const string & | sName | ||
) |
Remove a cursor stored in a CDC file.
idCDC | CDC id. |
sName | string with the cursor name (maximum size of 64 characters). |