From a82a27b38f85dd36e54d5f97c2ee181bd0682f6e Mon Sep 17 00:00:00 2001 From: Nordup Date: Tue, 20 Jun 2023 10:24:18 +0400 Subject: [PATCH] menu navigation done --- project/scenes/menu.tscn | 10 +++++----- project/scripts/ui/menu/history.gd | 12 ++++++++---- project/scripts/ui/menu/menu_navigation.gd | 13 +++++++++---- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/project/scenes/menu.tscn b/project/scenes/menu.tscn index c229559..3c93b4f 100644 --- a/project/scenes/menu.tscn +++ b/project/scenes/menu.tscn @@ -241,7 +241,7 @@ focus_neighbor_right = NodePath("") focus_neighbor_bottom = NodePath("") focus_next = NodePath("") focus_previous = NodePath("") -focus_mode = 2 +focus_mode = 0 mouse_filter = 0 mouse_force_pass_scroll_events = true mouse_default_cursor_shape = 2 @@ -310,7 +310,7 @@ focus_neighbor_right = NodePath("") focus_neighbor_bottom = NodePath("") focus_next = NodePath("") focus_previous = NodePath("") -focus_mode = 2 +focus_mode = 0 mouse_filter = 0 mouse_force_pass_scroll_events = true mouse_default_cursor_shape = 2 @@ -377,7 +377,7 @@ focus_neighbor_right = NodePath("") focus_neighbor_bottom = NodePath("") focus_next = NodePath("") focus_previous = NodePath("") -focus_mode = 2 +focus_mode = 0 mouse_filter = 0 mouse_force_pass_scroll_events = true mouse_default_cursor_shape = 2 @@ -449,7 +449,7 @@ focus_neighbor_right = NodePath("") focus_neighbor_bottom = NodePath("") focus_next = NodePath("") focus_previous = NodePath("") -focus_mode = 2 +focus_mode = 0 mouse_filter = 0 mouse_force_pass_scroll_events = true mouse_default_cursor_shape = 2 @@ -530,7 +530,7 @@ focus_neighbor_right = NodePath("") focus_neighbor_bottom = NodePath("") focus_next = NodePath("") focus_previous = NodePath("") -focus_mode = 2 +focus_mode = 0 mouse_filter = 0 mouse_force_pass_scroll_events = true mouse_default_cursor_shape = 2 diff --git a/project/scripts/ui/menu/history.gd b/project/scripts/ui/menu/history.gd index 09db7c2..e6a5540 100644 --- a/project/scripts/ui/menu/history.gd +++ b/project/scripts/ui/menu/history.gd @@ -24,18 +24,18 @@ func add(url: String) -> void: index += 1 history.resize(index) history.push_back(url) - print(str(history) + " " + str(index)) + print_history() func forw() -> String: index += 1 - print(str(history) + " " + str(index)) + print_history() return history[index] func back() -> String: index -= 1 - print(str(history) + " " + str(index)) + print_history() if index == -1: return "" return history[index] @@ -44,4 +44,8 @@ func back() -> String: func clear() -> void: index = -1 history.clear() - print(str(history) + " " + str(index)) + print_history() + + +func print_history() -> void: + Debug.logclr("History: " + str(history) + " Current: " + str(index), Color.DIM_GRAY) diff --git a/project/scripts/ui/menu/menu_navigation.gd b/project/scripts/ui/menu/menu_navigation.gd index 1c554a5..0e1430c 100644 --- a/project/scripts/ui/menu/menu_navigation.gd +++ b/project/scripts/ui/menu/menu_navigation.gd @@ -23,15 +23,19 @@ func _ready() -> void: func on_open_gate(url: String) -> void: history.add(url) enable([go_back, reload, home]) + if not history.can_forw(): + disable([go_forw]) func on_go_back() -> void: var url = history.back() - if url == "": - on_home() - else: - gate_events.open_gate_emit(url) + enable([go_forw]) + if history.can_back(): + gate_events.open_gate_emit(url) + else: + disable([go_back, reload, home]) + gate_events.exit_gate_emit() func on_go_forw() -> void: @@ -49,6 +53,7 @@ func on_reload() -> void: func on_home() -> void: + history.clear() disable([go_back, go_forw, reload, home]) gate_events.exit_gate_emit()