dont show rank for human/normal

This commit is contained in:
Sander Land committed 2021-01-03 10:21:30 +01:00
1 parent 5974bfb783
commit 5794934585
2 files changed
+20 -2

No files matched your search

+3 -1
View File
@@ -271,6 +271,7 @@
outline_color: Theme.BOX_BACKGROUND_COLOR
outline_width: 2
padding: [2*CP_PADDING,CP_PADDING,CP_PADDING,CP_PADDING]
subtype_label: subtype_label
CircleWithText:
size_hint: 0.32, 1
player: root.player
@@ -289,7 +290,8 @@
halign: 'center'
valign: 'middle'
Label: # todo: proper scaling/shortening label instead of this jank
text: (root.name if root.name and root.player_type==PLAYER_HUMAN and root.player_subtype == PLAYING_NORMAL else i18n._(root.player_subtype) ) + (" ({})".format(root.rank) if root.rank and root.player_subtype != PLAYING_TEACHING else "")
id: subtype_label
text: i18n._(root.player_subtype)
size_hint: 1,0.4
font_size: self.height * 0.7 if root.player_type==PLAYER_HUMAN else self.height * 0.7 * min(1,18/len(self.text))
text_size: self.size if root.player_type==PLAYER_HUMAN else (None,self.height)
+17 -1
View File
@@ -28,7 +28,7 @@ from kivymd.uix.navigationdrawer import MDNavigationDrawer
from kivymd.uix.selectioncontrol import MDCheckbox
from kivymd.uix.textfield import MDTextField
from katrain.core.constants import AI_STRATEGIES_RECOMMENDED_ORDER, GAME_TYPES, MODE_PLAY, PLAYER_AI
from katrain.core.constants import AI_STRATEGIES_RECOMMENDED_ORDER, GAME_TYPES, MODE_PLAY, PLAYER_AI, PLAYER_HUMAN, PLAYING_NORMAL, PLAYING_TEACHING
from katrain.core.lang import i18n
from katrain.gui.theme import Theme
@@ -372,6 +372,22 @@ class PlayerInfo(MDBoxLayout, BackgroundMixin):
rank = StringProperty("", allownone=True)
active = BooleanProperty(True)
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.bind(player_type=self.set_label,player_subtype=self.set_label,name=self.set_label,rank=self.set_label)
def set_label(self,*args):
if not self.subtype_label: #building
return
show_player_name = self.name and self.player_type == PLAYER_HUMAN and self.player_subtype == PLAYING_NORMAL
if show_player_name:
text = self.name
else:
text = i18n._(self.player_subtype)
if self.rank and self.player_subtype != PLAYING_TEACHING and (show_player_name or self.player_type==PLAYER_AI):
text += " ({})".format(self.rank)
self.subtype_label.text = text
class TimerOrMoveTree(MDBoxLayout):
mode = StringProperty(MODE_PLAY)