From 9f9741cb44cc3f8ef5dfb4287871e07491527b56 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 3 May 2021 19:06:57 +0200 Subject: [PATCH] added o_sort for options edit dialog --- functions.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/functions.lua b/functions.lua index f7e1571..06f94fa 100644 --- a/functions.lua +++ b/functions.lua @@ -1005,15 +1005,23 @@ local function get_fs_edit_option_dialog(player, n_id, d_id, o_id) "button[2.4,17;2.0,0.9;edit_option_add;Add]".. "tooltip[edit_option_add;Add a new option/answer to this dialog.]".. -- button: prev/next - "button[8.6,17;2.0,0.9;edit_option_prev;Prev]".. + "button[7.4,17;2.0,0.9;edit_option_prev;Prev]".. "tooltip[edit_option_prev;Go to previous option/answer (according to o_sort).]".. - "button[10.8,17;2.0,0.9;edit_option_next;Next]".. + "button[12.0,17;2.0,0.9;edit_option_next;Next]".. "tooltip[edit_option_next;Go to next option/answer (according to o_sort).]".. -- button: go back to dialog (repeated from top of the page) "button[15.8,17;5.0,0.9;show_current_dialog;Back to dialog ".. minetest.formspec_escape(d_id).."]".. "tooltip[show_current_dialog;Go back to dialog ".. - minetest.formspec_escape(d_id).." and continue editing that dialog.]" + minetest.formspec_escape(d_id).." and continue editing that dialog.]".. + -- allow to enter o_sort + "label[9.6,17.5;Sort:]".. + "field[10.6,17;1.0,0.9;edit_option_o_sort;;".. + minetest.formspec_escape(d_option.o_sort).."]".. + "tooltip[edit_option_o_sort;o_sort: The lower the number, the higher up in the ".. + "list this option goes\nNegative values are ignored;#FFFFFF;#000000]".. + -- hidden field containing the value of o_id + "field[40,40;0.1,0.1;o_id;;"..minetest.formspec_escape(o_id).."]" return formspec end @@ -2102,7 +2110,12 @@ minetest.register_on_player_receive_fields( minetest.show_formspec(pname, "yl_speak_up:talk", get_fs_talkdialog(player, n_id, d_id)) return end + --minetest.chat_send_player(pname, "Fields: "..minetest.serialize(fields)) + + -- if ESC is pressed or anything else unpredicted happens: go back to the main dialog edit window + -- reason: don't loose any unsaved changes to the dialog + minetest.show_formspec(pname, "yl_speak_up:talk", get_fs_talkdialog(player, n_id, d_id)) end )