diff --git a/LICENSE b/LICENSE index 89e8964..5ee9bb9 100644 --- a/LICENSE +++ b/LICENSE @@ -3,10 +3,10 @@ This repository includes: 1. Binaries for 'KataGo', which is Copyright 2019 David J Wu et al. For on related licenses for these binaries and libraries see https://github.com/lightvector/KataGo 2. Icons from www.flaticon.com, used with permission with the following attributions: -- New game/Load game/Config icons: made by Freepik from www.flaticon.com -- Save icon: made by Pixel perfect from www.flaticon.com +- New game/Load game/Config/Config clock icons: made by Freepik from www.flaticon.com +- Save icon, Pause Icon: made by Pixel perfect from www.flaticon.com - Next/Previous icons: made by/derived from ones made by RoundIcons from www.flaticon.com - +3. The True Type Font: DIGITAL-7 version 1.02 by Sizenko Alexander, which is free for non-commercial use. Aside from the above, the license for all other content in this repository is as follows: ---------------------------------------- diff --git a/katrain/gui.kv b/katrain/gui.kv index a295864..01372bc 100644 --- a/katrain/gui.kv +++ b/katrain/gui.kv @@ -7,6 +7,7 @@ #:set BUTTON_COLOR [0.23, 0.30, 0.35, 1] #:set TOOLTIP_COLOR [0.43, 0.50, 0.65, 1] #:set ICON_BUTTON_COLOR [0.71, 0.78, 0.81, 1] +#:set ICON_BUTTON_COLOR_DOWN [0.51, 0.58, 0.51, 1] #:set BOARD_COLOR [0.85, 0.68, 0.40,1] #:set GRAPH_DOT_COLOR [0.85, 0.3, 0.3,1] #:set BLACK [0.05,0.05,0.05,1] @@ -112,8 +113,9 @@ color: WHITE -: +: button_color: ICON_BUTTON_COLOR + button_color_down: ICON_BUTTON_COLOR_DOWN icon_margin: 0.15 * self.size[0] icon: '' icon_size: min(self.size[0]-2*self.icon_margin,self.size[1]-2*self.icon_margin) @@ -123,6 +125,8 @@ source: root.icon mipmap: True +: + : background_normal: '' background_color: (0,0,0,0) @@ -144,9 +148,17 @@ : bold: True + + color: BLACK + text_size: self.size + font_size: 0.9*self.size[1] + halign: 'right' + valign: 'center' + font_name: 'img/fonts/digital-7.ttf' + : # popups color: WHITE - font_size: 0.45*self.size[1] + font_size: 0.45*self.size[1]/self.num_lines : font_size: self.size[1]/10 @@ -601,14 +613,54 @@ text: 'Configure AIs' tooltip_text: "Strength Settings per AI" on_press: if not self.last_touch or self.last_touch.button=="left": root.configure_ais() - LargeLabel: - text: '' - size_hint: 1,0.2 + BoxLayout: + size_hint: 1,0.10 + padding: 5,5 + spacing: 3 + BoxLayout: + orientation: 'vertical' + size_hint: 0.15,1 + Label: + StyledIconButton: + height: self.width + size_hint: 1, None + icon: 'img/flaticon/cogwheel.png' + on_press: if not self.last_touch or self.last_touch.button=="left": root.configure_timer() + tooltip_text: "Configure timer" + Label: + Label: + size_hint: 0.025, 1 + TimerLabel: + size_hint: 0.45,1 + id: timer + text: '00:30' + DarkLabel: + size_hint: 0.1,1 + id: periods + text: 'x5' + font_size: self.width*0.75 + valign: 'top' + halign: 'left' + Label: + size_hint: 0.025, 1 + BoxLayout: + orientation: 'vertical' + size_hint: 0.15,1 + Label: + StyledIconStyledToggleButton: + height: self.width + size_hint: 1, None + icon_margin: 0.2 * self.size[0] + icon: 'img/flaticon/pause.png' + state: 'down' + Label: + Label: + size_hint: 1,0.1 CensorableLabel: id: score_change size_hint: 1, 0.024 label: 'Points Lost' - text: '' + text: '-' BoxLayout: size_hint: 1,0.2 orientation: 'vertical' diff --git a/katrain/gui/controls.py b/katrain/gui/controls.py index 7e78a45..42d3920 100644 --- a/katrain/gui/controls.py +++ b/katrain/gui/controls.py @@ -1,7 +1,7 @@ from kivy.uix.boxlayout import BoxLayout from kivy.uix.popup import Popup -from katrain.gui.popups import ConfigAIPopup, ConfigTeacherPopup +from katrain.gui.popups import ConfigAIPopup, ConfigTeacherPopup, ConfigTimerPopup class Controls(BoxLayout): @@ -12,6 +12,7 @@ class Controls(BoxLayout): self.ai_settings_popup = None self.teacher_settings_popup = None self.active_comment_node = None + self.timer_settings_popup = None def set_status(self, msg, at_node=None): self.status = msg @@ -78,14 +79,14 @@ class Controls(BoxLayout): if move and next_player_is_human_or_both_robots: # don't immediately hide this when an ai moves comes in points_lost = current_node.points_lost self.score_change.label = f"Points lost" if points_lost and points_lost > 0 else f"Points gained" - self.score_change.text = f"{move.player}: {abs(points_lost):.1f}" if points_lost else "..." + self.score_change.text = f"{move.player}: {abs(points_lost):.1f}" if points_lost else "-" elif not current_player_is_ai_playing_human: self.score_change.label = f"Points lost" - self.score_change.text = "" + self.score_change.text = "-" elif current_player_is_ai_playing_human and current_node.parent and current_node.parent.move: points_lost = current_node.parent.points_lost self.score_change.label = f"Points lost" if points_lost and points_lost > 0 else f"Points gained" - self.score_change.text = f"{current_node.parent.move.player}: {abs(points_lost):.1f}" if points_lost else "..." + self.score_change.text = f"{current_node.parent.move.player}: {abs(points_lost):.1f}" if points_lost else "-" elif both_players_are_robots and current_node.parent and current_node.parent.analysis_ready: self.score.text = current_node.parent.format_score() self.win_rate.text = current_node.parent.format_win_rate() @@ -105,3 +106,10 @@ class Controls(BoxLayout): self.teacher_settings_popup = Popup(title="Edit Teacher Settings", size_hint=(0.7, 0.8)).__self__ self.teacher_settings_popup.add_widget(ConfigTeacherPopup(self.katrain, self.teacher_settings_popup)) self.teacher_settings_popup.open() + + def configure_timer(self): + if not self.timer_settings_popup: + self.timer_settings_popup = Popup(title="Edit Timer Settings", size_hint=(0.4, 0.4)).__self__ + self.timer_settings_popup.add_widget(ConfigTimerPopup(self.katrain, self.timer_settings_popup)) + self.timer_settings_popup.open() + diff --git a/katrain/gui/kivyutils.py b/katrain/gui/kivyutils.py index 85286d8..9664d6c 100644 --- a/katrain/gui/kivyutils.py +++ b/katrain/gui/kivyutils.py @@ -64,7 +64,7 @@ class DarkLabel(Label): class ScaledLightLabel(DarkLabel): - pass + num_lines = NumericProperty(1) class LightHelpLabel(ScaledLightLabel): diff --git a/katrain/gui/popups.py b/katrain/gui/popups.py index 29f5748..7512315 100644 --- a/katrain/gui/popups.py +++ b/katrain/gui/popups.py @@ -320,3 +320,27 @@ class ConfigTeacherPopup(QuickConfigGui): return self.katrain.update_state() self.popup.dismiss() + + + +class ConfigTimerPopup(QuickConfigGui): + def __init__(self, katrain, popup, **kwargs): + self.settings = katrain.config("timer") + super().__init__(katrain, popup, self.settings, **kwargs) + Clock.schedule_once(self.build, 0) + self.spacing = 2 + + def build(self, _dt): + thrbox = GridLayout(spacing=1, padding=2, cols=2, rows=2,size_hint=(1,2)) + thrbox.add_widget(ScaledLightLabel(text="Byo-yomi\nperiod length (s)", bold=True,size_hint=(2,1),num_lines=2)) + thrbox.add_widget(LabelledIntInput(text='30', input_property="byo_length")) + thrbox.add_widget(ScaledLightLabel(text="Byo-yomi\nnumber of periods", bold=True,size_hint=(2,1),num_lines=2)) + thrbox.add_widget(LabelledIntInput(text='5', input_property="byo_num")) + self.add_widget(thrbox) + self.add_widget(StyledButton(text=f"Apply and Save", on_press=lambda _: self.update_config(True))) + + def update_config(self, save_to_file=False): + self.katrain.controls.timer_settings = self.collect_properties(self) + self.katrain.update_state() + self.popup.dismiss() + diff --git a/katrain/img/flaticon/cogwheel.png b/katrain/img/flaticon/cogwheel.png new file mode 100644 index 0000000..bece1e4 Binary files /dev/null and b/katrain/img/flaticon/cogwheel.png differ diff --git a/katrain/img/flaticon/confclock.png b/katrain/img/flaticon/confclock.png new file mode 100644 index 0000000..c80762d Binary files /dev/null and b/katrain/img/flaticon/confclock.png differ diff --git a/katrain/img/flaticon/pause.png b/katrain/img/flaticon/pause.png new file mode 100644 index 0000000..edac613 Binary files /dev/null and b/katrain/img/flaticon/pause.png differ diff --git a/katrain/img/fonts/digital-7 (mono).ttf b/katrain/img/fonts/digital-7 (mono).ttf new file mode 100644 index 0000000..a481b97 Binary files /dev/null and b/katrain/img/fonts/digital-7 (mono).ttf differ diff --git a/katrain/img/fonts/digital-7.ttf b/katrain/img/fonts/digital-7.ttf new file mode 100644 index 0000000..5dbe6f9 Binary files /dev/null and b/katrain/img/fonts/digital-7.ttf differ diff --git a/setup.py b/setup.py index b2f1d38..128a3c1 100644 --- a/setup.py +++ b/setup.py @@ -36,14 +36,15 @@ setup( url="https://github.com/sanderland/katrain", license="MIT", install_requires=[ - "kivy>=1.11", + "kivy>=1.11 ;python_version<'3.8'", + "kivy>=2.0.0rc2 ;python_version>='3.8'", "kivy_deps.glew;platform_system=='Windows'", "kivy_deps.sdl2;platform_system=='Windows'", "kivy_deps.gstreamer;platform_system=='Windows'", "importlib_resources ;python_version<'3.7'", "wheel", ], - python_requires=">=3.6, <3.8", + python_requires=">=3.6, <4", entry_points={"console_scripts": ["katrain=katrain.__main__:run_app"]}, classifiers=["Development Status :: 4 - Beta", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3"], packages=packages,