Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Dec 24, 2023
1 parent 572734d commit b7ee9a4
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
Expand All @@ -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());
Expand All @@ -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;

Expand Down Expand Up @@ -135,7 +128,7 @@ Engine::~Engine() {
std::cout << "-- engine finished" << std::endl;
}

GUI* Engine::getGUI() {
gui::GUI* Engine::getGUI() {
return gui;
}

Expand All @@ -147,23 +140,23 @@ Assets* Engine::getAssets() {
return assets.get();
}

void Engine::setScreen(shared_ptr<Screen> screen) {
void Engine::setScreen(std::shared_ptr<Screen> screen) {
this->screen = screen;
}

const Content* Engine::getContent() const {
return content.get();
}

vector<ContentPack>& Engine::getContentPacks() {
std::vector<ContentPack>& Engine::getContentPacks() {
return contentPacks;
}

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());
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit b7ee9a4

Please sign in to comment.