diff --git a/source/code/sago/SagoDataHolder.hpp b/source/code/sago/SagoDataHolder.hpp index 3c126aa..0abace8 100644 --- a/source/code/sago/SagoDataHolder.hpp +++ b/source/code/sago/SagoDataHolder.hpp @@ -82,12 +82,14 @@ public: */ SagoDataHolder(); explicit SagoDataHolder(SDL_Renderer* renderer); + /** * Return a pointer to the given texture. The pointer is valid for the lifetime of SagoDataHolder object it was taken from or until invalidateAll is called. * @param textureName Name of the texture * @return Pointer to the loaded texture */ SDL_Texture* getTexturePtr(const std::string &textureName) const; + TextureHandler getTextureHandler(const std::string &textureName) const; TTF_Font* getFontPtr(const std::string &fontName, int ptsize) const; Mix_Music* getMusicPtr(const std::string &musicName) const; @@ -95,10 +97,12 @@ public: Mix_Chunk* getSoundPtr(const std::string &soundName) const; SoundHandler getSoundHandler(const std::string &soundName) const; void setVerbose(bool value); + /** * Invalidates all pointers returned by any of the get variables */ void invalidateAll(); + /** * Invalidates all pointers returned by any of the get variables. * Also sets a new renderer. @@ -106,12 +110,14 @@ public: * Setting a new renderer might cause all old textures to no longer match the renderer format. */ void invalidateAll(SDL_Renderer* renderer); + /** * The version number. Changes everytime the pointers are invalidated. * Can be used to determen if it is neccecary to get a new pointer. * @return A globally unique number. */ Uint64 getVersion() const; + ~SagoDataHolder(); private: SagoDataHolder(const SagoDataHolder& base) = delete; diff --git a/source/code/sago/SagoSprite.hpp b/source/code/sago/SagoSprite.hpp index 688770a..d57cbed 100644 --- a/source/code/sago/SagoSprite.hpp +++ b/source/code/sago/SagoSprite.hpp @@ -33,6 +33,7 @@ class SagoSprite final { public: SagoSprite(); SagoSprite(const SagoDataHolder &texHolder, const std::string &texture,const SDL_Rect& initImage,const int animationFrames, const int animationFrameLength); + /** * Draws the sprite to a given render window * @param target The render window to draw on @@ -41,6 +42,7 @@ public: * @param y Place to draw the sprite */ void Draw(SDL_Renderer* target, Sint32 frameTime, int x, int y) const; + /** * Draws part of the sprite to a given render window * @param target The render window to draw on @@ -50,6 +52,7 @@ public: * @param part the part of the sprite that should be drawn. */ void Draw(SDL_Renderer* target, Sint32 frameTime, int x, int y, const SDL_Rect& part) const; + /** * Draws the wprite to the given renderer but makes sure to not draw outside th bounds given * @param target The render window to draw on @@ -58,7 +61,9 @@ public: * @param y Place to draw the sprite * @param bounds A recagular area that we must not draw outside. */ - void DrawBounded(SDL_Renderer* target, Sint32 frameTime, int x, int y, const SDL_Rect& bounds) const;/** + void DrawBounded(SDL_Renderer* target, Sint32 frameTime, int x, int y, const SDL_Rect& bounds) const; + + /** * Draws the sprite to a given render window * @param target The render window to draw on * @param progress A float with value from 0.0f to 1.0f. Tells how far in the animation that we got @@ -67,6 +72,7 @@ public: */ void DrawProgressive(SDL_Renderer* target, float progress, int x, int y) const; void DrawScaled(SDL_Renderer* target, Sint32 frameTime, int x, int y, int w, int h) const; + /** * Set a different origin. Normally it is the top left cornor. But in some cases you might want to center the origin or tranform it for other reasons * @param newOrigin the coordinates that should be the new origin. Call with {0,0} to reset to default diff --git a/source/code/sago/SagoTextBox.hpp b/source/code/sago/SagoTextBox.hpp index e0b7096..c1df5cc 100644 --- a/source/code/sago/SagoTextBox.hpp +++ b/source/code/sago/SagoTextBox.hpp @@ -47,6 +47,7 @@ public: void SetFont(const char* fontName); void SetFontSize(int fontSize); void SetOutline(int outlineSize, const SDL_Color& color); + /** * Sets the max width to generate. SagoTextBox will insert line breaks to keep the width below this number. * Outline is not included in the width: If you have a 2 pixels outline the rendere may go 2 pixels beyond. diff --git a/source/code/sago/SagoTextField.hpp b/source/code/sago/SagoTextField.hpp index 902ee16..d28114c 100644 --- a/source/code/sago/SagoTextField.hpp +++ b/source/code/sago/SagoTextField.hpp @@ -45,6 +45,7 @@ public: SagoTextField& operator=(const SagoTextField&& base) = delete; SagoTextField& operator=(const SagoTextField& base) = delete; ~SagoTextField(); + /** * This method creates a copy of a given font. * The cache will not be copied. @@ -53,40 +54,49 @@ public: * @return A reference to this object. */ SagoTextField& CopyFrom(const SagoTextField& base); + /** * Sets the data holder. This is MANDATORY * @param holder The data holder to fetch the fonts from */ void SetHolder(const SagoDataHolder* holder); + /** * Set the text to display. * @param text The actual UTF-8 encoded text */ void SetText(const char* text); + /** * Set the text to display. * @param text The actual UTF-8 encoded text */ void SetText(const std::string& text); + void SetColor(const SDL_Color& color); + /** * Set the name of the font. Must be known to the data holder. * The name could for instance be "freeserif". * @param fontName Name of the font as required by SagoDataHolder */ void SetFont(const char* fontName); + void SetFontSize(int fontSize); + /** * Enable outline against the font. * @param outlineSize Number of pixels of outline. * @param color The color of the outline. */ void SetOutline(int outlineSize, const SDL_Color& color); + /** * Get the text we are currently drawing * @return The text */ const std::string& GetText() const; + /** * A Shorthand for calling TTF_SizeUTF8 on the right font * The size is measuered WITHOUT the outline! @@ -96,9 +106,11 @@ public: * @param h Pointer to an int where the hight of the text will be stored. Maybe null. */ void GetRenderedSize(const char* text, int* w = nullptr, int* h = nullptr); + enum class Alignment { left = 0, right=1, center = 2 }; enum class VerticalAlignment { top = 0, center = 1, bottom = 2}; void Draw(SDL_Renderer* target, int x, int y, Alignment alignment = Alignment::left, VerticalAlignment verticalAlignment = VerticalAlignment::top); + /** * Updates the cache. * You normally do not want to call this from the outside as it is done just in time. @@ -106,6 +118,7 @@ public: * @param target Target the the text will eventually be rendered to */ void UpdateCache(SDL_Renderer* target); + /** * Clears the cache and forces the SagoTextField to render it again the next time it is drawn. * Can be used if you have changed font, color or sizes.