| 242 | } |
| 243 | |
| 244 | void Animation::loadImages( |
| 245 | vili::node& images, const System::Path& path, Engine::ResourceManager* resources) |
| 246 | { |
| 247 | vili::node& imageList = images.at("images"); |
| 248 | std::string model; |
| 249 | if (!images["model"].is_null()) |
| 250 | { |
| 251 | model = images.at("model"); |
| 252 | Debug::Log->trace( |
| 253 | " <Animation> Using following template to load images : {}", model); |
| 254 | } |
| 255 | for (auto& image : imageList) |
| 256 | { |
| 257 | std::string textureName; |
| 258 | if (image.is<vili::integer>() && !model.empty()) |
| 259 | { |
| 260 | textureName = Utils::String::replace( |
| 261 | model, "%s", std::to_string(image.as<vili::integer>())); |
| 262 | Debug::Log->trace(" <Animation> Loading image '{}' (name determined " |
| 263 | "with template[int])", |
| 264 | textureName); |
| 265 | } |
| 266 | else if (image.is<vili::string>() && !model.empty()) |
| 267 | { |
| 268 | textureName = Utils::String::replace(model, "%s", image); |
| 269 | Debug::Log->trace(" <Animation> Loading image '{}' (name determined " |
| 270 | "with template[str])", |
| 271 | textureName); |
| 272 | } |
| 273 | else if (image.is<vili::string>()) |
| 274 | { |
| 275 | textureName = image; |
| 276 | Debug::Log->trace(" <Animation> Loading image '{}'", textureName); |
| 277 | } |
| 278 | |
| 279 | std::string pathToTexture = path.add(textureName).toString(); |
| 280 | Debug::Log->trace( |
| 281 | " <Animation> Found Texture Path at '{}'", pathToTexture); |
| 282 | if (resources) |
| 283 | { |
| 284 | Debug::Log->trace( |
| 285 | " <Animation> Loading Texture {0} (using ResourceManager)", |
| 286 | textureName); |
| 287 | m_textures.emplace_back(resources->getTexture( |
| 288 | path.add(textureName).toString(), m_antiAliasing)); |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | Debug::Log->trace(" <Animation> Loading Texture {0}", textureName); |
| 293 | Graphics::Texture newTexture; |
| 294 | newTexture.loadFromFile(path.add(textureName).find()); |
| 295 | // TODO: Add a way to configure anti-aliasing for textures without ResourceManager |
| 296 | m_textures.push_back(std::move(newTexture)); |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | void Animation::loadGroups(vili::node& groups) |
no test coverage detected