Merge branch 'main' into release-0.32

This commit is contained in:
MihailRis 2026-11-01 04:39:46 +03:00
commit 9c439401ff
12 changed files with 114 additions and 31 deletions

View file

@ -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")

View file

@ -1,5 +1,5 @@
<panel size='400' color='0' interval='1' context='menu'> <panel size='400' color='0' interval='1' context='menu'>
<button onclick='menu.page="worlds"'>@Worlds</button> <button id='worlds_btn' onclick='menu.page="worlds"'>@Worlds</button>
<button onclick='menu.page="scripts"'>@Scripts</button> <button onclick='menu.page="scripts"'>@Scripts</button>
<button onclick='menu.page="settings"'>@Settings</button> <button onclick='menu.page="settings"'>@Settings</button>
<button onclick='menu.page="content_menu"'>@Content</button> <button onclick='menu.page="content_menu"'>@Content</button>

View file

@ -7,11 +7,11 @@
</textbox> </textbox>
<label>@Seed</label> <label>@Seed</label>
<textbox id='seed_box' placeholder='-' padding='4'></textbox> <textbox id='seed_box' placeholder='-' padding='4'></textbox>
<button onclick='save_state() menu.page="generators"' id='generator_btn'> <button id='generator_btn' onclick='save_state() menu.page="generators"'>
@World generator @World generator
</button> </button>
<button id='content_btn' onclick='save_state() menu.page="content"'/> <button id='content_btn' onclick='save_state() menu.page="content"'/>
<button onclick='create_world()' margin='0,20,0,1'> <button id='create_world_btn' onclick='create_world()' margin='0,20,0,1'>
@Create World @Create World
</button> </button>
<button onclick='menu:back()'>@Back</button> <button onclick='menu:back()'>@Back</button>

View file

@ -2,7 +2,7 @@
<button onclick='gui.close_menu()'>@Continue</button> <button onclick='gui.close_menu()'>@Continue</button>
<button onclick='menu.page="content?mode=world"'>@Content</button> <button onclick='menu.page="content?mode=world"'>@Content</button>
<button onclick='menu.page="settings"'>@Settings</button> <button onclick='menu.page="settings"'>@Settings</button>
<button onclick='app.close_world(true)'> <button id='quit_btn' onclick='app.close_world(true)'>
@Save and Quit to Menu @Save and Quit to Menu
</button> </button>
</panel> </panel>

View file

@ -1,5 +1,5 @@
<panel size='400' color='0' interval='1' context='menu'> <panel size='400' color='0' interval='1' context='menu'>
<button onclick='menu.page="new_world"'>@New World</button> <button id="new_world_btn" onclick='menu.page="new_world"'>@New World</button>
<panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'> <panel id='worlds' size='390,1' padding='5' color='#FFFFFF11' max-length='400'>
</panel> </panel>

View file

@ -76,6 +76,9 @@ local function complete_app_lib(app)
end end
function app.config_packs(packs_list) 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 -- Check if packs are valid and add dependencies to the configuration
packs_list = pack.assemble(packs_list) packs_list = pack.assemble(packs_list)

View file

@ -78,6 +78,8 @@ std::shared_ptr<UINode> create_debug_panel(
static int drawCallsMax = drawCalls; static int drawCallsMax = drawCalls;
static std::wstring drawCallsAvgString = L""; static std::wstring drawCallsAvgString = L"";
static std::wstring drawCallsMinMaxString = L""; static std::wstring drawCallsMinMaxString = L"";
static int verticesCount = 0;
static std::wstring verticesCountString = L"";
static size_t lastTotalDownload = 0; static size_t lastTotalDownload = 0;
static size_t lastTotalUpload = 0; static size_t lastTotalUpload = 0;
@ -151,6 +153,19 @@ std::shared_ptr<UINode> create_debug_panel(
panel->add(create_label(gui, []() { panel->add(create_label(gui, []() {
return drawCallsMinMaxString; return drawCallsMinMaxString;
})); }));
panel->add(create_label(gui, []() {
static int frame = 0;
verticesCount = std::max<int>(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, []() { panel->add(create_label(gui, []() {
return L"speakers: " + std::to_wstring(audio::count_speakers()) + return L"speakers: " + std::to_wstring(audio::count_speakers()) +
L" streams: " + std::to_wstring(audio::count_streams()); L" streams: " + std::to_wstring(audio::count_streams());

View file

@ -2,3 +2,4 @@
int MeshStats::meshesCount = 0; int MeshStats::meshesCount = 0;
int MeshStats::drawCalls = 0; int MeshStats::drawCalls = 0;
int MeshStats::vertices = 0;

View file

@ -8,6 +8,7 @@
struct MeshStats { struct MeshStats {
static int meshesCount; static int meshesCount;
static int drawCalls; static int drawCalls;
static int vertices;
}; };
struct IndexBufferData { struct IndexBufferData {

View file

@ -126,17 +126,20 @@ void Mesh<VertexStructure>::draw(unsigned int primitive, int iboIndex) const {
if (!ibos.empty()) { if (!ibos.empty()) {
if (iboIndex < ibos.size()) { if (iboIndex < ibos.size()) {
size_t indexCount = ibos.at(iboIndex).indexCount;
glBindVertexArray(vao); glBindVertexArray(vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibos[iboIndex].ibo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibos[iboIndex].ibo);
glDrawElements( glDrawElements(
primitive, ibos.at(iboIndex).indexCount, GL_UNSIGNED_INT, nullptr primitive, indexCount, GL_UNSIGNED_INT, nullptr
); );
glBindVertexArray(0); glBindVertexArray(0);
MeshStats::vertices += indexCount;
} }
} else if (vertexCount > 0) { } else if (vertexCount > 0) {
glBindVertexArray(vao); glBindVertexArray(vao);
glDrawArrays(primitive, 0, vertexCount); glDrawArrays(primitive, 0, vertexCount);
glBindVertexArray(0); glBindVertexArray(0);
MeshStats::vertices += vertexCount;
} }
} }

View file

@ -667,6 +667,25 @@ std::string util::format_data_size(size_t size) {
postfixes[group]; 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<int>(round(remainder / 1000.0f))) +
postfixes[group];
}
std::pair<std::string, std::string> util::split_at( std::pair<std::string, std::string> util::split_at(
std::string_view view, char c std::string_view view, char c
) { ) {

View file

@ -118,6 +118,7 @@ namespace util {
std::vector<std::wstring> split(const std::wstring& str, char delimiter); std::vector<std::wstring> split(const std::wstring& str, char delimiter);
std::string format_data_size(size_t size); std::string format_data_size(size_t size);
std::string format_count(size_t size);
std::pair<std::string, std::string> split_at(std::string_view view, char c); std::pair<std::string, std::string> split_at(std::string_view view, char c);