|
SDL2lazy
|

Public Member Functions | |
| SlManager () | |
| SlManager (const std::string &name, int width, int height) | |
| SlManager (const SlManager &)=delete | |
| SlManager & | operator= (const SlManager &)=delete |
| bool | appendToRenderQueue (const std::string &name, unsigned int destination=0) |
| SlRenderItem * | createRenderItem (const std::string &name, unsigned int destination) |
| void | deleteRenderItem (const std::string &name) |
| void | deleteSprite (const std::string &name) |
| void | deleteTexture (const std::string &name) |
| std::shared_ptr< SlSprite > | findSprite (const std::string &name) |
| SlTexture * | findTexture (const std::string &name) |
| void | handleEvent (const SDL_Event &event) |
| void | insertInRenderQueueAfter (const std::string &toAdd, const std::string &afterThis, unsigned int destToAdd=0, unsigned int destAfterThis=0) |
| void | insertInRenderQueueBefore (const std::string &toAdd, const std::string &beforeThis, unsigned int destToAdd=0, unsigned int destBeforeThis=0) |
| bool | moveInRenderQueueBefore (const std::string &toAdd, const std::string &beforeThis, unsigned int destToAdd=0, unsigned int destBeforeThis=0) |
| bool | moveInRenderQueueAfter (const std::string &toAdd, const std::string &afterThis, unsigned int destToAdd=0, unsigned int destAfterThis=0) |
| void | manipulateRenderQueue (const std::string &name, unsigned int destination, const std::string &whatToDo, const std::vector< std::string > ¶meters) |
| void | parseRenderQueueManipulation (std::ifstream &input) |
| bool | parseConfigurationFile (const std::string &filename="SlTextureConfig.ini") |
| void | parseIniFile (const std::string &filename="SlApplication.ini") |
| void | render () |
| SDL_Renderer * | renderer () |
| void | run () |
| int | screenWidth () |
| int | screenHeight () |
| void | setSpriteColor (const std::string &name, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha=0xFF, unsigned int destination=0) |
| void | setSpriteDestinationOrigin (const std::string &name, int x, int y, unsigned int destination=0) |
| void | setSpriteRenderOptions (const std::string &name, uint32_t renderOptions, unsigned int destination=0) |
| void | swapInRenderQueue (const std::string &toAdd, const std::string &toRemove, unsigned int destToAdd=0, unsigned int destToRemove=0) |
| void | swapInRenderQueueAtPosition (const std::string &toAdd, unsigned int destToAdd, unsigned int position) |
| void | swapInRenderQueueLastPosition (const std::string &toAdd, unsigned int destToAdd=0) |
| void | toggleRender (const std::string &toToggle, unsigned int destination=0, int onOrOff=-1) |
| void | toggleRenderOff (const std::string &toToggle, unsigned int destination=0) |
| void | toggleRenderOn (const std::string &toToggle, unsigned int destination=0) |
Protected Member Functions | |
| void | clear () |
| void | initialize () |
| void | initializeWindow (const std::string &name, int width, int height) |
| bool | moveInRenderQueue (const std::string &toMoveName, const std::string &targetName, unsigned int destToMove=0, unsigned int targetDest=0, int beforeOrAfter=0) |
Protected Attributes | |
| SDL_Window * | window_ = nullptr |
| SDL_Renderer * | renderer_ = nullptr |
Private Attributes | |
| std::vector< SlRenderItem * > | renderQueue_ |
| std::unique_ptr< SlTextureManager > | tmngr_ = nullptr |
| std::shared_ptr< SlSpriteManager > | smngr_ = nullptr |
| std::unique_ptr< SlEventHandler > | eventHandler_ = nullptr |
| int | screen_width_ |
| int | screen_height_ |
| SlValueParser | valParser_ |
| std::map< std::string, SlManipulation * > | renderManip_ |
| SlManager::SlManager | ( | ) |
Default constructor. Parses "SlApplication.ini" for window name and dimensions, and configuration file names.
| SlManager::SlManager | ( | const std::string & | name, |
| int | width, | ||
| int | height | ||
| ) |
Initializes SDL, creates window with name and width, height
|
delete |
Delete copy constructor. The manager owns the window, don't want copies of that.
| bool SlManager::appendToRenderQueue | ( | const std::string & | name, |
| unsigned int | destination = 0 |
||
| ) |
Adds the sprite 'name' to the end of the renderQueue_ .
| false | if sprite not found or destination out of bounds. |
|
protected |
Deletes all textures and sprites, empties render queue.
| SlRenderItem * SlManager::createRenderItem | ( | const std::string & | name, |
| unsigned int | destination | ||
| ) |
Creates new SlRenderItem for the specified sprite.
| nullptr | if sprite not found or destination out of bounds. |
| void SlManager::deleteRenderItem | ( | const std::string & | name | ) |
Delete all render items with the specified name from the renderQueue_ . Should be called before deleteSprite(const std::string& name).
| void SlManager::deleteSprite | ( | const std::string & | name | ) |
Tells smngr_ to delete the specified sprite. Also deletes all associated entries in renderQueue_ .
| void SlManager::deleteTexture | ( | const std::string & | name | ) |
Tells tmngr_ to delete the specified texture and remove from SlTextureManager::textures_ . Also deletes all associates SlSprites.
| std::shared_ptr< SlSprite > SlManager::findSprite | ( | const std::string & | name | ) |
Returns pointer to the sprite, nullptr if not found.
| SlTexture * SlManager::findTexture | ( | const std::string & | name | ) |
Returns pointer to the texture, nullptr if not found. Calls SlTextureManager tmngr_ .
|
inline |
Pass event on to SlEventHandler eventHandler_ . Deprecated, just call run().
|
protected |
Initializes SDL
< Needs to be shared with SlRenderQueueManipulation items.
|
protected |
Initializes window
| void SlManager::insertInRenderQueueAfter | ( | const std::string & | toAdd, |
| const std::string & | afterThis, | ||
| unsigned int | destToAdd = 0, |
||
| unsigned int | destAfterThis = 0 |
||
| ) |
Inserts the sprite into the renderQueue_ after the specified sprite.
| void SlManager::insertInRenderQueueBefore | ( | const std::string & | toAdd, |
| const std::string & | beforeThis, | ||
| unsigned int | destToAdd = 0, |
||
| unsigned int | destBeforeThis = 0 |
||
| ) |
Inserts the sprite into the renderQueue_ before the specified sprite.
| void SlManager::manipulateRenderQueue | ( | const std::string & | name, |
| unsigned int | destination, | ||
| const std::string & | whatToDo, | ||
| const std::vector< std::string > & | parameters | ||
| ) |
Move the render item based on configuration file.\ Currently implemented whatToDo:
append
|
protected |
Moves a SlRenderItem's position in the renderQueue_ to before of after the target item.
beforeOrAfter is 0 for before, 1 for after. Larger (smaller) values will result in the target item begin inserted further upstream (downstream) of the target. (Handle with care, currently no test for valid iterators beyond +1...)
| bool SlManager::moveInRenderQueueAfter | ( | const std::string & | toAdd, |
| const std::string & | afterThis, | ||
| unsigned int | destToAdd = 0, |
||
| unsigned int | destAfterThis = 0 |
||
| ) |
Moves the render item into the renderQueue_ after the specified sprite.
| bool SlManager::moveInRenderQueueBefore | ( | const std::string & | toAdd, |
| const std::string & | beforeThis, | ||
| unsigned int | destToAdd = 0, |
||
| unsigned int | destBeforeThis = 0 |
||
| ) |
Moves the render item into the renderQueue_ before the specified sprite.
Deleted, same reason as copy constructor.
| bool SlManager::parseConfigurationFile | ( | const std::string & | filename = "SlTextureConfig.ini" | ) |
Read texture and sprite definitions from configuration file.
Default file name: "SlTextures.ini".
| void SlManager::parseIniFile | ( | const std::string & | filename = "SlApplication.ini" | ) |
Reads application name, screen dimensions and config file names from from ini file "SlApplication.ini".
| void SlManager::parseRenderQueueManipulation | ( | std::ifstream & | input | ) |
Add sprites to render queue, change to order of the queue. (Currently only implemented: append.)
| void SlManager::render | ( | ) |
Render all items in the renderQueue_ .
| 0 | if all renders well. |
|
inline |
Temporary solution until all rendering related stuff happens in SlManager methods.
| void SlManager::run | ( | ) |
Run the event - render loop.
|
inline |
Returns the screen_height_ of the window.
|
inline |
Returns the screen_width_ of the window.
|
inline |
Sets color for SlSprite name at position i of SlSprite::destinations_.
Color is use when using color mod to render, and when creating a texture from a rectangle.
|
inline |
Changes destinationRect for SlSprite name at position destination of SlSprite::destinations_.
Sets where the sprite will be rendered.
|
inline |
Sets SlRenderOptions for SlSprite name at position i of SlSprite::destinations_.
| false | if i > SlSprite::destinations_ size. |
| void SlManager::swapInRenderQueue | ( | const std::string & | toAdd, |
| const std::string & | toRemove, | ||
| unsigned int | destToAdd = 0, |
||
| unsigned int | destToRemove = 0 |
||
| ) |
Replaces the sprite 'toRemove' in the renderQueue_ with sprite 'toAdd' .
| false | if sprite not found or destination out of bounds. |
| void SlManager::swapInRenderQueueAtPosition | ( | const std::string & | toAdd, |
| unsigned int | destToAdd, | ||
| unsigned int | position | ||
| ) |
Replaces the SlRenderItem at 'position' in the renderQueue_ with sprite 'toAdd'.
Note that the first item is in position 0.
| void SlManager::swapInRenderQueueLastPosition | ( | const std::string & | toAdd, |
| unsigned int | destToAdd = 0 |
||
| ) |
Replaces the last item in the renderQueue_ with sprite toAdd.
| void SlManager::toggleRender | ( | const std::string & | toToggle, |
| unsigned int | destination = 0, |
||
| int | onOrOff = -1 |
||
| ) |
Toggles rendering of an item in the renderQueue_ on and off. onOrOff is -1 to toggle, 0 to turn off, 1 to turn on.
|
inline |
Turns off rendering for the specified SlRenderItem in the renderQueue_ .
|
inline |
Turns on rendering for the specified SlRenderItem in the renderQueue_ .
|
private |
Event handler, parses events in configuration file, triggers SlManipulation on key input.
|
protected |
The renderer tied to the main window.
|
private |
Holds the various SlRenderQueueManipulations for the different tasks. The map key is the name of the manipulation, which is also the keyword used in the configuration file, the mapped value is the object that will do the actual work.
|
private |
Holds the items to be rendered. The front of the queue is rendered first (background) the last element is rendered last (foreground).
|
private |
Window height
|
private |
Window width.
|
private |
Sprite manager, creates, stores, manipulates, and deletes SlSprite objects.
|
private |
Texture manager, creates, stores, deletes SlTexture objects.
|
private |
Helper object to translate file input into values.
|
protected |
The main (and only) window.
1.8.9.1