Skip to content

Commit

Permalink
allows admins to make cast votes invisible to normal users (#6038)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
sometimes you wanna make the end result a surprise
<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

:cl:
add: Added option to make votes secret
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
TheLordME authored Oct 1, 2023
1 parent ca098ef commit 2776091
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ SUBSYSTEM_DEF(vote)
var/list/current_votes = list()
/// Who has voted
var/list/voting = list()
/// Anonymous votes
var/secret = FALSE

/datum/controller/subsystem/vote/fire(resumed)
if(mode)
Expand Down Expand Up @@ -222,6 +224,7 @@ SUBSYSTEM_DEF(vote)
"admin" = check_rights_for(user.client, R_ADMIN),

"vote_happening" = !!choices.len,
"secret" = secret,
)

for(var/key in choices)
Expand Down Expand Up @@ -262,4 +265,7 @@ SUBSYSTEM_DEF(vote)
submit_vote(usr.key,params["index"])
if("unvote")
submit_vote(usr.key, null)
if("hide")
secret = !secret
log_and_message_admins("[usr] made the individual vote numbers [(secret ? "invisibile" : "visible")].")
return TRUE
21 changes: 17 additions & 4 deletions tgui/packages/tgui/interfaces/Vote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface VoteContext {
choices : VoteChoice[];
question: string;
time_remaining : number;
secret : BooleanLike;
}

interface VoteChoice {
Expand Down Expand Up @@ -61,7 +62,7 @@ export const Vote = (props, context) => {

const StartVoteOptions = (props, context) => {
const { act, data } = useBackend<VoteContext>(context);
const { vote_happening } = data;
const { vote_happening, secret } = data;
return (
<Stack.Item>
<Collapsible title="Start a vote">
Expand All @@ -85,10 +86,22 @@ const StartVoteOptions = (props, context) => {
</Button>
</Stack.Item>
<Stack.Item>
<Button disabled={vote_happening} onClick={() => act("custom")}>
<Button
disabled={vote_happening}
onClick={() => act("custom")}
>
Custom Vote
</Button>
</Stack.Item>
<Stack.Item>
<Button
color={secret ? "green" : "red"}
onClick={() => act("hide")}
icon={secret ? 'lock' : 'unlock'}
>
Hide Votes
</Button>
</Stack.Item>
</Stack>
</Stack.Item>
</Stack>
Expand All @@ -99,7 +112,7 @@ const StartVoteOptions = (props, context) => {
// Display choices
const ChoicesPanel = (props, context) => {
const { act, data } = useBackend<VoteContext>(context);
const { choices, selected_choice, question } = data;
const { admin, choices, selected_choice, question, secret } = data;

return (
<Stack.Item grow>
Expand Down Expand Up @@ -133,7 +146,7 @@ const ChoicesPanel = (props, context) => {
name="vote-yea"
/>
)}
{choice.votes} Votes
{(!admin && secret) ? "?" : choice.votes} Votes
</LabeledList.Item>
<LabeledList.Divider />
</Box>
Expand Down

0 comments on commit 2776091

Please sign in to comment.