Added a dynamic layout system where UI elements can be moved about on a tiled grid.
This commit is contained in:
1 parent
ea6ba54666
commit
26c29df4ad
34 files changed
+1269
No files matched your search
@@ -0,0 +1,35 @@
|
||||
extends RefCounted
|
||||
|
||||
static func read_json(path: String) -> Variant:
|
||||
var file := FileAccess.open(path, FileAccess.READ)
|
||||
if file == null or file.get_length() > 1048576:
|
||||
return null
|
||||
var parser := JSON.new()
|
||||
if parser.parse(file.get_as_text()) != OK:
|
||||
return null
|
||||
return parser.data
|
||||
|
||||
static func write_json(path: String, document: Dictionary) -> Error:
|
||||
var absolute := ProjectSettings.globalize_path(path)
|
||||
var error := DirAccess.make_dir_recursive_absolute(absolute.get_base_dir())
|
||||
if error != OK:
|
||||
return error
|
||||
var temporary := absolute + ".tmp"
|
||||
var file := FileAccess.open(temporary, FileAccess.WRITE)
|
||||
if file == null:
|
||||
return FileAccess.get_open_error()
|
||||
file.store_string(JSON.stringify(document, "\t") + "\n")
|
||||
file.flush()
|
||||
error = file.get_error()
|
||||
file.close()
|
||||
if error != OK:
|
||||
return error
|
||||
return DirAccess.rename_absolute(temporary, absolute)
|
||||
|
||||
static func integer_array(value: Variant, length: int) -> bool:
|
||||
if not value is Array or value.size() != length:
|
||||
return false
|
||||
for number in value:
|
||||
if not (number is int or number is float) or not is_finite(float(number)) or float(number) != floorf(float(number)):
|
||||
return false
|
||||
return true
|
||||
Reference in new issue
Block a user