Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
sprite_manager.h
1 #pragma once
2 
3 #include "../sprite.h"
4 #include "../../managers/window_holder.h"
5 #include "../stage_node_manager.h"
6 #include "../stage_node_pool.h"
7 #include "../../path.h"
8 
9 namespace smlt {
10 
11 typedef StageNodeManager<StageNodePool, SpriteID, Sprite> TemplatedSpriteManager;
12 
13 typedef sig::signal<void (SpriteID)> SpriteCreatedSignal;
14 typedef sig::signal<void (SpriteID)> SpriteDestroyedSignal;
15 
17 
18  DEFINE_SIGNAL(SpriteCreatedSignal, signal_sprite_created);
19  DEFINE_SIGNAL(SpriteDestroyedSignal, signal_sprite_destroyed);
20 
21  friend class Sprite;
22 
23 public:
24  SpriteManager(Stage* stage, StageNodePool *pool);
25  virtual ~SpriteManager();
26 
27  SpritePtr new_sprite();
28  SpritePtr new_sprite_from_file(const smlt::Path& filename,
29  uint32_t frame_width, uint32_t frame_height,
30  const SpritesheetAttrs &attrs=SpritesheetAttrs()
31  );
32 
33  SpritePtr new_sprite_from_texture(TextureID texture_id,
34  uint32_t frame_width, uint32_t frame_height,
35  const SpritesheetAttrs &attrs=SpritesheetAttrs()
36  );
37 
38  SpritePtr sprite(SpriteID s);
39  bool has_sprite(SpriteID s) const;
40  SpritePtr destroy_sprite(SpriteID s);
41  std::size_t sprite_count() const;
42  void destroy_all();
43 
44  void destroy_object(Sprite* skybox);
45  void destroy_object_immediately(Sprite* skybox);
46 private:
47  Stage* stage_ = nullptr;
48  sig::connection clean_up_conn_;
49 
50  std::shared_ptr<TemplatedSpriteManager> sprite_manager_;
51 
52 public:
53  Property<decltype(&SpriteManager::stage_)> stage = { this, &SpriteManager::stage_ };
54 };
55 
56 }
smlt::Property
Definition: property.h:202
smlt::sig::Connection
Definition: signal.h:65
smlt::Stage
Definition: stage.h:92
smlt
Definition: animation.cpp:25
smlt::Polylist
Definition: polylist.h:67
smlt::Sprite
Definition: sprite.h:50
smlt::UniqueID< TexturePtr >
smlt::SpritesheetAttrs
Definition: sprite.h:37
smlt::Path
Definition: path.h:7
smlt::SpriteManager
Definition: sprite_manager.h:16
smlt::default_init_ptr
Definition: default_init_ptr.h:8
smlt::sig::signal
Definition: signal.h:319