2 #include "oxygine-include.h" 6 #include "pugixml/pugixml.hpp" 7 #include "closure/closure.h" 8 #include "core/Object.h" 13 #include <unordered_map> 31 ResourcesLoadOptions& prebuiltFolder(
const std::string& folder) {_prebuilFolder = folder;
return *
this; }
40 std::string _prebuilFolder;
47 typedef std::vector<spResource> resources;
49 typedef std::map<std::string, spResource> resourcesMap;
51 typedef std::unordered_map<std::string, spResource> resourcesMap;
55 typedef Closure<void (Resource*)> ResLoadedCallback;
61 static void registerResourceType(createResourceCallback creationCallback,
const char* resTypeID);
62 static void unregisterResourceType(
const char* resTypeID);
74 void add(
Resource* r,
bool accessByShortenID =
false);
77 void load(ResLoadedCallback cb = ResLoadedCallback());
91 Resource*
get(
const std::string& id, error_policy ep = ep_show_error)
const;
102 ResAnim*
getResAnim(
const std::string&
id, error_policy ep = ep_show_error)
const;
107 ResFont*
getResFont(
const std::string&
id, error_policy ep = ep_show_error)
const;
110 T* getT(
const std::string&
id, error_policy ep = ep_show_error)
const {
return safeCast<T*>(
get(id, ep)); }
118 resources& _getResources();
119 resourcesMap& _getResourcesMap();
122 void updateName(
const std::string& filename);
123 void _load(LoadResourcesContext* context)
override;
124 void _unload()
override;
131 createResourceCallback cb;
135 return strcmp(ob1.id, ob) > 0;
140 return strcmp(ob1.id, ob2.id) > 0;
143 bool operator < (
const char* ob2)
const 145 return strcmp(this->
id, ob2) > 0;
150 resources _resources;
151 resourcesMap _resourcesMap;
154 typedef std::vector< registeredResource > registeredResources;
155 static registeredResources _registeredResources;
158 std::vector<pugi::xml_document*> _docs;
Definition: Resources.h:19
static void registerResourceType(createResourceCallback creationCallback, const char *resTypeID)
Definition: Resources.h:127
void load(ResLoadedCallback cb=ResLoadedCallback())
ResFont * getResFont(const std::string &id, error_policy ep=ep_show_error) const
Resource * operator[](const std::string &id)
Definition: Resources.h:97
–oxgl-end–!
Definition: Actor.h:14
bool loadXML(const std::string &xmlFile, const ResourcesLoadOptions &opt=ResourcesLoadOptions())
Definition: Resource.h:10
void add(Resource *r, bool accessByShortenID=false)
ResAnim * getResAnim(const std::string &id, error_policy ep=ep_show_error) const
Definition: CreateResourceContext.h:60
void collect(resources &)
Definition: Resources.h:43