Redesign sfinv page using FS version 3
parent
4fb5fee254
commit
37b62380f1
87
gui.lua
87
gui.lua
|
@ -39,8 +39,10 @@ sfinv.register_page("classroom:edu", {
|
|||
return "label[0,0;" .. FS"Access denied" .. "]"
|
||||
end
|
||||
|
||||
|
||||
local fs = {
|
||||
"tablecolumns[color;text"
|
||||
"container[0.375,1.1]",
|
||||
"tablecolumns[color;text",
|
||||
}
|
||||
|
||||
context.select_toggle = context.select_toggle or "all"
|
||||
|
@ -51,10 +53,10 @@ sfinv.register_page("classroom:edu", {
|
|||
fs[#fs + 1] = ",padding=2"
|
||||
end
|
||||
end
|
||||
|
||||
fs[#fs + 1] = "]"
|
||||
|
||||
do
|
||||
fs[#fs + 1] = "tabheader[0.3,1.1;group;"
|
||||
fs[#fs + 1] = "tabheader[0,0;5.375,0.8;group;"
|
||||
fs[#fs + 1] = FS"All"
|
||||
local selected_group_idx = 1
|
||||
local i = 2
|
||||
|
@ -68,9 +70,9 @@ sfinv.register_page("classroom:edu", {
|
|||
end
|
||||
fs[#fs + 1] = ";"
|
||||
fs[#fs + 1] = tostring(selected_group_idx)
|
||||
fs[#fs + 1] = "]"
|
||||
fs[#fs + 1] = ";false;true]"
|
||||
end
|
||||
fs[#fs + 1] = "table[0,0.8;5,8;students;,Name"
|
||||
fs[#fs + 1] = "table[0,0;5.375,9.375;students;,Name"
|
||||
for _, col in pairs(infos) do
|
||||
fs[#fs + 1] = ",," .. col.title
|
||||
end
|
||||
|
@ -105,87 +107,93 @@ sfinv.register_page("classroom:edu", {
|
|||
fs[#fs + 1] = selection_id
|
||||
fs[#fs + 1] = "]"
|
||||
|
||||
fs[#fs + 1] = "button[5.25,-0.2;1.4,1;new_group;"
|
||||
fs[#fs + 1] = "container_end[]"
|
||||
|
||||
fs[#fs + 1] = "container[6.125,0.375]"
|
||||
|
||||
fs[#fs + 1] = "button[0,0;1.4,0.8;new_group;"
|
||||
fs[#fs + 1] = FS"New Group"
|
||||
fs[#fs + 1] = "]"
|
||||
if context.groupname then
|
||||
fs[#fs + 1] = "button[6.65,-0.2;1.4,1;edit_group;"
|
||||
fs[#fs + 1] = "button[1.6,0;1.4,0.8;edit_group;"
|
||||
fs[#fs + 1] = FS"Edit Group"
|
||||
fs[#fs + 1] = "]"
|
||||
else
|
||||
fs[#fs + 1] = "box[6.65,-0.1;1.2,0.7;#222]"
|
||||
fs[#fs + 1] = "label[6.8,0.05;"
|
||||
fs[#fs + 1] = "box[1.6,0;1.5,0.8;#222]"
|
||||
fs[#fs + 1] = "label[1.8,0.4;"
|
||||
fs[#fs + 1] = FS"Edit Group"
|
||||
fs[#fs + 1] = "]"
|
||||
fs[#fs + 1] = "tooltip[6.65,-0.2;1.4,1;"
|
||||
fs[#fs + 1] = "tooltip[1.6,0;1.4,1;"
|
||||
fs[#fs + 1] = FS"Please select a group first"
|
||||
fs[#fs + 1] = "]"
|
||||
end
|
||||
|
||||
fs[#fs + 1] = "container[5.25,1.1]"
|
||||
fs[#fs + 1] = "box[-0.25,-0.3;3.1,1.15;#666]"
|
||||
fs[#fs + 1] = "label[0,-0.3;"
|
||||
fs[#fs + 1] = "container[0,1.5]"
|
||||
fs[#fs + 1] = "label[0,-0.2;"
|
||||
fs[#fs + 1] = FS"Run actions on:"
|
||||
fs[#fs + 1] = "]"
|
||||
if context.select_toggle == "all" then
|
||||
fs[#fs + 1] = "box[0,0.1;0.8,0.7;#53ac56]"
|
||||
fs[#fs + 1] = "label[0.3,0.25;"
|
||||
fs[#fs + 1] = "box[0,0;1,0.8;#53ac56]"
|
||||
fs[#fs + 1] = "label[0.3,0.5;"
|
||||
fs[#fs + 1] = FS"All"
|
||||
fs[#fs + 1] = "]"
|
||||
else
|
||||
fs[#fs + 1] = "button[0,0;1,1;select_all;"
|
||||
fs[#fs + 1] = "button[0,0;1,0.8;select_all;"
|
||||
fs[#fs + 1] = FS"All"
|
||||
fs[#fs + 1] = "]"
|
||||
end
|
||||
if not context.groupname then
|
||||
fs[#fs + 1] = "box[0.9,0.1;0.8,0.7;#333]"
|
||||
fs[#fs + 1] = "label[1.05,0.25;"
|
||||
fs[#fs + 1] = "box[1.1,0;1,0.8;#333]"
|
||||
fs[#fs + 1] = "label[1.05,0.5;"
|
||||
fs[#fs + 1] = FS"Group"
|
||||
fs[#fs + 1] = "]"
|
||||
fs[#fs + 1] = "tooltip[0.9,0;1,1;"
|
||||
fs[#fs + 1] = "tooltip[0.9,0;1,0.8;"
|
||||
fs[#fs + 1] = FS"Please select a group first"
|
||||
fs[#fs + 1] = "]"
|
||||
elseif context.select_toggle == "group" then
|
||||
fs[#fs + 1] = "box[0.9,0.1;0.8,0.7;#53ac56]"
|
||||
fs[#fs + 1] = "label[1.05,0.25;"
|
||||
fs[#fs + 1] = "box[1.1,0;1,0.8;#53ac56]"
|
||||
fs[#fs + 1] = "label[1.05,0.5;"
|
||||
fs[#fs + 1] = FS"Group"
|
||||
fs[#fs + 1] = "]"
|
||||
else
|
||||
fs[#fs + 1] = "button[0.9,0;1,1;select_group;"
|
||||
fs[#fs + 1] = "button[1.1,0;1,0.8;select_group;"
|
||||
fs[#fs + 1] = FS"Group"
|
||||
fs[#fs + 1] = "]"
|
||||
end
|
||||
if not context.selected_student then
|
||||
fs[#fs + 1] = "box[1.8,0.1;0.8,0.7;#333]"
|
||||
fs[#fs + 1] = "label[1.85,0.25;"
|
||||
fs[#fs + 1] = "box[2.2,0;1,0.8;#333]"
|
||||
fs[#fs + 1] = "label[2.45,0.5;"
|
||||
fs[#fs + 1] = FS"Selected"
|
||||
fs[#fs + 1] = "]"
|
||||
fs[#fs + 1] = "tooltip[1.8,0;1,1;"
|
||||
fs[#fs + 1] = "tooltip[2.2,0;1,0.8;"
|
||||
fs[#fs + 1] = FS"Please select a student first"
|
||||
fs[#fs + 1] = "]"
|
||||
elseif context.select_toggle == "selected" then
|
||||
fs[#fs + 1] = "box[1.8,0.1;0.8,0.7;#53ac56]"
|
||||
fs[#fs + 1] = "label[1.85,0.25;"
|
||||
fs[#fs + 1] = "box[2.2,0;1,0.8;#53ac56]"
|
||||
fs[#fs + 1] = "label[2.45,0.5;"
|
||||
fs[#fs + 1] = FS"Selected"
|
||||
fs[#fs + 1] = "]"
|
||||
else
|
||||
fs[#fs + 1] = "button[1.8,0;1,1;select_selected;"
|
||||
fs[#fs + 1] = "button[2.2,0;1,0.8;select_selected;"
|
||||
fs[#fs + 1] = FS"Selected"
|
||||
fs[#fs + 1] = "]"
|
||||
end
|
||||
|
||||
fs[#fs + 1] = "label[0,0.9;"
|
||||
fs[#fs + 1] = "label[0,1.4;"
|
||||
fs[#fs + 1] = FS"Actions:"
|
||||
fs[#fs + 1] = "]"
|
||||
|
||||
local x = 0
|
||||
local y = 1.2
|
||||
local y = 1.7
|
||||
local spacing = 0.1
|
||||
local w = (4 - spacing) / 2
|
||||
local h = 0.8
|
||||
for _, action in pairs(classroom.get_actions()) do
|
||||
fs[#fs + 1] = "button["
|
||||
fs[#fs + 1] = tostring(x)
|
||||
fs[#fs + 1] = ","
|
||||
fs[#fs + 1] = tostring(y)
|
||||
fs[#fs + 1] = ";1,1;action_"
|
||||
fs[#fs + 1] = ";" .. w .. "," .. h .. ";action_"
|
||||
fs[#fs + 1] = action.name
|
||||
fs[#fs + 1] = ";"
|
||||
fs[#fs + 1] = minetest.formspec_escape(action.title)
|
||||
|
@ -197,22 +205,22 @@ sfinv.register_page("classroom:edu", {
|
|||
fs[#fs + 1] = minetest.formspec_escape(action.description)
|
||||
fs[#fs + 1] = "]"
|
||||
|
||||
if x < 1.5 then
|
||||
x = x + 0.9
|
||||
else
|
||||
x = x + w + spacing
|
||||
if x > 4 - w then
|
||||
x = 0
|
||||
y = y + 0.8
|
||||
y = y + h + spacing
|
||||
end
|
||||
end
|
||||
|
||||
y = y + 0.25
|
||||
y = y + 0.4
|
||||
|
||||
context.selected_student = "student1"
|
||||
if context.selected_student then
|
||||
fs[#fs + 1] = "container[0,"
|
||||
fs[#fs + 1] = tostring(y)
|
||||
fs[#fs + 1] = "]"
|
||||
|
||||
fs[#fs + 1] = "label[0,-0.1;"
|
||||
fs[#fs + 1] = "label[0,0;"
|
||||
fs[#fs + 1] = FS("Selected user: @1", context.selected_student)
|
||||
fs[#fs + 1] = "]"
|
||||
fs[#fs + 1] = "button[0,0.3;1.5,1;teleport;"
|
||||
|
@ -222,9 +230,12 @@ sfinv.register_page("classroom:edu", {
|
|||
fs[#fs + 1] = "container_end[]"
|
||||
end
|
||||
|
||||
fs[#fs + 1] = "container_end[]"
|
||||
fs[#fs + 1] = "container_end[]"
|
||||
|
||||
return sfinv.make_formspec(player, context, table.concat(fs, ""), false)
|
||||
-- (8-1)*5/4 + 0.375*2 + 1 = 10.5
|
||||
-- (8.6-1)*5/4 + 0.375*2 + 1 = 11.25
|
||||
return sfinv.make_formspec(player, context, table.concat(fs, ""), false, "formspec_version[3]size[10.5,10.85]")
|
||||
end,
|
||||
on_player_receive_fields = function(self, player, context, fields)
|
||||
if not self:check_perm(player) then
|
||||
|
|
3
init.lua
3
init.lua
|
@ -17,3 +17,6 @@ minetest.register_privilege("teacher", {
|
|||
classroom.get_connected_players = minetest.get_connected_players
|
||||
classroom.get_player_by_name = minetest.get_player_by_name
|
||||
classroom.check_player_privs = minetest.check_player_privs
|
||||
|
||||
-- Required MT version
|
||||
assert(minetest.features.formspec_version_element, "Minetest 5.1 or later is required.")
|
||||
|
|
|
@ -25,12 +25,12 @@ start_server() {
|
|||
|
||||
start_client() {
|
||||
echo "Starting client $1"
|
||||
$MT --address "127.0.0.1" --port 30000 --name "$1" --password "pass" --go &
|
||||
$MT --address "127.0.0.1" --port 30000 --name "$1" --password "" --go &
|
||||
}
|
||||
|
||||
start_headless_client() {
|
||||
echo "Starting headless client $1"
|
||||
xvfb-run $MT --address "127.0.0.1" --name $1 --password "pass" --config "$conf" --go &
|
||||
xvfb-run $MT --address "127.0.0.1" --name $1 --password "" --config "$conf" --go &
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue