mirror of
https://github.com/csd4ni3l/fractal-viewer.git
synced 2026-01-01 04:13:41 +01:00
Add controller exiting with B button
This commit is contained in:
@@ -66,9 +66,11 @@ class IterFractalViewer(arcade.gui.UIView):
|
||||
self.has_controller = True
|
||||
|
||||
def on_button_press(self, controller, button_name):
|
||||
if button_name == "a" and self.has_controller:
|
||||
if button_name == "a":
|
||||
self.zoom_start_position = self.cursor_sprite.center_x, self.cursor_sprite.center_y
|
||||
self.dragging_with_controller = True
|
||||
elif button_name == "b":
|
||||
self.main_exit()
|
||||
|
||||
def on_button_release(self, controller, button_name):
|
||||
if button_name == "a" and self.dragging_with_controller:
|
||||
|
||||
@@ -37,15 +37,6 @@ class SierpinskyCarpetViewer(arcade.gui.UIView):
|
||||
self.sprite_list.append(self.cursor_sprite)
|
||||
self.has_controller = True
|
||||
|
||||
def on_stick_motion(self, controller, name, vector):
|
||||
if name == "leftstick":
|
||||
self.cursor_sprite.center_x += vector.x * 5
|
||||
self.cursor_sprite.center_y += vector.y * 5
|
||||
|
||||
def main_exit(self):
|
||||
from menus.main import Main
|
||||
self.window.show_view(Main(self.pypresence_client))
|
||||
|
||||
def setup_ui(self):
|
||||
self.anchor = self.add_widget(arcade.gui.UIAnchorLayout(size_hint=(1, 1)))
|
||||
|
||||
@@ -85,6 +76,17 @@ class SierpinskyCarpetViewer(arcade.gui.UIView):
|
||||
def on_button_press(self, controller, name):
|
||||
if name == "a":
|
||||
self.on_mouse_press(self.cursor_sprite.left, self.cursor_sprite.bottom, arcade.MOUSE_BUTTON_LEFT, 0)
|
||||
elif name == "b":
|
||||
self.main_exit()
|
||||
|
||||
def on_stick_motion(self, controller, name, vector):
|
||||
if name == "leftstick":
|
||||
self.cursor_sprite.center_x += vector.x * 5
|
||||
self.cursor_sprite.center_y += vector.y * 5
|
||||
|
||||
def main_exit(self):
|
||||
from menus.main import Main
|
||||
self.window.show_view(Main(self.pypresence_client))
|
||||
|
||||
def on_draw(self):
|
||||
self.window.clear()
|
||||
|
||||
Reference in New Issue
Block a user