mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-23 17:17:31 -04:00
search results
This commit is contained in:
parent
a6f71b7a9a
commit
2cf1eb61df
9 changed files with 86 additions and 36 deletions
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://ct8gsph3wnepl"]
|
||||
[gd_scene load_steps=15 format=3 uid="uid://ct8gsph3wnepl"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/app.gd" id="1_skc7d"]
|
||||
[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_cdryv"]
|
||||
[ext_resource type="PackedScene" uid="uid://pgl3w7q5w84m" path="res://scenes/menu_body/bookmarks.tscn" id="3_l8glb"]
|
||||
[ext_resource type="PackedScene" uid="uid://5btb7nvgmfhl" path="res://scenes/menu.tscn" id="3_o1f7b"]
|
||||
[ext_resource type="PackedScene" uid="uid://kywrsqro3d5i" path="res://scenes/menu_body/world.tscn" id="4_p75rl"]
|
||||
[ext_resource type="PackedScene" uid="uid://dh3owgirapji5" path="res://scenes/menu_body/search_results.tscn" id="4_phjpd"]
|
||||
[ext_resource type="Script" path="res://scripts/bookmark_saver.gd" id="5_ev0ch"]
|
||||
[ext_resource type="Script" path="res://scripts/analytics/analytics.gd" id="6_25d48"]
|
||||
[ext_resource type="Resource" uid="uid://bewhdj6jugt6q" path="res://resources/bookmarks.tres" id="6_rupvx"]
|
||||
|
@ -18,6 +19,7 @@
|
|||
script = ExtResource("1_skc7d")
|
||||
gate_events = ExtResource("2_cdryv")
|
||||
bookmarks = ExtResource("3_l8glb")
|
||||
search_results = ExtResource("4_phjpd")
|
||||
world_scene = ExtResource("4_p75rl")
|
||||
scenes_root = NodePath("Menu/VBoxContainer/Body")
|
||||
|
||||
|
|
43
project/scenes/menu_body/search_results.tscn
Normal file
43
project/scenes/menu_body/search_results.tscn
Normal file
|
@ -0,0 +1,43 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dh3owgirapji5"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/ui/search/search_results.gd" id="1_bycb5"]
|
||||
[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_2plpa"]
|
||||
|
||||
[node name="search_results" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Space" type="Control" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(240, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("1_bycb5")
|
||||
gate_events = ExtResource("2_2plpa")
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer/VBoxContainer"]
|
||||
self_modulate = Color(1, 1, 1, 0.6)
|
||||
custom_minimum_size = Vector2(0, 64)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "-------------------------------------------------------------------------------------------------- Search results -------------------------------------------------------------------------------------------------"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Space2" type="Control" parent="HBoxContainer"]
|
||||
custom_minimum_size = Vector2(240, 0)
|
||||
layout_mode = 2
|
|
@ -31,9 +31,9 @@ func app_exit(time_spend: int) -> Dictionary:
|
|||
|
||||
# GATE
|
||||
|
||||
func search_press(url: String) -> Dictionary:
|
||||
var event = base("search_press")
|
||||
event.gate_url = url
|
||||
func search(query: String) -> Dictionary:
|
||||
var event = base("search")
|
||||
event.query = query
|
||||
return event
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ var gate_url: String
|
|||
func start() -> void:
|
||||
super.start()
|
||||
|
||||
gate_events.search_pressed.connect(send_search_press)
|
||||
gate_events.search.connect(send_search)
|
||||
gate_events.open_gate.connect(send_gate_open)
|
||||
gate_events.gate_entered.connect(send_gate_enter)
|
||||
gate_events.exit_gate.connect(send_gate_exit)
|
||||
|
@ -22,8 +22,8 @@ func start() -> void:
|
|||
analytics.send_event(JSON.parse_string(json))
|
||||
|
||||
|
||||
func send_search_press(url: String) -> void:
|
||||
analytics.send_event(AnalyticsEvents.search_press(url))
|
||||
func send_search(query: String) -> void:
|
||||
analytics.send_event(AnalyticsEvents.search(query))
|
||||
|
||||
|
||||
func send_gate_open(url: String) -> void:
|
||||
|
|
|
@ -2,15 +2,17 @@ extends Node
|
|||
|
||||
@export var gate_events: GateEvents
|
||||
@export var bookmarks: PackedScene
|
||||
@export var search_results: PackedScene
|
||||
@export var world_scene: PackedScene
|
||||
@export var scenes_root: Node
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
gate_events.search.connect(func(_query): switch_scene(search_results))
|
||||
gate_events.open_gate.connect(func(_url): switch_scene(world_scene))
|
||||
gate_events.exit_gate.connect(func(): switch_scene(bookmarks))
|
||||
|
||||
scenes_root.add_child(bookmarks.instantiate())
|
||||
switch_scene(bookmarks)
|
||||
|
||||
|
||||
func switch_scene(scene: PackedScene) -> void:
|
||||
|
|
|
@ -1,24 +1,30 @@
|
|||
extends Resource
|
||||
class_name GateEvents
|
||||
|
||||
signal search_pressed(url: String)
|
||||
signal search(query: String)
|
||||
signal open_gate(url: String)
|
||||
signal gate_info_loaded(gate: Gate)
|
||||
signal gate_loaded(gate: Gate)
|
||||
signal gate_entered
|
||||
signal exit_gate
|
||||
|
||||
var current_search_query: String
|
||||
var current_gate_url: String
|
||||
var current_gate: Gate
|
||||
|
||||
|
||||
func open_gate_emit(url: String) -> void:
|
||||
current_gate_url = Url.fix_gate_url(url)
|
||||
current_search_query = ""
|
||||
|
||||
open_gate.emit(current_gate_url)
|
||||
|
||||
|
||||
func search_pressed_emit(url: String) -> void:
|
||||
search_pressed.emit(url)
|
||||
func search_emit(query: String) -> void:
|
||||
current_search_query = query
|
||||
current_gate_url = ""
|
||||
|
||||
search.emit(query)
|
||||
|
||||
|
||||
func gate_info_loaded_emit(gate: Gate) -> void:
|
||||
|
@ -36,6 +42,8 @@ func gate_entered_emit() -> void:
|
|||
|
||||
|
||||
func exit_gate_emit() -> void:
|
||||
current_search_query = ""
|
||||
current_gate_url = ""
|
||||
current_gate = null
|
||||
|
||||
exit_gate.emit()
|
||||
|
|
|
@ -10,7 +10,8 @@ extends Node
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
gate_events.open_gate.connect(on_open_gate)
|
||||
gate_events.open_gate.connect(on_new)
|
||||
gate_events.search.connect(on_new)
|
||||
|
||||
go_back.pressed.connect(on_go_back)
|
||||
go_forw.pressed.connect(on_go_forw)
|
||||
|
@ -20,32 +21,32 @@ func _ready() -> void:
|
|||
disable([go_back, go_forw, reload, home])
|
||||
|
||||
|
||||
func on_open_gate(url: String) -> void:
|
||||
history.add(url)
|
||||
func on_new(location: String) -> void:
|
||||
history.add(location)
|
||||
enable([go_back, reload, home])
|
||||
if not history.can_forw():
|
||||
disable([go_forw])
|
||||
|
||||
|
||||
func on_go_back() -> void:
|
||||
var url = history.back()
|
||||
var location = history.back()
|
||||
|
||||
enable([go_forw])
|
||||
if history.can_back():
|
||||
gate_events.open_gate_emit(url)
|
||||
gate_events.open_gate_emit(location)
|
||||
else:
|
||||
disable([go_back, reload, home])
|
||||
gate_events.exit_gate_emit()
|
||||
|
||||
|
||||
func on_go_forw() -> void:
|
||||
var url = history.forw()
|
||||
var location = history.forw()
|
||||
|
||||
enable([go_back])
|
||||
if not history.can_forw():
|
||||
disable([go_forw])
|
||||
|
||||
gate_events.open_gate_emit(url)
|
||||
gate_events.open_gate_emit(location)
|
||||
|
||||
|
||||
func on_reload() -> void:
|
||||
|
|
|
@ -35,25 +35,8 @@ func _on_go_pressed() -> void:
|
|||
|
||||
|
||||
func open_gate() -> void:
|
||||
gate_events.search_pressed_emit(url)
|
||||
if Url.is_valid(url):
|
||||
release_focus()
|
||||
gate_events.open_gate_emit(url)
|
||||
else:
|
||||
shake()
|
||||
|
||||
|
||||
func shake() -> void:
|
||||
gate_events.search_emit(url)
|
||||
release_focus()
|
||||
var tween = get_tree().create_tween()
|
||||
var pos = position
|
||||
const delta = Vector2(0, 5)
|
||||
const duration = 0.07
|
||||
tween.tween_property(self, "position", pos + delta, duration)
|
||||
tween.tween_property(self, "position", pos - delta, duration)
|
||||
tween.tween_property(self, "position", pos + delta, duration)
|
||||
tween.tween_property(self, "position", pos - delta, duration)
|
||||
tween.tween_property(self, "position", pos, duration)
|
||||
await tween.finished
|
||||
grab_focus()
|
||||
|
||||
|
|
11
project/scripts/ui/search/search_results.gd
Normal file
11
project/scripts/ui/search/search_results.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends VBoxContainer
|
||||
|
||||
@export var gate_events: GateEvents
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
search(gate_events.current_search_query)
|
||||
|
||||
|
||||
func search(query: String) -> void:
|
||||
Debug.logclr("======== " + query + " ========", Color.LIGHT_SEA_GREEN)
|
Loading…
Add table
Add a link
Reference in a new issue