Merge branch 'main' into custom-level-loading-rewrite

This commit is contained in:
JHDev2006
2025-10-17 21:12:58 +01:00
200 changed files with 19511 additions and 16655 deletions

View File

@@ -38,6 +38,7 @@ const DEFAULT_SFX_LIBRARY := {
"firework": "res://Assets/Audio/SFX/Firework.wav",
"timer_beep": "res://Assets/Audio/SFX/TimerBeep.wav",
"hachisuke": "res://Assets/Audio/SFX/Hachisuke.wav",
"hammer_hit": "res://Assets/Audio/SFX/HammerHit.wav",
"burner": "res://Assets/Audio/SFX/Burner.wav",
"rank_up_1": "res://Assets/Audio/SFX/RankUpCBA.wav",
"rank_up_2": "res://Assets/Audio/SFX/RankUpSP.wav",
@@ -88,7 +89,7 @@ const OVERRIDE_STREAMS := [
"res://Assets/Audio/BGM/CastleFinish.json",
"res://Assets/Audio/BGM/Ending.json",
"res://Assets/Audio/SFX/FlagSlide.wav",
"res://Assets/Audio/BGM/Hammer.mp3",
("res://Assets/Audio/BGM/Hammer.json"),
("res://Assets/Audio/BGM/LoseRace.json"),
("res://Assets/Audio/BGM/WinRace.json"),
"res://Assets/Audio/BGM/Wing.json",
@@ -100,6 +101,7 @@ const MUSIC_BASE = preload("uid://da4vqkrpqnma0")
var character_sfx_map := {}
var audio_override_queue := []
#var audio_override_queue: Array[Dictionary] = []
func play_sfx(stream_name = "", position := Vector2.ZERO, pitch := 1.0) -> void:
@@ -158,6 +160,8 @@ func kill_sfx(sfx_name := "") -> void:
func set_music_override(stream: MUSIC_OVERRIDES, priority := 0, stop_on_finish := true, restart := true) -> void:
if audio_override_queue.has(stream):
if current_music_override == stream and restart:
music_override_player.stream = create_stream_from_json(OVERRIDE_STREAMS[stream])
music_override_player.bus = "Music" if stream != MUSIC_OVERRIDES.FLAG_POLE else "SFX"
music_override_player.play()
return
if music_override_priority > priority:
@@ -175,7 +179,6 @@ func set_music_override(stream: MUSIC_OVERRIDES, priority := 0, stop_on_finish :
await music_override_player.finished
stop_music_override(stream)
func stop_music_override(stream: MUSIC_OVERRIDES, force := false) -> void:
if not force:
if stream == null:
@@ -183,16 +186,17 @@ func stop_music_override(stream: MUSIC_OVERRIDES, force := false) -> void:
elif stream != current_music_override:
audio_override_queue.erase(stream)
return
else:
audio_override_queue.clear()
audio_override_queue.pop_back()
current_music_override = MUSIC_OVERRIDES.NONE
music_override_player.stop()
music_override_priority = -1
if audio_override_queue.is_empty():
audio_override_queue.clear()
music_override_priority = -1
current_music_override = MUSIC_OVERRIDES.NONE
music_override_player.stop()
else:
current_music_override = audio_override_queue[audio_override_queue.size() - 1]
set_music_override(audio_override_queue[audio_override_queue.size() - 1])
func load_sfx_map(json := {}) -> void:
@@ -245,8 +249,9 @@ func handle_music_override() -> void:
music_override_player.get_stream_playback().switch_to_clip(0)
func create_stream_from_json(json_path := "") -> AudioStream:
var path := ""
if json_path.contains(".json") == false:
var path = ResourceSetter.get_pure_resource_path(json_path)
path = ResourceSetter.get_pure_resource_path(json_path)
if path.contains(Global.config_path):
match json_path.get_slice(".", 1):
"wav":
@@ -258,8 +263,7 @@ func create_stream_from_json(json_path := "") -> AudioStream:
elif path.contains("res://"):
return load(path)
var bgm_file = $ResourceSetterNew.get_variation_json(JSON.parse_string(FileAccess.open(ResourceSetter.get_pure_resource_path(json_path), FileAccess.READ).get_as_text()).variations).source
var path = json_path.replace(json_path.get_file(), bgm_file)
path = ResourceSetter.get_pure_resource_path(path)
path = ResourceSetter.get_pure_resource_path(json_path.replace(json_path.get_file(), bgm_file))
var stream = null
if path.get_file().contains(".bgm"):
stream = generate_interactive_stream(JSON.parse_string(FileAccess.open(path, FileAccess.READ).get_as_text()))

View File

@@ -34,7 +34,7 @@ var ROM_POINTER_PATH = config_path.path_join("rom_pointer.smb")
var ROM_PATH = config_path.path_join("baserom.nes")
var ROM_ASSETS_PATH = config_path.path_join("resource_packs/BaseAssets")
const ROM_PACK_NAME := "BaseAssets"
const ROM_ASSETS_VERSION := 0
const ROM_ASSETS_VERSION := 1
var server_version := -1
var current_version := -1
@@ -235,6 +235,7 @@ func check_for_rom() -> void:
if pack_dict.get("version", -1) == ROM_ASSETS_VERSION:
rom_assets_exist = true
else:
ResourceGenerator.updating = true
OS.move_to_trash(ROM_ASSETS_PATH)
func _process(delta: float) -> void:
@@ -245,6 +246,10 @@ func _process(delta: float) -> void:
AudioManager.current_level_theme = ""
level_theme_changed.emit()
log_comment("Reloaded resource packs!")
if Input.is_action_just_pressed("toggle_fps_count"):
%FPSCount.visible = !%FPSCount.visible
%FPSCount.text = str(int(Engine.get_frames_per_second())) + " FPS"
handle_p_switch(delta)
if Input.is_key_label_pressed(KEY_F11) and debug_mode == false and OS.is_debug_build():
@@ -259,6 +264,10 @@ func take_screenshot() -> void:
var img: Image = get_viewport().get_texture().get_image()
var filename = Global.config_path.path_join("screenshots/screenshot_" + str(int(Time.get_unix_time_from_system())) + ".png")
var err = img.save_png(filename)
if !err:
log_comment("Screenshot Saved!")
else:
log_error(error_string(err))
func handle_p_switch(delta: float) -> void:
if p_switch_active and get_tree().paused == false:
@@ -458,7 +467,7 @@ func check_completionist_achievement() -> void:
if achievements.count("0") == 1:
unlock_achievement(AchievementID.COMPLETIONIST)
const FONT = preload("uid://cd221873lbtj1")
const FONT = preload("res://Assets/Sprites/UI/Font.fnt")
func sanitize_string(string := "") -> String:
string = string.to_upper()
@@ -466,3 +475,11 @@ func sanitize_string(string := "") -> String:
if FONT.has_char(string.unicode_at(i)) == false and string[i] != "\n":
string = string.replace(string[i], " ")
return string
func get_base_asset_version() -> int:
var json = JSON.parse_string(FileAccess.open("user://BaseAssets/pack_info.json", FileAccess.READ).get_as_text())
var version = json.version
return get_version_num_int(version)
func get_version_num_int(ver_num := "0.0.0") -> int:
return int(ver_num.replace(".", ""))

View File

@@ -10,6 +10,7 @@ var file := {
"visuals": 0,
"hud_size": 0,
"frame_limit" : 0,
"window_size": [256, 240]
},
"audio": {
"master": 10,
@@ -94,6 +95,11 @@ func _enter_tree() -> void:
await get_tree().physics_frame
apply_settings()
TranslationServer.set_locale(Settings.file.game.lang)
get_window().size_changed.connect(update_window_size)
func update_window_size() -> void:
var window_size = get_window().size
Settings.file.video.window_size = [window_size.x, window_size.y]
func save_settings() -> void:
var cfg_file = ConfigFile.new()
@@ -112,6 +118,12 @@ func load_settings() -> void:
for section in cfg_file.get_sections():
for key in cfg_file.get_section_keys(section):
file[section][key] = cfg_file.get_value(section, key)
fix_broken_settings()
func fix_broken_settings() -> void:
# Fix any "permanently-enabled" resource packs from 1.0.2 snapshots after portable mode was added, but before this bug was fixed
for i in range(file.visuals.resource_packs.size()):
file.visuals.resource_packs[i] = str(file.visuals.resource_packs[i]).trim_prefix("/")
func apply_settings() -> void:
for i in file.video.keys():