Minor refactor

This commit is contained in:
MihailRis 2023-12-24 11:18:21 +03:00
parent 572734dc80
commit b7ee9a4604

View File

@ -36,13 +36,6 @@
#include "definitions.h"
using std::unique_ptr;
using std::shared_ptr;
using std::string;
using std::vector;
using glm::vec3;
using gui::GUI;
namespace fs = std::filesystem;
Engine::Engine(EngineSettings& settings, EnginePaths* paths)
@ -71,7 +64,7 @@ Engine::Engine(EngineSettings& settings, EnginePaths* paths)
}
Audio::initialize();
gui = new GUI();
gui = new gui::GUI();
if (settings.ui.language == "auto") {
settings.ui.language = platform::detect_locale();
}
@ -88,7 +81,7 @@ void Engine::updateTimers() {
void Engine::updateHotkeys() {
if (Events::jpressed(keycode::F2)) {
unique_ptr<ImageData> image(Window::takeScreenshot());
std::unique_ptr<ImageData> image(Window::takeScreenshot());
image->flipY();
fs::path filename = paths->getScreenshotFile("png");
png::write_image(filename.string(), image.get());
@ -100,7 +93,7 @@ void Engine::updateHotkeys() {
}
void Engine::mainloop() {
setScreen(shared_ptr<Screen>(new MenuScreen(this)));
setScreen(std::make_shared<MenuScreen>(this));
std::cout << "-- preparing systems" << std::endl;
@ -135,7 +128,7 @@ Engine::~Engine() {
std::cout << "-- engine finished" << std::endl;
}
GUI* Engine::getGUI() {
gui::GUI* Engine::getGUI() {
return gui;
}
@ -147,7 +140,7 @@ Assets* Engine::getAssets() {
return assets.get();
}
void Engine::setScreen(shared_ptr<Screen> screen) {
void Engine::setScreen(std::shared_ptr<Screen> screen) {
this->screen = screen;
}
@ -155,7 +148,7 @@ const Content* Engine::getContent() const {
return content.get();
}
vector<ContentPack>& Engine::getContentPacks() {
std::vector<ContentPack>& Engine::getContentPacks() {
return contentPacks;
}
@ -163,7 +156,7 @@ EnginePaths* Engine::getPaths() {
return paths;
}
void Engine::setLanguage(string locale) {
void Engine::setLanguage(std::string locale) {
settings.ui.language = locale;
langs::setup(paths->getResources(), locale, contentPacks);
menus::create_menus(this, gui->getMenu());
@ -174,7 +167,7 @@ void Engine::loadContent() {
ContentBuilder contentBuilder;
setup_definitions(&contentBuilder);
vector<fs::path> resRoots;
std::vector<fs::path> resRoots;
for (auto& pack : contentPacks) {
ContentLoader loader(&pack);
loader.load(&contentBuilder);
@ -185,7 +178,7 @@ void Engine::loadContent() {
Shader::preprocessor->setPaths(resPaths.get());
unique_ptr<Assets> new_assets(new Assets());
std::unique_ptr<Assets> new_assets(new Assets());
std::cout << "-- loading assets" << std::endl;
AssetsLoader loader(new_assets.get(), resPaths.get());
AssetsLoader::createDefaults(loader);