Skip to content

Commit

Permalink
Make StatLabel derive from Label, improve padding
Browse files Browse the repository at this point in the history
  • Loading branch information
lykahb committed Sep 28, 2024
1 parent ed144d0 commit bddf8cd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
50 changes: 22 additions & 28 deletions katrain/gui.kv
Original file line number Diff line number Diff line change
Expand Up @@ -455,66 +455,60 @@
text: '+0'
size: self.texture_size


<StatsLabel>:
size_hint_y: EPSILON if root.hidden else 1
opacity: 0 if root.hidden else 1
Label:
size_hint: 0.6,1
id: desc
font_size: self.height * 0.7
font_name: root.font_name
text_size: self.size
valign: 'middle'
halign: 'center'
text: root.label
max_lines: 1
size_hint: 0.6,1
font_size: self.height * 0.7
font_name: root.font_name
text_size: self.size
valign: 'middle'
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
Label:
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
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

<StatsBox>
cols: 2
background_color: Theme.BOX_BACKGROUND_COLOR
labels: {'score':score_label,'winrate':winrate_label,'points':pointloss_label}
padding: CP_PADDING
StatsLabel:
id: winrate_label
label: i18n._('stats:winrate')
color: Theme.WINRATE_COLOR
StatsValue:
id: winrate_value
hidden: winrate_label.hidden
color: winrate_label.color
color: Theme.WINRATE_COLOR
text: root.winrate
StatsLabel:
id: score_label
label: i18n._('stats:score')
color: Theme.SCORE_COLOR
StatsValue:
id: score_value
hidden: score_label.hidden
color: score_label.color
color: Theme.SCORE_COLOR
text: 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')
color: Theme.POINTLOSS_COLOR
StatsValue:
id: pointloss_value
hidden: pointloss_label.hidden
color: pointloss_label.color
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 '...'

<ScrollableLabel>:
Expand Down
4 changes: 2 additions & 2 deletions katrain/gui/kivyutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ class LightLabel(Label):
pass


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

class StatsValue(MDBoxLayout):
class StatsValue(Label):
text = StringProperty("")
color = ListProperty([1, 1, 1, 1])
hidden = BooleanProperty(False)
Expand Down

0 comments on commit bddf8cd

Please sign in to comment.