mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-24 16:30:53 +00:00
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:
@@ -12,9 +12,12 @@ signal pack_created
|
|||||||
const base_info_json := {
|
const base_info_json := {
|
||||||
"name": "New Pack",
|
"name": "New Pack",
|
||||||
"description": "Template, give me a description!",
|
"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:
|
func create_template() -> void:
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
get_directories("res://Assets", files, directories)
|
get_directories("res://Assets", files, directories)
|
||||||
@@ -30,22 +33,43 @@ func create_template() -> void:
|
|||||||
if i.contains(".fnt"):
|
if i.contains(".fnt"):
|
||||||
data = await download_fnt_text(i)
|
data = await download_fnt_text(i)
|
||||||
## Imagine being one of the best open source game engines, yet not able to get the FUCKING CONTENTS
|
## 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.
|
## 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)
|
var resource = load(i)
|
||||||
if resource is Texture:
|
if resource is Texture:
|
||||||
|
if OS.is_debug_build(): print("texture:" + i)
|
||||||
data = resource.get_image().save_png_to_buffer()
|
data = resource.get_image().save_png_to_buffer()
|
||||||
elif resource is AudioStream:
|
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:
|
else:
|
||||||
|
if OS.is_debug_build(): print("else:" + i)
|
||||||
var old_file = FileAccess.open(i, FileAccess.READ)
|
var old_file = FileAccess.open(i, FileAccess.READ)
|
||||||
data = old_file.get_buffer(old_file.get_length())
|
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()
|
old_file.close()
|
||||||
|
|
||||||
var new_file = FileAccess.open(destination, FileAccess.WRITE)
|
if !data.is_empty():
|
||||||
new_file.store_buffer(data)
|
if OS.is_debug_build(): print("saving:" + i)
|
||||||
new_file.close()
|
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")
|
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())
|
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):
|
for i in DirAccess.get_files_at(base_dir):
|
||||||
if base_dir.contains("LevelGuides") == false:
|
if base_dir.contains("LevelGuides") == false:
|
||||||
i = i.replace(".import", "")
|
i = i.replace(".import", "")
|
||||||
print(i)
|
#print(i)
|
||||||
var target_path = base_dir + "/" + i
|
var target_path = base_dir + "/" + i
|
||||||
var rom_assets_path = target_path.replace("res://Assets", Global.config_path.path_join("resource_packs/BaseAssets"))
|
var rom_assets_path = target_path.replace("res://Assets", Global.config_path.path_join("resource_packs/BaseAssets"))
|
||||||
if FileAccess.file_exists(rom_assets_path):
|
if FileAccess.file_exists(rom_assets_path):
|
||||||
files.append(rom_assets_path)
|
files.append(rom_assets_path)
|
||||||
else:
|
else:
|
||||||
files.append(target_path)
|
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:
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func frame_limit_changed(new_value := 0) -> void:
|
|||||||
3: new_framerate = 144
|
3: new_framerate = 144
|
||||||
4: new_framerate = 240
|
4: new_framerate = 240
|
||||||
|
|
||||||
Engine.max_fps = new_framerate
|
Engine.set_max_fps(new_framerate)
|
||||||
Settings.file.video.frame_limit = new_value
|
Settings.file.video.frame_limit = new_value
|
||||||
|
|
||||||
func set_window_size(value := []) -> void:
|
func set_window_size(value := []) -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user