Add "Done" button to stats screen

This commit is contained in:
Wuzzy 2022-04-21 00:58:20 +02:00
parent 0e5010401f
commit 26dbf1d03d

View File

@ -1191,7 +1191,7 @@ local show_histogram_formspec = function(player, options, stats)
"label[1.1,8.15;"..F(S("Noise values")).."]"..
"label[0,7.0;"..F(S("Max.")).."\n"..F(S("Min.")).."]"..
"tooltip[0,6.8;0.7,1;"..F(S("Upper bounds (exclusive) and lower bounds (inclusive) of the noise value data bucketing")).."]"..
"box[0.75,0;0.025,8.3;"..FORMSPEC_HISTOGRAM_LINE_COLOR.."]"..
"box[0.75,0;0.025,8.5;"..FORMSPEC_HISTOGRAM_LINE_COLOR.."]"..
"box[0,6.65;"..HISTOGRAM_BUCKETS..",0.025;"..FORMSPEC_HISTOGRAM_LINE_COLOR.."]"..
"box[0,7.8;"..HISTOGRAM_BUCKETS..",0.025;"..FORMSPEC_HISTOGRAM_LINE_COLOR.."]"
local hstart = 1
@ -1276,13 +1276,14 @@ local show_histogram_formspec = function(player, options, stats)
]]..labels..[[
container_end[]
container[0,2.75]
box[0,0;]]..(HISTOGRAM_BUCKETS+0.5)..[[,9.0;]]..FORMSPEC_BOX_COLOR..[[]
box[0,0;]]..(HISTOGRAM_BUCKETS+0.5)..[[,9.25;]]..FORMSPEC_BOX_COLOR..[[]
box[0,0;]]..(HISTOGRAM_BUCKETS+0.5)..[[,0.4;]]..FORMSPEC_HEADER_COLOR..[[]
label[0.25,0.2;]]..F(S("Noise Value Histogram"))..[[]
container[0.25,0.6]
]]..histogram..[[
container_end[]
container_end[]
button[7.25,11.35;3,0.5;done;]]..F(S("Done"))..[[]
container_end[]
]]
minetest.show_formspec(player:get_player_name(), "perlin_explorer:histogram", form)
@ -1537,7 +1538,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
-- Analysis window
if formname == "perlin_explorer:analyze" or formname == "perlin_explorer:error" then
if formname == "perlin_explorer:analyze" or formname == "perlin_explorer:error" or formname == "perlin_explorer:histogram" then
if fields.done then
local noiseparams = formspec_states[player:get_player_name()].noiseparams
show_noise_formspec(player, noiseparams)
@ -1713,6 +1714,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Start statistics calculation
if fields.statistics then
formspec_states[player:get_player_name()].noiseparams = noiseparams
local max_spread = 0
max_spread = math.max(max_spread, noiseparams.spread.x)
max_spread = math.max(max_spread, noiseparams.spread.y)