mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-14 02:43:16 +00:00
* Verbose Vote Initiation Feedback Tooltippery (#69763) * Verbose Vote Initiation Feedback Tooltippery Hey there, So basically, the old implementation had it such that when a vote was disabled and you tried to trigger it, you could get a very nice message in your chat explaining why you could not trigger that vote in that moment. HOWEVER, there's a current fatal flaw in this logic: You can't ever get that to_chat reason as to _why_ this vote is disabled since you can't click the button. I don't know if this ever worked, which is sad, because we had a lot of these nice messages that one would never see. So, let's leverage the power of TGUI and add messages. The messages are applied per-datum singleton, and are a generic explanation of what the vote does when there is no specific reason assigned to it when the can_be_initiated() proc runs. If it can not be initiated, we change the message to reflect exactly why the player can not initiate the vote. It ends up looking something like this: In order for this to work well for the restart vote and to lessen the amount of copy-pasting I might have to do, I created a new proc that checks to see if a valid admin is online, and uses that for both updating the message and restarting the server if the vote clears. * fixes messages not resetting * removes misleading section the admin can always restart the server if they wish * Verbose Vote Initiation Feedback Tooltippery Co-authored-by: san7890 <the@san7890.com>
55 lines
1.5 KiB
Plaintext
55 lines
1.5 KiB
Plaintext
/// The max amount of options someone can have in a custom vote.
|
|
#define MAX_CUSTOM_VOTE_OPTIONS 10
|
|
|
|
/datum/vote/custom_vote
|
|
name = "Custom"
|
|
message = "Click here to start a custom vote."
|
|
|
|
// Custom votes ares always accessible.
|
|
/datum/vote/custom_vote/is_accessible_vote()
|
|
return TRUE
|
|
|
|
/datum/vote/custom_vote/reset()
|
|
default_choices = null
|
|
override_question = null
|
|
return ..()
|
|
|
|
/datum/vote/custom_vote/can_be_initiated(mob/by_who, forced = FALSE)
|
|
. = ..()
|
|
if(!.)
|
|
return FALSE
|
|
|
|
// Custom votes can only be created if they're forced to be made.
|
|
// (Either an admin makes it, or otherwise.)
|
|
return forced
|
|
|
|
/datum/vote/custom_vote/create_vote(mob/vote_creator)
|
|
override_question = tgui_input_text(vote_creator, "What is the vote for?", "Custom Vote")
|
|
if(!override_question)
|
|
return FALSE
|
|
|
|
default_choices = list()
|
|
for(var/i in 1 to MAX_CUSTOM_VOTE_OPTIONS)
|
|
var/option = tgui_input_text(vote_creator, "Please enter an option, or hit cancel to finish. [MAX_CUSTOM_VOTE_OPTIONS] max.", "Options", max_length = MAX_NAME_LEN)
|
|
if(!vote_creator?.client)
|
|
return FALSE
|
|
if(!option)
|
|
break
|
|
|
|
default_choices += capitalize(option)
|
|
|
|
if(!length(default_choices))
|
|
return FALSE
|
|
|
|
return ..()
|
|
|
|
/datum/vote/custom_vote/initiate_vote(initiator, duration)
|
|
. = ..()
|
|
. += "\n[override_question]"
|
|
|
|
// There are no winners or losers for custom votes
|
|
/datum/vote/custom_vote/get_winner_text(list/all_winners, real_winner, list/non_voters)
|
|
return "[span_bold("Did not vote:")] [length(non_voters)]"
|
|
|
|
#undef MAX_CUSTOM_VOTE_OPTIONS
|