mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
refactor: add ContentControl class
This commit is contained in:
parent
7262119f5b
commit
331734792d
21 changed files with 324 additions and 246 deletions
|
|
@ -71,8 +71,8 @@ inline audio::speakerid_t play_stream(
|
|||
if (std::strchr(filename, ':')) {
|
||||
file = std::string(filename);
|
||||
} else {
|
||||
auto paths = scripting::engine->getResPaths();
|
||||
file = paths->find(filename);
|
||||
const auto& paths = scripting::engine->getResPaths();
|
||||
file = paths.find(filename);
|
||||
}
|
||||
return audio::play_stream(
|
||||
file,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ using namespace scripting;
|
|||
static int l_find(lua::State* L) {
|
||||
auto path = lua::require_string(L, 1);
|
||||
try {
|
||||
return lua::pushstring(L, engine->getResPaths()->findRaw(path));
|
||||
return lua::pushstring(L, engine->getResPaths().findRaw(path));
|
||||
} catch (const std::runtime_error& err) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ static int l_write_bytes(lua::State* L) {
|
|||
}
|
||||
|
||||
static int l_list_all_res(lua::State* L, const std::string& path) {
|
||||
auto files = engine->getResPaths()->listdirRaw(path);
|
||||
auto files = engine->getResPaths().listdirRaw(path);
|
||||
lua::createtable(L, files.size(), 0);
|
||||
for (size_t i = 0; i < files.size(); i++) {
|
||||
lua::pushstring(L, files[i]);
|
||||
|
|
@ -222,7 +222,7 @@ static int l_read_combined_list(lua::State* L) {
|
|||
if (path.find(':') != std::string::npos) {
|
||||
throw std::runtime_error("entry point must not be specified");
|
||||
}
|
||||
return lua::pushvalue(L, engine->getResPaths()->readCombinedList(path));
|
||||
return lua::pushvalue(L, engine->getResPaths().readCombinedList(path));
|
||||
}
|
||||
|
||||
static int l_read_combined_object(lua::State* L) {
|
||||
|
|
@ -230,7 +230,7 @@ static int l_read_combined_object(lua::State* L) {
|
|||
if (path.find(':') != std::string::npos) {
|
||||
throw std::runtime_error("entry point must not be specified");
|
||||
}
|
||||
return lua::pushvalue(L, engine->getResPaths()->readCombinedObject(path));
|
||||
return lua::pushvalue(L, engine->getResPaths().readCombinedObject(path));
|
||||
}
|
||||
|
||||
static int l_is_writeable(lua::State* L) {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ static int l_get_generators(lua::State* L) {
|
|||
/// @return The ID of the default world generator
|
||||
static int l_get_default_generator(lua::State* L) {
|
||||
// content is not initialized yet
|
||||
auto combined = engine->getResPaths()->readCombinedObject(
|
||||
auto combined = engine->getResPaths().readCombinedObject(
|
||||
EnginePaths::CONFIG_DEFAULTS.string()
|
||||
);
|
||||
return lua::pushstring(L, combined["generator"].asString());
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "assets/AssetsLoader.hpp"
|
||||
#include "content/Content.hpp"
|
||||
#include "content/ContentControl.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "graphics/ui/gui_util.hpp"
|
||||
#include "graphics/ui/elements/Menu.hpp"
|
||||
|
|
@ -47,7 +48,8 @@ static int l_pack_get_available(lua::State* L) {
|
|||
if (level) {
|
||||
worldFolder = level->getWorld()->wfile->getFolder();
|
||||
}
|
||||
auto manager = engine->createPacksManager(worldFolder);
|
||||
PacksManager manager;
|
||||
manager.setSources(engine->getContentControl().getDefaultSources());
|
||||
manager.scan();
|
||||
|
||||
const auto& installed = engine->getContentPacks();
|
||||
|
|
@ -153,7 +155,8 @@ static int pack_get_infos(lua::State* L) {
|
|||
if (level) {
|
||||
worldFolder = level->getWorld()->wfile->getFolder();
|
||||
}
|
||||
auto manager = engine->createPacksManager(worldFolder);
|
||||
PacksManager manager;
|
||||
manager.setSources(engine->getContentControl().getDefaultSources());
|
||||
manager.scan();
|
||||
auto vec =
|
||||
manager.getAll(std::vector<std::string>(ids.begin(), ids.end()));
|
||||
|
|
@ -195,7 +198,8 @@ static int l_pack_get_info(lua::State* L) {
|
|||
if (level) {
|
||||
worldFolder = level->getWorld()->wfile->getFolder();
|
||||
}
|
||||
auto manager = engine->createPacksManager(worldFolder);
|
||||
PacksManager manager;
|
||||
manager.setSources(engine->getContentControl().getDefaultSources());
|
||||
manager.scan();
|
||||
auto vec = manager.getAll({packid});
|
||||
if (!vec.empty()) {
|
||||
|
|
@ -208,7 +212,7 @@ static int l_pack_get_info(lua::State* L) {
|
|||
}
|
||||
|
||||
static int l_pack_get_base_packs(lua::State* L) {
|
||||
auto& packs = engine->getBasePacks();
|
||||
auto& packs = engine->getContentControl().getBasePacks();
|
||||
lua::createtable(L, packs.size(), 0);
|
||||
for (size_t i = 0; i < packs.size(); i++) {
|
||||
lua::pushstring(L, packs[i]);
|
||||
|
|
@ -232,7 +236,8 @@ static int l_pack_assemble(lua::State* L) {
|
|||
if (level) {
|
||||
worldFolder = level->getWorld()->wfile->getFolder();
|
||||
}
|
||||
auto manager = engine->createPacksManager(worldFolder);
|
||||
PacksManager manager;
|
||||
manager.setSources(engine->getContentControl().getDefaultSources());
|
||||
manager.scan();
|
||||
try {
|
||||
ids = manager.assemble(ids);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue