insert mode
This commit is contained in:
1 parent
f85399ad57
commit
da42fc4e0f
33 files changed
+256
-172
No files matched your search
+10
-7
@@ -20,19 +20,19 @@ from kivymd.uix.floatlayout import MDFloatLayout
|
||||
from katrain.core.constants import (
|
||||
MODE_PLAY,
|
||||
OUTPUT_DEBUG,
|
||||
STATUS_TEACHING,
|
||||
OUTPUT_EXTRA_DEBUG,
|
||||
TOP_MOVE_OPTIONS,
|
||||
TOP_MOVE_NOTHING,
|
||||
STATUS_TEACHING,
|
||||
TOP_MOVE_DELTA_SCORE,
|
||||
TOP_MOVE_SCORE,
|
||||
TOP_MOVE_WINRATE,
|
||||
TOP_MOVE_DELTA_WINRATE,
|
||||
TOP_MOVE_NOTHING,
|
||||
TOP_MOVE_OPTIONS,
|
||||
TOP_MOVE_SCORE,
|
||||
TOP_MOVE_VISITS,
|
||||
TOP_MOVE_WINRATE,
|
||||
)
|
||||
from katrain.core.game import Move
|
||||
from katrain.core.lang import i18n
|
||||
from katrain.core.utils import evaluation_class, var_to_grid, format_visits
|
||||
from katrain.core.utils import evaluation_class, format_visits, var_to_grid
|
||||
from katrain.gui.kivyutils import BackgroundMixin, draw_circle, draw_text
|
||||
from katrain.gui.popups import I18NPopup, ReAnalyzeGamePopup
|
||||
from katrain.gui.style import *
|
||||
@@ -226,7 +226,10 @@ class BadukPanWidget(Widget):
|
||||
for i in range(board_size_y)
|
||||
]
|
||||
|
||||
Color(1, 0.95, 0.8, 1) # image is a bit too light
|
||||
if katrain.game.insert_mode:
|
||||
Color(1, 1, 1, 0.75) # dreamy
|
||||
else:
|
||||
Color(1, 0.95, 0.8, 1) # image is a bit too light
|
||||
Rectangle(
|
||||
pos=(self.gridpos_x[0] - self.grid_size * 1.5, self.gridpos_y[0] - self.grid_size * 1.5),
|
||||
size=(self.grid_size * x_grid_spaces, self.grid_size * y_grid_spaces),
|
||||
|
||||
@@ -2,11 +2,11 @@ import time
|
||||
|
||||
from kivy.clock import Clock
|
||||
from kivy.core.audio import SoundLoader
|
||||
from kivy.properties import ObjectProperty, OptionProperty, NumericProperty
|
||||
from kivy.properties import NumericProperty, ObjectProperty, OptionProperty
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivymd.uix.floatlayout import MDFloatLayout
|
||||
|
||||
from katrain.core.constants import MODE_PLAY, MODE_ANALYZE, STATUS_ERROR, STATUS_ANALYSIS, PLAYER_HUMAN
|
||||
from katrain.core.constants import MODE_ANALYZE, MODE_PLAY, PLAYER_HUMAN, STATUS_ANALYSIS, STATUS_ERROR
|
||||
from katrain.core.lang import rank_label
|
||||
from katrain.gui.kivyutils import AnalysisToggle, CollapsablePanel
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from kivy.clock import Clock
|
||||
from kivy.core.text import Label as CoreLabel
|
||||
from kivy.core.text.markup import MarkupLabel as CoreMarkupLabel
|
||||
|
||||
from kivy.core.window import Window
|
||||
from kivy.graphics import *
|
||||
from kivy.properties import (
|
||||
@@ -12,7 +11,7 @@ from kivy.properties import (
|
||||
OptionProperty,
|
||||
StringProperty,
|
||||
)
|
||||
from kivy.uix.behaviors import ButtonBehavior, ToggleButtonBehavior, FocusBehavior
|
||||
from kivy.uix.behaviors import ButtonBehavior, FocusBehavior, ToggleButtonBehavior
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.uix.button import Button
|
||||
from kivy.uix.label import Label
|
||||
|
||||
@@ -16,7 +16,7 @@ GREEN = [0.1, 0.8, 0.1, 1]
|
||||
YELLOW = [0.8, 0.8, 0.1, 1]
|
||||
DARKRED = [0.3, 0.1, 0.1, 1]
|
||||
ORANGE = [242 / 255, 96 / 255, 34 / 255, 1]
|
||||
|
||||
LIGHT_ORANGE = [1, 0.5, 0.25, 1]
|
||||
# gui colors
|
||||
BACKGROUND_COLOR = [36 / 255, 48 / 255, 62 / 255, 1]
|
||||
BOX_BACKGROUND_COLOR = [46 / 255, 65 / 255, 88 / 255, 1]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from katrain.gui.widgets.graph import ScoreGraph, RankGraph
|
||||
from katrain.gui.widgets.movetree import MoveTree
|
||||
from katrain.gui.widgets.filebrowser import I18NFileBrowser
|
||||
from katrain.gui.widgets.graph import RankGraph, ScoreGraph
|
||||
from katrain.gui.widgets.movetree import MoveTree
|
||||
from katrain.gui.widgets.selection_slider import SelectionSlider
|
||||
|
||||
__all__ = ["ScoreGraph", "RankGraph", "MoveTree", "I18NFileBrowser", "SelectionSlider"]
|
||||
@@ -12,8 +12,12 @@ from kivymd.app import MDApp
|
||||
from katrain.gui.kivyutils import BackgroundMixin, draw_circle, draw_text
|
||||
from katrain.gui.style import (
|
||||
BACKGROUND_COLOR,
|
||||
DARKRED,
|
||||
GREEN,
|
||||
LIGHT_ORANGE,
|
||||
LIGHTER_BACKGROUND_COLOR,
|
||||
LIGHTGREY,
|
||||
ORANGE,
|
||||
OUTLINE_COLORS,
|
||||
RED,
|
||||
STONE_COLORS,
|
||||
@@ -106,10 +110,9 @@ class MoveTreeCanvas(Widget):
|
||||
return
|
||||
self.set_game_node(same_x_moves[new_index][1])
|
||||
|
||||
def draw_move_tree(self, current_node):
|
||||
def draw_move_tree(self, current_node, insert_node):
|
||||
if not self.scroll_view_widget or not current_node:
|
||||
return
|
||||
|
||||
spacing = 5
|
||||
moves_vert = 3
|
||||
self.move_size = (self.scroll_view_widget.height - (moves_vert + 1) * spacing) / moves_vert
|
||||
@@ -148,6 +151,15 @@ class MoveTreeCanvas(Widget):
|
||||
|
||||
self.move_xy_pos = {n: xy_pos(x, y) for n, (x, y) in self.move_pos.items()}
|
||||
|
||||
special_nodes = {self.menu_selected_node: RED, current_node: YELLOW}
|
||||
|
||||
if insert_node:
|
||||
special_nodes[insert_node.parent] = GREEN
|
||||
insert_path = current_node
|
||||
while insert_path != insert_node.parent and insert_path.parent:
|
||||
special_nodes[insert_path] = ORANGE if insert_path == current_node else LIGHT_ORANGE
|
||||
insert_path = insert_path.parent
|
||||
|
||||
with self.canvas:
|
||||
self.canvas.clear()
|
||||
Color(*LIGHTGREY)
|
||||
@@ -157,8 +169,8 @@ class MoveTreeCanvas(Widget):
|
||||
Line(points=[x, y, x, cy, cx, cy], width=1)
|
||||
|
||||
for node, pos in self.move_xy_pos.items():
|
||||
if node == self.menu_selected_node or node == current_node:
|
||||
Color(*(RED if node == self.menu_selected_node else YELLOW))
|
||||
if node in special_nodes:
|
||||
Color(*special_nodes[node])
|
||||
Rectangle(
|
||||
pos=[c - self.move_size / 2 - spacing / 2 for c in self.move_xy_pos[node]],
|
||||
size=(self.move_size + spacing, self.move_size + spacing),
|
||||
@@ -177,11 +189,15 @@ class MoveTree(ScrollView, BackgroundMixin):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.insert_node = None
|
||||
self.redraw_tree_trigger = Clock.create_trigger(
|
||||
lambda _dt: self.move_tree_canvas.draw_move_tree(self.current_node)
|
||||
lambda _dt: self.move_tree_canvas.draw_move_tree(self.current_node, self.insert_node)
|
||||
)
|
||||
self.bind(current_node=self.redraw_tree_trigger, size=self.redraw_tree_trigger)
|
||||
|
||||
def redraw(self):
|
||||
self.redraw_tree_trigger()
|
||||
|
||||
def switch_branch(self, direction):
|
||||
self.move_tree_canvas.switch_branch(direction)
|
||||
|
||||
|
||||
Reference in new issue
Block a user