gui improvements
This commit is contained in:
1 parent
0ade2524ce
commit
4d3c134e49
6 files changed
+18
-13
No files matched your search
+5
-3
@@ -413,7 +413,7 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
try:
|
||||
msg = self.game.write_sgf(filename)
|
||||
self.log(msg, OUTPUT_INFO)
|
||||
self.controls.set_status(msg, STATUS_INFO)
|
||||
self.controls.set_status(msg, STATUS_INFO, check_level=False)
|
||||
except Exception as e:
|
||||
self.log(f"Failed to save SGF to {filename}: {e}", OUTPUT_ERROR)
|
||||
|
||||
@@ -428,12 +428,14 @@ class KaTrainGui(Screen, KaTrainBase):
|
||||
if not filename.lower().endswith(".sgf"):
|
||||
filename += ".sgf"
|
||||
save_game_popup.dismiss()
|
||||
path, file = os.path.split(filename)
|
||||
path, file = os.path.split(filename.strip())
|
||||
if not path:
|
||||
path = popup_contents.filesel.path # whatever dir is shown
|
||||
if path != self.config("general/sgf_save"):
|
||||
self.log(f"Updating sgf save path default to {path}", OUTPUT_DEBUG)
|
||||
self._config["general"]["sgf_save"] = path
|
||||
self.save_config("general")
|
||||
self._do_save_game(filename)
|
||||
self._do_save_game(os.path.join(path,file))
|
||||
|
||||
popup_contents.filesel.on_success = readfile
|
||||
popup_contents.filesel.on_submit = readfile
|
||||
|
||||
+7
-5
@@ -14,6 +14,7 @@
|
||||
#:import WHITE katrain.gui.style.WHITE
|
||||
#:import BLACK katrain.gui.style.BLACK
|
||||
#:import LIGHTGREY katrain.gui.style.LIGHTGREY
|
||||
#:import LIGHTERGREY katrain.gui.style.LIGHTERGREY
|
||||
#:import GREEN katrain.gui.style.GREEN
|
||||
#:import YELLOW katrain.gui.style.YELLOW
|
||||
#:import RED katrain.gui.style.RED
|
||||
@@ -534,7 +535,7 @@
|
||||
TimerOrMoveTree:
|
||||
id: timer_or_movetree
|
||||
size_hint_y: None
|
||||
height: root.timer_box_height
|
||||
height: root.timer_box_height + max(0,int(self.mode != MODE_PLAY) * (root.tab_option_height + root.graph_height - graph_panel.height))
|
||||
BoxLayout:
|
||||
size_hint_x: EPSILON if self.parent.mode != MODE_PLAY else 1
|
||||
opacity: 0 if self.parent.mode != MODE_PLAY else 1
|
||||
@@ -557,11 +558,12 @@
|
||||
on_left_release: root.katrain("resign")
|
||||
MoveTree:
|
||||
id: move_tree
|
||||
min_height: root.timer_box_height
|
||||
size_hint_x: EPSILON if self.parent.mode == MODE_PLAY else 1
|
||||
opacity: 0 if self.parent.mode == MODE_PLAY else 1
|
||||
CollapsablePanel:
|
||||
id: graph_panel
|
||||
content_height: graph.height # + rank_graph.height
|
||||
content_height: graph.height
|
||||
options_height: root.tab_option_height
|
||||
closed_label: 'closedlabel:scoregraph'
|
||||
options: ['score','winrate']
|
||||
@@ -574,7 +576,7 @@
|
||||
id: graph
|
||||
opacity: 0 if self.hidden else 1
|
||||
size_hint_y: None
|
||||
height: EPSILON if self.hidden else root.graph_height
|
||||
height: root.graph_height
|
||||
CollapsablePanel:
|
||||
id: stats_panel
|
||||
num_active: 3
|
||||
@@ -626,7 +628,7 @@
|
||||
padding: 0
|
||||
id: notebox
|
||||
size_hint: 1,0
|
||||
IMETextField:
|
||||
LabelledTextInput:
|
||||
id: note
|
||||
font_size: NOTES_FONT_SIZE
|
||||
multiline: True
|
||||
@@ -637,7 +639,7 @@
|
||||
size_hint: 1, 1
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: LIGHTGREY
|
||||
rgba: LIGHTERGREY
|
||||
Line:
|
||||
points: self.x, self.y+self.height, self.x+self.width, self.y+self.height
|
||||
width: 1
|
||||
|
||||
@@ -90,9 +90,9 @@ class ControlsPanel(BoxLayout):
|
||||
else rank_label(player_info.calculated_rank)
|
||||
)
|
||||
|
||||
def set_status(self, msg, status_type, at_node=None):
|
||||
def set_status(self, msg, status_type, at_node=None, check_level=True):
|
||||
at_node = at_node or self.katrain and self.katrain.game and self.katrain.game.current_node
|
||||
if at_node != self.status_state[2] or int(status_type) >= int(self.status_state[1]) or msg == "":
|
||||
if at_node != self.status_state[2] or not check_level or int(status_type) >= int(self.status_state[1]) or msg == "":
|
||||
if self.status_state != (msg, status_type, at_node): # prevent loop if error in update eval
|
||||
Clock.schedule_once(self.update_evaluation, 0)
|
||||
self.status_state = (msg, status_type, at_node)
|
||||
|
||||
@@ -372,7 +372,7 @@ class PlayerInfo(MDBoxLayout, BackgroundMixin):
|
||||
active = BooleanProperty(True)
|
||||
|
||||
|
||||
class TimerOrMoveTree(BoxLayout):
|
||||
class TimerOrMoveTree(MDBoxLayout):
|
||||
mode = StringProperty(MODE_PLAY)
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from collections import defaultdict
|
||||
from kivy.graphics.context_instructions import Color
|
||||
from kivy.graphics.vertex_instructions import Line, Rectangle
|
||||
from kivy.lang import Builder
|
||||
from kivy.metrics import dp
|
||||
from kivy.properties import BooleanProperty, Clock, NumericProperty, ObjectProperty
|
||||
from kivy.uix.dropdown import DropDown
|
||||
from kivy.uix.scrollview import ScrollView
|
||||
@@ -115,7 +116,7 @@ class MoveTreeCanvas(Widget):
|
||||
return
|
||||
spacing = 5
|
||||
moves_vert = 3
|
||||
self.move_size = (self.scroll_view_widget.height - (moves_vert + 1) * spacing) / moves_vert
|
||||
self.move_size = (self.scroll_view_widget.min_height - (moves_vert + 1) * spacing) / moves_vert
|
||||
|
||||
root = current_node.root
|
||||
|
||||
@@ -186,6 +187,7 @@ class MoveTreeCanvas(Widget):
|
||||
|
||||
class MoveTree(ScrollView, BackgroundMixin):
|
||||
current_node = ObjectProperty(None)
|
||||
min_height = NumericProperty(dp(50)) # non-expanded height, to determine the node size
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#:set INPUT_FONT_SIZE sp(25)
|
||||
#:set DESC_FONT_SIZE sp(20)
|
||||
|
||||
#:set LIGHTGREY [0.7,0.7,0.7,1]
|
||||
#:import BACKGROUND_COLOR katrain.gui.style.BACKGROUND_COLOR
|
||||
#:import LIGHTGREY katrain.gui.style.LIGHTGREY
|
||||
#:import TEXT_COLOR katrain.gui.style.TEXT_COLOR
|
||||
|
||||
Reference in new issue
Block a user