diff --git a/app/project.godot b/app/project.godot index 9d0c813..97d1ccd 100644 --- a/app/project.godot +++ b/app/project.godot @@ -34,6 +34,7 @@ FileDownloader="*res://scripts/loading/file_downloader.gd" Debug="*res://scripts/debug_log/debug.gd" AnalyticsEvents="*res://scripts/api/analytics/analytics_events.gd" Backend="*res://scripts/api/backend.gd" +Navigation="*res://scenes/autoloads/navigation.tscn" [debug] diff --git a/app/scenes/autoloads/navigation.tscn b/app/scenes/autoloads/navigation.tscn new file mode 100644 index 0000000..b194cfc --- /dev/null +++ b/app/scenes/autoloads/navigation.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=4 format=3 uid="uid://b81h2v72dlgt5"] + +[ext_resource type="Script" path="res://scripts/navigation.gd" id="1_urxac"] +[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_1l00j"] +[ext_resource type="Resource" uid="uid://bqgikyax6jfqa" path="res://resources/history.tres" id="3_qqkln"] + +[node name="Navigation" type="Node"] +script = ExtResource("1_urxac") +gate_events = ExtResource("2_1l00j") +history = ExtResource("3_qqkln") diff --git a/app/scenes/components/not_responding.tscn b/app/scenes/components/not_responding.tscn index 9e81ec8..6d7d27c 100644 --- a/app/scenes/components/not_responding.tscn +++ b/app/scenes/components/not_responding.tscn @@ -16,7 +16,7 @@ font = ExtResource("2_ugt55") font_size = 20 font_color = Color(0.431373, 0.435294, 0.494118, 1) -[node name="NotResponding" type="Control" node_paths=PackedStringArray("root", "reload", "wait")] +[node name="NotResponding" type="Control" node_paths=PackedStringArray("root", "reload", "back")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -29,7 +29,7 @@ gate_events = ExtResource("2_8u6e2") history = ExtResource("3_ge6h5") root = NodePath("TextureButton") reload = NodePath("TextureButton/Popup/MarginContainer/VBoxContainer/HBoxContainer/Reload") -wait = NodePath("TextureButton/Popup/MarginContainer/VBoxContainer/HBoxContainer/Hide") +back = NodePath("TextureButton/Popup/MarginContainer/VBoxContainer/HBoxContainer/Back") [node name="TextureButton" type="TextureButton" parent="."] layout_mode = 1 @@ -57,12 +57,12 @@ anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 offset_left = -219.0 -offset_top = -93.0 +offset_top = -115.0 offset_right = 219.0 -offset_bottom = 112.0 +offset_bottom = 115.0 grow_horizontal = 2 grow_vertical = 2 -ratio = 1.35 +ratio = 1.5 [node name="Panel" type="Panel" parent="TextureButton/Popup"] layout_mode = 2 @@ -71,26 +71,37 @@ theme_override_styles/panel = ExtResource("4_2kla0") [node name="MarginContainer" type="MarginContainer" parent="TextureButton/Popup"] layout_mode = 2 mouse_filter = 0 +theme_override_constants/margin_left = 24 theme_override_constants/margin_top = 24 +theme_override_constants/margin_right = 24 theme_override_constants/margin_bottom = 24 [node name="VBoxContainer" type="VBoxContainer" parent="TextureButton/Popup/MarginContainer"] layout_mode = 2 -theme_override_constants/separation = 20 +theme_override_constants/separation = 24 [node name="Label" type="Label" parent="TextureButton/Popup/MarginContainer/VBoxContainer"] layout_mode = 2 -text = "Gate is not responding" +text = "Oops! World Collapsed" label_settings = ExtResource("5_ruiif") horizontal_alignment = 1 vertical_alignment = 1 -[node name="Label2" type="Label" parent="TextureButton/Popup/MarginContainer/VBoxContainer"] +[node name="Control" type="Control" parent="TextureButton/Popup/MarginContainer/VBoxContainer"] layout_mode = 2 -text = "Reload the page or try -to wait if it responses" +size_flags_vertical = 3 + +[node name="Label2" type="Label" parent="TextureButton/Popup/MarginContainer/VBoxContainer/Control"] +layout_mode = 2 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_vertical = 6 +text = "The connection to this world has been lost. Reload to try again or go back to safety." label_settings = SubResource("LabelSettings_bkr01") horizontal_alignment = 1 +autowrap_mode = 3 [node name="HBoxContainer" type="HBoxContainer" parent="TextureButton/Popup/MarginContainer/VBoxContainer"] layout_mode = 2 @@ -107,12 +118,12 @@ theme_override_font_sizes/font_size = 20 text = "Reload" icon = null -[node name="Hide" parent="TextureButton/Popup/MarginContainer/VBoxContainer/HBoxContainer" instance=ExtResource("7_mxyw0")] -custom_minimum_size = Vector2(90, 26) +[node name="Back" parent="TextureButton/Popup/MarginContainer/VBoxContainer/HBoxContainer" instance=ExtResource("7_mxyw0")] +custom_minimum_size = Vector2(100, 26) layout_mode = 2 theme_override_colors/font_disabled_color = Color(0.431373, 0.435294, 0.494118, 1) theme_override_colors/font_color = Color(0.831373, 0.831373, 0.831373, 1) theme_override_fonts/font = ExtResource("2_ugt55") theme_override_font_sizes/font_size = 20 -text = "Wait" +text = "Go back" icon = null diff --git a/app/scenes/menu.tscn b/app/scenes/menu.tscn index 92d351e..d013c62 100644 --- a/app/scenes/menu.tscn +++ b/app/scenes/menu.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=28 format=3 uid="uid://5btb7nvgmfhl"] +[gd_scene load_steps=27 format=3 uid="uid://5btb7nvgmfhl"] [ext_resource type="Script" path="res://scripts/ui/menu/menu_navigation.gd" id="1_7anvm"] [ext_resource type="Script" path="res://scripts/ui/menu/menu.gd" id="1_o6vga"] [ext_resource type="PackedScene" uid="uid://dkfy3rcfbxqc6" path="res://scenes/components/tab.tscn" id="3_atekt"] [ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="3_m632k"] -[ext_resource type="Resource" uid="uid://bqgikyax6jfqa" path="res://resources/history.tres" id="3_wi554"] [ext_resource type="Texture2D" uid="uid://c80732g67qmvx" path="res://assets/textures/plus.svg" id="4_rdyyc"] [ext_resource type="PackedScene" uid="uid://ctam0fxigbefk" path="res://scenes/components/search/search.tscn" id="5_li2do"] [ext_resource type="PackedScene" uid="uid://xagbhqfidf2" path="res://scenes/components/round_button.tscn" id="6_gxcmo"] @@ -196,7 +195,6 @@ theme_override_constants/separation = 12 alignment = 1 script = ExtResource("1_7anvm") gate_events = ExtResource("3_m632k") -history = ExtResource("3_wi554") go_back = NodePath("HBoxContainer/Back") go_forw = NodePath("HBoxContainer/Forward") reload = NodePath("HBoxContainer/Reload") diff --git a/app/scripts/navigation.gd b/app/scripts/navigation.gd new file mode 100644 index 0000000..db65ca7 --- /dev/null +++ b/app/scripts/navigation.gd @@ -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) diff --git a/app/scripts/sandbox/process_checker.gd b/app/scripts/sandbox/process_checker.gd index 9e5cffb..b9783ca 100644 --- a/app/scripts/sandbox/process_checker.gd +++ b/app/scripts/sandbox/process_checker.gd @@ -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) diff --git a/app/scripts/ui/menu/menu_navigation.gd b/app/scripts/ui/menu/menu_navigation.gd index da52d74..71138bf 100644 --- a/app/scripts/ui/menu/menu_navigation.gd +++ b/app/scripts/ui/menu/menu_navigation.gd @@ -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() diff --git a/app/scripts/ui/world/not_responding.gd b/app/scripts/ui/world/not_responding.gd index 985ff96..7cbae1e 100644 --- a/app/scripts/ui/world/not_responding.gd +++ b/app/scripts/ui/world/not_responding.gd @@ -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()