stuff
This commit is contained in:
1 parent
52aefb47f4
commit
1d80815c8e
13 files changed
+52
-46
No files matched your search
+1
-1
@@ -64,7 +64,7 @@ class Controls(BoxLayout):
|
||||
self.win_rate.text = current_node.format_win_rate()
|
||||
if move and next_player_is_human_or_both_robots: # don't immediately hide this when an ai moves comes in
|
||||
points_lost = current_node.points_lost
|
||||
self.score_change.label = f"Points lost for {move.player}" if points_lost and points_lost > 0 else f"Points gained for {move.player}"
|
||||
self.score_change.label = f"Points lost ({move.player})" if points_lost and points_lost > 0 else f"Points gained ({move.player})"
|
||||
self.score_change.text = f"{abs(points_lost):.1f}" if points_lost else "..."
|
||||
elif not current_player_is_ai_playing_human:
|
||||
self.score_change.label = f"Points lost"
|
||||
|
||||
+3
-1
@@ -24,9 +24,11 @@ class DarkLabel(Label):
|
||||
class ScaledLightLabel(DarkLabel):
|
||||
pass
|
||||
|
||||
|
||||
class LightHelpLabel(ScaledLightLabel):
|
||||
pass
|
||||
|
||||
|
||||
class StyledButton(Button):
|
||||
button_color = ListProperty([])
|
||||
button_color_down = ListProperty([])
|
||||
@@ -79,7 +81,7 @@ class ToggleButtonContainer(GridLayout):
|
||||
def _size(self, _dt):
|
||||
if self.autosize:
|
||||
for tb in self.children:
|
||||
tb.size_hint = (tb.texture_size[0] + 25, 1)
|
||||
tb.size_hint = (tb.texture_size[0] + 10, 1)
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
|
||||
+24
-14
@@ -8,7 +8,17 @@ from kivy.uix.label import Label
|
||||
from common import OUTPUT_DEBUG, OUTPUT_ERROR
|
||||
from engine import KataGoEngine
|
||||
from game import Game, GameNode
|
||||
from gui.kivyutils import LabelledCheckBox, LabelledFloatInput, LabelledIntInput, LabelledObjectInputArea, LabelledSpinner, LabelledTextInput, ScaledLightLabel, StyledButton, LightHelpLabel
|
||||
from gui.kivyutils import (
|
||||
LabelledCheckBox,
|
||||
LabelledFloatInput,
|
||||
LabelledIntInput,
|
||||
LabelledObjectInputArea,
|
||||
LabelledSpinner,
|
||||
LabelledTextInput,
|
||||
ScaledLightLabel,
|
||||
StyledButton,
|
||||
LightHelpLabel,
|
||||
)
|
||||
|
||||
|
||||
class InputParseError(Exception):
|
||||
@@ -16,7 +26,7 @@ class InputParseError(Exception):
|
||||
|
||||
|
||||
class QuickConfigGui(BoxLayout):
|
||||
def __init__(self, katrain, popup, initial_values=None,**kwargs):
|
||||
def __init__(self, katrain, popup, initial_values=None, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.katrain = katrain
|
||||
self.popup = popup
|
||||
@@ -65,7 +75,7 @@ class LoadSGFPopup(BoxLayout):
|
||||
class NewGamePopup(QuickConfigGui):
|
||||
def __init__(self, katrain, popup, properties, **kwargs):
|
||||
properties["RU"] = KataGoEngine.get_rules(katrain.game.root)
|
||||
super().__init__(katrain, popup, properties,**kwargs)
|
||||
super().__init__(katrain, popup, properties, **kwargs)
|
||||
self.rules_spinner.values = list(set(self.katrain.engine.RULESETS.values()))
|
||||
self.rules_spinner.text = properties["RU"]
|
||||
|
||||
@@ -82,11 +92,11 @@ class NewGamePopup(QuickConfigGui):
|
||||
|
||||
|
||||
class ConfigPopup(QuickConfigGui):
|
||||
def __init__(self, katrain, popup, config, ignore_cats,**kwargs):
|
||||
def __init__(self, katrain, popup, config, ignore_cats, **kwargs):
|
||||
self.config = config
|
||||
self.ignore_cats = ignore_cats
|
||||
self.orientation = "vertical"
|
||||
super().__init__(katrain, popup,**kwargs)
|
||||
super().__init__(katrain, popup, **kwargs)
|
||||
Clock.schedule_once(self._build, 0)
|
||||
|
||||
def _build(self, _):
|
||||
@@ -161,22 +171,22 @@ class ConfigPopup(QuickConfigGui):
|
||||
|
||||
class ConfigAIPopup(QuickConfigGui):
|
||||
def __init__(self, katrain, popup, ai_modes, **kwargs):
|
||||
super().__init__(katrain, popup, katrain.ai_settings, **kwargs)
|
||||
super().__init__(katrain, popup, katrain.ai_settings, **kwargs)
|
||||
self.settings = self.katrain.ai_settings
|
||||
self.ai_modes = ai_modes
|
||||
Clock.schedule_once(self._build, 0)
|
||||
self.orientation ='vertical'
|
||||
self.orientation = "vertical"
|
||||
|
||||
def _build(self,_dt):
|
||||
def _build(self, _dt):
|
||||
colbox = BoxLayout(spacing=5)
|
||||
for mode in self.ai_modes:
|
||||
mode_settings = self.settings[mode]
|
||||
num_rows = len(mode_settings) - 2
|
||||
column = GridLayout(cols=2, rows=max(num_rows,4) + 3,spacing=1,padding=3)
|
||||
column = GridLayout(cols=2, rows=max(num_rows, 4) + 3, spacing=1, padding=3)
|
||||
column.add_widget(ScaledLightLabel(text=f"Settings for AI"))
|
||||
column.add_widget(ScaledLightLabel(text=f"{mode}", bold=True))
|
||||
column.add_widget(LightHelpLabel(size_hint=(1,3),text=mode_settings.get('_help_left','')))
|
||||
column.add_widget(LightHelpLabel(size_hint=(1,3),text=mode_settings.get('_help_right', '')))
|
||||
column.add_widget(LightHelpLabel(size_hint=(1, 3), text=mode_settings.get("_help_left", "")))
|
||||
column.add_widget(LightHelpLabel(size_hint=(1, 3), text=mode_settings.get("_help_right", "")))
|
||||
for k, v in mode_settings.items():
|
||||
if not k.startswith("_"):
|
||||
column.add_widget(ScaledLightLabel(text=f"{k}"))
|
||||
@@ -185,9 +195,9 @@ class ConfigAIPopup(QuickConfigGui):
|
||||
column.add_widget(ScaledLightLabel(text=f""))
|
||||
column.add_widget(ScaledLightLabel(text=f""))
|
||||
colbox.add_widget(column)
|
||||
if len(self.ai_modes)==1:
|
||||
if len(self.ai_modes) == 1:
|
||||
colbox.add_widget(ScaledLightLabel(text=f""))
|
||||
bl = BoxLayout(size_hint=(1,0.2),spacing=2)
|
||||
bl = BoxLayout(size_hint=(1, 0.2), spacing=2)
|
||||
bl.add_widget(StyledButton(text=f"Apply", on_press=lambda _: self.update_config(False)))
|
||||
bl.add_widget(StyledButton(text=f"Apply and Save", on_press=lambda _: self.update_config(True)))
|
||||
self.add_widget(colbox)
|
||||
@@ -197,7 +207,7 @@ class ConfigAIPopup(QuickConfigGui):
|
||||
try:
|
||||
for k, v in self.collect_properties(self).items():
|
||||
k1, k2 = k.split("/")
|
||||
print(k1,k2,v,self.settings[k1][k2])
|
||||
print(k1, k2, v, self.settings[k1][k2])
|
||||
if self.settings[k1][k2] != v:
|
||||
self.katrain.log(f"Updating setting {k} = {v}", OUTPUT_DEBUG)
|
||||
|
||||
|
||||
Reference in new issue
Block a user