diff options
Diffstat (limited to 'src/FbTk/LResource.cc')
-rw-r--r-- | src/FbTk/LResource.cc | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc index 18209cb..589e52f 100644 --- a/src/FbTk/LResource.cc +++ b/src/FbTk/LResource.cc | |||
@@ -89,21 +89,6 @@ namespace { | |||
89 | 89 | ||
90 | } // anonymous namespace | 90 | } // anonymous namespace |
91 | 91 | ||
92 | void LResourceManager::convert(ResourceManager &old, const std::string &new_file) { | ||
93 | Lua l; | ||
94 | |||
95 | LResourceManager new_rm(old.root(), l); | ||
96 | for(ResourceList::const_iterator i = old.begin(); i != old.end(); ++i) { | ||
97 | // adding the resource to new_rm will set it to default value | ||
98 | // we save the value to a temp variable so we can restore it later | ||
99 | const std::string &t = (*i)->getString(); | ||
100 | new_rm.addResource(**i); | ||
101 | (*i)->setFromString(t.c_str()); | ||
102 | } | ||
103 | |||
104 | new_rm.save(new_file.c_str(), NULL); | ||
105 | } | ||
106 | |||
107 | LResourceManager::LResourceManager(const std::string &root, Lua &l, unsigned int autosave) | 92 | LResourceManager::LResourceManager(const std::string &root, Lua &l, unsigned int autosave) |
108 | : ResourceManager_base(root), m_l(&l) { | 93 | : ResourceManager_base(root), m_l(&l) { |
109 | 94 | ||
@@ -116,6 +101,25 @@ LResourceManager::LResourceManager(const std::string &root, Lua &l, unsigned int | |||
116 | setLua(l); | 101 | setLua(l); |
117 | } | 102 | } |
118 | 103 | ||
104 | LResourceManager::LResourceManager(ResourceManager &old, Lua &l) | ||
105 | : ResourceManager_base(old.root()), m_l(&l) { | ||
106 | |||
107 | // We create a copy of the list so we can safely traverse it while the resources disassociate | ||
108 | // themselves from the old resource manager | ||
109 | ResourceList list; | ||
110 | for(ResourceList::const_iterator i = old.begin(); i != old.end(); ++i) { | ||
111 | list.push_back(*i); | ||
112 | } | ||
113 | |||
114 | for(ResourceList::const_iterator i = list.begin(); i != list.end(); ++i) { | ||
115 | // adding the resource to this resource manager will set it to default value | ||
116 | // we save the value to a temp variable so we can restore it later | ||
117 | const std::string &t = (*i)->getString(); | ||
118 | (*i)->setResourceManager(*this); | ||
119 | (*i)->setFromString(t.c_str()); | ||
120 | } | ||
121 | } | ||
122 | |||
119 | void LResourceManager::doLoad(const std::string &filename) { | 123 | void LResourceManager::doLoad(const std::string &filename) { |
120 | m_l->checkstack(1); | 124 | m_l->checkstack(1); |
121 | lua::stack_sentry s(*m_l); | 125 | lua::stack_sentry s(*m_l); |