From 9c9c611285bc3b81e55a2b21ea6bc55da0543846 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Thu, 9 Jul 2020 23:34:35 -0700 Subject: [PATCH 1/3] ok --- code/controllers/subsystem/vote.dm | 52 +++++++++++++++++++++++++++++- code/modules/mob/mob.dm | 2 ++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 97a5ec2c2b..c8a48ef188 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -15,6 +15,8 @@ SUBSYSTEM_DEF(vote) var/vote_system = PLURALITY_VOTING var/question = null var/list/choices = list() + /// List of choice = object for statclick objects for statpanel voting + var/list/choice_statclicks = list() var/list/scores = list() var/list/choice_descs = list() // optional descriptions var/list/voted = list() @@ -47,7 +49,32 @@ SUBSYSTEM_DEF(vote) client_popup.open(0) next_pop = world.time+VOTE_COOLDOWN - +/** + * Renders a statpanel. Directly uses statpanel/stat calls since this is called from base of mob/Stat(). + */ +/datum/controller/subsystem/vote/proc/render_statpanel(mob/M) + if(!mode) // check if vote is running + return + if(!statpanel("Vote")) // don't bother if they're not focused on this panel + return + var/static/list/supported = list(PLURALITY_VOTING, APPROVAL_VOTING) + if(!(vote_system in supported)) + stat("Vote Manually!", "The current vote system is not supported by statpanel rendering. Please vote manually by opening the vote popup using the action button or chat link.") + return + stat("Time Left:", "[round(end_time - world.time)] seconds") + stat("Question:", question) + stat(null, null) + stat("Choices:", null) + stat(null, null) + for(var/i in 1 to choice_statclicks.len) + var/choice = choice_statclicks[i] + var/ivotedforthis = FALSE + switch(vote_system) + if(APPROVAL_VOTING) + ivotedforthis = voted[usr.ckey] && (i in voted[usr.ckey]) + if(PLURALITY_VOTING) + ivotedforthis = voted[usr.ckey] == i + stat(ivotedforthis? "\[X\]" : "\[ \]", choice_statclicks[choice]) /datum/controller/subsystem/vote/proc/reset() initiator = null @@ -59,9 +86,26 @@ SUBSYSTEM_DEF(vote) voted.Cut() voting.Cut() scores.Cut() + cleanup_statclicks() display_votes = initial(display_votes) //CIT CHANGE - obfuscated votes remove_action_buttons() +/datum/controller/subsystem/vote/proc/cleanup_statclicks() + for(var/choice in choice_statclicks) + qdel(choice_statclicks[choice]) + choice_statclicks = list() + +/obj/effect/statclick/vote + name = "ERROR" + var/choice + +/obj/effect/statclick/vote/Click() + SSvote.submit_vote(choice) + +/obj/effect/statclick/vote/New(loc, choice, name) + src.choice = choice + src.name = name + /datum/controller/subsystem/vote/proc/get_result() //get the highest number of votes var/greatest_votes = 0 @@ -536,6 +580,12 @@ SUBSYSTEM_DEF(vote) vp = CONFIG_GET(number/vote_period) to_chat(world, "\n[text]\nType vote or click here to place your votes.\nYou have [DisplayTimeText(vp)] to vote.") end_time = started_time+vp + // generate statclick list + cleanup_statclicks() + for(var/i in 1 to choices.len) + var/choice = choices[i] + choice_statclicks[choice] = new /obj/effect/statclick/vote(null, i, choice) + // for(var/c in GLOB.clients) SEND_SOUND(c, sound('sound/misc/server-ready.ogg')) var/client/C = c diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index fd9afc91cd..d81ddec271 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -539,6 +539,8 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0) /mob/Stat() ..() + SSvote?.render_statpanel(src) + //This is only called from client/Stat(), let's assume client exists. if(statpanel("Status")) From 214b95445e47bcf8ad0ee1d22e64b07605464077 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Thu, 9 Jul 2020 23:59:51 -0700 Subject: [PATCH 2/3] status panel --- code/controllers/subsystem/vote.dm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index c8a48ef188..390d42dcb4 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -55,14 +55,15 @@ SUBSYSTEM_DEF(vote) /datum/controller/subsystem/vote/proc/render_statpanel(mob/M) if(!mode) // check if vote is running return - if(!statpanel("Vote")) // don't bother if they're not focused on this panel + if(!statpanel("Status")) // don't bother if they're not focused on this panel return var/static/list/supported = list(PLURALITY_VOTING, APPROVAL_VOTING) + stat(null, null) + stat("Vote active!", "There is currently a vote running. Question: [question]") if(!(vote_system in supported)) - stat("Vote Manually!", "The current vote system is not supported by statpanel rendering. Please vote manually by opening the vote popup using the action button or chat link.") + stat("", "The current vote system is not supported by statpanel rendering. Please vote manually by opening the vote popup using the action button or chat link.") return stat("Time Left:", "[round(end_time - world.time)] seconds") - stat("Question:", question) stat(null, null) stat("Choices:", null) stat(null, null) From 630d65dfec72a32419d5f2de593cb7b25b9e60a9 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Fri, 10 Jul 2020 00:08:53 -0700 Subject: [PATCH 3/3] done --- code/controllers/subsystem/vote.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 390d42dcb4..a93aff7d2b 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -58,7 +58,6 @@ SUBSYSTEM_DEF(vote) if(!statpanel("Status")) // don't bother if they're not focused on this panel return var/static/list/supported = list(PLURALITY_VOTING, APPROVAL_VOTING) - stat(null, null) stat("Vote active!", "There is currently a vote running. Question: [question]") if(!(vote_system in supported)) stat("", "The current vote system is not supported by statpanel rendering. Please vote manually by opening the vote popup using the action button or chat link.") @@ -76,6 +75,7 @@ SUBSYSTEM_DEF(vote) if(PLURALITY_VOTING) ivotedforthis = voted[usr.ckey] == i stat(ivotedforthis? "\[X\]" : "\[ \]", choice_statclicks[choice]) + stat(null, null) /datum/controller/subsystem/vote/proc/reset() initiator = null