add license, move folders

This commit is contained in:
Nordup 2024-05-04 00:14:24 +04:00
parent 185cc74060
commit 271c4a46a1
132 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,16 @@
extends GridContainer
@export var bookmarks: Bookmarks
@export var bookmark_scene: PackedScene
func _ready() -> void:
bookmarks.on_star.connect(show_bookmark)
for gate in bookmarks.gates.values():
show_bookmark(gate)
func show_bookmark(gate: Gate, _featured: bool = false) -> void:
var bookmark: BookmarkUI = bookmark_scene.instantiate()
bookmark.fill(gate)
add_child(bookmark)

View file

@ -0,0 +1,21 @@
extends Node
class_name BookmarkUI
@export var gate_events: GateEvents
@export var image: TextureRect
@export var title: Label
var url: String
func fill(gate: Gate) -> void:
if gate == null: return
url = gate.url
title.text = "Unnamed" if gate.title.is_empty() else gate.title
image.texture = FileTools.load_external_tex(gate.image)
func _on_base_button_pressed() -> void:
if url.is_empty(): return
gate_events.open_gate_emit(url)

View file

@ -0,0 +1,5 @@
extends BaseButton
func _on_pressed() -> void:
get_tree().quit()

View file

@ -0,0 +1,52 @@
extends Resource
class_name History
var history: Array[String]
var index := -1
func get_current() -> String:
if index == -1: return ""
return history[index]
func can_forw() -> bool:
return index + 1 < history.size()
func can_back() -> bool:
return index > -1
func add(url: String) -> void:
if url == get_current(): return
index += 1
history.resize(index)
history.push_back(url)
print_history()
func forw() -> String:
index += 1
print_history()
return history[index]
func back() -> String:
index -= 1
print_history()
if index == -1:
return ""
return history[index]
func clear() -> void:
index = -1
history.clear()
print_history()
func print_history() -> void:
# Debug.logclr("History: " + str(history) + " Current: " + str(index), Color.DIM_GRAY)
pass

View file

@ -0,0 +1,13 @@
extends Control
@export var ui_events: UiEvents
func _ready() -> void:
resized.connect(on_resized)
on_resized()
func on_resized() -> void:
Debug.logclr("Ui resized: %dx%d" % [size.x, size.y], Debug.SILENT_CLR)
ui_events.ui_size_changed_emit(size)

View file

@ -0,0 +1,80 @@
extends Node
@export var gate_events: GateEvents
@export var history: History
@export var go_back: BaseButton
@export var go_forw: BaseButton
@export var reload: BaseButton
@export var home: BaseButton
func _ready() -> void:
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)
reload.pressed.connect(on_reload)
home.pressed.connect(on_home)
disable([go_back, go_forw, reload, home])
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 location = history.back()
enable([go_forw])
if history.can_back():
open(location)
else:
disable([go_back, reload, home])
gate_events.exit_gate_emit()
func on_go_forw() -> void:
var location = history.forw()
enable([go_back])
if not history.can_forw():
disable([go_forw])
open(location)
func on_reload() -> void:
open(history.get_current())
func on_home() -> void:
history.clear()
disable([go_back, go_forw, reload, home])
gate_events.exit_gate_emit()
func open(location: String) -> void:
if Url.is_valid(location):
gate_events.open_gate_emit(location)
else:
gate_events.search_emit(location)
func disable(buttons: Array[BaseButton]) -> void:
for button in buttons:
button.disabled = true
button.modulate.a = 0.5
button.mouse_default_cursor_shape = Control.CURSOR_ARROW
func enable(buttons: Array[BaseButton]) -> void:
for button in buttons:
button.disabled = false
button.modulate.a = 1
button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND

View file

@ -0,0 +1,62 @@
extends Node
@export var gate_events: GateEvents
@export var bookmarks: Bookmarks
@export var star: Control
@export var unstar: Control
var gate: Gate
var url: String
func _ready() -> void:
star.visible = false
unstar.visible = false
gate_events.open_gate.connect(show_buttons)
gate_events.search.connect(func(_query): hide_buttons())
gate_events.exit_gate.connect(hide_buttons)
gate_events.gate_info_loaded.connect(update_info)
func show_buttons(_url: String) -> void:
url = _url
if bookmarks.gates.has(url):
star.visible = false
unstar.visible = true
else:
star.visible = true
unstar.visible = false
func hide_buttons() -> void:
star.visible = false
unstar.visible = false
gate = null
func update_info(_gate: Gate, _is_cached: bool) -> void:
gate = _gate
if bookmarks.gates.has(gate.url):
bookmarks.update(gate)
func _on_star_pressed() -> void:
if gate == null:
gate = Gate.new()
gate.url = url
bookmarks.star(gate)
star.visible = false
unstar.visible = true
func _on_unstar_pressed() -> void:
if gate == null:
gate = Gate.new()
gate.url = url
bookmarks.unstar(gate)
star.visible = true
unstar.visible = false