hopefully don't draw wrong stuff in wrong places

This commit is contained in:
whosit 2025-03-23 17:26:53 +03:00
parent f58553895a
commit e3df852809

View File

@ -13,6 +13,8 @@ local function show_vote_welcome()
-- window shown before player can see the ballot
-- by making them click the button, we can know their name
mem.state_vote = "welcome"
if mem.vote_active then
digiline_send(
"vote",
@ -263,6 +265,7 @@ end
local function show_vote_ballot(username)
mem.state_vote = "ballot"
local total_pages = math.ceil(#mem.ballot_entries / ENTRIES_PER_PAGE)
local c1 =
{
@ -311,6 +314,7 @@ local function show_vote_ballot(username)
mem.draw_ballot_username = username
mem.draw_ballot_i = 1
mem.draw_ballot_page = page
mem.draw_ballot_version = mem.db_version
interrupt(0.3, "draw_ballot")
end
@ -399,12 +403,15 @@ if event.type == "program" then
mem.admin_entries_idx = nil -- stores list selection for "edit" screen
mem.votes = mem.votes or {} -- user votes
mem.state_admin = "welcome" -- which admin window is currently displayed
mem.state_vote = "welcome"
mem.sort_type = "sum" -- what sort to use ("sum" or 1,2,3,4)
mem.ballot_page = 0 -- current ballot page
mem.vote_active = true
mem.submit_active = true
mem.submitter_name = nil
mem.db_version = mem.db_version or 0
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)."
@ -586,6 +593,7 @@ elseif event.type == "digiline" then
end
show_admin_edit()
end
mem.db_version = mem.db_version + 1
elseif event.msg.delete_entry then
-- removing selected entry
-- TODO either re-index existing votes, or even wipe all of them?!
@ -603,6 +611,7 @@ elseif event.type == "digiline" then
mem.admin_entries_idx = math.min(mem.admin_entries_idx, #mem.entries)
show_admin_edit()
end
mem.db_version = mem.db_version + 1
elseif event.msg.edit_accept then
local entry = mem.entries[mem.admin_entries_idx]
if entry then
@ -618,6 +627,7 @@ elseif event.type == "digiline" then
end
show_admin_edit()
end
mem.db_version = mem.db_version + 1
elseif event.msg.edit_back then
mem.state_admin = "welcome"
show_admin_welcome()
@ -695,8 +705,16 @@ elseif event.type == "digiline" then
end
elseif event.type == "interrupt" then
if event.iid == "draw_ballot" then
-- TODO if clicker is different, restart? abort?
if mem.state_vote ~= "ballot" then
goto done
end
-- TODO if clicker is different, restart? abort? should not happen.
-- TODO if "database version" changed, restart? abort?
if mem.db_version ~= mem.draw_ballot_version then
-- ballot possibly has changed, just abort
show_vote_welcome()
goto done
end
local username = mem.draw_ballot_username
local i = mem.draw_ballot_i
local page = mem.draw_ballot_page