small racing game im working on
Diffstat (limited to 'ui/editor/save.gd')
-rw-r--r--ui/editor/save.gd19
1 files changed, 19 insertions, 0 deletions
diff --git a/ui/editor/save.gd b/ui/editor/save.gd
new file mode 100644
index 0000000..c77ea48
--- /dev/null
+++ b/ui/editor/save.gd
@@ -0,0 +1,19 @@
+extends Button
+
+@onready var hist: UndoRedo = owner.history
+
+const icons: PackedStringArray = ['󰆓', '󰽂', '󱣪']
+var unsaved := false:
+ set(un):
+ unsaved = un
+ text = icons[int(un)]
+
+func _on_pressed() -> void:
+ var data := (owner as TrackEditor).get_trackdata()
+ if FileAccess.file_exists(Globals.TRACKS % data.name):
+ pass
+ data.save(Globals.TRACKS % data.name)
+ unsaved = false
+
+func _ready() -> void:
+ hist.version_changed.connect(func(): unsaved = true)