player name save/load,komi

This commit is contained in:
Sander Land committed 2020-12-06 23:06:55 +01:00
1 parent fbefcdbb7f
commit b3ee899ec4
4 files changed
+8 -9

No files matched your search

+3 -2
View File
@@ -64,7 +64,7 @@ from katrain.core.constants import (
STATUS_ERROR,
STATUS_INFO,
PLAYING_NORMAL,
PLAYER_HUMAN,
PLAYER_HUMAN, SGF_INTERNAL_COMMENTS_MARKER,
)
from katrain.gui.popups import ConfigTeacherPopup, ConfigTimerPopup, I18NPopup, SaveSGFPopup
from katrain.core.base_katrain import KaTrainBase
@@ -217,7 +217,8 @@ class KaTrainGui(Screen, KaTrainBase):
def update_player(self, bw, **kwargs):
super().update_player(bw, **kwargs)
if self.game:
self.players_info[bw].name = self.game.root.get_property("P" + bw)
sgf_name = self.game.root.get_property("P" + bw)
self.players_info[bw].name = None if SGF_INTERNAL_COMMENTS_MARKER in sgf_name else sgf_name
if self.controls:
self.controls.update_players()
self.update_state()
+3 -3
View File
@@ -20,7 +20,7 @@ from katrain.core.constants import (
STATUS_ERROR,
STATUS_INFO,
STATUS_TEACHING,
VERSION,
VERSION, SGF_INTERNAL_COMMENTS_MARKER,
)
from katrain.core.engine import KataGoEngine
from katrain.core.game_node import GameNode
@@ -399,7 +399,7 @@ class Game:
x_properties = {}
if PROGRAM_NAME in self.root.get_property("AP", ""):
for bw in "BW":
x_properties["P" + bw] = player_name(self.katrain.players_info[bw])
x_properties["P" + bw] = player_name(self.katrain.players_info[bw]) + SGF_INTERNAL_COMMENTS_MARKER
player_info = self.katrain.players_info[bw]
if player_info.player_type == PLAYER_AI:
x_properties[bw + "R"] = rank_label(player_info.calculated_rank)
@@ -407,7 +407,7 @@ class Game:
x_properties["RE"] = self.end_result
x_properties["KTV"] = ANALYSIS_FORMAT_VERSION
self.root.properties = {**root_properties, **{k: [v] for k, v in x_properties.items()}}
player_names = {bw: re.sub(r"['<>:\"/\\|?*]", "", self.root.get_property("P" + bw, bw)) for bw in "BW"}
player_names = {bw: re.sub(r"[\u200b\u3164'<>:\"/\\|?*]", "", self.root.get_property("P" + bw, bw)) for bw in "BW"}
base_game_name = f"{PROGRAM_NAME}_{player_names['B']} vs {player_names['W']}"
return f"{base_game_name} {self.game_id}.sgf"
+1 -1
View File
@@ -136,7 +136,7 @@ class GameNode(SGFNode):
comments = [
i18n._("SGF start message") + SGF_INTERNAL_COMMENTS_MARKER + "\n",
*comments,
f"\nSGF with generated by {PROGRAM_NAME} {VERSION}{SGF_INTERNAL_COMMENTS_MARKER}.\n",
f"\nSGF generated by {PROGRAM_NAME} {VERSION}{SGF_INTERNAL_COMMENTS_MARKER}\n",
]
if self.shortcut_from:
properties["KTSF"] = [id(self.shortcut_from)]
+1 -3
View File
@@ -269,10 +269,8 @@ class NewGamePopup(QuickConfigGui):
name = self.katrain.game.root.get_property("P" + bw, None)
if name:
self.player_name[bw].text = name
komi = self.katrain.game.root.komi
rules = self.normalized_rules()
if komi is not None:
self.km.text = str(komi)
self.km.text = str(self.katrain.game.root.komi)
if rules is not None:
self.rules_spinner.select_key(rules.strip())