56 lines
1.2 KiB
GDScript
56 lines
1.2 KiB
GDScript
extends Node
|
|
|
|
func error(msg):
|
|
get_node("ErrorPopup/ErrorLbl").text = msg
|
|
get_node("ErrorPopup").popup_centered()
|
|
|
|
|
|
func _on_Quit_pressed():
|
|
get_tree().quit() # Quits the game
|
|
|
|
|
|
func _on_BrowseButton_pressed():
|
|
get_node("GCKFileDialog").popup()
|
|
|
|
|
|
func _on_GCKFileDialog_dir_selected(dir):
|
|
get_node("GiantsDir").text = dir
|
|
|
|
|
|
func _on_Start_pressed():
|
|
if (check_path(get_node("GiantsDir").text)):
|
|
var f = File.new()
|
|
f.open("res://dir.txt", File.WRITE)
|
|
f.store_string(get_node("GiantsDir").text)
|
|
f.close()
|
|
|
|
get_tree().change_scene("res://viewer.tscn")
|
|
|
|
|
|
func check_path(path) -> bool:
|
|
var ret = true
|
|
var d = Directory.new()
|
|
if not d.dir_exists(path):
|
|
error("%s is not a valid directory!" % path)
|
|
ret = false
|
|
|
|
if not d.file_exists("%s/Giants.exe" % path):
|
|
error("%s does not contain Giants.exe!" % path)
|
|
ret = false
|
|
return ret
|
|
|
|
func _on_Node_ready():
|
|
var f = File.new()
|
|
f.open("res://dir.txt", File.READ)
|
|
var dir = f.get_as_text()
|
|
f.close()
|
|
get_node("GiantsDir").text = dir
|
|
|
|
if dir:
|
|
if check_path(get_node("GiantsDir").text):
|
|
get_tree().change_scene("res://viewer.tscn")
|
|
# error("Changed")
|
|
|
|
func _on_Close_pressed():
|
|
get_node("ErrorPopup").visible = false
|