fiddling some more

This commit is contained in:
Sander Land committed 2020-04-19 19:29:04 +02:00
1 parent 0f8393bb2e
commit 2054445b72
4 files changed
+35 -22

No files matched your search

+18 -21
View File
@@ -52,7 +52,7 @@
source: root.icon source: root.icon
<DarkLabel@Label>: <DarkLabel>:
color: (0.05,0.05,0.05,1) color: (0.05,0.05,0.05,1)
<LargeLabel@DarkLabel>: <LargeLabel@DarkLabel>:
@@ -127,10 +127,10 @@
id: value id: value
bold: True bold: True
<BaseCircleWithText@DarkLabel> <BaseCircleWithText>
text: '' text: ''
color: 0.95,0.95,0.95,1 color: 0.95,0.95,0.95,1
font_size: min(self.height,self.width) * 0.6 font_size: min(self.height,self.width) * 0.6 / (0.5 + 0.5 * len(self.text))
halign: 'center' halign: 'center'
valign: 'center' valign: 'center'
bold: True bold: True
@@ -140,23 +140,23 @@
Color: Color:
rgba: 0.05,0.05,0.05,1 rgba: 0.05,0.05,0.05,1
Ellipse: Ellipse:
pos: self.pos[0] + self.width/2 - min(self.height,self.width) * 0.48, self.pos[1] + self.height/2 - min(self.height,self.width) * 0.48 pos: self.pos[0] + self.width/2 - min(self.height,self.width) * root.radius, self.pos[1] + self.height/2 - min(self.height,self.width) * root.radius
size: min(self.height,self.width) * 0.96, min(self.height,self.width) * 0.96 size: min(self.height,self.width) * 2 * root.radius, min(self.height,self.width) * 2* root.radius
<WhiteCircleWithText@BaseCircleWithText> <WhiteCircleWithText@BaseCircleWithText+ButtonBehavior>
color: 0.05,0.05,0.05,1 color: 0.05,0.05,0.05,1
outline: True outline: True
canvas.before: canvas.before:
Color: Color:
rgba: 0.95,0.95,0.95,1 rgba: 0.95,0.95,0.95,1
Ellipse: Ellipse:
pos: self.pos[0] + self.width/2 - min(self.height,self.width) * 0.48, self.pos[1] + self.height/2 - min(self.height,self.width) * 0.48 pos: self.pos[0] + self.width/2 - min(self.height,self.width) * root.radius, self.pos[1] + self.height/2 - min(self.height,self.width) * root.radius
size: min(self.height,self.width) * 0.96, min(self.height,self.width) * 0.96 size: min(self.height,self.width) * 2 * root.radius, min(self.height,self.width) * 2 * root.radius
canvas.after: canvas.after:
Color: Color:
rgba: 0.05,0.05,0.05,1 rgba: 0.05,0.05,0.05,1
Line: Line:
circle: self.pos[0] + self.width/2, self.pos[1] + self.height/2, min(self.height,self.width)*0.47 circle: self.pos[0] + self.width/2, self.pos[1] + self.height/2, min(self.height,self.width) * root.radius - 1
width: 1.1 if root.outline else 0.0001 width: 1.1 if root.outline else 0.0001
<BadukPanWidget>: <BadukPanWidget>:
@@ -168,6 +168,7 @@
katrain: self.parent.parent katrain: self.parent.parent
black_prisoners: black_prisoners black_prisoners: black_prisoners
white_prisoners: white_prisoners white_prisoners: white_prisoners
mid_circles_container: mid_circles_container
pass_btn: pass_btn pass_btn: pass_btn
canvas.before: canvas.before:
Color: Color:
@@ -200,17 +201,17 @@
margin: (3, self.size[1]/3, 3, self.size[1]/3) margin: (3, self.size[1]/3, 3, self.size[1]/3)
size_hint: 0.1, 1 size_hint: 0.1, 1
on_press: root.katrain('undo') on_press: root.katrain('undo')
BoxLayout: FloatLayout:
size_hint: 0.25, 1 size_hint: 0.2, 1
id: mid_circles_container
BlackCircleWithText: BlackCircleWithText:
id: black_prisoners id: black_prisoners
size_hint: 0.3,1 pos: (self.parent.pos[0]-self.height/3,self.parent.pos[1]) if self.parent else (0,0)
text: '0' radius: 0.4
WhiteCircleWithText: WhiteCircleWithText:
id: white_prisoners id: white_prisoners
size_hint: 0.3,1 pos: (self.parent.pos[0]+self.height/3,self.parent.pos[1]) if self.parent else (0,0)
text: '0' radius: 0.4
outline: False
TransparentIconButton: TransparentIconButton:
icon: 'img/flaticon/next.png' icon: 'img/flaticon/next.png'
margin: (3, self.size[1]/3, 3, self.size[1]/3) margin: (3, self.size[1]/3, 3, self.size[1]/3)
@@ -394,13 +395,9 @@
size_hint: 1, 0.03 size_hint: 1, 0.03
label: 'Point loss' label: 'Point loss'
text: '...' text: '...'
GridLayout:
cols: 2
rows: 1
size_hint: 1, 0.05
TextInput: TextInput:
id: info id: info
size_hint: 1, 0.2 size_hint: 1, 0.25
valign: 'middle' valign: 'middle'
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
+1
View File
@@ -7,6 +7,7 @@ from gui.kivyutils import (
LabelledFloatInput, LabelledFloatInput,
LabelledIntInput, LabelledIntInput,
StyledButton, StyledButton,
DarkLabel,BaseCircleWithText,
LabelledSpinner, LabelledSpinner,
LabelledCheckBox, LabelledCheckBox,
LabelledTextInput, LabelledTextInput,
+7 -1
View File
@@ -1,11 +1,12 @@
from kivy.core.text import Label as CoreLabel from kivy.core.text import Label as CoreLabel
from kivy.graphics import * from kivy.graphics import *
from kivy.properties import BooleanProperty, StringProperty from kivy.properties import BooleanProperty, StringProperty, NumericProperty
from kivy.uix.boxlayout import BoxLayout from kivy.uix.boxlayout import BoxLayout
import re import re
from kivy.uix.button import Button from kivy.uix.button import Button
from kivy.uix.checkbox import CheckBox from kivy.uix.checkbox import CheckBox
from kivy.uix.label import Label
from kivy.uix.spinner import Spinner from kivy.uix.spinner import Spinner
from kivy.uix.textinput import TextInput from kivy.uix.textinput import TextInput
@@ -24,6 +25,11 @@ class CheckBoxHint(BoxLayout):
def on_active(self, *args): def on_active(self, *args):
pass pass
class DarkLabel(Label):
pass
class BaseCircleWithText(DarkLabel):
radius = NumericProperty(0.48)
class LabelledTextInput(TextInput): class LabelledTextInput(TextInput):
input_property = StringProperty("") input_property = StringProperty("")
+9
View File
@@ -80,16 +80,25 @@ class KaTrainGui(BoxLayout):
self._do_new_game() self._do_new_game()
def update_state(self, redraw_board=False): def update_state(self, redraw_board=False):
# AI and Trainer/auto-undo handlers
cn = self.game.current_node cn = self.game.current_node
if cn.analysis_ready and self.controls.ai_auto.active(cn.next_player) and not cn.children and not self.game.game_ended: if cn.analysis_ready and self.controls.ai_auto.active(cn.next_player) and not cn.children and not self.game.game_ended:
self("ai-move", cn) self("ai-move", cn)
if cn.analysis_ready and self.controls.auto_undo.active(cn.next_player): if cn.analysis_ready and self.controls.auto_undo.active(cn.next_player):
self.game.analyze_undo(cn, self.config("trainer")) # not via message loop self.game.analyze_undo(cn, self.config("trainer")) # not via message loop
# Handle prisoners and next player display
prisoners = self.game.prisoner_count prisoners = self.game.prisoner_count
top,bot = self.board_controls.black_prisoners,self.board_controls.white_prisoners
if self.game.next_player == 'W':
top, bot = bot,top
self.board_controls.mid_circles_container.clear_widgets()
self.board_controls.mid_circles_container.add_widget(bot)
self.board_controls.mid_circles_container.add_widget(top)
self.board_controls.black_prisoners.text = str(prisoners[1]) self.board_controls.black_prisoners.text = str(prisoners[1])
self.board_controls.white_prisoners.text = str(prisoners[0]) self.board_controls.white_prisoners.text = str(prisoners[0])
# Update board and status
if redraw_board: if redraw_board:
Clock.schedule_once(self.board_gui.draw_board, -1) # main thread needs to do this Clock.schedule_once(self.board_gui.draw_board, -1) # main thread needs to do this
Clock.schedule_once(self.board_gui.draw_board_contents, -1) Clock.schedule_once(self.board_gui.draw_board_contents, -1)