forked from FelipeRenault/gamechanger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoreboard.py
More file actions
63 lines (54 loc) · 2.27 KB
/
Copy pathscoreboard.py
File metadata and controls
63 lines (54 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import time
import streamlit as st
def render_scoreboard(text_slide_offset, is_cover_slide):
ss = st.session_state
if st.session_state.edit_mode or is_cover_slide or not ss.scoreboard_enabled:
return
with st.container(key="scoreboard"):
visible_players = [
(name, data)
for name, data in ss.players.items()
if ss.slide >= data["starting_slide"] + text_slide_offset - 1
]
for index, ((player, data), col) in enumerate(
zip(visible_players, st.columns(len(visible_players))),
start=1,
):
with col:
st.header(player)
st.markdown(
f'<div class="score-value">{data["score"]}</div>',
unsafe_allow_html=True,
)
minus_col, plus_col = st.columns(2)
minus_shortcut = (
str(index)
if ss.points_inverted_shortcut
else f"{ss.points_modifier_shortcut}+{index}"
)
plus_shortcut = (
f"{ss.points_modifier_shortcut}+{index}"
if ss.points_inverted_shortcut
else str(index)
)
with minus_col:
with st.container(horizontal=True, horizontal_alignment="right"):
if st.button(
"-",
key=f"minus_{player}",
shortcut=minus_shortcut,
type=ss.points_buttons_css_type,
):
ss.players[player]["score"] -= 1
ss.pending_lose_sound = time.time() if ss.lose_points_sound_enabled else None
st.rerun()
with plus_col:
if st.button(
"+",
key=f"plus_{player}",
shortcut=plus_shortcut,
type=ss.points_buttons_css_type,
):
ss.players[player]["score"] += 1
ss.pending_gain_sound = time.time() if ss.gain_points_sound_enabled else None
st.rerun()