From 6ba611e5397e19c0c37524c82a34787282692a4e Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Sat, 16 Jul 2016 18:54:27 -0400 Subject: [PATCH] Clean up left and right selection of hexes. --- main.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index 65f17ad..e03b5dc 100644 --- a/main.py +++ b/main.py @@ -91,24 +91,27 @@ class HexMapCell(Label): def on_touch_down(self, touch): if super(HexMapCell, self).on_touch_down(touch): - return True - - if not self.collide_point(touch.x, touch.y): return False if not self.visible_on_map: - return True + return False - self.selected = not self.selected - with self.canvas.after: - if self.selected and touch.button == 'left': - Color(*kivy.utils.get_color_from_hex('#00FF00')) - elif self.selected and touch.button == 'right': - Color(*kivy.utils.get_color_from_hex('#FF0000')) - else: + if not self.collide_point(touch.x, touch.y): + with self.canvas.after: Color(*kivy.utils.get_color_from_hex('#A1A5AA')) + radius = 2 * self.height + self.ell = Line(circle=(self.x, self.y, radius, 0, 360, 6), width=2) + return False + + with self.canvas.after: + if 'button' in touch.profile and touch.button == 'left': + Color(*kivy.utils.get_color_from_hex('#00FF00')) + + if 'button' in touch.profile and touch.button == 'right': + # TODO Will refactor to have separate on_touch_up for selected target hex instead. + Color(*kivy.utils.get_color_from_hex('#FF0000')) radius = 2 * self.height - self.ell = Line(circle=(self.x, self.y, radius, 0, 360, 6), width=4) + self.ell = Line(circle=(self.x, self.y, radius, 0, 360, 6), width=2) return True