diff --git a/project/scripts/resources/ui_events.gd b/project/scripts/resources/ui_events.gd index d945557..43d6b71 100644 --- a/project/scripts/resources/ui_events.gd +++ b/project/scripts/resources/ui_events.gd @@ -1,14 +1,20 @@ extends Resource class_name UiEvents -signal ui_visibility_changed(visible: bool) +signal ui_mode_changed(mode: UiMode) signal ui_size_changed(size: Vector2) +enum UiMode +{ + INITIAL, + FULL_SCREEN +} + var current_ui_size: Vector2 -func ui_visibility_changed_emit(visible: bool) -> void: - ui_visibility_changed.emit(visible) +func ui_mode_changed_emit(mode: UiMode) -> void: + ui_mode_changed.emit(mode) func ui_size_changed_emit(size: Vector2) -> void: diff --git a/project/scripts/sandbox/input_sync.gd b/project/scripts/sandbox/input_sync.gd index 0bb8950..dc0b464 100644 --- a/project/scripts/sandbox/input_sync.gd +++ b/project/scripts/sandbox/input_sync.gd @@ -13,7 +13,7 @@ var should_send := false func _ready() -> void: gate_events.gate_entered.connect(start_server) - ui_events.ui_visibility_changed.connect(on_ui_visibility_changed) + ui_events.ui_mode_changed.connect(on_ui_mode_changed) scale_width = float(render_result.width) / ui_events.current_ui_size.x scale_height = float(render_result.height) / ui_events.current_ui_size.y @@ -25,8 +25,8 @@ func start_server() -> void: input_sync.bind() -func on_ui_visibility_changed(visible: bool) -> void: - should_send = not visible +func on_ui_mode_changed(mode: UiEvents.UiMode) -> void: + should_send = mode == UiEvents.UiMode.FULL_SCREEN func _input(event: InputEvent) -> void: diff --git a/project/scripts/ui/fullscreen_animation.gd b/project/scripts/ui/fullscreen_animation.gd index fb717e6..5236b12 100644 --- a/project/scripts/ui/fullscreen_animation.gd +++ b/project/scripts/ui/fullscreen_animation.gd @@ -11,15 +11,15 @@ var fullscreen := false func _ready() -> void: - ui_events.ui_visibility_changed.connect(on_ui_visibility_changed) - gate_events.open_gate.connect(func(_url): on_ui_visibility_changed(true)) + ui_events.ui_mode_changed.connect(on_ui_mode_changed) + gate_events.open_gate.connect(func(_url): on_ui_mode_changed(UiEvents.UiMode.INITIAL)) -func on_ui_visibility_changed(visible: bool) -> void: - if visible and fullscreen: +func on_ui_mode_changed(mode: UiEvents.UiMode) -> void: + if mode == UiEvents.UiMode.INITIAL and fullscreen: fullscreen = false play(INITIAL) - if not visible and not fullscreen: + if mode == UiEvents.UiMode.FULL_SCREEN and not fullscreen: fullscreen = true play(FULLSCREEN) diff --git a/project/scripts/ui/menu/menu.gd b/project/scripts/ui/menu/menu.gd index d3f403f..95f6897 100644 --- a/project/scripts/ui/menu/menu.gd +++ b/project/scripts/ui/menu/menu.gd @@ -9,4 +9,5 @@ func _ready() -> void: func on_resized() -> void: + Debug.logclr("Ui resized: %dx%d" % [size.x, size.y], Debug.SILENT_CLR) ui_events.ui_size_changed_emit(size) diff --git a/project/scripts/ui/world/world_ui.gd b/project/scripts/ui/world/world_ui.gd index bf1870a..d081189 100644 --- a/project/scripts/ui/world/world_ui.gd +++ b/project/scripts/ui/world/world_ui.gd @@ -31,7 +31,7 @@ func show_ui() -> void: _visible = true Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - ui_events.ui_visibility_changed_emit(true) + ui_events.ui_mode_changed_emit(UiEvents.UiMode.INITIAL) func hide_ui() -> void: @@ -39,4 +39,4 @@ func hide_ui() -> void: _visible = false Input.set_mouse_mode(mouse_mode) - ui_events.ui_visibility_changed_emit(false) + ui_events.ui_mode_changed_emit(UiEvents.UiMode.FULL_SCREEN)