cleanup
This commit is contained in:
parent
e442402e43
commit
f99d909f34
@ -48,6 +48,8 @@ std::vector<std::string>& ContentControl::getBasePacks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ContentControl::resetContent() {
|
void ContentControl::resetContent() {
|
||||||
|
paths.setCurrentWorldFolder("");
|
||||||
|
|
||||||
scripting::cleanup();
|
scripting::cleanup();
|
||||||
std::vector<PathsRoot> resRoots;
|
std::vector<PathsRoot> resRoots;
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,6 +29,7 @@ public:
|
|||||||
|
|
||||||
std::vector<std::string>& getBasePacks();
|
std::vector<std::string>& getBasePacks();
|
||||||
|
|
||||||
|
/// @brief Reset content to base packs list
|
||||||
void resetContent();
|
void resetContent();
|
||||||
|
|
||||||
void loadContent(const std::vector<std::string>& names);
|
void loadContent(const std::vector<std::string>& names);
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
#include "coders/json.hpp"
|
#include "coders/json.hpp"
|
||||||
#include "coders/toml.hpp"
|
#include "coders/toml.hpp"
|
||||||
#include "coders/commons.hpp"
|
#include "coders/commons.hpp"
|
||||||
#include "content/Content.hpp"
|
|
||||||
#include "content/ContentControl.hpp"
|
#include "content/ContentControl.hpp"
|
||||||
#include "core_defs.hpp"
|
#include "core_defs.hpp"
|
||||||
#include "io/io.hpp"
|
#include "io/io.hpp"
|
||||||
@ -322,20 +321,6 @@ void Engine::loadAssets() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::loadContent() {
|
|
||||||
content->loadContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::resetContent() {
|
|
||||||
paths.setCurrentWorldFolder("");
|
|
||||||
content->resetContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::loadWorldContent(const io::path& folder) {
|
|
||||||
paths.setCurrentWorldFolder(folder);
|
|
||||||
content->loadContent(ContentPack::worldPacksList("world:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::setScreen(std::shared_ptr<Screen> screen) {
|
void Engine::setScreen(std::shared_ptr<Screen> screen) {
|
||||||
// reset audio channels (stop all sources)
|
// reset audio channels (stop all sources)
|
||||||
audio::reset_channel(audio::get_channel_index("regular"));
|
audio::reset_channel(audio::get_channel_index("regular"));
|
||||||
|
|||||||
@ -4,9 +4,6 @@
|
|||||||
#include "typedefs.hpp"
|
#include "typedefs.hpp"
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#include "content/content_fwd.hpp"
|
|
||||||
#include "content/ContentPack.hpp"
|
|
||||||
#include "content/PacksManager.hpp"
|
|
||||||
#include "io/engine_paths.hpp"
|
#include "io/engine_paths.hpp"
|
||||||
#include "io/settings_io.hpp"
|
#include "io/settings_io.hpp"
|
||||||
#include "util/ObjectsKeeper.hpp"
|
#include "util/ObjectsKeeper.hpp"
|
||||||
@ -15,7 +12,6 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class Window;
|
class Window;
|
||||||
class Assets;
|
class Assets;
|
||||||
@ -114,17 +110,6 @@ public:
|
|||||||
/// @param locale isolanguage_ISOCOUNTRY (example: en_US)
|
/// @param locale isolanguage_ISOCOUNTRY (example: en_US)
|
||||||
void setLanguage(std::string locale);
|
void setLanguage(std::string locale);
|
||||||
|
|
||||||
/// @brief Load all selected content-packs and reload assets
|
|
||||||
void loadContent();
|
|
||||||
|
|
||||||
/// @brief Reset content to base packs list
|
|
||||||
void resetContent();
|
|
||||||
|
|
||||||
/// @brief Collect world content-packs and load content
|
|
||||||
/// @see loadContent
|
|
||||||
/// @param folder world folder
|
|
||||||
void loadWorldContent(const io::path& folder);
|
|
||||||
|
|
||||||
/// @brief Get active assets storage instance
|
/// @brief Get active assets storage instance
|
||||||
Assets* getAssets();
|
Assets* getAssets();
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "util/stringutil.hpp"
|
#include "util/stringutil.hpp"
|
||||||
#include "assets/assetload_funcs.hpp"
|
#include "assets/assetload_funcs.hpp"
|
||||||
|
#include "content/ContentPack.hpp"
|
||||||
|
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "MenuScreen.hpp"
|
#include "MenuScreen.hpp"
|
||||||
|
|
||||||
|
#include "content/ContentControl.hpp"
|
||||||
#include "graphics/ui/GUI.hpp"
|
#include "graphics/ui/GUI.hpp"
|
||||||
#include "graphics/ui/elements/Menu.hpp"
|
#include "graphics/ui/elements/Menu.hpp"
|
||||||
#include "graphics/core/Batch2D.hpp"
|
#include "graphics/core/Batch2D.hpp"
|
||||||
@ -12,7 +13,7 @@
|
|||||||
#include "engine/Engine.hpp"
|
#include "engine/Engine.hpp"
|
||||||
|
|
||||||
MenuScreen::MenuScreen(Engine& engine) : Screen(engine) {
|
MenuScreen::MenuScreen(Engine& engine) : Screen(engine) {
|
||||||
engine.resetContent();
|
engine.getContentControl().resetContent();
|
||||||
|
|
||||||
auto menu = engine.getGUI().getMenu();
|
auto menu = engine.getGUI().getMenu();
|
||||||
menu->reset();
|
menu->reset();
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#include "coders/json.hpp"
|
#include "coders/json.hpp"
|
||||||
#include "content/ContentReport.hpp"
|
#include "content/ContentReport.hpp"
|
||||||
#include "content/ContentControl.hpp"
|
#include "content/ContentControl.hpp"
|
||||||
|
#include "content/PacksManager.hpp"
|
||||||
#include "world/files/WorldConverter.hpp"
|
#include "world/files/WorldConverter.hpp"
|
||||||
#include "world/files/WorldFiles.hpp"
|
#include "world/files/WorldFiles.hpp"
|
||||||
#include "frontend/locale.hpp"
|
#include "frontend/locale.hpp"
|
||||||
@ -130,12 +131,15 @@ static void show_convert_request(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool load_world_content(Engine& engine, const io::path& folder) {
|
static bool load_world_content(Engine& engine, const io::path& folder) {
|
||||||
|
auto& paths = engine.getPaths();
|
||||||
|
auto& contentControl = engine.getContentControl();
|
||||||
|
paths.setCurrentWorldFolder(folder);
|
||||||
if (engine.isHeadless()) {
|
if (engine.isHeadless()) {
|
||||||
engine.loadWorldContent(folder);
|
contentControl.loadContent(ContentPack::worldPacksList("world:"));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return menus::call(engine, [&engine, folder]() {
|
return menus::call(engine, [&contentControl]() {
|
||||||
engine.loadWorldContent(folder);
|
contentControl.loadContent(ContentPack::worldPacksList("world:"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,10 +267,10 @@ void EngineController::createWorld(
|
|||||||
auto folder = paths.getWorldsFolder() / name;
|
auto folder = paths.getWorldsFolder() / name;
|
||||||
|
|
||||||
if (engine.isHeadless()) {
|
if (engine.isHeadless()) {
|
||||||
engine.loadContent();
|
engine.getContentControl().loadContent();
|
||||||
paths.setCurrentWorldFolder(folder);
|
paths.setCurrentWorldFolder(folder);
|
||||||
} else if (!menus::call(engine, [this, &paths, folder]() {
|
} else if (!menus::call(engine, [this, &paths, folder]() {
|
||||||
engine.loadContent();
|
engine.getContentControl().loadContent();
|
||||||
paths.setCurrentWorldFolder(folder);
|
paths.setCurrentWorldFolder(folder);
|
||||||
})) {
|
})) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include "assets/Assets.hpp"
|
#include "assets/Assets.hpp"
|
||||||
#include "content/Content.hpp"
|
#include "content/Content.hpp"
|
||||||
|
#include "content/ContentControl.hpp"
|
||||||
#include "debug/Logger.hpp"
|
#include "debug/Logger.hpp"
|
||||||
#include "engine/Engine.hpp"
|
#include "engine/Engine.hpp"
|
||||||
#include "io/engine_paths.hpp"
|
#include "io/engine_paths.hpp"
|
||||||
@ -30,7 +31,7 @@ static int l_get_version(lua::State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int l_load_content(lua::State* L) {
|
static int l_load_content(lua::State* L) {
|
||||||
engine->loadContent();
|
content_control->loadContent();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ static int l_reset_content(lua::State* L) {
|
|||||||
if (level != nullptr) {
|
if (level != nullptr) {
|
||||||
throw std::runtime_error("world must be closed before");
|
throw std::runtime_error("world must be closed before");
|
||||||
}
|
}
|
||||||
engine->resetContent();
|
content_control->resetContent();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include "assets/AssetsLoader.hpp"
|
#include "assets/AssetsLoader.hpp"
|
||||||
#include "content/Content.hpp"
|
#include "content/Content.hpp"
|
||||||
#include "content/ContentControl.hpp"
|
#include "content/ContentControl.hpp"
|
||||||
|
#include "content/PacksManager.hpp"
|
||||||
#include "engine/Engine.hpp"
|
#include "engine/Engine.hpp"
|
||||||
#include "graphics/ui/gui_util.hpp"
|
#include "graphics/ui/gui_util.hpp"
|
||||||
#include "graphics/ui/elements/Menu.hpp"
|
#include "graphics/ui/elements/Menu.hpp"
|
||||||
@ -44,10 +45,6 @@ static int l_pack_get_installed(lua::State* L) {
|
|||||||
|
|
||||||
/// @brief pack.get_available() -> array<string>
|
/// @brief pack.get_available() -> array<string>
|
||||||
static int l_pack_get_available(lua::State* L) {
|
static int l_pack_get_available(lua::State* L) {
|
||||||
io::path worldFolder;
|
|
||||||
if (level) {
|
|
||||||
worldFolder = level->getWorld()->wfile->getFolder();
|
|
||||||
}
|
|
||||||
PacksManager manager;
|
PacksManager manager;
|
||||||
manager.setSources(content_control->getDefaultSources());
|
manager.setSources(content_control->getDefaultSources());
|
||||||
manager.scan();
|
manager.scan();
|
||||||
@ -150,10 +147,6 @@ static int pack_get_infos(lua::State* L) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ids.empty()) {
|
if (!ids.empty()) {
|
||||||
io::path worldFolder;
|
|
||||||
if (level) {
|
|
||||||
worldFolder = level->getWorld()->wfile->getFolder();
|
|
||||||
}
|
|
||||||
PacksManager manager;
|
PacksManager manager;
|
||||||
manager.setSources(content_control->getDefaultSources());
|
manager.setSources(content_control->getDefaultSources());
|
||||||
manager.scan();
|
manager.scan();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user