Complete the graphics settings television

This commit is contained in:
Wuzzy 2024-08-13 09:05:52 +02:00
parent 4fac7e52a4
commit 494643d6c6
6 changed files with 69 additions and 35 deletions

View File

@ -137,6 +137,11 @@ lzr_gui.show_menu_markers = function(player)
S("Ambience"), S("Ambience"),
vector.offset(vector.add(lzr_globals.MENU_SHIP_POS, lzr_globals.MENU_SHIP_SPEAKER_OFFSET), 0, 0.75, 0) vector.offset(vector.add(lzr_globals.MENU_SHIP_POS, lzr_globals.MENU_SHIP_SPEAKER_OFFSET), 0, 0.75, 0)
}, },
{
"graphics",
S("Graphics settings"),
vector.offset(vector.add(lzr_globals.MENU_SHIP_POS, lzr_globals.MENU_SHIP_TELEVISION_OFFSET), 0, 0.75, 0)
},
} }
for m=1, #markers do for m=1, #markers do
local world_pos = markers[m][3] local world_pos = markers[m][3]

View File

@ -240,62 +240,91 @@ lzr_ambience.register_on_ambience_change(function(state)
update_speaker_infotext(SPEAKER_POS) update_speaker_infotext(SPEAKER_POS)
end) end)
local graphics_settings_initial_state = { local graphics_settings_initial = {
opaque_lasers = minetest.settings:get_bool("lzr_opaque_lasers", false), opaque_lasers = minetest.settings:get_bool("lzr_opaque_lasers", false),
patterned_lasers = minetest.settings:get_bool("lzr_patterned_lasers", false), patterned_lasers = minetest.settings:get_bool("lzr_patterned_lasers", false),
} }
local graphics_settings_state = table.copy(graphics_settings_initial_state)
local graphics_settings_state = table.copy(graphics_settings_initial)
local open_graphics_settings = function(player) local open_graphics_settings = function(player)
local form = "formspec_version[4]size[10,10]".. local form = "formspec_version[4]size[9,5.1]"..
"checkbox[1,1;opaque_lasers;"..FS("Opaque lasers")..";"..tostring(graphics_settings_state.opaque_lasers).."]".. "checkbox[2.3,1;opaque_lasers;"..FS("Opaque lasers")..";"..tostring(graphics_settings_state.opaque_lasers).."]"
"checkbox[1,2;patterned_lasers;"..FS("Laser color patterns")..";"..tostring(graphics_settings_state.patterned_lasers).."]"..
"tooltip[patterned_lasers;"..FS("If activated, special patterns will be drawn on the lasers, one for each color. Helps to distinguish lasers without relying on color alone").."]".. form = form .. "box[1,0.5;1,1;#0000003f]"
"button_exit[1,4;3,1;apply;"..FS("Apply").."]".. if graphics_settings_state.opaque_lasers then
"button_exit[5,4;3,1;cancel;"..FS("Cancel").."]" form = form .. "image[1.1,0.6;0.8,0.8;lzr_menu_settings_opaque_lasers_on.png]"
else
form = form .. "image[1.1,0.6;0.8,0.8;lzr_menu_settings_opaque_lasers_off.png]"
end
form = form .. "tooltip[opaque_lasers;"..FS("If enabled, lasers arent translucent. Can improve performance.").."]"
if graphics_settings_state.opaque_lasers ~= graphics_settings_initial.opaque_lasers then
form = form .. "label[6,1;"..minetest.formspec_escape("(*)").."]" ..
"tooltip[5.92,0.8;0.4,0.4;"..S("This setting will take effect after a restart.").."]"
end
form = form .. "box[1,1.6;1,1;#0000003f]"
if graphics_settings_state.patterned_lasers then
form = form .. "image[1.1,1.7.1;0.8,0.8;lzr_menu_settings_patterned_lasers_on.png]"
else
form = form .. "image[1.1,1.7.1;0.8,0.8;lzr_menu_settings_patterned_lasers_off.png]"
end
form = form .. "checkbox[2.3,2.1;patterned_lasers;"..FS("Laser color patterns")..";"..tostring(graphics_settings_state.patterned_lasers).."]" ..
"tooltip[patterned_lasers;"..FS("Special patterns will appear on the lasers, one for each color. Helps to distinguish lasers without relying on color alone.").."]"
if graphics_settings_state.patterned_lasers ~= graphics_settings_initial.patterned_lasers then
form = form .. "label[6,2.1;"..minetest.formspec_escape("(*)").."]" ..
"tooltip[5.92,1.9;0.4,0.4;"..S("This setting will take effect after a restart.").."]"
end
form = form .. "button[1,3.5;3.1,0.8;apply;"..FS("Apply").."]"..
"button_exit[5,3.5;3.1,0.8;cancel;"..FS("Cancel").."]"
minetest.show_formspec(player:get_player_name(), "lzr_menu:graphics_settings", form) minetest.show_formspec(player:get_player_name(), "lzr_menu:graphics_settings", form)
end end
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
local pname = player:get_player_name()
if formname == "lzr_menu:graphics_settings" then if formname == "lzr_menu:graphics_settings" then
if fields.opaque_lasers == "true" then if fields.opaque_lasers == "true" then
graphics_settings_state.opaque_lasers = true graphics_settings_state.opaque_lasers = true
open_graphics_settings(player)
elseif fields.opaque_lasers == "false" then elseif fields.opaque_lasers == "false" then
graphics_settings_state.opaque_lasers = false graphics_settings_state.opaque_lasers = false
open_graphics_settings(player)
end end
if fields.patterned_lasers == "true" then if fields.patterned_lasers == "true" then
graphics_settings_state.patterned_lasers = true graphics_settings_state.patterned_lasers = true
open_graphics_settings(player)
elseif fields.patterned_lasers == "false" then elseif fields.patterned_lasers == "false" then
graphics_settings_state.patterned_lasers = false graphics_settings_state.patterned_lasers = false
open_graphics_settings(player)
end end
if fields.quit then if fields.apply then
if fields.apply then if graphics_settings_initial.opaque_lasers == graphics_settings_state.opaque_lasers and
if graphics_settings_initial_state.opaque_lasers == graphics_settings_state.opaque_lasers and graphics_settings_initial.patterned_lasers == graphics_settings_state.patterned_lasers then
graphics_settings_initial_state.patterned_lasers == graphics_settings_state.patterned_lasers then -- Nothing has changed: Nothing to do.
minetest.log("error", "INO") minetest.close_formspec(pname, "lzr_menu:graphics_settings")
-- Nothing has changed: Nothing to do. return
return
end
minetest.log("error", "IN")
minetest.settings:set_bool("lzr_opaque_lasers", graphics_settings_state.opaque_lasers)
minetest.settings:set_bool("lzr_patterned_lasers", graphics_settings_state.patterned_lasers)
local form = "formspec_version[4]size[6,3]"..
"label[1,1;"..FS("The game needs to be restarted for the new graphics settings to take effect.").."]"..
"button_exit[1,3;3,1;restart;"..FS("Restart now").."]"..
"button_exit[6,3;3,1;cancel;"..FS("Keep playing").."]"
minetest.show_formspec(player:get_player_name(), "lzr_menu:confirm_restart", form)
else
graphics_settings_state = {
opaque_lasers = tostring(minetest.settings:get_bool("lzr_opaque_lasers", false)),
patterned_lasers = tostring(minetest.settings:get_bool("lzr_patterned_lasers", false)),
}
end end
minetest.settings:set_bool("lzr_opaque_lasers", graphics_settings_state.opaque_lasers)
minetest.settings:set_bool("lzr_patterned_lasers", graphics_settings_state.patterned_lasers)
local form = "formspec_version[4]size[10,4]"..
"label[1,1;"..FS("The game needs to be restarted for the new graphics settings to take effect.").."]"..
"button_exit[1,2;3,0.8;restart;"..FS("Restart").."]"..
"button_exit[5,2;3,0.8;cancel;"..FS("Keep playing").."]"
minetest.show_formspec(pname, "lzr_menu:confirm_restart", form)
elseif fields.quit or fields.cancel then
graphics_settings_state = {
opaque_lasers = minetest.settings:get_bool("lzr_opaque_lasers", false),
patterned_lasers = minetest.settings:get_bool("lzr_patterned_lasers", false),
}
end end
elseif formname == "lzr_menu:confirm_restart" then elseif formname == "lzr_menu:confirm_restart" then
if fields.restart then if fields.restart then
minetest.disconnect_player(player, S("Start the game again for the settings to take effect.")) minetest.disconnect_player(pname, S("Youve quit the game. Start the game again for the settings to take effect."))
end end
end end
end) end)
@ -311,10 +340,10 @@ end
minetest.register_node("lzr_menu:television", { minetest.register_node("lzr_menu:television", {
description = S("Television"), description = S("Television"),
tiles = { tiles = {
"xdecor_television_left.png^[transformR90",
"xdecor_television_left.png^[transformR270",
"xdecor_television_left.png", "xdecor_television_left.png",
"xdecor_television_left.png", "xdecor_television_left.png^[transformR180",
"xdecor_television_left.png",
"xdecor_television_left.png",
"xdecor_television_back.png", "xdecor_television_back.png",
{ name = "xdecor_television_front_animated.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 1 } }, { name = "xdecor_television_front_animated.png", animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 1 } },
}, },

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B