Fix up the backend so it has sane names like get_sprite and get_icon, then implemented a guecs::Icon for icons. Those don't scale and typically have other properties different from a Sprite.
This commit is contained in:
parent
31a02505aa
commit
5a7c096b52
9 changed files with 76 additions and 29 deletions
|
@ -9,10 +9,11 @@ namespace sfml {
|
|||
public:
|
||||
|
||||
Backend();
|
||||
guecs::SpriteTexture texture_get(const string& name);
|
||||
guecs::SpriteTexture get_sprite(const string& name);
|
||||
guecs::SpriteTexture get_icon(const string& name);
|
||||
void sound_play(const string& name);
|
||||
void sound_stop(const string& name);
|
||||
std::shared_ptr<sf::Shader> shader_get(const std::string& name);
|
||||
std::shared_ptr<sf::Shader> get_shader(const std::string& name);
|
||||
bool shader_updated();
|
||||
guecs::Theme theme();
|
||||
};
|
||||
|
|
|
@ -38,12 +38,16 @@ namespace guecs {
|
|||
};
|
||||
|
||||
struct Sprite {
|
||||
// either you set a filename here,
|
||||
// or some kind of config,
|
||||
// or a callback that does the loading,
|
||||
// or a virtual function and you subclass
|
||||
// or there's a static config function you call once,
|
||||
// that's passed an object with all the necessary gear
|
||||
string name;
|
||||
int padding = THEME.PADDING;
|
||||
std::shared_ptr<sf::Sprite> sprite = nullptr;
|
||||
|
||||
void init(lel::Cell &cell);
|
||||
void update(const string& new_name);
|
||||
void render(sf::RenderWindow& window, sf::Shader *shader_ptr);
|
||||
};
|
||||
|
||||
struct Icon {
|
||||
string name;
|
||||
int padding = THEME.PADDING;
|
||||
std::shared_ptr<sf::Sprite> sprite = nullptr;
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace textures {
|
|||
struct SpriteTexture {
|
||||
std::shared_ptr<sf::Sprite> sprite = nullptr;
|
||||
std::shared_ptr<sf::Texture> texture = nullptr;
|
||||
sf::Vector2i frame_size;
|
||||
};
|
||||
|
||||
struct TextureManager {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue