move tree fix

This commit is contained in:
Sander Land committed 2020-06-19 19:16:15 +02:00
1 parent a018a62067
commit 3c2f2a9b46
8 files changed
+23 -18

No files matched your search

+6 -5
View File
@@ -6,7 +6,7 @@ os.environ["KCFG_KIVY_LOG_LEVEL"] = os.environ.get("KCFG_KIVY_LOG_LEVEL", "warni
os.environ["KIVY_AUDIO"] = "sdl2" # force working audio os.environ["KIVY_AUDIO"] = "sdl2" # force working audio
# next, icon # next, icon
from katrain.core.utils import find_package_resource from katrain.core.utils import find_package_resource, PATHS
from kivy.config import Config from kivy.config import Config
from kivy.utils import platform from kivy.utils import platform
@@ -471,7 +471,8 @@ class KaTrainApp(MDApp):
kv_file = find_package_resource("katrain/gui.kv") kv_file = find_package_resource("katrain/gui.kv")
popup_kv_file = find_package_resource("katrain/popups.kv") popup_kv_file = find_package_resource("katrain/popups.kv")
resource_add_path(os.path.split(kv_file)[0]) resource_add_path(PATHS["PACKAGE"])
Builder.load_file(kv_file) Builder.load_file(kv_file)
Window.bind(on_request_close=self.on_request_close) Window.bind(on_request_close=self.on_request_close)
@@ -489,9 +490,9 @@ class KaTrainApp(MDApp):
self.gui.controls.set_status("") self.gui.controls.set_status("")
def webbrowser(self, site_key): def webbrowser(self, site_key):
WEBSITES = {"homepage": HOMEPAGE + "#manual", "support": HOMEPAGE + "#support"} websites = {"homepage": HOMEPAGE + "#manual", "support": HOMEPAGE + "#support"}
if site_key in WEBSITES: if site_key in websites:
webbrowser.open(WEBSITES[site_key]) webbrowser.open(websites[site_key])
def on_start(self): def on_start(self):
self.language = self.gui.config("general/lang") self.language = self.gui.config("general/lang")
+1 -1
View File
@@ -1,4 +1,4 @@
VERSION = "1.2.0" VERSION = "1.2.1"
HOMEPAGE = "https://github.com/sanderland/katrain" HOMEPAGE = "https://github.com/sanderland/katrain"
CONFIG_MIN_VERSION = "1.2.0" CONFIG_MIN_VERSION = "1.2.0"
+1 -1
View File
@@ -56,7 +56,7 @@ class Lang(Observable):
self.font_name = self.FONTS.get(lang) or DEFAULT_FONT self.font_name = self.FONTS.get(lang) or DEFAULT_FONT
i18n_dir, _ = os.path.split(find_package_resource("katrain/i18n/__init__.py")) i18n_dir, _ = os.path.split(find_package_resource("katrain/i18n/__init__.py"))
locale_dir = os.path.join(i18n_dir, "locales") locale_dir = os.path.join(i18n_dir, "locales")
locales = gettext.translation("katrain", locale_dir, languages=[lang,DEFAULT_LANGUAGE]) locales = gettext.translation("katrain", locale_dir, languages=[lang, DEFAULT_LANGUAGE])
self.ugettext = locales.gettext self.ugettext = locales.gettext
# update all the kv rules attached to this text # update all the kv rules attached to this text
+5 -5
View File
@@ -37,19 +37,19 @@ def check_thread(tb=False): # for checking if draws occur in correct thread
traceback.print_stack() traceback.print_stack()
PACKAGE_PATH = None PATHS = {}
def find_package_resource(path, silent_errors=False): def find_package_resource(path, silent_errors=False):
global PACKAGE_PATH global PATHS
if path.startswith("katrain"): if path.startswith("katrain"):
if PACKAGE_PATH is None: if not PATHS.get("PACKAGE"):
try: try:
with pkg_resources.path("katrain", "__init__.py") as p: with pkg_resources.path("katrain", "__init__.py") as p:
PACKAGE_PATH = os.path.split(str(p))[0] PATHS["PACKAGE"] = os.path.split(str(p))[0]
except (ModuleNotFoundError, FileNotFoundError, ValueError) as e: except (ModuleNotFoundError, FileNotFoundError, ValueError) as e:
print(f"Package file {path} not found, installation possibly broken", file=sys.stderr) print(f"Package file {path} not found, installation possibly broken", file=sys.stderr)
return f"FILENOTFOUND/{path}" return f"FILENOTFOUND/{path}"
return os.path.join(PACKAGE_PATH, path.replace("katrain\\", "katrain/").replace("katrain/", "")) return os.path.join(PATHS["PACKAGE"], path.replace("katrain\\", "katrain/").replace("katrain/", ""))
else: else:
return os.path.abspath(os.path.expanduser(path)) # absolute path return os.path.abspath(os.path.expanduser(path)) # absolute path
+1 -1
View File
@@ -112,7 +112,7 @@ class BadukPanWidget(Widget):
katrain.log(f"\nAnalysis:\n{nodes_here[-1].analysis}", OUTPUT_DEBUG) katrain.log(f"\nAnalysis:\n{nodes_here[-1].analysis}", OUTPUT_DEBUG)
katrain.log(f"\nParent Analysis:\n{nodes_here[-1].parent.analysis}", OUTPUT_DEBUG) katrain.log(f"\nParent Analysis:\n{nodes_here[-1].parent.analysis}", OUTPUT_DEBUG)
katrain.controls.info.text = nodes_here[-1].comment(sgf=True) katrain.controls.info.text = nodes_here[-1].comment(sgf=True)
katrain.controls.active_comment_node = nodes_here[-1].parent katrain.controls.active_comment_node = nodes_here[-1]
if nodes_here[-1].parent.analysis_ready: if nodes_here[-1].parent.analysis_ready:
self.set_animating_pv(nodes_here[-1].parent.candidate_moves[0]["pv"], nodes_here[-1].parent) self.set_animating_pv(nodes_here[-1].parent.candidate_moves[0]["pv"], nodes_here[-1].parent)
+3 -1
View File
@@ -53,7 +53,9 @@ class PlayAnalyzeSelect(MDFloatLayout):
def switch_ui_mode(self): # on tab press, fake ui click and trigger everything top down def switch_ui_mode(self): # on tab press, fake ui click and trigger everything top down
if self.mode == MODE_PLAY: if self.mode == MODE_PLAY:
Clock.schedule_once(lambda _dt: self.analyze.trigger_action(duration=0)) # normal trigger does not cross thread Clock.schedule_once(
lambda _dt: self.analyze.trigger_action(duration=0)
) # normal trigger does not cross thread
else: else:
Clock.schedule_once(lambda _dt: self.play.trigger_action(duration=0)) Clock.schedule_once(lambda _dt: self.play.trigger_action(duration=0))
+5 -3
View File
@@ -131,14 +131,16 @@ class ScoreGraph(BackgroundMixin):
self.nodes[index] = node self.nodes[index] = node
if index > 1 and node.parent: # sometimes things go so fast if index > 1 and node.parent: # sometimes things go so fast
backfill, bfnode = index - 1, node.parent backfill, bfnode = index - 1, node.parent
while self.nodes[backfill] is None: while bfnode is not None and self.nodes[backfill] != bfnode:
self.nodes[backfill] = bfnode self.nodes[backfill] = bfnode
backfill -= 1 backfill -= 1
bfnode = bfnode.parent bfnode = bfnode.parent
if index + 1 < len(self.nodes) and (node is None or self.nodes[index + 1] not in node.children): if index + 1 < len(self.nodes) and (
node is None or not node.children or self.nodes[index + 1] != node.ordered_children[0]
):
self.nodes = self.nodes[: index + 1] # on branch switching, don't show history from other branch self.nodes = self.nodes[: index + 1] # on branch switching, don't show history from other branch
if index == len(self.nodes) - 1: # possibly just switched branch if index == len(self.nodes) - 1: # possibly just switched branch or the line above triggered
while node.children: # add children back while node.children: # add children back
node = node.ordered_children[0] node = node.ordered_children[0]
self.nodes.append(node) self.nodes.append(node)
+1 -1
View File
@@ -43,7 +43,7 @@ a.datas = [
print("DATA FILTERED", len(a.datas)) print("DATA FILTERED", len(a.datas))
console_names = {True:"KaTrain",False:"KaTrainNC"} console_names = {True:"DebugKaTrain",False:"KaTrain"}
for console, name in console_names.items(): for console, name in console_names.items():