Skip to content

Commit

Permalink
Refactor stat class fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lykahb committed Sep 28, 2024
1 parent bddf8cd commit 69d4c82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
23 changes: 9 additions & 14 deletions katrain/gui.kv
Original file line number Diff line number Diff line change
Expand Up @@ -455,31 +455,26 @@
text: '+0'
size: self.texture_size

<StatsLabel>:
<StatsItem>:
size_hint_y: EPSILON if root.hidden else 1
opacity: 0 if root.hidden else 1
size_hint: 0.6,1
font_size: self.height * 0.7
font_name: root.font_name
text_size: self.size
valign: 'middle'
max_lines: 1

<StatsLabel>:
size_hint: 0.6,1
halign: 'left'
text: root.label
max_lines: 1

<StatsValue>:
size_hint_y: EPSILON if root.hidden else 1
opacity: 0 if root.hidden else 1
size_hint: 0.4,1
color: root.color
font_size: self.height * 0.7
font_name: root.font_name
text_size: self.size
valign: 'middle'
halign: 'left'
bold: True
text: root.text
max_lines: 1
text: root.value

<StatsBox>
cols: 2
Expand All @@ -493,23 +488,23 @@
id: winrate_value
hidden: winrate_label.hidden
color: Theme.WINRATE_COLOR
text: root.winrate
value: root.winrate
StatsLabel:
id: score_label
label: i18n._('stats:score')
StatsValue:
id: score_value
hidden: score_label.hidden
color: Theme.SCORE_COLOR
text: root.score
value: root.score
StatsLabel:
id: pointloss_label
label: i18n._('stats:pointslost') if root.points_lost is None or root.points_lost > 0 else i18n._('stats:pointsgained')
StatsValue:
id: pointloss_value
hidden: pointloss_label.hidden
color: Theme.POINTLOSS_COLOR
text: '{}: {:.1f}'.format(i18n._(f'short color {root.player}'), abs(root.points_lost)) if root.points_lost is not None else '...'
value: '{}: {:.1f}'.format(i18n._(f'short color {root.player}'), abs(root.points_lost)) if root.points_lost is not None else '...'

<ScrollableLabel>:
background_color: Theme.BOX_BACKGROUND_COLOR
Expand Down
15 changes: 8 additions & 7 deletions katrain/gui/kivyutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,18 @@ class LightLabel(Label):
pass


class StatsLabel(Label):
label = StringProperty("")
color = ListProperty([1, 1, 1, 1])
class StatsItem(Label):
hidden = BooleanProperty(False)
font_name = StringProperty(Theme.DEFAULT_FONT)

class StatsValue(Label):
text = StringProperty("")

class StatsLabel(StatsItem):
label = StringProperty("")


class StatsValue(StatsItem):
value = StringProperty("")
color = ListProperty([1, 1, 1, 1])
hidden = BooleanProperty(False)
font_name = StringProperty(Theme.DEFAULT_FONT)


class MyNavigationDrawer(MDNavigationDrawer):
Expand Down

0 comments on commit 69d4c82

Please sign in to comment.