init
This commit is contained in:
commit
f389e4e807
186 changed files with 10853 additions and 0 deletions
70
addons/AsepriteWizard/importers/helpers/bakery.gd
Normal file
70
addons/AsepriteWizard/importers/helpers/bakery.gd
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
@tool
|
||||
extends RefCounted
|
||||
|
||||
const logger = preload("../../config/logger.gd")
|
||||
|
||||
func save_bake_file(source_path: String, resource: Resource) -> int:
|
||||
var bake_path = _bake_path(source_path)
|
||||
var hash = FileAccess.get_md5(source_path)
|
||||
|
||||
resource.set_meta('source_hash', hash)
|
||||
|
||||
var result = ResourceSaver.save(resource, bake_path)
|
||||
ResourceLoader.load(bake_path, "", ResourceLoader.CACHE_MODE_REPLACE_DEEP)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
func has_bake_file(source_path: String) -> bool:
|
||||
var bake_path = _bake_path(source_path)
|
||||
return ResourceLoader.exists(bake_path)
|
||||
|
||||
|
||||
func load_bake_file(source_path: String, target_path: String) -> int:
|
||||
var source_hash = FileAccess.get_md5(source_path)
|
||||
var bake_path = _bake_path(source_path)
|
||||
var bake = ResourceLoader.load(bake_path, "", ResourceLoader.CACHE_MODE_REPLACE_DEEP)
|
||||
|
||||
if bake.get_meta('source_hash') != source_hash:
|
||||
logger.warn("baked file hash does not match current source file", source_path)
|
||||
|
||||
var result = ResourceSaver.save(bake, target_path)
|
||||
|
||||
ResourceLoader.load(target_path, "", ResourceLoader.CACHE_MODE_REPLACE_DEEP)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
func load_bake_texture(source_path: String, target_path: String) -> int:
|
||||
var source_hash = FileAccess.get_md5(source_path)
|
||||
var bake_path = _bake_path(source_path)
|
||||
var bake: PortableCompressedTexture2D = ResourceLoader.load(bake_path, "", ResourceLoader.CACHE_MODE_REPLACE_DEEP)
|
||||
|
||||
if bake.get_meta('source_hash') != source_hash:
|
||||
logger.warn("baked file hash does not match current source file", source_path)
|
||||
|
||||
|
||||
var tex := PortableCompressedTexture2D.new()
|
||||
tex.create_from_image(bake.get_image(), PortableCompressedTexture2D.COMPRESSION_MODE_LOSSLESS)
|
||||
|
||||
var result = ResourceSaver.save(tex, target_path)
|
||||
ResourceLoader.load(target_path, "PortableCompressedTexture2D", ResourceLoader.CACHE_MODE_REPLACE_DEEP)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
func delete_bake_file(source_path: String) -> int:
|
||||
return DirAccess.remove_absolute(_bake_path(source_path))
|
||||
|
||||
|
||||
func move_bake_file(old_path: String, new_path: String) -> int:
|
||||
var old_bake_path = _bake_path(old_path)
|
||||
var new_bake_path = _bake_path(new_path)
|
||||
|
||||
return DirAccess.rename_absolute(old_bake_path, new_bake_path)
|
||||
|
||||
|
||||
func _bake_path(source_path: String) -> String:
|
||||
var file = source_path.get_file()
|
||||
var dir = source_path.get_base_dir()
|
||||
return dir.path_join(".%s.ase_bake.res" % file)
|
||||
1
addons/AsepriteWizard/importers/helpers/bakery.gd.uid
Normal file
1
addons/AsepriteWizard/importers/helpers/bakery.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://crehekgicyf6e
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
@tool
|
||||
extends Node
|
||||
|
||||
const WAIT_TIME_IN_SECONDS := 0.8
|
||||
var _time_left := 0.0
|
||||
var _scheduled := false
|
||||
|
||||
## Schedule a file system scan. This method works like a debouncer
|
||||
## postponing the scan until no more calls are being made
|
||||
func schedule_file_system_scan() -> void:
|
||||
_time_left = WAIT_TIME_IN_SECONDS
|
||||
_scheduled = true
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if _scheduled:
|
||||
if _time_left > 0.0:
|
||||
_time_left -= delta
|
||||
else:
|
||||
_scheduled = false
|
||||
if not EditorInterface.get_resource_filesystem().is_scanning():
|
||||
EditorInterface.get_resource_filesystem().scan.call_deferred()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://gc2xkqnjlarn
|
||||
Loading…
Add table
Add a link
Reference in a new issue