general settings

This commit is contained in:
Sander Land committed 2020-05-29 23:12:04 +02:00
1 parent d62fc46626
commit bb0d0c9e57
11 files changed
+412 -74

No files matched your search

+8 -9
View File
@@ -222,7 +222,7 @@ class KaTrainGui(Screen, KaTrainBase):
def _do_timer_popup(self):
self.controls.timer.paused = True
if not self.timer_settings_popup:
self.timer_settings_popup = I18NPopup(title_key="timer settings", size=[450, 450], content=ConfigTimerPopup(self)).__self__
self.timer_settings_popup = I18NPopup(title_key="timer settings", size=[350, 350], content=ConfigTimerPopup(self)).__self__
self.timer_settings_popup.content.popup = self.timer_settings_popup
self.timer_settings_popup.open()
@@ -233,6 +233,13 @@ class KaTrainGui(Screen, KaTrainBase):
self.teacher_settings_popup.content.popup = self.teacher_settings_popup
self.teacher_settings_popup.open()
def _do_config_popup(self):
self.controls.timer.paused = True
if not self.config_popup:
self.config_popup = I18NPopup(title_key="general settings title", size=[1200, 800], content=ConfigPopup(self)).__self__
self.config_popup.content.popup = self.config_popup
self.config_popup.open()
# todo pop
def _do_analyze_sgf_popup(self):
@@ -256,14 +263,6 @@ class KaTrainGui(Screen, KaTrainBase):
popup_contents.filesel.on_submit = readfile
self.fileselect_popup.open()
def _do_config_popup(self):
self.controls.timer.paused = True
if not self.config_popup:
self.config_popup = Popup(title=f"Edit Settings - {self.config_file}", size_hint=(0.9, 0.9)).__self__
popup_contents = ConfigPopup(self, self.config_popup, dict(self._config), ignore_cats=("trainer", "ai"))
self.config_popup.add_widget(popup_contents)
self.config_popup.open()
def _do_ai_popup(self):
self.controls.timer.paused = True
if not self.ai_settings_popup: # persist state of popup etc
+1 -1
View File
@@ -40,7 +40,7 @@ def find_package_resource(path):
print(f"File {path} not found, installation possibly broken", file=sys.stderr)
return f"FILENOTFOUND::{path}"
else:
return path # absolute path
return os.path.abspath(os.path.expanduser(path)) # absolute path
class Lang(Observable):
+1 -1
View File
@@ -241,7 +241,7 @@ class BadukPanWidget(Widget):
nodes = katrain.game.current_node.nodes_from_root
realized_points_lost = None
katrain.config("teacher/show_dots")
katrain.config("trainer/show_dots")
for i, node in enumerate(nodes[::-1]): # reverse order!
points_lost = node.points_lost
evalsize = 1
+17 -6
View File
@@ -1,5 +1,5 @@
from collections import defaultdict
import re
import re, os
from typing import Dict, Tuple, Any, Union, List
from kivy.clock import Clock
@@ -13,7 +13,7 @@ from kivymd.uix.textfield import MDTextField
from katrain.core.constants import OUTPUT_ERROR, OUTPUT_DEBUG, OUTPUT_INFO
from katrain.core.engine import KataGoEngine
from katrain.core.utils import i18n
from katrain.core.utils import i18n, find_package_resource
from katrain.gui.kivyutils import StyledSpinner, BackgroundMixin
from katrain.gui.style import DEFAULT_FONT, EVAL_COLORS
@@ -32,6 +32,16 @@ class LabelledTextInput(MDTextField):
return self.text
class LabelledPathInput(LabelledTextInput):
def on_text(self, widget, text, **kwargs):
self.error = not os.path.exists(find_package_resource(self.input_value))
return super().on_text(widget, text, **kwargs)
@property
def input_value(self):
return self.text.strip().replace("\n", " ").replace("\r", " ")
class LabelledCheckBox(MDCheckbox):
input_property = StringProperty("")
@@ -110,7 +120,7 @@ class QuickConfigGui(MDBoxLayout):
ret[k] = v
return ret
def get_setting(self, key) -> Tuple[Any,Union[Dict,List],str]:
def get_setting(self, key) -> Tuple[Any, Union[Dict, List], str]:
keys = key.split("/")
config = self.katrain._config
for k in keys[:-1]:
@@ -196,14 +206,14 @@ def wrap_anchor(widget):
class ConfigTeacherPopup(QuickConfigGui):
def __init__(self, katrain):
self.build()
super().__init__(katrain)
Clock.schedule_once(self.build, 0)
def add_option_widgets(self, widgets):
for widget in widgets:
self.options_grid.add_widget(wrap_anchor(widget))
def build(self):
def build(self, _dt):
undos = self.katrain.config("trainer/num_undo_prompts")
thresholds = self.katrain.config("trainer/eval_thresholds")
savesgfs = self.katrain.config("trainer/save_feedback")
@@ -212,13 +222,14 @@ class ConfigTeacherPopup(QuickConfigGui):
for i, (color, threshold, undo, show_dot, savesgf) in enumerate(zip(EVAL_COLORS, thresholds, undos, show_dots, savesgfs)):
self.add_option_widgets(
[
BackgroundMixin(background_color=color[:3]),
BackgroundMixin(background_color=color, size_hint=[0.9, 0.9]),
LabelledFloatInput(text=str(threshold), input_property=f"trainer/eval_thresholds::{i}"),
LabelledFloatInput(text=str(undo), input_property=f"trainer/num_undo_prompts::{i}"),
LabelledCheckBox(text=str(show_dot), input_property=f"trainer/show_dots::{i}"),
LabelledCheckBox(text=str(savesgf), input_property=f"trainer/save_feedback::{i}"),
]
)
self.set_properties(self)
class ConfigPopup(QuickConfigGui):
Binary file not shown.
+72 -9
View File
@@ -278,16 +278,15 @@ msgstr "Note that handicaps above 9 are not supported on non-square boards."
msgid "new game"
msgstr "Start New Game"
# teacher settings from here
msgstr "teacher settings"
msgid "Edit Teacher Settings"
msgid "teacher settings"
msgstr "Edit Teacher Settings"
msgid "point loss threshold"
msgstr "Point loss greater than"
msgid "num undos"
msgstr "Number of undos"
msgstr "Number of undos per mistake"
msgid "num undos"
msgstr "Number of undos"
@@ -302,22 +301,86 @@ msgid "save dots"
msgstr "Save in SGF"
msgid "show last n dots"
msgstr "Show dots for the last <this many> moves"
msgstr ""
"Show dots for the last\n"
"<this many> moves"
msgid "show ai dots"
msgstr "Show dots/SGF comments for AI players"
msgstr ""
"Show dots/SGF comments\n"
" for AI players"
msgid "lock ai when teaching"
msgstr "Disable analysis while in teach mode"
msgstr ""
"Disable analysis\n"
" while in teach mode"
#. submit button
msgid "update teacher"
msgstr "Update Teaching Game Settings"
msgstr "Update Feedback Settings"
#main config settings
# main config settings
msgid "restarting engine"
msgstr "Restarting Engine after Settings Change."
# title
msgid "general settings title"
msgstr "General and Engine Settings"
msgid "file not found"
msgstr "Path does not exist"
msgid "general settings"
msgstr "General Settings"
msgid "engine settings"
msgstr "KataGo Engine Settings"
msgid "engine:katago"
msgstr "Path to KataGo executable"
msgid "engine:katago:hint"
msgstr "Leave blank to use included executable"
msgid "engine:model"
msgstr "Path to KataGo model file"
msgid "engine:config"
msgstr "Path to KataGo config file"
msgid "engine:config"
msgstr "Path to KataGo config file"
msgid "engine:max_visits"
msgstr "Maximum number of visits in analysis"
msgid "engine:fast_visits"
msgstr "Maximum number of visits in fast analysis"
msgid "engine:max_time"
msgstr "Maximum time for analysis"
msgid "engine:time:hint"
msgstr "Time in seconds"
msgid "general:sgf_load"
msgstr "Path for loading SGF files"
msgid "general:sgf_save"
msgstr "Path for saving SGF files"
msgid "general:anim_pv_time"
msgstr "Time between moves when animating a sequence"
msgid "general:debug_level"
msgstr "Debug level in the console"
msgid "general:debug_level:hint"
msgstr "Set to 1 when reporting errors"
msgid "update settings"
msgstr "Update Settings"
#. misc errors and info messages
msgid "sgf written"
msgstr "SGF with analysis written to {file_name}"
Binary file not shown.
@@ -482,3 +482,123 @@ msgstr ""
#. TODO
msgid "ai:p:territory"
msgstr "Respond Locally"
#. TODO
msgid "save dots"
msgstr "Save in SGF"
#. TODO
msgid "num undos"
msgstr "Number of undos"
#. TODO
msgid "teacher settings"
msgstr "Edit Teacher Settings"
#. TODO
msgid "show dots"
msgstr "Show dots"
#. TODO
msgid "point loss threshold"
msgstr "Point loss greater than"
#. TODO
msgid "dot color"
msgstr "Colour (fixed)"
#. TODO
msgid "show ai dots"
msgstr "Show dots/SGF comments for AI players"
#. TODO
msgid "restarting engine"
msgstr "Restarting Engine after Settings Change."
#. TODO
msgid "lock ai when teaching"
msgstr "Disable analysis while in teach mode"
#. TODO
msgid "show last n dots"
msgstr "Show dots for the last <this many> moves"
#. TODO
msgid "update teacher"
msgstr "Update Teaching Game Settings"
#. TODO
msgid "engine:max_visits"
msgstr "Maximum number of visits in analysis"
#. TODO
msgid "general settings"
msgstr "General Settings"
#. TODO
msgid "update settings"
msgstr "Update Settings"
#. TODO
msgid "engine:max_time"
msgstr "Maximum time for analysis"
#. TODO
msgid "engine:fast_visits"
msgstr "Maximum number of visits in fast analysis"
#. TODO
msgid "engine:config"
msgstr "Path to KataGo config file"
#. TODO
msgid "general:sgf_save"
msgstr "Path for saving SGF files"
#. TODO
msgid "general:sgf_load"
msgstr "Path for loading SGF files"
#. TODO
msgid "general:debug_level"
msgstr "Debug level in the console"
#. TODO
msgid "general settings title"
msgstr "General and Engine Settings"
#. TODO
msgid "engine settings"
msgstr "KataGo Engine Settings"
#. TODO
msgid "engine:model"
msgstr "Path to KataGo model file"
#. TODO
msgid "general:anim_pv_time"
msgstr "Time between moves when animating a sequence"
#. TODO
msgid "engine:katago"
msgstr "Path to KataGo executable"
#. TODO
msgid "general:debug_level:hint"
msgstr "Use 0 for little output, 1 for getting details when reporting errors"
#. TODO
msgid "engine:max_time:hint"
msgstr "Time in seconds"
#. TODO
msgid "engine:time:hint"
msgstr "Time in seconds"
#. TODO
msgid "engine:katago:hint"
msgstr "Leave blank to use included executable"
#. TODO
msgid "file not found"
msgstr "Path does not exist"
Binary file not shown.
@@ -514,3 +514,123 @@ msgstr ""
#. TODO
msgid "ai:p:territory"
msgstr "Respond Locally"
#. TODO
msgid "save dots"
msgstr "Save in SGF"
#. TODO
msgid "num undos"
msgstr "Number of undos"
#. TODO
msgid "teacher settings"
msgstr "Edit Teacher Settings"
#. TODO
msgid "show dots"
msgstr "Show dots"
#. TODO
msgid "point loss threshold"
msgstr "Point loss greater than"
#. TODO
msgid "dot color"
msgstr "Colour (fixed)"
#. TODO
msgid "show ai dots"
msgstr "Show dots/SGF comments for AI players"
#. TODO
msgid "restarting engine"
msgstr "Restarting Engine after Settings Change."
#. TODO
msgid "lock ai when teaching"
msgstr "Disable analysis while in teach mode"
#. TODO
msgid "show last n dots"
msgstr "Show dots for the last <this many> moves"
#. TODO
msgid "update teacher"
msgstr "Update Teaching Game Settings"
#. TODO
msgid "engine:max_visits"
msgstr "Maximum number of visits in analysis"
#. TODO
msgid "general settings"
msgstr "General Settings"
#. TODO
msgid "update settings"
msgstr "Update Settings"
#. TODO
msgid "engine:max_time"
msgstr "Maximum time for analysis"
#. TODO
msgid "engine:fast_visits"
msgstr "Maximum number of visits in fast analysis"
#. TODO
msgid "engine:config"
msgstr "Path to KataGo config file"
#. TODO
msgid "general:sgf_save"
msgstr "Path for saving SGF files"
#. TODO
msgid "general:sgf_load"
msgstr "Path for loading SGF files"
#. TODO
msgid "general:debug_level"
msgstr "Debug level in the console"
#. TODO
msgid "general settings title"
msgstr "General and Engine Settings"
#. TODO
msgid "engine settings"
msgstr "KataGo Engine Settings"
#. TODO
msgid "engine:model"
msgstr "Path to KataGo model file"
#. TODO
msgid "general:anim_pv_time"
msgstr "Time between moves when animating a sequence"
#. TODO
msgid "engine:katago"
msgstr "Path to KataGo executable"
#. TODO
msgid "general:debug_level:hint"
msgstr "Use 0 for little output, 1 for getting details when reporting errors"
#. TODO
msgid "engine:max_time:hint"
msgstr "Time in seconds"
#. TODO
msgid "engine:time:hint"
msgstr "Time in seconds"
#. TODO
msgid "engine:katago:hint"
msgstr "Leave blank to use included executable"
#. TODO
msgid "file not found"
msgstr "Path does not exist"
+73 -48
View File
@@ -26,11 +26,19 @@
hint_text: ""
helper_text: ""
<LabelledPathInput>:
font_size: dp(16)
multiline: True # just for wrapping
helper_text_mode: "on_error"
<LabelledIntInput>:
font_size: INPUT_FONT_SIZE
size_hint: 0.5, None
<LabelledFloatInput>:
font_size: INPUT_FONT_SIZE
size_hint: 0.5, None
<LabelledCheckBox>:
color: WHITE
@@ -43,7 +51,7 @@
font_size: DESC_FONT_SIZE
<I18NPopup>:
#background_color: [*[c*255/66 for c in BACKGROUND_COLOR[:3]], 1]
background_color: [*[c*255/66 for c in BACKGROUND_COLOR[:3]], 1]
title: i18n._(self.title_key)
title_size: DESC_FONT_SIZE
title_font: self.font_name
@@ -67,6 +75,7 @@
<ConfigPopup>:
BoxLayout:
size_hint: 1,9
orientation: 'horizontal'
GridLayout:
cols: 2
@@ -74,28 +83,44 @@
spacing: CP_SPACING
Label:
Label:
text: 'engine'
text: i18n._('General Settings')
DescriptionLabel:
text: i18n._("general:sgf_load")
multiline: True
font_size: DESC_FONT_SIZE * 0.8
AnchorLayout:
LabelledTextInput:
LabelledPathInput:
input_property: "general/sgf_load" # just last load dir?
multiline: True
font_size: DESC_FONT_SIZE * 0.8
DescriptionLabel:
text: i18n._("general:sgf_save")
AnchorLayout:
LabelledTextInput:
LabelledPathInput:
input_property: "general/sgf_save"
multiline: True
font_size: DESC_FONT_SIZE * 0.8
DescriptionLabel:
text: i18n._("general:anim_pv_time")
AnchorLayout:
LabelledFloatInput:
input_property: "general/anim_pv_time"
helper_text: i18n._("engine:time:hint")
DescriptionLabel:
text: i18n._("general:debug_level")
AnchorLayout:
LabelledIntInput:
input_property: "general/debug_level"
BackgroundMixing:
helper_text: i18n._("general:debug_level:hint")
Label:
Label:
Label:
Label:
Label:
Label:
Label:
Label:
BackgroundMixin:
background_color: LIGHTGREY
size_hint: None, 1
width: 2
@@ -105,37 +130,41 @@
spacing: CP_SPACING
Label:
Label:
text: 'engine'
text: i18n._('Engine Settings')
DescriptionLabel:
text: i18n._("engine:katago")
AnchorLayout:
LabelledTextInput:
LabelledPathInput:
input_property: "engine/katago"
hint_text: i18n._("engine:katago:hint")
helper_text: i18n._("file not found")
DescriptionLabel:
text: i18n._("engine:model")
AnchorLayout:
LabelledTextInput:
LabelledPathInput:
input_property: "engine/model"
DescriptionLabel:
text: i18n._("engine:config")
AnchorLayout:
LabelledTextInput:
LabelledPathInput:
input_property: "engine/config"
DescriptionLabel:
text: i18n._("engine:max_visits")
AnchorLayout:
LabelledIntInput:
input_property: "engine/max_visits"
DescriptionLabel:
text: i18n._("engine:fast_visits")
AnchorLayout:
LabelledIntInput:
input_property: "engine/fast_visits"
DescriptionLabel:
text: i18n._("engine:max_time")
AnchorLayout:
LabelledFloatInput:
input_property: "engine/fast_visits"
DescriptionLabel:
text: i18n._("engine:fast_visits")
AnchorLayout:
LabelledFloatInput:
input_property: "engine/max_time"
helper_text: i18n._("engine:time:hint")
helper_text_mode: "on_focus"
DescriptionLabel:
text: i18n._("engine:threads")
AnchorLayout:
@@ -147,7 +176,7 @@
LabelledFloatInput:
input_property: "engine/wide_root_noise"
AnchorLayout:
size_hint: 1,1
size_hint: 1,1.5
AutoSizedRoundedRectangleButton:
padding_x: 15
size_hint: None,0.5
@@ -171,32 +200,34 @@
text: i18n._("show dots")
DescriptionLabel:
text: i18n._("save dots")
GridLayout:
cols: 2
rows: 3
size_hint: 1, 3
DescriptionLabel:
text: i18n._("show last n dots")
AnchorLayout:
LabelledIntInput:
input_property: "trainer/eval_off_show_last"
DescriptionLabel:
text: i18n._("show ai dots")
AnchorLayout:
LabelledIntInput:
input_property: "trainer/eval_off_show_last"
DescriptionLabel:
text: i18n._("show last n dots")
AnchorLayout:
LabelledIntInput:
input_property: "trainer/eval_show_ai"
DescriptionLabel:
text: i18n._("lock ai when teaching")
AnchorLayout:
LabelledCheckBox:
input_property: "trainer/lock_ai"
AnchorLayout:
size_hint: 1,1
size_hint: 1, 3
GridLayout:
cols: 2
rows: 3
padding: 4
size_hint: 0.66, 1
DescriptionLabel:
text: i18n._("show last n dots")
size_hint: 2,1
AnchorLayout:
LabelledIntInput:
size_hint: 0.33, 1
input_property: "trainer/eval_off_show_last"
DescriptionLabel:
size_hint: 2,1
text: i18n._("show ai dots")
AnchorLayout:
LabelledCheckBox:
input_property: "trainer/eval_show_ai"
DescriptionLabel:
size_hint: 2,1
text: i18n._("lock ai when teaching")
AnchorLayout:
LabelledCheckBox:
input_property: "trainer/lock_ai"
AnchorLayout:
size_hint: 1,1.5
AutoSizedRoundedRectangleButton:
padding_x: 15
size_hint: None,0.5
@@ -207,7 +238,7 @@
<ConfigTimerPopup>:
MDGridLayout:
cols: 2
rows: 3
rows: 2
spacing: CP_SPACING
size_hint: 1,2
DescriptionLabel:
@@ -222,13 +253,6 @@
LabelledIntInput:
text: "5"
input_property: "timer/byo_periods"
DescriptionLabel:
text: 'test'
AnchorLayout:
LabelledTextInput:
value: i18n._('byoyomi periods')
hint_text: i18n._('byoyomi periods')
helper_text: i18n._('byoyomi length')
AnchorLayout:
size_hint: 1,1
AutoSizedRoundedRectangleButton:
@@ -258,6 +282,7 @@
text: '19'
id: boardsize
input_property: 'game/size'
size_hint: 0.5, None
AnchorLayout:
MDBoxLayout:
adaptive_size: True