wip
This commit is contained in:
@@ -362,9 +362,17 @@ void create_new_world_panel(Engine* engine) {
|
|||||||
auto seedstr = std::to_wstring(randU64());
|
auto seedstr = std::to_wstring(randU64());
|
||||||
auto seedInput = std::make_shared<TextBox>(seedstr, glm::vec4(6.0f));
|
auto seedInput = std::make_shared<TextBox>(seedstr, glm::vec4(6.0f));
|
||||||
panel->add(seedInput);
|
panel->add(seedInput);
|
||||||
|
|
||||||
panel->add(guiutil::gotoButton(langs::get(L"World generator", L"world"), "world_generators", engine->getGUI()->getMenu()));
|
panel->add(guiutil::gotoButton(langs::get(L"World generator", L"world"), "world_generators", engine->getGUI()->getMenu()));
|
||||||
|
|
||||||
|
panel->add(menus::create_button(L"Content", glm::vec4(10), glm::vec4(1), [=](GUI* gui) {
|
||||||
|
engine->loadAllPacks();
|
||||||
|
auto panel = menus::create_packs_panel(engine->getContentPacks(), engine, false, nullptr, nullptr);
|
||||||
|
auto menu = gui->getMenu();
|
||||||
|
menu->addPage("content-packs", panel);
|
||||||
|
menu->setPage("content-packs");
|
||||||
|
}));
|
||||||
|
|
||||||
panel->add(menus::create_button(L"Create World", glm::vec4(10), glm::vec4(1, 20, 1, 1),
|
panel->add(menus::create_button(L"Create World", glm::vec4(10), glm::vec4(1, 20, 1, 1),
|
||||||
[=](GUI*) {
|
[=](GUI*) {
|
||||||
if (!nameInput->validate())
|
if (!nameInput->validate())
|
||||||
|
|||||||
@@ -2,16 +2,34 @@
|
|||||||
#define FRONTEND_MENU_MENU_H_
|
#define FRONTEND_MENU_MENU_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
#include "../../content/ContentPack.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace gui {
|
||||||
|
class Panel;
|
||||||
|
}
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
class LevelController;
|
class LevelController;
|
||||||
|
|
||||||
|
using packconsumer = std::function<void(const ContentPack& pack)>;
|
||||||
|
|
||||||
namespace menus {
|
namespace menus {
|
||||||
// implemented in menu_settings.cpp
|
// implemented in menu_settings.cpp
|
||||||
extern void create_settings_panel(Engine* engine);
|
extern void create_settings_panel(Engine* engine);
|
||||||
|
|
||||||
// implemented in menu_pause.cpp
|
// implemented in menu_pause.cpp
|
||||||
extern void create_pause_panel(Engine* engine, LevelController* controller);
|
extern void create_pause_panel(Engine* engine, LevelController* controller);
|
||||||
|
extern std::shared_ptr<gui::Panel> create_packs_panel(
|
||||||
|
const std::vector<ContentPack>& packs,
|
||||||
|
Engine* engine,
|
||||||
|
bool backbutton,
|
||||||
|
packconsumer callback,
|
||||||
|
packconsumer remover
|
||||||
|
);
|
||||||
|
|
||||||
/// @brief Load world, convert if required and set to LevelScreen.
|
/// @brief Load world, convert if required and set to LevelScreen.
|
||||||
/// @param name world name
|
/// @param name world name
|
||||||
|
|||||||
@@ -16,9 +16,7 @@
|
|||||||
|
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
using packconsumer = std::function<void(const ContentPack& pack)>;
|
std::shared_ptr<Panel> menus::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,
|
||||||
@@ -39,7 +37,7 @@ std::shared_ptr<Panel> create_packs_panel(
|
|||||||
callback(pack);
|
callback(pack);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
auto runtime = engine->getContent()->getPackRuntime(pack.id);
|
auto runtime = engine->getContent() ? engine->getContent()->getPackRuntime(pack.id) : nullptr;
|
||||||
auto idlabel = std::make_shared<Label>(
|
auto idlabel = std::make_shared<Label>(
|
||||||
(runtime && runtime->getStats().hasSavingContent())
|
(runtime && runtime->getStats().hasSavingContent())
|
||||||
? "*["+pack.id+"]"
|
? "*["+pack.id+"]"
|
||||||
@@ -121,7 +119,7 @@ void create_content_panel(Engine* engine, LevelController* controller) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto panel = create_packs_panel(
|
auto panel = menus::create_packs_panel(
|
||||||
engine->getContentPacks(), engine, false, nullptr,
|
engine->getContentPacks(), engine, false, nullptr,
|
||||||
[=](const ContentPack& pack) {
|
[=](const ContentPack& pack) {
|
||||||
auto world = level->getWorld();
|
auto world = level->getWorld();
|
||||||
@@ -143,7 +141,7 @@ void create_content_panel(Engine* engine, LevelController* controller) {
|
|||||||
mainPanel->add(panel);
|
mainPanel->add(panel);
|
||||||
mainPanel->add(menus::create_button(
|
mainPanel->add(menus::create_button(
|
||||||
langs::get(L"Add", L"content"), glm::vec4(10.0f), glm::vec4(1), [=](GUI* gui) {
|
langs::get(L"Add", L"content"), glm::vec4(10.0f), glm::vec4(1), [=](GUI* gui) {
|
||||||
auto panel = create_packs_panel(scanned, engine, true,
|
auto panel = menus::create_packs_panel(scanned, engine, true,
|
||||||
[=](const ContentPack& pack) {
|
[=](const ContentPack& pack) {
|
||||||
auto world = level->getWorld();
|
auto world = level->getWorld();
|
||||||
auto worldFolder = paths->getWorldFolder();
|
auto worldFolder = paths->getWorldFolder();
|
||||||
|
|||||||
Reference in New Issue
Block a user