timer start, py3.8 support

This commit is contained in:
Sander Land committed 2020-05-18 19:25:22 +02:00
1 parent 51dfcee774
commit 78bab1c6d8
11 files changed
+101 -16

No files matched your search

+3 -3
View File
@@ -3,10 +3,10 @@ This repository includes:
1. Binaries for 'KataGo', which is Copyright 2019 David J Wu et al. 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 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: 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 - New game/Load game/Config/Config clock icons: made by Freepik from www.flaticon.com
- Save icon: made by Pixel perfect 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 - 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: Aside from the above, the license for all other content in this repository is as follows:
---------------------------------------- ----------------------------------------
+58 -6
View File
@@ -7,6 +7,7 @@
#:set BUTTON_COLOR [0.23, 0.30, 0.35, 1] #:set BUTTON_COLOR [0.23, 0.30, 0.35, 1]
#:set TOOLTIP_COLOR [0.43, 0.50, 0.65, 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 [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 BOARD_COLOR [0.85, 0.68, 0.40,1]
#:set GRAPH_DOT_COLOR [0.85, 0.3, 0.3,1] #:set GRAPH_DOT_COLOR [0.85, 0.3, 0.3,1]
#:set BLACK [0.05,0.05,0.05,1] #:set BLACK [0.05,0.05,0.05,1]
@@ -112,8 +113,9 @@
color: WHITE color: WHITE
<StyledIconButton@StyledButton+ToolTipBehavior>: <StyledIconButton@StyledButton>:
button_color: ICON_BUTTON_COLOR button_color: ICON_BUTTON_COLOR
button_color_down: ICON_BUTTON_COLOR_DOWN
icon_margin: 0.15 * self.size[0] icon_margin: 0.15 * self.size[0]
icon: '' icon: ''
icon_size: min(self.size[0]-2*self.icon_margin,self.size[1]-2*self.icon_margin) icon_size: min(self.size[0]-2*self.icon_margin,self.size[1]-2*self.icon_margin)
@@ -123,6 +125,8 @@
source: root.icon source: root.icon
mipmap: True mipmap: True
<StyledIconStyledToggleButton@StyledIconButton+ToggleButtonBehavior>:
<TransparentIconButton@Button>: <TransparentIconButton@Button>:
background_normal: '' background_normal: ''
background_color: (0,0,0,0) background_color: (0,0,0,0)
@@ -144,9 +148,17 @@
<LargeLabel@DarkLabel>: <LargeLabel@DarkLabel>:
bold: True bold: True
<TimerLabel@Label>
color: BLACK
text_size: self.size
font_size: 0.9*self.size[1]
halign: 'right'
valign: 'center'
font_name: 'img/fonts/digital-7.ttf'
<ScaledLightLabel>: # popups <ScaledLightLabel>: # popups
color: WHITE color: WHITE
font_size: 0.45*self.size[1] font_size: 0.45*self.size[1]/self.num_lines
<LightHelpLabel>: <LightHelpLabel>:
font_size: self.size[1]/10 font_size: self.size[1]/10
@@ -601,14 +613,54 @@
text: 'Configure AIs' text: 'Configure AIs'
tooltip_text: "Strength Settings per AI" tooltip_text: "Strength Settings per AI"
on_press: if not self.last_touch or self.last_touch.button=="left": root.configure_ais() on_press: if not self.last_touch or self.last_touch.button=="left": root.configure_ais()
LargeLabel: BoxLayout:
text: '' size_hint: 1,0.10
size_hint: 1,0.2 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: CensorableLabel:
id: score_change id: score_change
size_hint: 1, 0.024 size_hint: 1, 0.024
label: 'Points Lost' label: 'Points Lost'
text: '' text: '-'
BoxLayout: BoxLayout:
size_hint: 1,0.2 size_hint: 1,0.2
orientation: 'vertical' orientation: 'vertical'
+12 -4
View File
@@ -1,7 +1,7 @@
from kivy.uix.boxlayout import BoxLayout from kivy.uix.boxlayout import BoxLayout
from kivy.uix.popup import Popup from kivy.uix.popup import Popup
from katrain.gui.popups import ConfigAIPopup, ConfigTeacherPopup from katrain.gui.popups import ConfigAIPopup, ConfigTeacherPopup, ConfigTimerPopup
class Controls(BoxLayout): class Controls(BoxLayout):
@@ -12,6 +12,7 @@ class Controls(BoxLayout):
self.ai_settings_popup = None self.ai_settings_popup = None
self.teacher_settings_popup = None self.teacher_settings_popup = None
self.active_comment_node = None self.active_comment_node = None
self.timer_settings_popup = None
def set_status(self, msg, at_node=None): def set_status(self, msg, at_node=None):
self.status = msg 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 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 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.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: elif not current_player_is_ai_playing_human:
self.score_change.label = f"Points lost" 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: elif current_player_is_ai_playing_human and current_node.parent and current_node.parent.move:
points_lost = current_node.parent.points_lost 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.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: elif both_players_are_robots and current_node.parent and current_node.parent.analysis_ready:
self.score.text = current_node.parent.format_score() self.score.text = current_node.parent.format_score()
self.win_rate.text = current_node.parent.format_win_rate() 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 = 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.add_widget(ConfigTeacherPopup(self.katrain, self.teacher_settings_popup))
self.teacher_settings_popup.open() 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()
+1 -1
View File
@@ -64,7 +64,7 @@ class DarkLabel(Label):
class ScaledLightLabel(DarkLabel): class ScaledLightLabel(DarkLabel):
pass num_lines = NumericProperty(1)
class LightHelpLabel(ScaledLightLabel): class LightHelpLabel(ScaledLightLabel):
+24
View File
@@ -320,3 +320,27 @@ class ConfigTeacherPopup(QuickConfigGui):
return return
self.katrain.update_state() self.katrain.update_state()
self.popup.dismiss() 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()
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.
Binary file not shown.
+3 -2
View File
@@ -36,14 +36,15 @@ setup(
url="https://github.com/sanderland/katrain", url="https://github.com/sanderland/katrain",
license="MIT", license="MIT",
install_requires=[ 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.glew;platform_system=='Windows'",
"kivy_deps.sdl2;platform_system=='Windows'", "kivy_deps.sdl2;platform_system=='Windows'",
"kivy_deps.gstreamer;platform_system=='Windows'", "kivy_deps.gstreamer;platform_system=='Windows'",
"importlib_resources ;python_version<'3.7'", "importlib_resources ;python_version<'3.7'",
"wheel", "wheel",
], ],
python_requires=">=3.6, <3.8", python_requires=">=3.6, <4",
entry_points={"console_scripts": ["katrain=katrain.__main__:run_app"]}, 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"], classifiers=["Development Status :: 4 - Beta", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3"],
packages=packages, packages=packages,