From f9b74cef2798e374aabc4aa0157d2e676390c46e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 17 Apr 2022 00:01:32 +0200 Subject: [PATCH] Add histogram loading screen --- init.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index bd0d227..3b5e535 100644 --- a/init.lua +++ b/init.lua @@ -711,6 +711,21 @@ minetest.register_chatcommand("perlin_generate", { end, }) +local show_histogram_loading_formspec = function(player) + local form = [[ + formspec_version[4]size[10,2] + container[0.25,0.25] + box[0,0;9.5,1.5;]]..FORMSPEC_BOX_COLOR..[[] + box[0,0;9.5,0.4;]]..FORMSPEC_HEADER_COLOR..[[] + label[0.25,0.2;]]..F(S("Performing deep analysis ..."))..[[] + container[0.25,0.8] + label[0,0;]]..F(S("Collecting data, please wait …"))..[[] + container_end[] + container_end[] + ]] + minetest.show_formspec(player:get_player_name(), "perlin_explorer:histogram_loading", form) +end + local show_histogram_formspec = function(player, stats) local txt = "" local maxh = 6.0 @@ -753,7 +768,7 @@ local show_histogram_formspec = function(player, stats) container[0.25,0.25] box[0,0;9.5,10;]]..FORMSPEC_BOX_COLOR..[[] box[0,0;9.5,0.4;]]..FORMSPEC_HEADER_COLOR..[[] - label[0.25,0.2;]]..F(S("Noise Parameter Histogram"))..[[] + label[0.25,0.2;]]..F(S("Noise Value Histogram"))..[[] container[0.25,0.8] ]]..labels..[[ ]]..boxes..[[ @@ -989,9 +1004,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) else -- 3 dimensions size = 162 -- 163^3 is roughly equal to 2048 end + -- Show a loading formspec + show_histogram_loading_formspec(player) + -- This takes long local _, stats = create_perlin(pos, {dimensions=current_perlin.dimensions, size=size, set_nodes=false}) if stats then + -- Update the formspec to show the result show_histogram_formspec(player, stats) + else + minetest.log("error", "[perlin_explorer] Error while creating stats from Perlin noise!") end return end