diff --git a/dev/tests/client/creating_new_world.lua b/dev/tests/client/creating_new_world.lua
new file mode 100644
index 000000000..7f2667b77
--- /dev/null
+++ b/dev/tests/client/creating_new_world.lua
@@ -0,0 +1,40 @@
+app.tick()
+app.set_setting("ui.language", "en_US")
+
+local main_page = Document.new("core:pages/main")
+test.click(main_page.worlds_btn)
+
+local worlds_page = Document.new("core:pages/worlds")
+test.click(worlds_page.new_world_btn)
+
+local page = Document.new("core:pages/new_world")
+local world_name = "test-"..random.uuid()
+test.fill(page.name_box, world_name)
+test.fill(page.seed_box, "randomseed")
+test.click(page.generator_btn)
+
+local generators_page = Document.new("core:pages/generators")
+test.click(test.find_by_text(generators_page.root, "Flat_grass"))
+
+local new_world_page = Document.new("core:pages/new_world")
+test.click(new_world_page.create_world_btn)
+
+app.sleep_until(function() return gui.root["hud.hotbar"].exists end)
+
+test.press("escape")
+local pause_page = Document.new("core:pages/pause")
+test.click(pause_page.quit_btn)
+
+test.click(main_page.worlds_btn)
+
+local world_button = test.find_by_text(worlds_page.root, world_name).parent
+local delete_button = test.find_by_attr(world_button, "src", "gui/delete_icon")
+test.click(delete_button)
+
+assert(test.find_by_text(
+ gui.root.root, string.format("Do you want to delete world forever? (user:worlds/%s)", world_name)
+), "World deletion confirm dialog not shown")
+
+test.press("enter")
+
+assert(not world_button.exists, "World still shown in worlds list after deletion")
diff --git a/res/layouts/pages/main.xml b/res/layouts/pages/main.xml
index b05ac7158..66f6793b2 100644
--- a/res/layouts/pages/main.xml
+++ b/res/layouts/pages/main.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/res/layouts/pages/new_world.xml b/res/layouts/pages/new_world.xml
index fc13d5084..1bfc625c4 100644
--- a/res/layouts/pages/new_world.xml
+++ b/res/layouts/pages/new_world.xml
@@ -7,11 +7,11 @@
-
diff --git a/res/layouts/pages/worlds.xml b/res/layouts/pages/worlds.xml
index 34fe3400c..f28ffe572 100644
--- a/res/layouts/pages/worlds.xml
+++ b/res/layouts/pages/worlds.xml
@@ -1,5 +1,5 @@
- @New World
+ @New World
diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua
index b3bec82ce..868a8b635 100644
--- a/res/scripts/stdlib.lua
+++ b/res/scripts/stdlib.lua
@@ -76,6 +76,9 @@ local function complete_app_lib(app)
end
function app.config_packs(packs_list)
+ if tick_required and not internals.is_post_runnable_context() then
+ __app_tick()
+ end
-- Check if packs are valid and add dependencies to the configuration
packs_list = pack.assemble(packs_list)
diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp
index 84e85f3e9..2e10d55c4 100644
--- a/src/frontend/debug_panel.cpp
+++ b/src/frontend/debug_panel.cpp
@@ -78,6 +78,8 @@ std::shared_ptr create_debug_panel(
static int drawCallsMax = drawCalls;
static std::wstring drawCallsAvgString = L"";
static std::wstring drawCallsMinMaxString = L"";
+ static int verticesCount = 0;
+ static std::wstring verticesCountString = L"";
static size_t lastTotalDownload = 0;
static size_t lastTotalUpload = 0;
@@ -151,6 +153,19 @@ std::shared_ptr create_debug_panel(
panel->add(create_label(gui, []() {
return drawCallsMinMaxString;
}));
+ panel->add(create_label(gui, []() {
+ static int frame = 0;
+ verticesCount = std::max(verticesCount, MeshStats::vertices);
+ if (frame % 4 == 0) {
+ verticesCountString =
+ L"vertices: " + std::to_wstring(verticesCount) + L" (" +
+ util::str2wstr_utf8(util::format_count(verticesCount)) + L")";
+ }
+ frame++;
+ MeshStats::vertices = 0;
+ verticesCount = 0;
+ return verticesCountString;
+ }));
panel->add(create_label(gui, []() {
return L"speakers: " + std::to_wstring(audio::count_speakers()) +
L" streams: " + std::to_wstring(audio::count_streams());
diff --git a/src/graphics/core/Mesh.cpp b/src/graphics/core/Mesh.cpp
index f1f79f3e6..6cb2aa0d7 100644
--- a/src/graphics/core/Mesh.cpp
+++ b/src/graphics/core/Mesh.cpp
@@ -1,4 +1,5 @@
#include "graphics/core/Mesh.hpp"
int MeshStats::meshesCount = 0;
- int MeshStats::drawCalls = 0;
\ No newline at end of file
+ int MeshStats::drawCalls = 0;
+ int MeshStats::vertices = 0;
diff --git a/src/graphics/core/Mesh.hpp b/src/graphics/core/Mesh.hpp
index 2ff15cc2a..f27fc4e2a 100644
--- a/src/graphics/core/Mesh.hpp
+++ b/src/graphics/core/Mesh.hpp
@@ -8,6 +8,7 @@
struct MeshStats {
static int meshesCount;
static int drawCalls;
+ static int vertices;
};
struct IndexBufferData {
diff --git a/src/graphics/core/Mesh.inl b/src/graphics/core/Mesh.inl
index 4c6424dd1..b92c1b26e 100644
--- a/src/graphics/core/Mesh.inl
+++ b/src/graphics/core/Mesh.inl
@@ -126,17 +126,20 @@ void Mesh::draw(unsigned int primitive, int iboIndex) const {
if (!ibos.empty()) {
if (iboIndex < ibos.size()) {
+ size_t indexCount = ibos.at(iboIndex).indexCount;
glBindVertexArray(vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibos[iboIndex].ibo);
glDrawElements(
- primitive, ibos.at(iboIndex).indexCount, GL_UNSIGNED_INT, nullptr
+ primitive, indexCount, GL_UNSIGNED_INT, nullptr
);
glBindVertexArray(0);
+ MeshStats::vertices += indexCount;
}
} else if (vertexCount > 0) {
glBindVertexArray(vao);
glDrawArrays(primitive, 0, vertexCount);
glBindVertexArray(0);
+ MeshStats::vertices += vertexCount;
}
}
diff --git a/src/util/stringutil.cpp b/src/util/stringutil.cpp
index a2743a8ba..a41ceaf00 100644
--- a/src/util/stringutil.cpp
+++ b/src/util/stringutil.cpp
@@ -1,11 +1,11 @@
-#include "stringutil.hpp"
-
-#include
-#include
-#include
-#include
-#include
-#include
+#include "stringutil.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include
@@ -511,22 +511,22 @@ int util::replaceAll(
return replace_all(str, from, to);
}
-double util::parse_double(const std::string& str) {
- const char* begin = str.data();
- const char* end = begin + str.size();
- while (begin != end && std::isspace(static_cast(*begin))) {
- begin++;
- }
- if (begin != end && *begin == '+') {
- begin++;
- }
- double d = 0.0;
- const auto result = std::from_chars(begin, end, d);
- if (result.ec != std::errc()) {
- throw std::runtime_error("invalid number format");
- }
- return d;
-}
+double util::parse_double(const std::string& str) {
+ const char* begin = str.data();
+ const char* end = begin + str.size();
+ while (begin != end && std::isspace(static_cast(*begin))) {
+ begin++;
+ }
+ if (begin != end && *begin == '+') {
+ begin++;
+ }
+ double d = 0.0;
+ const auto result = std::from_chars(begin, end, d);
+ if (result.ec != std::errc()) {
+ throw std::runtime_error("invalid number format");
+ }
+ return d;
+}
double util::parse_double(const std::string& str, size_t offset, size_t len) {
return parse_double(str.substr(offset, len));
@@ -667,6 +667,25 @@ std::string util::format_data_size(size_t size) {
postfixes[group];
}
+std::string util::format_count(size_t count) {
+ if (count < 1000) {
+ return std::to_string(count);
+ }
+ const std::string postfixes[] {
+ "", " K", " M", " B"
+ };
+ int group = 0;
+ size_t remainder = 0;
+ while (count >= 1000) {
+ group++;
+ remainder = count % 1000;
+ count /= 1000;
+ }
+ return std::to_string(count) + "." +
+ std::to_string(static_cast(round(remainder / 1000.0f))) +
+ postfixes[group];
+}
+
std::pair util::split_at(
std::string_view view, char c
) {
diff --git a/src/util/stringutil.hpp b/src/util/stringutil.hpp
index 3f2263efb..4e2ff39c2 100644
--- a/src/util/stringutil.hpp
+++ b/src/util/stringutil.hpp
@@ -118,6 +118,7 @@ namespace util {
std::vector split(const std::wstring& str, char delimiter);
std::string format_data_size(size_t size);
+ std::string format_count(size_t size);
std::pair split_at(std::string_view view, char c);