mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-09-03 23:25:46 -04:00
add license, move folders
This commit is contained in:
parent
185cc74060
commit
271c4a46a1
132 changed files with 21 additions and 0 deletions
25
app/scripts/ui/world/gate_info.gd
Normal file
25
app/scripts/ui/world/gate_info.gd
Normal file
|
@ -0,0 +1,25 @@
|
|||
extends Control
|
||||
|
||||
@export var gate_events: GateEvents
|
||||
|
||||
@export var image: TextureRect
|
||||
@export var title: Label
|
||||
@export var description: RichTextLabel
|
||||
|
||||
var gate: Gate
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
gate_events.gate_info_loaded.connect(display_info)
|
||||
gate_events.gate_error.connect(on_gate_error)
|
||||
|
||||
|
||||
func display_info(_gate: Gate, _is_cached: bool) -> void:
|
||||
gate = _gate
|
||||
title.text = "Unnamed" if gate.title.is_empty() else gate.title
|
||||
description.text = "No description" if gate.description.is_empty() else gate.description
|
||||
image.texture = FileTools.load_external_tex(gate.image)
|
||||
|
||||
|
||||
func on_gate_error(_code: GateEvents.GateError) -> void:
|
||||
description.set_text("")
|
34
app/scripts/ui/world/loading_status.gd
Normal file
34
app/scripts/ui/world/loading_status.gd
Normal file
|
@ -0,0 +1,34 @@
|
|||
extends Label
|
||||
|
||||
@export var gate_events: GateEvents
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
gate_events.gate_info_loaded.connect(func(_gate, _is_cached): on_gate_info_loaded())
|
||||
gate_events.gate_entered.connect(on_gate_entered)
|
||||
gate_events.gate_error.connect(on_gate_error)
|
||||
set_text("Connecting...")
|
||||
|
||||
|
||||
func on_gate_info_loaded() -> void:
|
||||
gate_events.download_progress.connect(show_progress)
|
||||
|
||||
|
||||
func show_progress(_url: String, body_size: int, downloaded_bytes: int) -> void:
|
||||
var percent = int(downloaded_bytes * 100 / body_size)
|
||||
set_text("Downloading: %d%s" % [percent, "%"])
|
||||
|
||||
|
||||
func on_gate_entered() -> void:
|
||||
gate_events.download_progress.disconnect(show_progress)
|
||||
set_text("")
|
||||
|
||||
|
||||
func on_gate_error(code: GateEvents.GateError) -> void:
|
||||
match code:
|
||||
GateEvents.GateError.NOT_FOUND:
|
||||
set_text("Gate not found")
|
||||
GateEvents.GateError.MISSING_PACK, GateEvents.GateError.MISSING_LIBS:
|
||||
set_text("Cannot load gate resources")
|
||||
_:
|
||||
set_text("Error")
|
12
app/scripts/ui/world/loading_ui.gd
Normal file
12
app/scripts/ui/world/loading_ui.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Control
|
||||
|
||||
@export var gate_events: GateEvents
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
gate_events.gate_entered.connect(hide_ui)
|
||||
visible = true
|
||||
|
||||
|
||||
func hide_ui() -> void:
|
||||
visible = false
|
8
app/scripts/ui/world/release_focus.gd
Normal file
8
app/scripts/ui/world/release_focus.gd
Normal file
|
@ -0,0 +1,8 @@
|
|||
extends Control
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if (has_focus()
|
||||
and event is InputEventMouseButton
|
||||
and not get_global_rect().has_point(event.position)):
|
||||
release_focus()
|
24
app/scripts/ui/world/world_canvas.gd
Normal file
24
app/scripts/ui/world/world_canvas.gd
Normal file
|
@ -0,0 +1,24 @@
|
|||
extends Control
|
||||
|
||||
@export var ui_events: UiEvents
|
||||
@export var interpolate: float:
|
||||
set(value):
|
||||
interpolate = value
|
||||
animate(value)
|
||||
|
||||
var initial: int
|
||||
var full_screen: int
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var viewport_width = ProjectSettings.get_setting("display/window/size/viewport_width", 1152)
|
||||
var scale_width = float(custom_minimum_size.x) / viewport_width
|
||||
|
||||
full_screen = int(ui_events.current_ui_size.x)
|
||||
initial = int(full_screen * scale_width)
|
||||
custom_minimum_size.x = initial
|
||||
Debug.logclr("WorldCanvas initial: %d full_screen: %d" % [initial, full_screen], Color.DIM_GRAY)
|
||||
|
||||
|
||||
func animate(value: float) -> void:
|
||||
custom_minimum_size.x = lerp(initial, full_screen, value)
|
42
app/scripts/ui/world/world_ui.gd
Normal file
42
app/scripts/ui/world/world_ui.gd
Normal file
|
@ -0,0 +1,42 @@
|
|||
extends Control
|
||||
|
||||
@export var ui_events: UiEvents
|
||||
@export var gate_events: GateEvents
|
||||
@export var command_events: CommandEvents
|
||||
|
||||
var mouse_mode: int = Input.MOUSE_MODE_VISIBLE
|
||||
var _visible: bool = true
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
command_events.set_mouse_mode.connect(set_mouse_mode)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
|
||||
|
||||
func set_mouse_mode(mode: int) -> void:
|
||||
mouse_mode = mode
|
||||
if not _visible: Input.set_mouse_mode(mode)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("show_ui") and not event.is_echo():
|
||||
if _visible:
|
||||
hide_ui()
|
||||
else:
|
||||
show_ui()
|
||||
|
||||
|
||||
func show_ui() -> void:
|
||||
if _visible: return
|
||||
_visible = true
|
||||
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
ui_events.ui_mode_changed_emit(UiEvents.UiMode.INITIAL)
|
||||
|
||||
|
||||
func hide_ui() -> void:
|
||||
if not _visible: return
|
||||
_visible = false
|
||||
|
||||
Input.set_mouse_mode(mouse_mode)
|
||||
ui_events.ui_mode_changed_emit(UiEvents.UiMode.FULL_SCREEN)
|
Loading…
Add table
Add a link
Reference in a new issue