editable messages

This commit is contained in:
whosit 2025-03-09 02:10:28 +03:00
parent 1a0435105a
commit 00b63b6636

View File

@ -49,12 +49,12 @@ function show_vote_welcome()
{
{command = "clear"},
{command = "set",
width = 6,
height = 2,
width = 10.5,
height = 7,
real_coordinates = true,
},
{command = "addlabel", label = "Welcome!", X = 0.5, Y = 1.0},
{command = "addbutton", name = "start", label = "Start Vote", X = 2.6, Y = 0.5, W = 3, H = 1},
{command = "addtextarea", name = "", default = mem.message_welcome_vote, X = 1.8, Y = 1.4, W = 7, H = 2.6},
{command = "addbutton", name = "start", label = "Begin voting", X = 3.1, Y = 4.6, W = 4.3, H = 1.7},
}
)
else
@ -110,19 +110,20 @@ function show_admin_welcome()
{command = "addlabel", label = "Admin only!", X = 4.4, Y = 1.3},
{command = "addlabel",
label = "Submissions: " .. (mem.submit_active and "accepting" or "stopped"),
X = 3.4, Y = 2.0},
X = 0.6, Y = 2.0},
{command = "addlabel",
label = "Voting: " .. (mem.vote_active and "active" or "stopped"),
X = 3.4, Y = 2.3},
{command = "addbutton", name = "edit_entries", label = "Edit entries", X = 3.7, Y = 3.3, W = 3, H = 0.8},
{command = "addbutton", name = "view_results", label = "View results", X = 3.7, Y = 4.7, W = 3, H = 0.8},
X = 0.6, Y = 2.3},
{command = "addbutton", name = "edit_entries", label = "Edit entries", X = 3.7, Y = 2.3, W = 3, H = 0.8},
{command = "addbutton", name = "view_results", label = "View results", X = 3.7, Y = 3.7, W = 3, H = 0.8},
{command = "addbutton", name = "toggle_submit",
label = toggle_submit_label,
X = 3.7, Y = 6.1, W = 3, H = 0.8},
X = 3.7, Y = 5.1, W = 3, H = 0.8},
{command = "addbutton", name = "toggle_vote",
label = toggle_vote_label,
X = 3.7, Y = 7.5, W = 3, H = 0.8},
{command = "addbutton", name = "danger_zone", label = "Danger zone", X = 3.7, Y = 8.9, W = 3, H = 0.8},
X = 3.7, Y = 6.5, W = 3, H = 0.8},
{command = "addbutton", name = "edit_messages", label = "Edit messages", X = 3.7, Y = 7.9, W = 3, H = 0.8},
{command = "addbutton", name = "danger_zone", label = "Danger zone", X = 3.7, Y = 9.3, W = 3, H = 0.8},
}
)
@ -259,6 +260,28 @@ function show_admin_danger()
end
function show_admin_messages()
digiline_send("admin",
{
{command = "clear"},
{command = "set",
width = 16,
height = 12,
real_coordinates = true,
locked = true, -- does not prevent someone from looking at it :(
},
{command = "addlabel", label = "Enter information about vote", X = 1, Y = 0.9},
{command = "addbutton", name = "messages_back", label = "Back", X = 12.7, Y = 0.3, W = 3, H = 1},
{command = "addtextarea", name = "message_welcome_vote", label = "Voting welcome", default = mem.message_welcome_vote, X = 0.5, Y = 1.5, W = 15.0, H = 2.5},
{command = "addtextarea", name = "message_welcome_submission", label = "Submission welcome", default = mem.message_welcome_submission, X = 0.5, Y = 4.5, W = 15.0, H = 2.5},
{command = "addtextarea", name = "message_submission_instructions", label = "Submission instructions", default = mem.message_submission_instructions, X = 0.5, Y = 7.5, W = 15.0, H = 2.5},
{command = "addbutton", name = "messages_ok", label = "OK", X = 12.6, Y = 10.7, W = 3, H = 0.8},
}
)
end
function show_vote_ballot(username)
local c =
{
@ -318,12 +341,12 @@ function show_submit_welcome()
{
{command = "clear"},
{command = "set",
width = 9,
height = 2,
width = 10.5,
height = 7,
real_coordinates = true,
},
{command = "addlabel", label = "Welcome to entry submission!", X = 0.5, Y = 1.0},
{command = "addbutton", name = "start_submission", label = "Enter submission", X = 4.6, Y = 0.5, W = 3, H = 1},
{command = "addtextarea", name = "", default = mem.message_welcome_submission, X = 1.8, Y = 1.4, W = 7, H = 2.6},
{command = "addbutton", name = "start_submission", label = "Enter submission", X = 3.1, Y = 4.6, W = 4.3, H = 1.7},
}
)
else
@ -356,9 +379,9 @@ function show_submit(username)
{command = "add", element = "box", X = 0.6, Y = 10.5, W = 17.0, H = 1.2, color = "#00FF00"},
{command = "addtextarea", name = "", label = "", default = "Please fill the fields and press 'submit'", X = 0.7, Y = 10.55, W = 13.5, H = 1.05},
{command = "addlabel", label = string.format("Welcome %s!", username), X = 0.9, Y = 0.7},
{command = "addtextarea", name = "", label = "", default = "Please enter the coords of your build and describe how to get there (what is the closest city, means of transporation, etc).", X = 0.9, Y = 1.8, W = 16.3, H = 2},
{command = "addfield", name = "submission_title", label = "Name of submission:", default = submission.title or "", X = 0.7, Y = 3, W = 10, H = 0.8},
{command = "addfield", name = "submission_coords", label = "Coordinates:", default = submission.coords or "", X = 0.7, Y = 4.5, W = 5, H = 0.8},
{command = "addtextarea", name = "", label = "", default = mem.message_submission_instructions, X = 0.9, Y = 1.8, W = 16.3, H = 2},
{command = "addfield", name = "submission_title", label = "Name of submission:", default = submission.title or "", X = 0.7, Y = 3.5, W = 10, H = 0.8},
{command = "addfield", name = "submission_coords", label = "Coordinates:", default = submission.coords or "", X = 0.7, Y = 5.0, W = 5, H = 0.8},
{command = "addtextarea", name = "submission_description", label = "Please enter your submission:", default = submission.description or "", X = 0.7, Y = 6.8, W = 16.8, H = 3.5},
{command = "addbutton", name = "submission_submit", label = mem.entries_by_user[username] and "Update" or "Submit", X = 14.5, Y = 10.7, W = 3, H = 0.8},
{command = "addbutton", name = "submission_back", label = "Back", X = 14.5, Y = 0.7, W = 3, H = 0.8},
@ -388,6 +411,11 @@ if event.type == "program" then
mem.vote_active = true
mem.submit_active = true
mem.submitter_name = nil
mem.message_welcome_submission = mem.message_welcome_submission or "Welcome to the entry submission for BOTM 2025 decebruary!"
mem.message_welcome_vote = mem.message_welcome_vote or "Welcome! Please vote for BOTM 2025 decebruary submissions!"
mem.message_submission_instructions = mem.message_submission_instructions or "Please enter the coords of your build and describe how to get there (what is the closest city, means of transporation, etc)."
elseif event.type == "digiline" then
if event.channel == "vote" then
if not mem.vote_active then
@ -524,7 +552,10 @@ elseif event.type == "digiline" then
mem.submit_active = not mem.submit_active
show_admin_welcome()
show_submit_welcome()
elseif event.msg.danger_zone then
elseif event.msg.edit_messages then
mem.state_admin = "messages"
show_admin_messages()
elseif event.msg.danger_zone then
mem.state_admin = "danger_zone"
show_admin_danger()
end
@ -607,6 +638,19 @@ elseif event.type == "digiline" then
mem.sort_type = 4
show_admin_results()
end
elseif mem.state_admin == "messages" then
if event.msg.messages_back then
mem.state_admin = "welcome"
show_admin_welcome()
elseif event.msg.messages_ok then
mem.message_welcome_vote = event.msg.message_welcome_vote
mem.message_welcome_submission = event.msg.message_welcome_submission
mem.message_submission_instructions = event.msg.message_submission_instructions
show_admin_welcome()
show_vote_welcome()
show_submit_welcome()
mem.state_admin = "welcome"
end
elseif mem.state_admin == "danger_zone" then
if event.msg.danger_back then
mem.state_admin = "welcome"
@ -633,6 +677,11 @@ elseif event.type == "digiline" then
mem.vote_active = true
mem.submit_active = true
mem.submitter_name = nil
mem.message_welcome_submission = "Welcome to the entry submission for BOTM 2025 decebruary!"
mem.message_welcome_vote = "Welcome! Please vote for BOTM 2025 decebruary submissions!"
mem.message_submission_instructions = "Please enter the coords of your build and describe how to get there (what is the closest city, means of transporation, etc)."
end
end
end