settings page completely moved to xml
This commit is contained in:
@@ -17,9 +17,6 @@ class LevelController;
|
||||
using packconsumer = std::function<void(const ContentPack& pack)>;
|
||||
|
||||
namespace menus {
|
||||
// implemented in menu_settings.cpp
|
||||
extern void create_settings_panel(Engine* engine);
|
||||
|
||||
extern std::shared_ptr<gui::Panel> create_packs_panel(
|
||||
const std::vector<ContentPack>& packs,
|
||||
Engine* engine,
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
#include "menu.h"
|
||||
#include "menu_commons.h"
|
||||
|
||||
#include "../locale/langs.h"
|
||||
#include "../../graphics/ui/GUI.h"
|
||||
#include "../../graphics/ui/gui_util.h"
|
||||
#include "../../engine.h"
|
||||
#include "../../util/stringutil.h"
|
||||
#include "../../window/Events.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
using namespace gui;
|
||||
|
||||
void menus::create_settings_panel(Engine* engine) {
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
auto panel = menus::create_page(engine, "settings", 400, 0.0f, 1);
|
||||
|
||||
/* V-Sync checkbox */{
|
||||
auto checkbox = std::make_shared<FullCheckBox>(
|
||||
langs::get(L"V-Sync", L"settings"), glm::vec2(400, 32)
|
||||
);
|
||||
checkbox->setSupplier([=]() {
|
||||
return engine->getSettings().display.swapInterval != 0;
|
||||
});
|
||||
checkbox->setConsumer([=](bool checked) {
|
||||
engine->getSettings().display.swapInterval = checked;
|
||||
});
|
||||
panel->add(checkbox);
|
||||
}
|
||||
|
||||
/* Backlight checkbox */{
|
||||
auto checkbox = std::make_shared<FullCheckBox>(
|
||||
langs::get(L"Backlight", L"settings"), glm::vec2(400, 32)
|
||||
);
|
||||
checkbox->setSupplier([=]() {
|
||||
return engine->getSettings().graphics.backlight;
|
||||
});
|
||||
checkbox->setConsumer([=](bool checked) {
|
||||
engine->getSettings().graphics.backlight = checked;
|
||||
});
|
||||
panel->add(checkbox);
|
||||
}
|
||||
|
||||
/* Camera shaking checkbox */ {
|
||||
auto checkbox = std::make_shared<FullCheckBox>(
|
||||
langs::get(L"Camera Shaking", L"settings"), glm::vec2(400, 32)
|
||||
);
|
||||
checkbox->setSupplier([=]() {
|
||||
return engine->getSettings().camera.shaking;
|
||||
});
|
||||
checkbox->setConsumer([=](bool checked) {
|
||||
engine->getSettings().camera.shaking = checked;
|
||||
});
|
||||
panel->add(checkbox);
|
||||
}
|
||||
|
||||
std::string langName = langs::locales_info.at(langs::current->getId()).name;
|
||||
panel->add(guiutil::gotoButton(
|
||||
langs::get(L"Language", L"settings")+L": "+
|
||||
util::str2wstr_utf8(langName),
|
||||
"languages", menu));
|
||||
|
||||
panel->add(guiutil::gotoButton(L"Audio", "settings_audio", menu));
|
||||
panel->add(guiutil::gotoButton(L"Controls", "controls", menu));
|
||||
panel->add(guiutil::backButton(menu));
|
||||
}
|
||||
@@ -102,7 +102,7 @@ LevelScreen::LevelScreen(Engine* engine, Level* level) : Screen(engine) {
|
||||
hud = std::make_unique<Hud>(engine, frontend.get(), controller->getPlayer());
|
||||
|
||||
|
||||
backlight = settings.graphics.backlight;
|
||||
backlight = settings.graphics.backlight.get();
|
||||
|
||||
animator = std::make_unique<TextureAnimator>();
|
||||
animator->addAnimations(assets->getAnimations());
|
||||
@@ -167,9 +167,9 @@ void LevelScreen::update(float delta) {
|
||||
// TODO: subscribe for setting change
|
||||
EngineSettings& settings = engine->getSettings();
|
||||
controller->getPlayer()->camera->setFov(glm::radians(settings.camera.fov.get()));
|
||||
if (settings.graphics.backlight != backlight) {
|
||||
if (settings.graphics.backlight.get() != backlight) {
|
||||
controller->getLevel()->chunks->saveAndClear();
|
||||
backlight = settings.graphics.backlight;
|
||||
backlight = settings.graphics.backlight.get();
|
||||
}
|
||||
|
||||
if (!hud->isPause()) {
|
||||
|
||||
Reference in New Issue
Block a user