mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-23 08:17:34 -04:00
UiMode enum
This commit is contained in:
parent
7ab7255140
commit
f821952b9a
5 changed files with 20 additions and 13 deletions
|
@ -1,14 +1,20 @@
|
||||||
extends Resource
|
extends Resource
|
||||||
class_name UiEvents
|
class_name UiEvents
|
||||||
|
|
||||||
signal ui_visibility_changed(visible: bool)
|
signal ui_mode_changed(mode: UiMode)
|
||||||
signal ui_size_changed(size: Vector2)
|
signal ui_size_changed(size: Vector2)
|
||||||
|
|
||||||
|
enum UiMode
|
||||||
|
{
|
||||||
|
INITIAL,
|
||||||
|
FULL_SCREEN
|
||||||
|
}
|
||||||
|
|
||||||
var current_ui_size: Vector2
|
var current_ui_size: Vector2
|
||||||
|
|
||||||
|
|
||||||
func ui_visibility_changed_emit(visible: bool) -> void:
|
func ui_mode_changed_emit(mode: UiMode) -> void:
|
||||||
ui_visibility_changed.emit(visible)
|
ui_mode_changed.emit(mode)
|
||||||
|
|
||||||
|
|
||||||
func ui_size_changed_emit(size: Vector2) -> void:
|
func ui_size_changed_emit(size: Vector2) -> void:
|
||||||
|
|
|
@ -13,7 +13,7 @@ var should_send := false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
gate_events.gate_entered.connect(start_server)
|
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_width = float(render_result.width) / ui_events.current_ui_size.x
|
||||||
scale_height = float(render_result.height) / ui_events.current_ui_size.y
|
scale_height = float(render_result.height) / ui_events.current_ui_size.y
|
||||||
|
@ -25,8 +25,8 @@ func start_server() -> void:
|
||||||
input_sync.bind()
|
input_sync.bind()
|
||||||
|
|
||||||
|
|
||||||
func on_ui_visibility_changed(visible: bool) -> void:
|
func on_ui_mode_changed(mode: UiEvents.UiMode) -> void:
|
||||||
should_send = not visible
|
should_send = mode == UiEvents.UiMode.FULL_SCREEN
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
|
|
|
@ -11,15 +11,15 @@ var fullscreen := false
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
ui_events.ui_visibility_changed.connect(on_ui_visibility_changed)
|
ui_events.ui_mode_changed.connect(on_ui_mode_changed)
|
||||||
gate_events.open_gate.connect(func(_url): on_ui_visibility_changed(true))
|
gate_events.open_gate.connect(func(_url): on_ui_mode_changed(UiEvents.UiMode.INITIAL))
|
||||||
|
|
||||||
|
|
||||||
func on_ui_visibility_changed(visible: bool) -> void:
|
func on_ui_mode_changed(mode: UiEvents.UiMode) -> void:
|
||||||
if visible and fullscreen:
|
if mode == UiEvents.UiMode.INITIAL and fullscreen:
|
||||||
fullscreen = false
|
fullscreen = false
|
||||||
play(INITIAL)
|
play(INITIAL)
|
||||||
|
|
||||||
if not visible and not fullscreen:
|
if mode == UiEvents.UiMode.FULL_SCREEN and not fullscreen:
|
||||||
fullscreen = true
|
fullscreen = true
|
||||||
play(FULLSCREEN)
|
play(FULLSCREEN)
|
||||||
|
|
|
@ -9,4 +9,5 @@ func _ready() -> void:
|
||||||
|
|
||||||
|
|
||||||
func on_resized() -> 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)
|
ui_events.ui_size_changed_emit(size)
|
||||||
|
|
|
@ -31,7 +31,7 @@ func show_ui() -> void:
|
||||||
_visible = true
|
_visible = true
|
||||||
|
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
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:
|
func hide_ui() -> void:
|
||||||
|
@ -39,4 +39,4 @@ func hide_ui() -> void:
|
||||||
_visible = false
|
_visible = false
|
||||||
|
|
||||||
Input.set_mouse_mode(mouse_mode)
|
Input.set_mouse_mode(mouse_mode)
|
||||||
ui_events.ui_visibility_changed_emit(false)
|
ui_events.ui_mode_changed_emit(UiEvents.UiMode.FULL_SCREEN)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue