mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 02:17:27 -04:00
52 lines
797 B
GDScript
52 lines
797 B
GDScript
extends Resource
|
|
class_name History
|
|
|
|
var history: Array[String] = [""]
|
|
var index := 0
|
|
|
|
|
|
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 > 0
|
|
|
|
|
|
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
|