xml: image element

This commit is contained in:
MihailRis
2024-02-12 22:54:09 +03:00
parent 2de5f5c646
commit de6a6dd771
11 changed files with 101 additions and 71 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ bool AssetsLoader::loadNext() {
return false;
}
aloader_func loader = found->second;
bool status = loader(assets, paths, entry.filename, entry.alias, entry.config);
bool status = loader(*this, assets, paths, entry.filename, entry.alias, entry.config);
entries.pop();
return status;
}
+3 -1
View File
@@ -15,9 +15,10 @@ const short ASSET_LAYOUT = 5;
class ResPaths;
class Assets;
class AssetsLoader;
class Content;
using aloader_func = std::function<bool(Assets*, const ResPaths*, const std::string&, const std::string&, std::shared_ptr<void>)>;
using aloader_func = std::function<bool(AssetsLoader&, Assets*, const ResPaths*, const std::string&, const std::string&, std::shared_ptr<void>)>;
struct aloader_entry {
int tag;
@@ -40,6 +41,7 @@ public:
const std::string alias,
std::shared_ptr<void> settings=nullptr
);
bool hasNext() const;
bool loadNext();
+31 -22
View File
@@ -3,6 +3,7 @@
#include <iostream>
#include <filesystem>
#include "Assets.h"
#include "AssetsLoader.h"
#include "../files/files.h"
#include "../files/engine_paths.h"
#include "../coders/png.h"
@@ -18,11 +19,13 @@
namespace fs = std::filesystem;
bool assetload::texture(Assets* assets,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void>
bool assetload::texture(
AssetsLoader&,
Assets* assets,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void>
) {
std::unique_ptr<Texture> texture(
png::load_texture(paths->find(filename).u8string())
@@ -35,11 +38,13 @@ bool assetload::texture(Assets* assets,
return true;
}
bool assetload::shader(Assets* assets,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void>
bool assetload::shader(
AssetsLoader&,
Assets* assets,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void>
) {
fs::path vertexFile = paths->find(filename+".glslv");
fs::path fragmentFile = paths->find(filename+".glslf");
@@ -80,11 +85,13 @@ static bool appendAtlas(AtlasBuilder& atlas, const fs::path& file) {
return true;
}
bool assetload::atlas(Assets* assets,
const ResPaths* paths,
const std::string directory,
const std::string name,
std::shared_ptr<void>
bool assetload::atlas(
AssetsLoader&,
Assets* assets,
const ResPaths* paths,
const std::string directory,
const std::string name,
std::shared_ptr<void>
) {
AtlasBuilder builder;
for (const auto& file : paths->listdir(directory)) {
@@ -98,11 +105,13 @@ bool assetload::atlas(Assets* assets,
return true;
}
bool assetload::font(Assets* assets,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void>
bool assetload::font(
AssetsLoader&,
Assets* assets,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void>
) {
std::vector<std::unique_ptr<Texture>> pages;
for (size_t i = 0; i <= 4; i++) {
@@ -123,6 +132,7 @@ bool assetload::font(Assets* assets,
}
bool assetload::layout(
AssetsLoader& loader,
Assets* assets,
const ResPaths* paths,
const std::string file,
@@ -131,7 +141,7 @@ bool assetload::layout(
) {
try {
LayoutCfg* cfg = reinterpret_cast<LayoutCfg*>(config.get());
auto document = UiDocument::read(cfg->env, name, file);
auto document = UiDocument::read(loader, cfg->env, name, file);
assets->store(document.release(), name);
return true;
} catch (const parsing_error& err) {
@@ -141,7 +151,6 @@ bool assetload::layout(
}
}
bool assetload::animation(Assets* assets,
const ResPaths* paths,
const std::string directory,
+12 -6
View File
@@ -6,39 +6,45 @@
class ResPaths;
class Assets;
class AssetsLoader;
class Atlas;
namespace assetload {
bool texture(
Assets* assets,
AssetsLoader&,
Assets*,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void> settings
);
bool shader(
Assets* assets,
AssetsLoader&,
Assets*,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void> settings
);
bool atlas(
Assets* assets,
AssetsLoader&,
Assets*,
const ResPaths* paths,
const std::string directory,
const std::string name,
std::shared_ptr<void> settings
);
bool font(
Assets* assets,
AssetsLoader&,
Assets*,
const ResPaths* paths,
const std::string filename,
const std::string name,
std::shared_ptr<void> settings
);
bool layout(
Assets* assets,
AssetsLoader&,
Assets*,
const ResPaths* paths,
const std::string file,
const std::string name,
@@ -46,7 +52,7 @@ namespace assetload {
);
bool animation(
Assets* assets,
Assets*,
const ResPaths* paths,
const std::string directory,
const std::string name,