Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
CrafterSvK committed Jan 24, 2024
1 parent 0dbe3c1 commit dcf4b61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ enum ZOOM_DIRECTION {IN, OUT}
@export var zoom_direction: ZOOM_DIRECTION

func _ready() -> void:
pressed.connect(Callable(self, "_on_ZoomButton_pressed"))
pressed.connect(_on_ZoomButton_pressed)

if zoom_direction == ZOOM_DIRECTION.IN:
Global.camera_max_zoom.connect(Callable(self, "_on_camera_min_max_zoom"))
Global.camera_max_zoom.connect(_on_camera_min_max_zoom)
elif zoom_direction == ZOOM_DIRECTION.OUT:
Global.camera_min_zoom.connect(Callable(self, "_on_camera_min_max_zoom"))
Global.camera_min_zoom.connect(_on_camera_min_max_zoom)

func _on_camera_min_max_zoom(value: bool):
disabled = value
func _on_camera_min_max_zoom(is_limit_reached: bool):
disabled = is_limit_reached

func _on_ZoomButton_pressed():
func _on_ZoomButton_pressed() -> void:
if zoom_direction == ZOOM_DIRECTION.IN:
Global.emit_signal("camera_zoom_in")
elif zoom_direction == ZOOM_DIRECTION.OUT:
Expand Down
4 changes: 2 additions & 2 deletions Assets/World/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ signal camera_rotate_left
signal camera_rotate_right
signal camera_zoom_in
signal camera_zoom_out
signal camera_max_zoom(flag)
signal camera_min_zoom(flag)
signal camera_max_zoom(is_limit_reached: bool)
signal camera_min_zoom(is_limit_reached: bool)

enum WindowMode {
WINDOWED,
Expand Down
4 changes: 2 additions & 2 deletions Assets/World/WorldThing.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func _ready() -> void:
set_rotation_degree(rotation_degree)

if not Engine.is_editor_hint():
Global.camera_rotate_left.connect(Callable(self, "_on_camera_rotate_left"))
Global.camera_rotate_right.connect(Callable(self, "_on_camera_rotate_right"))
Global.camera_rotate_left.connect(_on_camera_rotate_left)
Global.camera_rotate_right.connect(_on_camera_rotate_right)

func _process(_delta: float) -> void:
if Engine.is_editor_hint():
Expand Down

0 comments on commit dcf4b61

Please sign in to comment.