This commit is contained in:
Sander Land committed 2020-04-22 17:54:07 +02:00
1 parent 39556ad690
commit 751c66a902
7 files changed
+162 -119

No files matched your search

+11 -10
View File
@@ -110,7 +110,7 @@ class BadukPanWidget(Widget):
# grid lines
margin = 1.5
margin_x = margin + (max_board_size - board_size_x) / 2
margin_y = margin + (max_board_size - board_size_y) / 2
margin_y = margin - 0.125 + (max_board_size - board_size_y) / 2
self.grid_size = board_px_size / (max_board_size - 1 + 1.5 * margin)
self.stone_size = self.grid_size * self.ui_config["stone_size"]
@@ -215,15 +215,16 @@ class BadukPanWidget(Widget):
# children of current moves in undo / review
undo_coords = set()
alpha = self.ui_config["_child_alpha"]
for child_node in current_node.children:
points_lost = child_node.points_lost
m = child_node.single_move
if m and m.coords is not None:
undo_coords.add(m.coords)
evalcol = (*self.eval_color(points_lost), alpha) if points_lost is not None else None
scale = self.ui_config.get("_child_scale", 0.95)
self.draw_stone(m.coords[0], m.coords[1], (*stone_color[m.player][:3], alpha), None, None, evalcol, evalscale=scale, scale=scale)
if katrain.controls.show_children.active:
alpha = self.ui_config["ghost_alpha"]
for child_node in current_node.children:
points_lost = child_node.points_lost
m = child_node.single_move
if m and m.coords is not None:
undo_coords.add(m.coords)
evalcol = (*self.eval_color(points_lost), alpha) if points_lost is not None else None
scale = self.ui_config.get("_child_scale", 0.95)
self.draw_stone(m.coords[0], m.coords[1], (*stone_color[m.player][:3], alpha), None, None, evalcol, evalscale=scale, scale=scale)
# hints
if katrain.controls.hints.active and not game_ended:
+8 -2
View File
@@ -11,7 +11,7 @@ class Controls(BoxLayout):
def set_status(self, msg, at_node=None):
self.status = msg
self.status_node = at_node or self.parent.game and self.parent.game.current_node
self.status_node = at_node or self.katrain.game and self.parent.game.current_node
self.info.text = msg
self.update_evaluation()
@@ -21,6 +21,12 @@ class Controls(BoxLayout):
else:
self.play_tab_button.trigger_action(duration=0)
def switch_mode(self):
if self.play_tab_button.state == "down":
self.select_mode("analyze")
else:
self.select_mode("play")
def show_evaluation_stats(self, node):
if node.analysis_ready:
self.score.text = node.format_score().replace("-", "\u2013")
@@ -49,7 +55,7 @@ class Controls(BoxLayout):
# handles showing completed analysis and score graph
def update_evaluation(self):
katrain = self.parent
katrain = self.katrain
current_node = katrain.game and katrain.game.current_node
info = ""
+4 -3
View File
@@ -47,7 +47,7 @@ class ToggleButtonContainer(GridLayout):
selected = StringProperty("")
group = StringProperty(None)
autosize = BooleanProperty(True)
margin = ListProperty([0, 0, 1, 1]) # TODO outer vs inner margin?
spacing = ListProperty((1, 1))
def __init__(self, **kwargs):
super().__init__(**kwargs)
@@ -71,7 +71,7 @@ class ToggleButtonContainer(GridLayout):
for i, opt in enumerate(self.options):
state = "down" if opt == self.selected else "normal"
self.add_widget(StyledToggleButton(group=self.group, text=self.labels[i], value=opt, state=state, margin=self.margin, on_press=state_handler))
self.add_widget(StyledToggleButton(group=self.group, text=self.labels[i], value=opt, state=state, on_press=state_handler))
Clock.schedule_once(self._size, 0)
def _size(self, _dt):
@@ -166,6 +166,7 @@ class ScoreGraph(Label):
line_points = ListProperty([])
dot_pos = ListProperty([0, 0])
highlighted_index = NumericProperty(None)
min_scale = NumericProperty(1)
def __init__(self, **kwargs):
super().__init__(**kwargs)
@@ -184,7 +185,7 @@ class ScoreGraph(Label):
if nodes:
values = [n.score if n and n.score else 0 for n in nodes]
val_range = min(values or [0]), max(values or [0])
scale = math.ceil(max(3, max(-val_range[0], val_range[1]) * 1.05))
scale = math.ceil(max(self.min_scale, max(-val_range[0], val_range[1]) * 1.05))
xscale = self.width * 0.9 / max(len(values), 20)
available_height = self.height * (1 - 2 * self.marginy)