Remember last opened file and open it on start, implements #33
This commit is contained in:
parent
ec7544cb3b
commit
974c40fcb4
2 changed files with 19 additions and 0 deletions
|
@ -65,11 +65,25 @@ func load_shader(path: String):
|
|||
if "/" in path: # update current working directory
|
||||
self.cwd = path.substr(0, path.rfind("/"))
|
||||
self.last_shader_savepath = path
|
||||
store_last_opened_file()
|
||||
|
||||
func save_shader(path: String):
|
||||
print("Save ", path)
|
||||
var file = FileAccess.open(path, FileAccess.WRITE)
|
||||
file.store_string(self.shader_code)
|
||||
file.flush()
|
||||
if "/" in path: # update current working directory
|
||||
self.cwd = path.substr(0, path.rfind("/"))
|
||||
self.last_shader_savepath = path
|
||||
store_last_opened_file()
|
||||
|
||||
func store_last_opened_file():
|
||||
var f = FileAccess.open("user://last_opened", FileAccess.WRITE)
|
||||
if f != null:
|
||||
f.store_pascal_string(last_shader_savepath)
|
||||
f.flush()
|
||||
|
||||
func remember_last_opened_file():
|
||||
var f = FileAccess.open("user://last_opened", FileAccess.READ)
|
||||
if f != null:
|
||||
last_shader_savepath = f.get_pascal_string()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
extends Node
|
||||
|
||||
@onready var editor_window = %EditorWindow
|
||||
@onready var ui_container = %UserInterfaceContainer
|
||||
@onready var app_name = ProjectSettings.get_setting("application/config/name")
|
||||
|
||||
func _ready():
|
||||
|
@ -11,6 +12,10 @@ func _ready():
|
|||
editor_window.position.y)
|
||||
get_window().min_size = Vector2i(400, 400)
|
||||
editor_window.min_size = Vector2i(560, 400)
|
||||
# Load last opened file
|
||||
Filesystem.remember_last_opened_file()
|
||||
if Filesystem.last_shader_savepath != "":
|
||||
ui_container.get_node("Editor")._on_open_shader_dialog_file_selected(Filesystem.last_shader_savepath)
|
||||
|
||||
func update_title(current_file: String = ""):
|
||||
if current_file == "":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue