From 9cc2f93cfd9a7c13d0f110fc7e413e4d22e46ca0 Mon Sep 17 00:00:00 2001 From: Onran <100285264+Onran0@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:54:10 +0900 Subject: [PATCH] More world generators support --- src/frontend/menu.cpp | 37 ++++++++++++++- src/logic/ChunksController.cpp | 5 ++- src/voxels/FlatWorldGenerator.cpp | 28 ++++++++++++ src/voxels/FlatWorldGenerator.h | 18 ++++++++ src/voxels/WorldGenerator.h | 5 ++- src/world/World.cpp | 75 +++++++++++++++++++++---------- src/world/World.h | 16 ++++++- src/world/WorldTypes.cpp | 37 +++++++++++++++ src/world/WorldTypes.h | 18 ++++++++ 9 files changed, 209 insertions(+), 30 deletions(-) create mode 100644 src/voxels/FlatWorldGenerator.cpp create mode 100644 src/voxels/FlatWorldGenerator.h create mode 100644 src/world/WorldTypes.cpp create mode 100644 src/world/WorldTypes.h diff --git a/src/frontend/menu.cpp b/src/frontend/menu.cpp index ce1ab9cc..1fd76916 100644 --- a/src/frontend/menu.cpp +++ b/src/frontend/menu.cpp @@ -19,6 +19,7 @@ #include "../files/WorldConverter.h" #include "../files/WorldFiles.h" #include "../world/World.h" +#include "../world/WorldTypes.h" #include "../world/Level.h" #include "../window/Events.h" #include "../window/Window.h" @@ -38,6 +39,10 @@ using glm::vec4; namespace fs = std::filesystem; using namespace gui; +namespace menus { + std::string worldType; +} + inline uint64_t randU64() { srand(time(NULL)); return rand() ^ (rand() << 8) ^ @@ -168,6 +173,28 @@ void create_languages_panel(Engine* engine) { panel->add(guiutil::backButton(menu)); } +void create_world_types_panel(Engine* engine) { + auto menu = engine->getGUI()->getMenu(); + auto panel = create_page(engine, "world_types", 400, 0.5f, 1); + panel->setScrollable(true); + + std::vector worldTypes = WorldTypes::getWorldTypes(); + std::sort(worldTypes.begin(), worldTypes.end()); + for (std::string& type : worldTypes) { + std::string& fullName = util::wstr2str_utf8(langs::get(util::str2wstr_utf8(type), L"world.types")); + auto button = std::make_shared