Files
Paradise/code/modules/vote/vote_verb.dm
T
ac5add482f [READY] TGUI Input Collection (#23891)
* List Input refresh

* Modal Alerts

* Text Input

* Number Input

* Split Button

* Renaming

* Alert converts

* Text Input Conversion (Part 1)

And TextArea Autofocus + maxLength

* Text Input Conversion (Part 2)

* AAAAAAAAAAAAAAAAAAAA

* I'm FUCKED

* @GDNgit review changes

* "'" fixes

* Revert TGUI Alert from admin delete

* NumberInput Window size

* CRASH if empty list

* Update code/modules/tgui/tgui_input/list_input.dm

* TGUI Rebuild

* TGUI Rebuild

* Update code/modules/paperwork/faxmachine.dm

* _char

* compile

* Rebuild

---------

Co-authored-by: Aylong <69762909+Aylong220@users.noreply.github.com>
Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com>
2024-02-19 11:55:01 +00:00

62 lines
1.7 KiB
Plaintext

/client/verb/vote()
set category = "OOC"
set name = "Vote"
if(SSvote.active_vote)
SSvote.active_vote.ui_interact(usr)
else
to_chat(usr, "There is no active vote")
/client/proc/start_vote()
set category = "Admin"
set name = "Start Vote"
set desc = "Start a vote on the server"
if(!check_rights(R_ADMIN))
return
if(SSvote.active_vote)
to_chat(usr, "A vote is already in progress")
return
// Ask admins which type of vote they want to start
var/vote_types = subtypesof(/datum/vote)
vote_types |= "\[CUSTOM]"
// This needs to be a map to instance it properly. I do hate it as well, dont worry.
var/list/votemap = list()
for(var/vtype in vote_types)
votemap["[vtype]"] = vtype
var/choice = tgui_input_list(usr, "Select a vote type", "Vote", vote_types)
if(choice == null)
return
if(choice != "\[CUSTOM]")
// Not custom, figure it out
var/datum/vote/votetype = votemap["[choice]"]
SSvote.start_vote(new votetype(usr.ckey))
return
// Its custom, lets ask
var/question = tgui_input_text(usr, "What is the vote for?", "Create Vote", encode = FALSE)
if(!question)
return
var/list/choices = list()
for(var/i in 1 to 10)
var/option = tgui_input_text(usr, "Please enter an option or hit cancel to finish", "Create Vote", encode = FALSE)
if(!option || !usr.client)
break
choices |= option
var/c2 = tgui_alert(usr, "Show counts while vote is happening?", "Counts", list("Yes", "No"))
var/c3 = input(usr, "Select a result calculation type", "Vote", VOTE_RESULT_TYPE_MAJORITY) as anything in list(VOTE_RESULT_TYPE_MAJORITY)
var/datum/vote/V = new /datum/vote(usr.ckey, question, choices, TRUE)
V.show_counts = (c2 == "Yes")
V.vote_result_type = c3
SSvote.start_vote(V)