Resource pack export fixes for specific filetypes (#657)

* Resource pack creator fixes

* Spacing fix + comments for Joe

* Some further fixes, added an array of files which shouldn't be loaded in-engine to remove large amount of ifs
This commit is contained in:
guzlad
2025-10-23 22:43:53 +02:00
committed by GitHub
parent 64cce1bb68
commit 27396cca5d
2 changed files with 34 additions and 9 deletions

View File

@@ -12,8 +12,11 @@ signal pack_created
const base_info_json := {
"name": "New Pack",
"description": "Template, give me a description!",
"author": "Me, until you change it"
"author": "Me, until you change it",
"version": "1.0"
}
const disallowed_files := ["bgm","ctex","json","fnt", "svg"]
func create_template() -> void:
await get_tree().process_frame
@@ -30,22 +33,43 @@ func create_template() -> void:
if i.contains(".fnt"):
data = await download_fnt_text(i)
## Imagine being one of the best open source game engines, yet not able to get the FUCKING CONTENTS
## OF AN FNT FILE SO INSTEAD YOU HAVE TO WRITE THE MOST BULLSHIT CODE TO DOWNLOAD THE FUCKING FILE
## OF AN FNT FILE SO INSTEAD YOU HAVE TO WRITE THE MOST BULLSHIT CODzE TO DOWNLOAD THE FUCKING FILE
## FROM THE FUCKING GITHUB REPO. WHY? BECAUSE GODOT IS SHIT. FUCK GODOT.
elif i.contains(".bgm") == false and i.contains(".ctex") == false and i.contains(".json") == false and i.contains("res://") and i.contains(".fnt") == false:
elif i.contains(".svg"):
## DON'T import SVGs
continue
elif disallowed_files.has(i.get_extension()) == false and i.contains("res://"):
var resource = load(i)
if resource is Texture:
if OS.is_debug_build(): print("texture:" + i)
data = resource.get_image().save_png_to_buffer()
elif resource is AudioStream:
data = resource.get_data()
match i.get_extension():
"mp3":
if OS.is_debug_build(): print("mp3:" + i)
data = resource.get_data()
"wav":
## guzlad: CAN NOT BE format FORMAT_IMA_ADPCM or FORMAT_QOA as they don't support the save function
## guzlad: Should be FORMAT_16_BITS like most of our other .wav files
if OS.is_debug_build(): print("wav:" + i)
var wav_file: AudioStreamWAV = load(i)
if OS.is_debug_build(): print(error_string(wav_file.save_to_wav(destination)))
## guzlad: No OGG yet
_:
data = resource.get_data()
else:
if OS.is_debug_build(): print("else:" + i)
var old_file = FileAccess.open(i, FileAccess.READ)
data = old_file.get_buffer(old_file.get_length())
if OS.is_debug_build(): print("else error: " + error_string(old_file.get_error()))
old_file.close()
var new_file = FileAccess.open(destination, FileAccess.WRITE)
new_file.store_buffer(data)
new_file.close()
if !data.is_empty():
if OS.is_debug_build(): print("saving:" + i)
var new_file = FileAccess.open(destination, FileAccess.WRITE)
new_file.store_buffer(data)
if OS.is_debug_build(): print("saving error: " + error_string(new_file.get_error()))
new_file.close()
var pack_info_path = Global.config_path.path_join("resource_packs/new_pack/pack_info.json")
DirAccess.make_dir_recursive_absolute(pack_info_path.get_base_dir())
@@ -81,10 +105,11 @@ func get_files(base_dir := "", files := []) -> void:
for i in DirAccess.get_files_at(base_dir):
if base_dir.contains("LevelGuides") == false:
i = i.replace(".import", "")
print(i)
#print(i)
var target_path = base_dir + "/" + i
var rom_assets_path = target_path.replace("res://Assets", Global.config_path.path_join("resource_packs/BaseAssets"))
if FileAccess.file_exists(rom_assets_path):
files.append(rom_assets_path)
else:
files.append(target_path)
# elif i.contains(".bgm") == false and i.contains(".ctex") == false and i.contains(".json") == false and i.contains("res://") and i.contains(".fnt") == false:

View File

@@ -56,7 +56,7 @@ func frame_limit_changed(new_value := 0) -> void:
3: new_framerate = 144
4: new_framerate = 240
Engine.max_fps = new_framerate
Engine.set_max_fps(new_framerate)
Settings.file.video.frame_limit = new_value
func set_window_size(value := []) -> void: