better gate not responding

This commit is contained in:
Nordup 2025-08-16 04:32:25 +07:00
parent 262f14caeb
commit eecf9b31b7
8 changed files with 112 additions and 64 deletions

54
app/scripts/navigation.gd Normal file
View file

@ -0,0 +1,54 @@
extends Node
#class_name Navigation
signal updated()
@export var gate_events: GateEvents
@export var history: History
func _ready() -> void:
gate_events.open_gate.connect(new)
gate_events.search.connect(new)
gate_events.exit_gate.connect(new.bind(""))
func can_forw() -> bool:
return history.can_forw()
func can_back() -> bool:
return history.can_back()
func new(location: String) -> void:
history.add(location)
updated.emit()
func go_back() -> void:
open(history.back())
updated.emit()
func go_forw() -> void:
open(history.forw())
updated.emit()
func reload() -> void:
open(history.get_current())
updated.emit()
func home() -> void:
gate_events.exit_gate_emit()
func open(location: String) -> void:
if location == "":
gate_events.exit_gate_emit()
elif Url.is_valid(location):
gate_events.open_gate_emit(location)
else:
gate_events.search_emit(location)

View file

@ -5,8 +5,8 @@ extends Node
@export var snbx_manager: SandboxManager
# Timeout intervals for child process responsiveness
const BOOTUP_CHECK_SEC = 1
const HEARTBEAT_INTERVAL_SEC = 5
const BOOTUP_CHECK_SEC = 3
const HEARTBEAT_INTERVAL_SEC = 10
const WAIT_INTERVAL_SEC = 15
var bootup_timer: Timer
@ -20,7 +20,7 @@ func _ready() -> void:
add_child(heartbeat_timer)
bootup_timer.timeout.connect(bootup_check)
heartbeat_timer.timeout.connect(on_timeout)
heartbeat_timer.timeout.connect(heartbeat_check)
gate_events.gate_entered.connect(start_bootup_check)
gate_events.first_frame.connect(start_heartbeat_timer)
@ -35,7 +35,7 @@ func bootup_check() -> void:
if snbx_manager.is_sandbox_running(): return
bootup_timer.stop()
on_timeout()
on_timeout("Gate crashed")
func start_heartbeat_timer() -> void:
@ -47,7 +47,14 @@ func restart_heartbeat_timer() -> void:
heartbeat_timer.start(HEARTBEAT_INTERVAL_SEC)
func on_timeout() -> void:
Debug.logerr("Gate is not responding")
func heartbeat_check() -> void:
var error = "Gate is not responding" if snbx_manager.is_sandbox_running() else "Gate crashed"
heartbeat_timer.stop()
on_timeout(error)
func on_timeout(error: String) -> void:
Debug.logerr(error)
gate_events.not_responding_emit()
heartbeat_timer.start(WAIT_INTERVAL_SEC)

View file

@ -1,7 +1,6 @@
extends Node
@export var gate_events: GateEvents
@export var history: History
@export var go_back: RoundButton
@export var go_forw: RoundButton
@ -10,50 +9,18 @@ extends Node
func _ready() -> void:
gate_events.open_gate.connect(on_new)
gate_events.search.connect(on_new)
gate_events.exit_gate.connect(on_new.bind(""))
go_back.pressed.connect(Navigation.go_back)
go_forw.pressed.connect(Navigation.go_forw)
reload.pressed.connect(Navigation.reload)
home.pressed.connect(Navigation.home)
go_back.pressed.connect(on_go_back)
go_forw.pressed.connect(on_go_forw)
reload.pressed.connect(on_reload)
home.pressed.connect(gate_events.exit_gate_emit)
go_back.disable()
go_forw.disable()
func on_new(location: String) -> void:
history.add(location)
Navigation.updated.connect(update_buttons)
update_buttons()
func on_go_back() -> void:
open(history.back())
update_buttons()
func on_go_forw() -> void:
open(history.forw())
update_buttons()
func on_reload() -> void:
open(history.get_current())
func open(location: String) -> void:
if location == "":
gate_events.exit_gate_emit()
elif Url.is_valid(location):
gate_events.open_gate_emit(location)
else:
gate_events.search_emit(location)
func update_buttons() -> void:
if history.can_back(): go_back.enable()
if Navigation.can_back(): go_back.enable()
else: go_back.disable()
if history.can_forw(): go_forw.enable()
if Navigation.can_forw(): go_forw.enable()
else: go_forw.disable()

View file

@ -4,7 +4,7 @@ extends Control
@export var history: History
@export var root: TextureButton
@export var reload: Button
@export var wait: Button
@export var back: Button
@export var fade_in: float = 1.0
@export var fade_out: float = 0.2
@ -18,7 +18,7 @@ func _ready() -> void:
gate_events.not_responding.connect(show_message)
reload.pressed.connect(reload_gate)
root.pressed.connect(hide_message)
wait.pressed.connect(hide_message)
back.pressed.connect(Navigation.go_back)
visible = true
root.hide()