#pragma once #include "core/vfs.h" #include #include #include #include namespace playground { struct CharacterFrame { int x=0, y=0, w=0, h=0, regx=0, regy=0; }; // Frame 0 is the full portrait; later frames are expressions aligned by regx/regy. bool parseCharacterFrames(std::string_view xml, std::vector& frames, std::string* error=nullptr); class CharacterAtlas { public: CharacterAtlas()=default; ~CharacterAtlas(); CharacterAtlas(const CharacterAtlas&)=delete; CharacterAtlas& operator=(const CharacterAtlas&)=delete; bool load(SDL_Renderer* renderer,const Vfs& assets,std::string_view name, std::string* error=nullptr); bool draw(SDL_Renderer* renderer,float x,float y,size_t expression=0, Uint8 alpha=255) const; const std::vector& frames() const { return frames_; } SDL_Texture* texture() const { return texture_; } private: SDL_Texture* texture_=nullptr; std::vector frames_; }; } // namespace playground