#pragma once

#include <frostbite2D/2d/sprite.h>
#include <frostbite2D/types/type_color.h>
#include <frostbite2D/types/type_math.h>
#include <string>

namespace frostbite2D {

class TextSprite : public Sprite {
public:
  enum class Align {
    Left,
    Center,
    Right
  };

  TextSprite();
  ~TextSprite();

  static Ptr<TextSprite> create();
  static Ptr<TextSprite> create(const std::string& text, const std::string& fontName);

  void SetText(const std::string& text);
  const std::string& GetText() const { return text_; }

  void SetFont(const std::string& fontName);
  const std::string& GetFontName() const { return fontName_; }

  void SetTextColor(const Color& color);
  void SetTextColor(float r, float g, float b, float a = 1.0f);
  const Color& GetTextColor() const { return textColor_; }

  void SetAlign(Align align);
  Align GetAlign() const { return align_; }

  void RenderText();
  Vec2 GetTextSize() const;

private:
  void updateTexture();

  std::string text_;
  std::string fontName_;
  Color textColor_ = Colors::White;
  Align align_ = Align::Left;
};

}
