Oxygine  1
2g game engine
CreateResourceContext.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include <string>
4 #include "pugixml/pugixml.hpp"
5 #include "core/Object.h"
6 
7 namespace oxygine
8 {
10  class XmlWalker
11  {
12  public:
13  XmlWalker(const std::string* xmlFolder,
14  const std::string& path,
15  float scaleFactor,
16  bool load, bool alpha,
17  pugi::xml_node xml, pugi::xml_node meta);
18 
19  bool empty() const {return _root.empty();}
20 
21  const std::string& getCurrentFolder() const { return _path; }
22  const std::string& getXmlFolder() const { return *_xmlFolder; }
23  std::string getPath(const char* attrName) const;
24  pugi::xml_node getNode() const {return _root;}
25  pugi::xml_node getMeta() const {return _rootMeta;}
26  float getScaleFactor() const {return _scaleFactor;}
27  bool getLoad() const {return _load;}
28  bool getAlphaHitTest() const { return _alphaHitTest; }
29  const char* getType() const {return _root.name();}
30 
31  void checkSetAttributes();
32  void setXmlFolder(const std::string* ptr) { _xmlFolder = ptr; }
33 
34 
35  XmlWalker next();
36  pugi::xml_node nextMeta();
37 
38  private:
39  void _checkSetAttributes(pugi::xml_node node);
40  std::string connectPath(const char* currentPath, const char* str);
41 
42  const std::string* _xmlFolder;
43  std::string _path;
44 
45  pugi::xml_node _root;
46  pugi::xml_node _last;
47 
48  pugi::xml_node _rootMeta;
49  pugi::xml_node _lastMeta;
50 
51  bool _notStarted;
52  bool _notStartedMeta;
53 
54  float _scaleFactor;
55  bool _load;
56  bool _alphaHitTest;
57  };
58 
59 
61  {
62  public:
63  CreateResourceContext() : resources(0), xml_name(0), prebuilt_folder(0), options(0),
64  walker(0, "", 1.0f, true, false, pugi::xml_node(), pugi::xml_node())
65  {
66  }
67 
68  Resources* resources;
69  XmlWalker walker;
70 
71  const std::string* xml_name;
72  const std::string* prebuilt_folder;
73  const ResourcesLoadOptions* options;
74  };
75 
76  DECLARE_SMART(Image, spImage);
77  DECLARE_SMART(NativeTexture, spNativeTexture);
78 
79 
81  {
82  public:
84 
85  spImage src;
86  spNativeTexture dest;
87  bool linearFilter;
88  bool clamp2edge;
89 
90  void ready() const;
91  };
92 
95  {
96  public:
97  static LoadResourcesContext* get();
98 
99  virtual ~LoadResourcesContext() {}
100 
101 
102  virtual void createTexture(const CreateTextureTask& opt) = 0;
103  virtual bool isNeedProceed(spNativeTexture t) = 0;
104  };
105 
107  {
108  public:
109  static SingleThreadResourcesContext instance;
110  void createTexture(const CreateTextureTask& opt) override;
111  bool isNeedProceed(spNativeTexture t) override;
112  };
113 
115  {
116  public:
117  static MTLoadingResourcesContext instance;
118  void createTexture(const CreateTextureTask& opt) override;
119  bool isNeedProceed(spNativeTexture t) override;
120  };
121 
123  {
124  public:
125  static RestoreResourcesContext instance;
126  void createTexture(const CreateTextureTask& opt) override;
127  bool isNeedProceed(spNativeTexture t) override;
128  };
129 }
Definition: CreateResourceContext.h:114
Definition: CreateResourceContext.h:94
Definition: Image.h:23
Definition: Resources.h:19
Definition: CreateResourceContext.h:80
–oxgl-end–!
Definition: Actor.h:14
Definition: CreateResourceContext.h:10
Definition: CreateResourceContext.h:106
Definition: CreateResourceContext.h:60
Definition: CreateResourceContext.h:122
Definition: Resources.h:43
Definition: NativeTexture.h:10