frontend/gui refactor
This commit is contained in:
+1
-1
@@ -214,7 +214,7 @@ void Engine::setScreen(std::shared_ptr<Screen> screen) {
|
|||||||
void Engine::setLanguage(std::string locale) {
|
void Engine::setLanguage(std::string locale) {
|
||||||
settings.ui.language = locale;
|
settings.ui.language = locale;
|
||||||
langs::setup(paths->getResources(), locale, contentPacks);
|
langs::setup(paths->getResources(), locale, contentPacks);
|
||||||
menus::create_menus(this, gui->getMenu());
|
menus::create_menus(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
gui::GUI* Engine::getGUI() {
|
gui::GUI* Engine::getGUI() {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ GUI::GUI() {
|
|||||||
uicamera->perspective = false;
|
uicamera->perspective = false;
|
||||||
uicamera->flipped = true;
|
uicamera->flipped = true;
|
||||||
|
|
||||||
menu = new PagesControl();
|
menu = std::make_shared<PagesControl>();
|
||||||
container->add(menu);
|
container->add(menu);
|
||||||
container->scrollable(false);
|
container->scrollable(false);
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ GUI::~GUI() {
|
|||||||
delete container;
|
delete container;
|
||||||
}
|
}
|
||||||
|
|
||||||
PagesControl* GUI::getMenu() {
|
std::shared_ptr<PagesControl> GUI::getMenu() {
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ namespace gui {
|
|||||||
std::unordered_map<std::string, std::shared_ptr<UINode>> storage;
|
std::unordered_map<std::string, std::shared_ptr<UINode>> storage;
|
||||||
|
|
||||||
Camera* uicamera;
|
Camera* uicamera;
|
||||||
PagesControl* menu;
|
std::shared_ptr<PagesControl> menu;
|
||||||
void actMouse(float delta);
|
void actMouse(float delta);
|
||||||
public:
|
public:
|
||||||
GUI();
|
GUI();
|
||||||
~GUI();
|
~GUI();
|
||||||
|
|
||||||
PagesControl* getMenu();
|
std::shared_ptr<PagesControl> getMenu();
|
||||||
|
|
||||||
std::shared_ptr<UINode> getFocused() const;
|
std::shared_ptr<UINode> getFocused() const;
|
||||||
bool isFocusCaught() const;
|
bool isFocusCaught() const;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ Label::Label(std::string text, std::string fontName)
|
|||||||
: UINode(vec2(), vec2(text.length() * 8, 15)),
|
: UINode(vec2(), vec2(text.length() * 8, 15)),
|
||||||
text(util::str2wstr_utf8(text)),
|
text(util::str2wstr_utf8(text)),
|
||||||
fontName_(fontName) {
|
fontName_(fontName) {
|
||||||
|
setInteractive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ Label::Label(std::wstring text, std::string fontName)
|
|||||||
: UINode(vec2(), vec2(text.length() * 8, 15)),
|
: UINode(vec2(), vec2(text.length() * 8, 15)),
|
||||||
text(text),
|
text(text),
|
||||||
fontName_(fontName) {
|
fontName_(fontName) {
|
||||||
|
setInteractive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::setText(std::wstring text) {
|
void Label::setText(std::wstring text) {
|
||||||
@@ -314,7 +316,7 @@ void TextBox::text(std::wstring value) {
|
|||||||
InputBindBox::InputBindBox(Binding& binding, vec4 padding)
|
InputBindBox::InputBindBox(Binding& binding, vec4 padding)
|
||||||
: Panel(vec2(100,32), padding, 0, false),
|
: Panel(vec2(100,32), padding, 0, false),
|
||||||
binding(binding) {
|
binding(binding) {
|
||||||
label = new Label(L"");
|
label = std::make_shared<Label>(L"");
|
||||||
add(label);
|
add(label);
|
||||||
scrollable(false);
|
scrollable(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace gui {
|
|||||||
protected:
|
protected:
|
||||||
glm::vec4 hoverColor {0.05f, 0.1f, 0.2f, 0.75f};
|
glm::vec4 hoverColor {0.05f, 0.1f, 0.2f, 0.75f};
|
||||||
glm::vec4 focusedColor {0.0f, 0.0f, 0.0f, 1.0f};
|
glm::vec4 focusedColor {0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
Label* label;
|
std::shared_ptr<Label> label;
|
||||||
Binding& binding;
|
Binding& binding;
|
||||||
public:
|
public:
|
||||||
InputBindBox(Binding& binding, glm::vec4 padding=glm::vec4(6.0f));
|
InputBindBox(Binding& binding, glm::vec4 padding=glm::vec4(6.0f));
|
||||||
|
|||||||
@@ -10,24 +10,31 @@ using namespace gui;
|
|||||||
using glm::vec2;
|
using glm::vec2;
|
||||||
using glm::vec4;
|
using glm::vec4;
|
||||||
|
|
||||||
Button* guiutil::backButton(PagesControl* menu) {
|
std::shared_ptr<Button> guiutil::backButton(std::shared_ptr<PagesControl> menu) {
|
||||||
return (new Button(langs::get(L"Back"), vec4(10.f)))->listenAction([=](GUI* gui) {
|
auto button = std::make_shared<Button>(
|
||||||
|
langs::get(L"Back"), vec4(10.f)
|
||||||
|
);
|
||||||
|
button->listenAction([=](GUI* gui) {
|
||||||
menu->back();
|
menu->back();
|
||||||
});
|
});
|
||||||
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button* guiutil::gotoButton(
|
std::shared_ptr<Button> guiutil::gotoButton(
|
||||||
std::wstring text,
|
std::wstring text,
|
||||||
const std::string& page,
|
const std::string& page,
|
||||||
PagesControl* menu) {
|
std::shared_ptr<PagesControl> menu
|
||||||
|
) {
|
||||||
text = langs::get(text, L"menu");
|
text = langs::get(text, L"menu");
|
||||||
return (new Button(text, vec4(10.f)))->listenAction([=](GUI* gui) {
|
auto button = std::make_shared<Button>(text, vec4(10.f));
|
||||||
|
button->listenAction([=](GUI* gui) {
|
||||||
menu->set(page);
|
menu->set(page);
|
||||||
});
|
});
|
||||||
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
void guiutil::alert(GUI* gui, const std::wstring& text, gui::runnable on_hidden) {
|
void guiutil::alert(GUI* gui, const std::wstring& text, gui::runnable on_hidden) {
|
||||||
PagesControl* menu = gui->getMenu();
|
auto menu = gui->getMenu();
|
||||||
Panel* panel = new Panel(vec2(500, 200), vec4(8.0f), 8.0f);
|
Panel* panel = new Panel(vec2(500, 200), vec4(8.0f), 8.0f);
|
||||||
panel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
panel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
||||||
|
|
||||||
@@ -43,17 +50,19 @@ void guiutil::alert(GUI* gui, const std::wstring& text, gui::runnable on_hidden)
|
|||||||
}
|
}
|
||||||
extra = std::min(extra, wrap_length);
|
extra = std::min(extra, wrap_length);
|
||||||
std::wstring part = text.substr(offset, extra);
|
std::wstring part = text.substr(offset, extra);
|
||||||
panel->add(new Label(part));
|
panel->add(std::make_shared<Label>(part));
|
||||||
offset += extra;
|
offset += extra;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panel->add(new Label(text));
|
panel->add(std::make_shared<Label>(text));
|
||||||
}
|
}
|
||||||
panel->add((new Button(langs::get(L"Ok"), vec4(10.f)))->listenAction([=](GUI* gui) {
|
auto button = std::make_shared<Button>(langs::get(L"Ok"), vec4(10.f));
|
||||||
|
button->listenAction([=](GUI* gui) {
|
||||||
if (on_hidden)
|
if (on_hidden)
|
||||||
on_hidden();
|
on_hidden();
|
||||||
menu->back();
|
menu->back();
|
||||||
}));
|
});
|
||||||
|
panel->add(button);
|
||||||
panel->refresh();
|
panel->refresh();
|
||||||
menu->add("<alert>", panel);
|
menu->add("<alert>", panel);
|
||||||
menu->set("<alert>");
|
menu->set("<alert>");
|
||||||
@@ -68,20 +77,27 @@ void guiutil::confirm(
|
|||||||
if (yestext.empty()) yestext = langs::get(L"Yes");
|
if (yestext.empty()) yestext = langs::get(L"Yes");
|
||||||
if (notext.empty()) notext = langs::get(L"No");
|
if (notext.empty()) notext = langs::get(L"No");
|
||||||
|
|
||||||
PagesControl* menu = gui->getMenu();
|
auto menu = gui->getMenu();
|
||||||
Panel* panel = new Panel(vec2(600, 200), vec4(8.0f), 8.0f);
|
auto panel = std::make_shared<Panel>(vec2(600, 200), vec4(8.0f), 8.0f);
|
||||||
panel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
panel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
||||||
panel->add(new Label(text));
|
panel->add(std::make_shared<Label>(text));
|
||||||
Panel* subpanel = new Panel(vec2(600, 53));
|
auto subpanel = std::make_shared<Panel>(vec2(600, 53));
|
||||||
subpanel->setColor(vec4(0));
|
subpanel->setColor(vec4(0));
|
||||||
subpanel->add((new Button(yestext, vec4(8.0f)))->listenAction([=](GUI*){
|
|
||||||
|
auto yesbtn = std::make_shared<Button>(yestext, vec4(8.f));
|
||||||
|
yesbtn->listenAction([=](GUI*){
|
||||||
if (on_confirm)
|
if (on_confirm)
|
||||||
on_confirm();
|
on_confirm();
|
||||||
menu->back();
|
menu->back();
|
||||||
}));
|
});
|
||||||
subpanel->add((new Button(notext, vec4(8.0f)))->listenAction([=](GUI*){
|
subpanel->add(yesbtn);
|
||||||
|
|
||||||
|
auto nobtn = std::make_shared<Button>(notext, vec4(8.f));
|
||||||
|
nobtn->listenAction([=](GUI*){
|
||||||
menu->back();
|
menu->back();
|
||||||
}));
|
});
|
||||||
|
subpanel->add(nobtn);
|
||||||
|
|
||||||
panel->add(subpanel);
|
panel->add(subpanel);
|
||||||
|
|
||||||
panel->refresh();
|
panel->refresh();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef FRONTEND_GUI_GUI_UTIL_H_
|
#ifndef FRONTEND_GUI_GUI_UTIL_H_
|
||||||
#define FRONTEND_GUI_GUI_UTIL_H_
|
#define FRONTEND_GUI_GUI_UTIL_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "GUI.h"
|
#include "GUI.h"
|
||||||
|
|
||||||
@@ -9,11 +10,28 @@ namespace gui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace guiutil {
|
namespace guiutil {
|
||||||
gui::Button* backButton(gui::PagesControl* menu);
|
std::shared_ptr<gui::Button> backButton(
|
||||||
gui::Button* gotoButton(std::wstring text, const std::string& page, gui::PagesControl* menu);
|
std::shared_ptr<gui::PagesControl> menu
|
||||||
void alert(gui::GUI* gui, const std::wstring& text, gui::runnable on_hidden=nullptr);
|
);
|
||||||
void confirm(gui::GUI* gui, const std::wstring& text, gui::runnable on_confirm=nullptr,
|
|
||||||
std::wstring yestext=L"", std::wstring notext=L"");
|
std::shared_ptr<gui::Button> gotoButton(
|
||||||
|
std::wstring text,
|
||||||
|
const std::string& page,
|
||||||
|
std::shared_ptr<gui::PagesControl> menu
|
||||||
|
);
|
||||||
|
|
||||||
|
void alert(
|
||||||
|
gui::GUI* gui,
|
||||||
|
const std::wstring& text,
|
||||||
|
gui::runnable on_hidden=nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
void confirm(
|
||||||
|
gui::GUI* gui,
|
||||||
|
const std::wstring& text,
|
||||||
|
gui::runnable on_confirm=nullptr,
|
||||||
|
std::wstring yestext=L"",
|
||||||
|
std::wstring notext=L"");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FRONTEND_GUI_GUI_UTIL_H_
|
#endif // FRONTEND_GUI_GUI_UTIL_H_
|
||||||
|
|||||||
@@ -108,10 +108,6 @@ void Container::add(std::shared_ptr<UINode> node) {
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::add(UINode* node) {
|
|
||||||
add(std::shared_ptr<UINode>(node));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Container::add(std::shared_ptr<UINode> node, glm::vec2 coord) {
|
void Container::add(std::shared_ptr<UINode> node, glm::vec2 coord) {
|
||||||
node->setCoord(coord);
|
node->setCoord(coord);
|
||||||
add(node);
|
add(node);
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ namespace gui {
|
|||||||
virtual std::shared_ptr<UINode> getAt(glm::vec2 pos, std::shared_ptr<UINode> self) override;
|
virtual std::shared_ptr<UINode> getAt(glm::vec2 pos, std::shared_ptr<UINode> self) override;
|
||||||
virtual void addBack(std::shared_ptr<UINode> node);
|
virtual void addBack(std::shared_ptr<UINode> node);
|
||||||
virtual void add(std::shared_ptr<UINode> node);
|
virtual void add(std::shared_ptr<UINode> node);
|
||||||
virtual void add(UINode* node);
|
|
||||||
virtual void add(std::shared_ptr<UINode> node, glm::vec2 coord);
|
virtual void add(std::shared_ptr<UINode> node, glm::vec2 coord);
|
||||||
virtual void remove(std::shared_ptr<UINode> node);
|
virtual void remove(std::shared_ptr<UINode> node);
|
||||||
virtual void scrolled(int value) override;
|
virtual void scrolled(int value) override;
|
||||||
|
|||||||
@@ -97,18 +97,18 @@ std::shared_ptr<UINode> HudRenderer::createDebugPanel(Engine* engine) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
for (int ax = 0; ax < 3; ax++){
|
for (int ax = 0; ax < 3; ax++){
|
||||||
Panel* sub = new Panel(vec2(10, 27), vec4(0.0f));
|
auto sub = std::make_shared<Panel>(vec2(10, 27), vec4(0.0f));
|
||||||
sub->orientation(Orientation::horizontal);
|
sub->orientation(Orientation::horizontal);
|
||||||
|
|
||||||
std::wstring str = L"x: ";
|
std::wstring str = L"x: ";
|
||||||
str[0] += ax;
|
str[0] += ax;
|
||||||
Label* label = new Label(str);
|
auto label = std::make_shared<Label>(str);
|
||||||
label->setMargin(vec4(2, 3, 2, 3));
|
label->setMargin(vec4(2, 3, 2, 3));
|
||||||
sub->add(label);
|
sub->add(label);
|
||||||
sub->setColor(vec4(0.0f));
|
sub->setColor(vec4(0.0f));
|
||||||
|
|
||||||
// Coord input
|
// Coord input
|
||||||
TextBox* box = new TextBox(L"");
|
auto box = std::make_shared<TextBox>(L"");
|
||||||
box->textSupplier([=]() {
|
box->textSupplier([=]() {
|
||||||
Hitbox* hitbox = level->player->hitbox.get();
|
Hitbox* hitbox = level->player->hitbox.get();
|
||||||
return util::to_wstring(hitbox->position[ax], 2);
|
return util::to_wstring(hitbox->position[ax], 2);
|
||||||
@@ -139,19 +139,21 @@ std::shared_ptr<UINode> HudRenderer::createDebugPanel(Engine* engine) {
|
|||||||
return L"time: "+timeString;
|
return L"time: "+timeString;
|
||||||
}));
|
}));
|
||||||
{
|
{
|
||||||
TrackBar* bar = new TrackBar(0.0f, 1.0f, 1.0f, 0.005f, 8);
|
auto bar = std::make_shared<TrackBar>(0.0f, 1.0f, 1.0f, 0.005f, 8);
|
||||||
bar->supplier([=]() {return level->world->daytime;});
|
bar->supplier([=]() {return level->world->daytime;});
|
||||||
bar->consumer([=](double val) {level->world->daytime = val;});
|
bar->consumer([=](double val) {level->world->daytime = val;});
|
||||||
panel->add(bar);
|
panel->add(bar);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TrackBar* bar = new TrackBar(0.0f, 1.0f, 0.0f, 0.005f, 8);
|
auto bar = std::make_shared<TrackBar>(0.0f, 1.0f, 0.0f, 0.005f, 8);
|
||||||
bar->supplier([=]() {return WorldRenderer::fog;});
|
bar->supplier([=]() {return WorldRenderer::fog;});
|
||||||
bar->consumer([=](double val) {WorldRenderer::fog = val;});
|
bar->consumer([=](double val) {WorldRenderer::fog = val;});
|
||||||
panel->add(bar);
|
panel->add(bar);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto checkbox = new FullCheckBox(L"Show Chunk Borders", vec2(400, 32));
|
auto checkbox = std::make_shared<FullCheckBox>(
|
||||||
|
L"Show Chunk Borders", vec2(400, 32)
|
||||||
|
);
|
||||||
checkbox->supplier([=]() {
|
checkbox->supplier([=]() {
|
||||||
return engine->getSettings().debug.showChunkBorders;
|
return engine->getSettings().debug.showChunkBorders;
|
||||||
});
|
});
|
||||||
|
|||||||
+128
-98
@@ -37,6 +37,8 @@ using glm::vec4;
|
|||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
|
const int PACKS_PANEL_WIDTH = 550;
|
||||||
|
|
||||||
inline uint64_t randU64() {
|
inline uint64_t randU64() {
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
return rand() ^ (rand() << 8) ^
|
return rand() ^ (rand() << 8) ^
|
||||||
@@ -46,13 +48,20 @@ inline uint64_t randU64() {
|
|||||||
((uint64_t)rand() << 56);
|
((uint64_t)rand() << 56);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Panel> create_page(
|
static std::shared_ptr<Label> create_label(gui::wstringsupplier supplier) {
|
||||||
Engine* engine,
|
auto label = std::make_shared<Label>(L"-");
|
||||||
std::string name,
|
label->textSupplier(supplier);
|
||||||
int width,
|
return label;
|
||||||
float opacity,
|
}
|
||||||
int interval) {
|
|
||||||
PagesControl* menu = engine->getGUI()->getMenu();
|
static std::shared_ptr<Panel> create_page(
|
||||||
|
Engine* engine,
|
||||||
|
std::string name,
|
||||||
|
int width,
|
||||||
|
float opacity,
|
||||||
|
int interval
|
||||||
|
) {
|
||||||
|
auto menu = engine->getGUI()->getMenu();
|
||||||
auto panel = std::make_shared<Panel>(
|
auto panel = std::make_shared<Panel>(
|
||||||
vec2(width, 200), vec4(8.0f), interval
|
vec2(width, 200), vec4(8.0f), interval
|
||||||
);
|
);
|
||||||
@@ -61,38 +70,43 @@ std::shared_ptr<Panel> create_page(
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button* create_button(std::wstring text,
|
static std::shared_ptr<Button> create_button(
|
||||||
glm::vec4 padding,
|
std::wstring text,
|
||||||
glm::vec4 margin,
|
glm::vec4 padding,
|
||||||
gui::onaction action) {
|
glm::vec4 margin,
|
||||||
|
gui::onaction action
|
||||||
auto btn = new Button(langs::get(text, L"menu"),
|
) {
|
||||||
padding, margin);
|
auto btn = std::make_shared<Button>(
|
||||||
|
langs::get(text, L"menu"), padding, margin
|
||||||
|
);
|
||||||
btn->listenAction(action);
|
btn->listenAction(action);
|
||||||
return btn;
|
return btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_content_missing(Engine* engine, const Content* content,
|
static void show_content_missing(
|
||||||
std::shared_ptr<ContentLUT> lut) {
|
Engine* engine,
|
||||||
|
const Content* content,
|
||||||
|
std::shared_ptr<ContentLUT> lut
|
||||||
|
) {
|
||||||
auto* gui = engine->getGUI();
|
auto* gui = engine->getGUI();
|
||||||
auto* menu = gui->getMenu();
|
auto menu = gui->getMenu();
|
||||||
auto panel = create_page(engine, "missing-content", 500, 0.5f, 8);
|
auto panel = create_page(engine, "missing-content", 500, 0.5f, 8);
|
||||||
|
|
||||||
panel->add(new Label(langs::get(L"menu.missing-content")));
|
panel->add(std::make_shared<Label>(langs::get(L"menu.missing-content")));
|
||||||
|
|
||||||
Panel* subpanel = new Panel(vec2(500, 100));
|
auto subpanel = std::make_shared<Panel>(vec2(500, 100));
|
||||||
subpanel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
subpanel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
||||||
|
|
||||||
for (auto& entry : lut->getMissingContent()) {
|
for (auto& entry : lut->getMissingContent()) {
|
||||||
Panel* hpanel = new Panel(vec2(500, 30));
|
auto hpanel = std::make_shared<Panel>(vec2(500, 30));
|
||||||
hpanel->setColor(vec4(0.0f));
|
hpanel->setColor(vec4(0.0f));
|
||||||
hpanel->orientation(Orientation::horizontal);
|
hpanel->orientation(Orientation::horizontal);
|
||||||
|
|
||||||
Label* namelabel = new Label(util::str2wstr_utf8(entry.name));
|
auto namelabel = std::make_shared<Label>(util::str2wstr_utf8(entry.name));
|
||||||
namelabel->setColor(vec4(1.0f, 0.2f, 0.2f, 0.5f));
|
namelabel->setColor(vec4(1.0f, 0.2f, 0.2f, 0.5f));
|
||||||
|
|
||||||
auto contentname = util::str2wstr_utf8(contenttype_name(entry.type));
|
auto contentname = util::str2wstr_utf8(contenttype_name(entry.type));
|
||||||
Label* typelabel = new Label(L"["+contentname+L"]");
|
auto typelabel = std::make_shared<Label>(L"["+contentname+L"]");
|
||||||
typelabel->setColor(vec4(0.5f));
|
typelabel->setColor(vec4(0.5f));
|
||||||
hpanel->add(typelabel);
|
hpanel->add(typelabel);
|
||||||
hpanel->add(namelabel);
|
hpanel->add(namelabel);
|
||||||
@@ -101,11 +115,13 @@ void show_content_missing(Engine* engine, const Content* content,
|
|||||||
subpanel->maxLength(400);
|
subpanel->maxLength(400);
|
||||||
panel->add(subpanel);
|
panel->add(subpanel);
|
||||||
|
|
||||||
panel->add((new Button(langs::get(L"Back to Main Menu", L"menu"),
|
auto button = std::make_shared<Button>(
|
||||||
vec4(8.0f)))
|
langs::get(L"Back to Main Menu", L"menu"), vec4(8.0f)
|
||||||
->listenAction([=](GUI*){
|
);
|
||||||
|
button->listenAction([=](GUI*){
|
||||||
menu->back();
|
menu->back();
|
||||||
}));
|
});
|
||||||
|
panel->add(button);
|
||||||
menu->set("missing-content");
|
menu->set("missing-content");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +129,8 @@ void show_convert_request(
|
|||||||
Engine* engine,
|
Engine* engine,
|
||||||
const Content* content,
|
const Content* content,
|
||||||
std::shared_ptr<ContentLUT> lut,
|
std::shared_ptr<ContentLUT> lut,
|
||||||
fs::path folder) {
|
fs::path folder
|
||||||
|
) {
|
||||||
guiutil::confirm(engine->getGUI(), langs::get(L"world.convert-request"),
|
guiutil::confirm(engine->getGUI(), langs::get(L"world.convert-request"),
|
||||||
[=]() {
|
[=]() {
|
||||||
// TODO: add multithreading here
|
// TODO: add multithreading here
|
||||||
@@ -125,7 +142,8 @@ void show_convert_request(
|
|||||||
}, L"", langs::get(L"Cancel"));
|
}, L"", langs::get(L"Cancel"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_languages_panel(Engine* engine, PagesControl* menu) {
|
void create_languages_panel(Engine* engine) {
|
||||||
|
auto menu = engine->getGUI()->getMenu();
|
||||||
auto panel = create_page(engine, "languages", 400, 0.5f, 1);
|
auto panel = create_page(engine, "languages", 400, 0.5f, 1);
|
||||||
panel->scrollable(true);
|
panel->scrollable(true);
|
||||||
|
|
||||||
@@ -138,7 +156,9 @@ void create_languages_panel(Engine* engine, PagesControl* menu) {
|
|||||||
auto& locale = langs::locales_info.at(name);
|
auto& locale = langs::locales_info.at(name);
|
||||||
std::string& fullName = locale.name;
|
std::string& fullName = locale.name;
|
||||||
|
|
||||||
Button* button = new Button(util::str2wstr_utf8(fullName), vec4(10.f));
|
auto button = std::make_shared<Button>(
|
||||||
|
util::str2wstr_utf8(fullName), vec4(10.f)
|
||||||
|
);
|
||||||
button->listenAction([=](GUI*) {
|
button->listenAction([=](GUI*) {
|
||||||
engine->setLanguage(name);
|
engine->setLanguage(name);
|
||||||
menu->back();
|
menu->back();
|
||||||
@@ -191,8 +211,8 @@ void open_world(std::string name, Engine* engine) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Panel* create_worlds_panel(Engine* engine) {
|
std::shared_ptr<Panel> create_worlds_panel(Engine* engine) {
|
||||||
auto panel = new Panel(vec2(390, 200), vec4(5.0f));
|
auto panel = std::make_shared<Panel>(vec2(390, 200), vec4(5.0f));
|
||||||
panel->setColor(vec4(1.0f, 1.0f, 1.0f, 0.07f));
|
panel->setColor(vec4(1.0f, 1.0f, 1.0f, 0.07f));
|
||||||
panel->maxLength(400);
|
panel->maxLength(400);
|
||||||
|
|
||||||
@@ -205,13 +225,10 @@ Panel* create_worlds_panel(Engine* engine) {
|
|||||||
auto btn = std::make_shared<RichButton>(vec2(390, 46));
|
auto btn = std::make_shared<RichButton>(vec2(390, 46));
|
||||||
btn->setColor(vec4(1.0f, 1.0f, 1.0f, 0.1f));
|
btn->setColor(vec4(1.0f, 1.0f, 1.0f, 0.1f));
|
||||||
btn->setHoverColor(vec4(1.0f, 1.0f, 1.0f, 0.17f));
|
btn->setHoverColor(vec4(1.0f, 1.0f, 1.0f, 0.17f));
|
||||||
|
|
||||||
auto label = std::make_shared<Label>(namews);
|
|
||||||
label->setInteractive(false);
|
|
||||||
btn->add(label, vec2(8, 8));
|
|
||||||
btn->listenAction([=](GUI*) {
|
btn->listenAction([=](GUI*) {
|
||||||
open_world(name, engine);
|
open_world(name, engine);
|
||||||
});
|
});
|
||||||
|
btn->add(std::make_shared<Label>(namews), vec2(8, 8));
|
||||||
|
|
||||||
auto image = std::make_shared<Image>("gui/delete_icon", vec2(32, 32));
|
auto image = std::make_shared<Image>("gui/delete_icon", vec2(32, 32));
|
||||||
image->setColor(vec4(1, 1, 1, 0.5f));
|
image->setColor(vec4(1, 1, 1, 0.5f));
|
||||||
@@ -219,45 +236,47 @@ Panel* create_worlds_panel(Engine* engine) {
|
|||||||
auto delbtn = std::make_shared<Button>(image, vec4(2));
|
auto delbtn = std::make_shared<Button>(image, vec4(2));
|
||||||
delbtn->setColor(vec4(0.0f));
|
delbtn->setColor(vec4(0.0f));
|
||||||
delbtn->setHoverColor(vec4(1.0f, 1.0f, 1.0f, 0.17f));
|
delbtn->setHoverColor(vec4(1.0f, 1.0f, 1.0f, 0.17f));
|
||||||
|
|
||||||
btn->add(delbtn, vec2(330, 3));
|
|
||||||
|
|
||||||
delbtn->listenAction([=](GUI* gui) {
|
delbtn->listenAction([=](GUI* gui) {
|
||||||
guiutil::confirm(gui, langs::get(L"delete-confirm", L"world")+
|
guiutil::confirm(gui, langs::get(L"delete-confirm", L"world")+
|
||||||
L" ("+util::str2wstr_utf8(folder.u8string())+L")", [=]()
|
L" ("+util::str2wstr_utf8(folder.u8string())+L")", [=]()
|
||||||
{
|
{
|
||||||
std::cout << "deleting " << folder.u8string() << std::endl;
|
std::cout << "deleting " << folder.u8string() << std::endl;
|
||||||
fs::remove_all(folder);
|
fs::remove_all(folder);
|
||||||
menus::refresh_menus(engine, gui->getMenu());
|
menus::refresh_menus(engine);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
btn->add(delbtn, vec2(330, 3));
|
||||||
|
|
||||||
panel->add(btn);
|
panel->add(btn);
|
||||||
}
|
}
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_main_menu_panel(Engine* engine, PagesControl* menu) {
|
void create_main_menu_panel(Engine* engine) {
|
||||||
|
auto menu = engine->getGUI()->getMenu();
|
||||||
|
|
||||||
auto panel = create_page(engine, "main", 400, 0.0f, 1);
|
auto panel = create_page(engine, "main", 400, 0.0f, 1);
|
||||||
panel->add(guiutil::gotoButton(L"New World", "new-world", menu));
|
panel->add(guiutil::gotoButton(L"New World", "new-world", menu));
|
||||||
panel->add(create_worlds_panel(engine));
|
panel->add(create_worlds_panel(engine));
|
||||||
panel->add(guiutil::gotoButton(L"Settings", "settings", menu));
|
panel->add(guiutil::gotoButton(L"Settings", "settings", menu));
|
||||||
panel->add((new Button(langs::get(L"Quit", L"menu"), vec4(10.f)))
|
|
||||||
->listenAction([](GUI* gui) {
|
auto quitbtn = std::make_shared<Button>(
|
||||||
|
langs::get(L"Quit", L"menu"), vec4(10.f)
|
||||||
|
);
|
||||||
|
quitbtn->listenAction([](GUI* gui) {
|
||||||
Window::setShouldClose(true);
|
Window::setShouldClose(true);
|
||||||
}));
|
});
|
||||||
|
panel->add(quitbtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::function<void(const ContentPack& pack)> packconsumer;
|
typedef std::function<void(const ContentPack& pack)> packconsumer;
|
||||||
|
|
||||||
const int PACKS_PANEL_WIDTH = 550;
|
|
||||||
|
|
||||||
std::shared_ptr<Panel> create_packs_panel(
|
std::shared_ptr<Panel> create_packs_panel(
|
||||||
const std::vector<ContentPack>& packs,
|
const std::vector<ContentPack>& packs,
|
||||||
Engine* engine,
|
Engine* engine,
|
||||||
bool backbutton,
|
bool backbutton,
|
||||||
packconsumer callback)
|
packconsumer callback
|
||||||
{
|
){
|
||||||
auto assets = engine->getAssets();
|
auto assets = engine->getAssets();
|
||||||
auto panel = std::make_shared<Panel>(vec2(PACKS_PANEL_WIDTH, 200), vec4(5.0f));
|
auto panel = std::make_shared<Panel>(vec2(PACKS_PANEL_WIDTH, 200), vec4(5.0f));
|
||||||
panel->setColor(vec4(1.0f, 1.0f, 1.0f, 0.07f));
|
panel->setColor(vec4(1.0f, 1.0f, 1.0f, 0.07f));
|
||||||
@@ -310,7 +329,8 @@ std::shared_ptr<Panel> create_packs_panel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
void create_content_panel(Engine* engine, PagesControl* menu) {
|
void create_content_panel(Engine* engine) {
|
||||||
|
auto menu = engine->getGUI()->getMenu();
|
||||||
auto paths = engine->getPaths();
|
auto paths = engine->getPaths();
|
||||||
auto mainPanel = create_page(engine, "content", PACKS_PANEL_WIDTH, 0.0f, 5);
|
auto mainPanel = create_page(engine, "content", PACKS_PANEL_WIDTH, 0.0f, 5);
|
||||||
|
|
||||||
@@ -375,7 +395,7 @@ inline uint64_t str2seed(std::wstring seedstr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_new_world_panel(Engine* engine, PagesControl* menu) {
|
void create_new_world_panel(Engine* engine) {
|
||||||
auto panel = create_page(engine, "new-world", 400, 0.0f, 1);
|
auto panel = create_page(engine, "new-world", 400, 0.0f, 1);
|
||||||
|
|
||||||
panel->add(std::make_shared<Label>(langs::get(L"Name", L"world")));
|
panel->add(std::make_shared<Label>(langs::get(L"Name", L"world")));
|
||||||
@@ -398,54 +418,59 @@ void create_new_world_panel(Engine* engine, PagesControl* menu) {
|
|||||||
if (!nameInput->validate())
|
if (!nameInput->validate())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::wstring name = nameInput->text();
|
std::string name = util::wstr2str_utf8(nameInput->text());
|
||||||
std::string nameutf8 = util::wstr2str_utf8(name);
|
uint64_t seed = str2seed(seedInput->text());
|
||||||
EnginePaths* paths = engine->getPaths();
|
|
||||||
|
|
||||||
std::wstring seedstr = seedInput->text();
|
|
||||||
uint64_t seed = str2seed(seedstr);
|
|
||||||
std::cout << "world seed: " << seed << std::endl;
|
std::cout << "world seed: " << seed << std::endl;
|
||||||
|
|
||||||
auto folder = paths->getWorldsFolder()/fs::u8path(nameutf8);
|
EnginePaths* paths = engine->getPaths();
|
||||||
|
auto folder = paths->getWorldsFolder()/fs::u8path(name);
|
||||||
try {
|
try {
|
||||||
engine->loadAllPacks();
|
engine->loadAllPacks();
|
||||||
engine->loadContent();
|
engine->loadContent();
|
||||||
paths->setWorldFolder(folder);
|
paths->setWorldFolder(folder);
|
||||||
} catch (const contentpack_error& error) {
|
} catch (const contentpack_error& error) {
|
||||||
guiutil::alert(engine->getGUI(),
|
guiutil::alert(
|
||||||
langs::get(L"Content Error", L"menu")+
|
engine->getGUI(),
|
||||||
L":\n"+util::str2wstr_utf8(std::string(error.what())+
|
langs::get(L"Content Error", L"menu")+L":\n"+
|
||||||
"\npack '"+error.getPackId()+"' from "+
|
util::str2wstr_utf8(
|
||||||
error.getFolder().u8string()));
|
std::string(error.what())+
|
||||||
|
"\npack '"+error.getPackId()+"' from "+
|
||||||
|
error.getFolder().u8string()
|
||||||
|
)
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
} catch (const std::runtime_error& error) {
|
} catch (const std::runtime_error& error) {
|
||||||
guiutil::alert(engine->getGUI(),
|
guiutil::alert(
|
||||||
langs::get(L"Content Error", L"menu")+
|
engine->getGUI(),
|
||||||
L": "+util::str2wstr_utf8(error.what()));
|
langs::get(L"Content Error", L"menu")+
|
||||||
|
L": "+util::str2wstr_utf8(error.what())
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Level* level = World::create(
|
Level* level = World::create(
|
||||||
nameutf8, folder, seed,
|
name, folder, seed,
|
||||||
engine->getSettings(),
|
engine->getSettings(),
|
||||||
engine->getContent(),
|
engine->getContent(),
|
||||||
engine->getContentPacks());
|
engine->getContentPacks()
|
||||||
|
);
|
||||||
engine->setScreen(std::make_shared<LevelScreen>(engine, level));
|
engine->setScreen(std::make_shared<LevelScreen>(engine, level));
|
||||||
}));
|
}));
|
||||||
panel->add(guiutil::backButton(menu));
|
panel->add(guiutil::backButton(engine->getGUI()->getMenu()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_controls_panel(Engine* engine, PagesControl* menu) {
|
void create_controls_panel(Engine* engine) {
|
||||||
|
auto menu = engine->getGUI()->getMenu();
|
||||||
auto panel = create_page(engine, "controls", 400, 0.0f, 1);
|
auto panel = create_page(engine, "controls", 400, 0.0f, 1);
|
||||||
|
|
||||||
/* Camera sensitivity setting track bar */{
|
/* Camera sensitivity setting track bar */{
|
||||||
panel->add((new Label(L""))->textSupplier([=]() {
|
panel->add(create_label([=]() {
|
||||||
float s = engine->getSettings().camera.sensitivity;
|
float s = engine->getSettings().camera.sensitivity;
|
||||||
return langs::get(L"Mouse Sensitivity", L"settings")+L": "+
|
return langs::get(L"Mouse Sensitivity", L"settings")+L": "+
|
||||||
util::to_wstring(s, 1);
|
util::to_wstring(s, 1);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TrackBar* trackbar = new TrackBar(0.1, 10.0, 2.0, 0.1, 4);
|
auto trackbar = std::make_shared<TrackBar>(0.1, 10.0, 2.0, 0.1, 4);
|
||||||
trackbar->supplier([=]() {
|
trackbar->supplier([=]() {
|
||||||
return engine->getSettings().camera.sensitivity;
|
return engine->getSettings().camera.sensitivity;
|
||||||
});
|
});
|
||||||
@@ -455,19 +480,18 @@ void create_controls_panel(Engine* engine, PagesControl* menu) {
|
|||||||
panel->add(trackbar);
|
panel->add(trackbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
Panel* scrollPanel = new Panel(vec2(400, 200), vec4(2.0f), 1.0f);
|
auto scrollPanel = std::make_shared<Panel>(vec2(400, 200), vec4(2.0f), 1.0f);
|
||||||
scrollPanel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.3f));
|
scrollPanel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.3f));
|
||||||
scrollPanel->maxLength(400);
|
scrollPanel->maxLength(400);
|
||||||
for (auto& entry : Events::bindings){
|
for (auto& entry : Events::bindings){
|
||||||
std::string bindname = entry.first;
|
std::string bindname = entry.first;
|
||||||
|
|
||||||
Panel* subpanel = new Panel(vec2(400, 40), vec4(5.0f), 1.0f);
|
auto subpanel = std::make_shared<Panel>(vec2(400, 40), vec4(5.0f), 1.0f);
|
||||||
subpanel->setColor(vec4(0.0f));
|
subpanel->setColor(vec4(0.0f));
|
||||||
subpanel->orientation(Orientation::horizontal);
|
subpanel->orientation(Orientation::horizontal);
|
||||||
|
subpanel->add(std::make_shared<InputBindBox>(entry.second));
|
||||||
|
|
||||||
InputBindBox* bindbox = new InputBindBox(entry.second);
|
auto label = std::make_shared<Label>(langs::get(util::str2wstr_utf8(bindname)));
|
||||||
subpanel->add(bindbox);
|
|
||||||
Label* label = new Label(langs::get(util::str2wstr_utf8(bindname)));
|
|
||||||
label->setMargin(vec4(6.0f));
|
label->setMargin(vec4(6.0f));
|
||||||
subpanel->add(label);
|
subpanel->add(label);
|
||||||
scrollPanel->add(subpanel);
|
scrollPanel->add(subpanel);
|
||||||
@@ -476,16 +500,17 @@ void create_controls_panel(Engine* engine, PagesControl* menu) {
|
|||||||
panel->add(guiutil::backButton(menu));
|
panel->add(guiutil::backButton(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_settings_panel(Engine* engine, PagesControl* menu) {
|
void create_settings_panel(Engine* engine) {
|
||||||
|
auto menu = engine->getGUI()->getMenu();
|
||||||
auto panel = create_page(engine, "settings", 400, 0.0f, 1);
|
auto panel = create_page(engine, "settings", 400, 0.0f, 1);
|
||||||
|
|
||||||
/* Load Distance setting track bar */{
|
/* Load Distance setting track bar */{
|
||||||
panel->add((new Label(L""))->textSupplier([=]() {
|
panel->add(create_label([=]() {
|
||||||
return langs::get(L"Load Distance", L"settings")+L": " +
|
return langs::get(L"Load Distance", L"settings")+L": " +
|
||||||
std::to_wstring(engine->getSettings().chunks.loadDistance);
|
std::to_wstring(engine->getSettings().chunks.loadDistance);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TrackBar* trackbar = new TrackBar(3, 66, 10, 1, 3);
|
auto trackbar = std::make_shared<TrackBar>(3, 66, 10, 1, 3);
|
||||||
trackbar->supplier([=]() {
|
trackbar->supplier([=]() {
|
||||||
return engine->getSettings().chunks.loadDistance;
|
return engine->getSettings().chunks.loadDistance;
|
||||||
});
|
});
|
||||||
@@ -496,12 +521,12 @@ void create_settings_panel(Engine* engine, PagesControl* menu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Load Speed setting track bar */{
|
/* Load Speed setting track bar */{
|
||||||
panel->add((new Label(L""))->textSupplier([=]() {
|
panel->add(create_label([=]() {
|
||||||
return langs::get(L"Load Speed", L"settings")+L": " +
|
return langs::get(L"Load Speed", L"settings")+L": " +
|
||||||
std::to_wstring(engine->getSettings().chunks.loadSpeed);
|
std::to_wstring(engine->getSettings().chunks.loadSpeed);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TrackBar* trackbar = new TrackBar(1, 32, 10, 1, 1);
|
auto trackbar = std::make_shared<TrackBar>(1, 32, 10, 1, 1);
|
||||||
trackbar->supplier([=]() {
|
trackbar->supplier([=]() {
|
||||||
return engine->getSettings().chunks.loadSpeed;
|
return engine->getSettings().chunks.loadSpeed;
|
||||||
});
|
});
|
||||||
@@ -512,13 +537,13 @@ void create_settings_panel(Engine* engine, PagesControl* menu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fog Curve setting track bar */{
|
/* Fog Curve setting track bar */{
|
||||||
panel->add((new Label(L""))->textSupplier([=]() {
|
panel->add(create_label([=]() {
|
||||||
float value = engine->getSettings().graphics.fogCurve;
|
float value = engine->getSettings().graphics.fogCurve;
|
||||||
return langs::get(L"Fog Curve", L"settings")+L": " +
|
return langs::get(L"Fog Curve", L"settings")+L": " +
|
||||||
util::to_wstring(value, 1);
|
util::to_wstring(value, 1);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TrackBar* trackbar = new TrackBar(1.0, 6.0, 1.0, 0.1, 2);
|
auto trackbar = std::make_shared<TrackBar>(1.0, 6.0, 1.0, 0.1, 2);
|
||||||
trackbar->supplier([=]() {
|
trackbar->supplier([=]() {
|
||||||
return engine->getSettings().graphics.fogCurve;
|
return engine->getSettings().graphics.fogCurve;
|
||||||
});
|
});
|
||||||
@@ -529,12 +554,12 @@ void create_settings_panel(Engine* engine, PagesControl* menu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fov setting track bar */{
|
/* Fov setting track bar */{
|
||||||
panel->add((new Label(L""))->textSupplier([=]() {
|
panel->add(create_label([=]() {
|
||||||
int fov = (int)engine->getSettings().camera.fov;
|
int fov = (int)engine->getSettings().camera.fov;
|
||||||
return langs::get(L"FOV", L"settings")+L": "+std::to_wstring(fov)+L"°";
|
return langs::get(L"FOV", L"settings")+L": "+std::to_wstring(fov)+L"°";
|
||||||
}));
|
}));
|
||||||
|
|
||||||
TrackBar* trackbar = new TrackBar(30.0, 120.0, 90, 1, 4);
|
auto trackbar = std::make_shared<TrackBar>(30.0, 120.0, 90, 1, 4);
|
||||||
trackbar->supplier([=]() {
|
trackbar->supplier([=]() {
|
||||||
return engine->getSettings().camera.fov;
|
return engine->getSettings().camera.fov;
|
||||||
});
|
});
|
||||||
@@ -545,7 +570,9 @@ void create_settings_panel(Engine* engine, PagesControl* menu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* V-Sync checkbox */{
|
/* V-Sync checkbox */{
|
||||||
auto checkbox = new FullCheckBox(langs::get(L"V-Sync", L"settings"), vec2(400, 32));
|
auto checkbox = std::make_shared<FullCheckBox>(
|
||||||
|
langs::get(L"V-Sync", L"settings"), vec2(400, 32)
|
||||||
|
);
|
||||||
checkbox->supplier([=]() {
|
checkbox->supplier([=]() {
|
||||||
return engine->getSettings().display.swapInterval != 0;
|
return engine->getSettings().display.swapInterval != 0;
|
||||||
});
|
});
|
||||||
@@ -556,7 +583,9 @@ void create_settings_panel(Engine* engine, PagesControl* menu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Backlight checkbox */{
|
/* Backlight checkbox */{
|
||||||
auto checkbox = new FullCheckBox(langs::get(L"Backlight", L"settings"), vec2(400, 32));
|
auto checkbox = std::make_shared<FullCheckBox>(
|
||||||
|
langs::get(L"Backlight", L"settings"), vec2(400, 32)
|
||||||
|
);
|
||||||
checkbox->supplier([=]() {
|
checkbox->supplier([=]() {
|
||||||
return engine->getSettings().graphics.backlight != 0;
|
return engine->getSettings().graphics.backlight != 0;
|
||||||
});
|
});
|
||||||
@@ -576,14 +605,15 @@ void create_settings_panel(Engine* engine, PagesControl* menu) {
|
|||||||
panel->add(guiutil::backButton(menu));
|
panel->add(guiutil::backButton(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_pause_panel(Engine* engine, PagesControl* menu) {
|
void create_pause_panel(Engine* engine) {
|
||||||
|
auto menu = engine->getGUI()->getMenu();
|
||||||
auto panel = create_page(engine, "pause", 400, 0.0f, 1);
|
auto panel = create_page(engine, "pause", 400, 0.0f, 1);
|
||||||
|
|
||||||
panel->add(create_button(L"Continue", vec4(10.0f), vec4(1), [=](GUI*){
|
panel->add(create_button(L"Continue", vec4(10.0f), vec4(1), [=](GUI*){
|
||||||
menu->reset();
|
menu->reset();
|
||||||
}));
|
}));
|
||||||
panel->add(create_button(L"Content", vec4(10.0f), vec4(1), [=](GUI*) {
|
panel->add(create_button(L"Content", vec4(10.0f), vec4(1), [=](GUI*) {
|
||||||
create_content_panel(engine, menu);
|
create_content_panel(engine);
|
||||||
menu->set("content");
|
menu->set("content");
|
||||||
}));
|
}));
|
||||||
panel->add(guiutil::gotoButton(L"Settings", "settings", menu));
|
panel->add(guiutil::gotoButton(L"Settings", "settings", menu));
|
||||||
@@ -596,16 +626,16 @@ void create_pause_panel(Engine* engine, PagesControl* menu) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void menus::create_menus(Engine* engine, PagesControl* menu) {
|
void menus::create_menus(Engine* engine) {
|
||||||
create_new_world_panel(engine, menu);
|
create_new_world_panel(engine);
|
||||||
create_settings_panel(engine, menu);
|
create_settings_panel(engine);
|
||||||
create_controls_panel(engine, menu);
|
create_controls_panel(engine);
|
||||||
create_pause_panel(engine, menu);
|
create_pause_panel(engine);
|
||||||
create_languages_panel(engine, menu);
|
create_languages_panel(engine);
|
||||||
create_main_menu_panel(engine, menu);
|
create_main_menu_panel(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menus::refresh_menus(Engine* engine, PagesControl* menu) {
|
void menus::refresh_menus(Engine* engine) {
|
||||||
create_main_menu_panel(engine, menu);
|
create_main_menu_panel(engine);
|
||||||
create_new_world_panel(engine, menu);
|
create_new_world_panel(engine);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-6
@@ -3,13 +3,9 @@
|
|||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
|
|
||||||
namespace gui {
|
|
||||||
class PagesControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace menus {
|
namespace menus {
|
||||||
void create_menus(Engine* engine, gui::PagesControl* menu);
|
void create_menus(Engine* engine);
|
||||||
void refresh_menus(Engine* engine, gui::PagesControl* menu);
|
void refresh_menus(Engine* engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FRONTEND_MENU_H_
|
#endif // FRONTEND_MENU_H_
|
||||||
@@ -45,7 +45,7 @@ Screen::~Screen() {
|
|||||||
|
|
||||||
MenuScreen::MenuScreen(Engine* engine_) : Screen(engine_) {
|
MenuScreen::MenuScreen(Engine* engine_) : Screen(engine_) {
|
||||||
auto menu = engine->getGUI()->getMenu();
|
auto menu = engine->getGUI()->getMenu();
|
||||||
menus::refresh_menus(engine, menu);
|
menus::refresh_menus(engine);
|
||||||
menu->reset();
|
menu->reset();
|
||||||
menu->set("main");
|
menu->set("main");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user