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
<DarkLabel@Label>:
<DarkLabel>:
color: (0.05,0.05,0.05,1)
<LargeLabel@DarkLabel>:
@@ -127,10 +127,10 @@
id: value
bold: True
<BaseCircleWithText@DarkLabel>
<BaseCircleWithText>
text: ''
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'
valign: 'center'
bold: True
@@ -140,23 +140,23 @@
Color:
rgba: 0.05,0.05,0.05,1
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
size: min(self.height,self.width) * 0.96, min(self.height,self.width) * 0.96
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) * 2 * root.radius, min(self.height,self.width) * 2* root.radius
<WhiteCircleWithText@BaseCircleWithText>
<WhiteCircleWithText@BaseCircleWithText+ButtonBehavior>
color: 0.05,0.05,0.05,1
outline: True
canvas.before:
Color:
rgba: 0.95,0.95,0.95,1
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
size: min(self.height,self.width) * 0.96, min(self.height,self.width) * 0.96
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) * 2 * root.radius, min(self.height,self.width) * 2 * root.radius
canvas.after:
Color:
rgba: 0.05,0.05,0.05,1
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
<BadukPanWidget>:
@@ -168,6 +168,7 @@
katrain: self.parent.parent
black_prisoners: black_prisoners
white_prisoners: white_prisoners
mid_circles_container: mid_circles_container
pass_btn: pass_btn
canvas.before:
Color:
@@ -200,17 +201,17 @@
margin: (3, self.size[1]/3, 3, self.size[1]/3)
size_hint: 0.1, 1
on_press: root.katrain('undo')
BoxLayout:
size_hint: 0.25, 1
FloatLayout:
size_hint: 0.2, 1
id: mid_circles_container
BlackCircleWithText:
id: black_prisoners
size_hint: 0.3,1
text: '0'
pos: (self.parent.pos[0]-self.height/3,self.parent.pos[1]) if self.parent else (0,0)
radius: 0.4
WhiteCircleWithText:
id: white_prisoners
size_hint: 0.3,1
text: '0'
outline: False
pos: (self.parent.pos[0]+self.height/3,self.parent.pos[1]) if self.parent else (0,0)
radius: 0.4
TransparentIconButton:
icon: 'img/flaticon/next.png'
margin: (3, self.size[1]/3, 3, self.size[1]/3)
@@ -394,13 +395,9 @@
size_hint: 1, 0.03
label: 'Point loss'
text: '...'
GridLayout:
cols: 2
rows: 1
size_hint: 1, 0.05
TextInput:
id: info
size_hint: 1, 0.2
size_hint: 1, 0.25
valign: 'middle'
BoxLayout:
orientation: 'horizontal'
+1
View File
@@ -7,6 +7,7 @@ from gui.kivyutils import (
LabelledFloatInput,
LabelledIntInput,
StyledButton,
DarkLabel,BaseCircleWithText,
LabelledSpinner,
LabelledCheckBox,
LabelledTextInput,
+7 -1
View File
@@ -1,11 +1,12 @@
from kivy.core.text import Label as CoreLabel
from kivy.graphics import *
from kivy.properties import BooleanProperty, StringProperty
from kivy.properties import BooleanProperty, StringProperty, NumericProperty
from kivy.uix.boxlayout import BoxLayout
import re
from kivy.uix.button import Button
from kivy.uix.checkbox import CheckBox
from kivy.uix.label import Label
from kivy.uix.spinner import Spinner
from kivy.uix.textinput import TextInput
@@ -24,6 +25,11 @@ class CheckBoxHint(BoxLayout):
def on_active(self, *args):
pass
class DarkLabel(Label):
pass
class BaseCircleWithText(DarkLabel):
radius = NumericProperty(0.48)
class LabelledTextInput(TextInput):
input_property = StringProperty("")
+9
View File
@@ -80,16 +80,25 @@ class KaTrainGui(BoxLayout):
self._do_new_game()
def update_state(self, redraw_board=False):
# AI and Trainer/auto-undo handlers
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:
self("ai-move", cn)
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
# Handle prisoners and next player display
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.white_prisoners.text = str(prisoners[0])
# Update board and status
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_contents, -1)