Clean up left and right selection of hexes.

This commit is contained in:
Dorian 2016-07-16 18:54:27 -04:00
parent d28e9b33ad
commit 6ba611e539
1 changed files with 15 additions and 12 deletions

27
main.py
View File

@ -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