Skip to content

Commit

Permalink
Toggle the ability for the dead to vote in-game + understandability f…
Browse files Browse the repository at this point in the history
…or the dead whether voting is disabled. (tgstation#84352)

## About The Pull Request

Adds a convenient switch to change the ability to vote dead (previously
only in the config), and also turns off the button and adds a tooltip to
let players know why they can't vote (previously, you could just click,
since the button wasn't turned off, but the vote didn't count).



https://github.com/tgstation/tgstation/assets/78199449/404aac9c-0b41-4c16-8ffd-2a435cf25e2c

## Why It's Good For The Game

At the right moments, you can just stop considering the opinions of dead
players.
The dead players will be able to understand why they can't vote.

## Changelog

:cl: Vishenka0704
qol: With voting turned off for the dead, you can now understand why you
can't vote (being dead).
admin: Voting switch for the dead players
/:cl:
  • Loading branch information
AnywayFarus authored Jul 12, 2024
1 parent dd87bab commit fa0d602
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
19 changes: 19 additions & 0 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ SUBSYSTEM_DEF(vote)
return FALSE

return TRUE

/datum/controller/subsystem/vote/proc/toggle_dead_voting(mob/toggle_initiator)
var/switch_deadvote_config = !CONFIG_GET(flag/no_dead_vote)
CONFIG_SET(flag/no_dead_vote, switch_deadvote_config)
var/text_verb = !switch_deadvote_config ? "enabled" : "disabled"
log_admin("[key_name(toggle_initiator)] [text_verb] Dead Vote.")
message_admins("[key_name_admin(toggle_initiator)] [text_verb] Dead Vote.")
SSblackbox.record_feedback("nested tally", "admin_toggle", 1, list("Toggle Dead Vote", text_verb))

/datum/controller/subsystem/vote/ui_state()
return GLOB.always_state

Expand All @@ -293,6 +302,7 @@ SUBSYSTEM_DEF(vote)

data["user"] = list(
"ckey" = user.client?.ckey,
"isGhost" = CONFIG_GET(flag/no_dead_vote) && user.stat == DEAD && !user.client?.holder,
"isLowerAdmin" = is_lower_admin,
"isUpperAdmin" = is_upper_admin,
// What the current user has selected in any ongoing votes.
Expand Down Expand Up @@ -377,6 +387,15 @@ SUBSYSTEM_DEF(vote)
end_vote()
return TRUE

if("toggleDeadVote")
if(!check_rights_for(voter.client, R_ADMIN))
message_admins("[key_name(voter)] tried to toggle vote abillity for ghosts while having improper rights, \
this is potentially a malicious exploit and worth noting.")
return

toggle_dead_voting(voter)
return TRUE

if("toggleVote")
var/datum/vote/selected = possible_votes[params["voteName"]]
if(!istype(selected))
Expand Down
3 changes: 3 additions & 0 deletions code/modules/admin/verbs/server.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ ADMIN_VERB(toggle_ooc_dead, R_ADMIN, "Toggle Dead OOC", "Toggle the OOC channel
message_admins("[key_name_admin(user)] toggled Dead OOC.")
SSblackbox.record_feedback("nested tally", "admin_toggle", 1, list("Toggle Dead OOC", "[GLOB.dooc_allowed ? "Enabled" : "Disabled"]"))

ADMIN_VERB(toggle_vote_dead, R_ADMIN, "Toggle Dead Vote", "Toggle the vote for dead players on or off.", ADMIN_CATEGORY_SERVER)
SSvote.toggle_dead_voting(user)

ADMIN_VERB(start_now, R_SERVER, "Start Now", "Start the round RIGHT NOW.", ADMIN_CATEGORY_SERVER)
var/static/list/waiting_states = list(GAME_STATE_PREGAME, GAME_STATE_STARTUP)
if(!(SSticker.current_state in waiting_states))
Expand Down
36 changes: 29 additions & 7 deletions tgui/packages/tgui/interfaces/VotePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ActiveVote = {

type UserData = {
ckey: string;
isGhost: BooleanLike;
isLowerAdmin: BooleanLike;
isUpperAdmin: BooleanLike;
singleSelection: string | null;
Expand Down Expand Up @@ -88,12 +89,24 @@ export const VotePanel = (props) => {
title="Create Vote"
buttons={
!!user.isLowerAdmin && (
<Button
icon="refresh"
content="Reset Cooldown"
disabled={LastVoteTime + VoteCD <= 0}
onClick={() => act('resetCooldown')}
/>
<Stack>
<Stack.Item>
<Button
icon="refresh"
content="Reset Cooldown"
disabled={LastVoteTime + VoteCD <= 0}
onClick={() => act('resetCooldown')}
/>
</Stack.Item>
<Stack.Item>
<Button
icon="skull"
content="Toggle dead vote"
disabled={!user.isUpperAdmin}
onClick={() => act('toggleDeadVote')}
/>
</Stack.Item>
</Stack>
)
}
>
Expand Down Expand Up @@ -242,7 +255,12 @@ const ChoicesPanel = (props) => {
textAlign="right"
buttons={
<Button
disabled={user.singleSelection === choice.name}
tooltip={
user.isGhost && 'Ghost voting was disabled by an admin.'
}
disabled={
user.singleSelection === choice.name || user.isGhost
}
onClick={() => {
act('voteSingle', { voteOption: choice.name });
}}
Expand Down Expand Up @@ -283,6 +301,10 @@ const ChoicesPanel = (props) => {
textAlign="right"
buttons={
<Button
tooltip={
user.isGhost && 'Ghost voting was disabled by an admin.'
}
disabled={user.isGhost}
onClick={() => {
act('voteMulti', { voteOption: choice.name });
}}
Expand Down

0 comments on commit fa0d602

Please sign in to comment.