mirror of
https://github.com/Relintai/pandemonium_cms.git
synced 2024-11-14 09:37:19 +01:00
55 lines
1.3 KiB
GDScript
55 lines
1.3 KiB
GDScript
tool
|
|
extends WebNode
|
|
class_name WebPage, "res://addons/web_pages/icons/icon_web_page.svg"
|
|
|
|
export(Array, Resource) var entries : Array
|
|
|
|
signal entries_changed()
|
|
|
|
func add_entry(var entry : WebPageEntry, var after : WebPageEntry = null) -> void:
|
|
if after != null:
|
|
for i in range(entries.size()):
|
|
if entries[i] == after:
|
|
entries.insert(i + 1, entry)
|
|
break
|
|
else:
|
|
entries.push_back(entry)
|
|
|
|
emit_signal("entries_changed")
|
|
|
|
func remove_entry(var entry : WebPageEntry) -> void:
|
|
entries.erase(entry)
|
|
|
|
emit_signal("entries_changed")
|
|
|
|
func move_entry_up(var entry : WebPageEntry) -> void:
|
|
# Skips checking the first entry (1, entries.size())
|
|
for i in range(1, entries.size()):
|
|
if entries[i] == entry:
|
|
entries[i] = entries[i - 1]
|
|
entries[i - 1] = entry
|
|
emit_signal("entries_changed")
|
|
return
|
|
|
|
func move_entry_down(var entry : WebPageEntry) -> void:
|
|
# Skips checking the last entry (size() - 1)
|
|
for i in range(entries.size() - 1):
|
|
if entries[i] == entry:
|
|
entries[i] = entries[i + 1]
|
|
entries[i + 1] = entry
|
|
emit_signal("entries_changed")
|
|
return
|
|
|
|
func get_entry_before(var entry : WebPageEntry) -> WebPageEntry:
|
|
if entries.size() < 2:
|
|
return null
|
|
|
|
if entries[0] == entry:
|
|
return null
|
|
|
|
for i in range(1, entries.size()):
|
|
if entries[i] == entry:
|
|
return entries[i - 1]
|
|
|
|
return null
|