diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 7395a71b7b..37df1c9623 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -567,6 +567,7 @@ asset.content.badname = [red]Invalid name! Most symbols are not allowed. asset.content.import.file = Import File asset.content.import.clipboard = Import From Clipboard asset.exists = An asset of that type with the same path/name already exists:\n[lightgray]{0} +asset.exists.audio = A sound/music asset with that name is already loaded:\n[lightgray]{0} asset.broken = This asset file could not be located.\nThis can be caused by improper import of data, or an incorrectly exported save. asset.audio.invalid = Audio file could not be loaded.\nEnsure that it is a valid OGG or MP3 file. asset.delete.confirm = Are you sure you want to delete this asset? diff --git a/core/src/mindustry/editor/data/MapAudioView.java b/core/src/mindustry/editor/data/MapAudioView.java index ca89b74932..9730537469 100644 --- a/core/src/mindustry/editor/data/MapAudioView.java +++ b/core/src/mindustry/editor/data/MapAudioView.java @@ -97,6 +97,7 @@ public class MapAudioView implements AssetView{ if(audioSource != null){ audioSource.dispose(); } + Core.assets.unload("dp-" + asset.name); assets.remove(asset); diag.rebuild(); }); @@ -106,7 +107,7 @@ public class MapAudioView implements AssetView{ } if(list.getChildren().isEmpty()){ - list.add("@patch.none"); + list.add("@none.found"); } list.add(new Element(){ @@ -142,6 +143,9 @@ public class MapAudioView implements AssetView{ if(other != null){ ui.showErrorMessage(Core.bundle.format("asset.exists", other.name + " (" + other.path + ")")); return; + }else if(Core.assets.getOrNull("dp-" + name, Music.class) != null || Core.assets.getOrNull("dp-" + name, Sound.class) != null){ + ui.showErrorMessage(Core.bundle.format("asset.exists.audio", name)); + return; } DataAsset asset = (type == DataAssetType.music ? new MusicAsset() : new SoundAsset()); diff --git a/core/src/mindustry/input/Binding.java b/core/src/mindustry/input/Binding.java index 9cabe97c32..8590a4bc97 100644 --- a/core/src/mindustry/input/Binding.java +++ b/core/src/mindustry/input/Binding.java @@ -86,7 +86,7 @@ public class Binding{ zoom = KeyBind.add("zoom", new Axis(KeyCode.scroll), "view"), detachCamera = KeyBind.add("detach_camera", KeyCode.unset), - teleportCursor = KeyBind.add("teleport_cusor", KeyCode.unset), + teleportCursor = KeyBind.add("teleport_cursor", KeyCode.unset), menu = KeyBind.add("menu", Vars.android ? KeyCode.back : KeyCode.escape), fullscreen = KeyBind.add("fullscreen", KeyCode.f11), pause = KeyBind.add("pause", KeyCode.space), diff --git a/core/src/mindustry/mod/DataAudioLoader.java b/core/src/mindustry/mod/DataAudioLoader.java index 8f78ced12f..20a7daaa63 100644 --- a/core/src/mindustry/mod/DataAudioLoader.java +++ b/core/src/mindustry/mod/DataAudioLoader.java @@ -4,6 +4,7 @@ import arc.*; import arc.audio.*; import arc.files.*; import arc.struct.*; +import arc.util.*; import mindustry.*; import mindustry.gen.*; import mindustry.mod.data.*; @@ -14,13 +15,17 @@ public class DataAudioLoader{ private Seq loadedSounds = new Seq<>(); private Seq loadedMusic = new Seq<>(); - private Seq registered = new Seq<>(); + private ObjectSet registered = new ObjectSet<>(); public void load(Seq sounds, Seq musics){ int nextSoundId = soundIdOffset + 1; for(var asset : sounds){ + if(registered.contains(prefix + asset.name)){ + Log.warn("Duplicate audio file: " + asset.name); + continue; + } Fi file = asset.getCacheFile(); Sound sound = Vars.headless || file == null ? new Sound() : Sound.createStream(file); loadedSounds.add(sound); @@ -34,6 +39,10 @@ public class DataAudioLoader{ } for(var asset : musics){ + if(registered.contains(prefix + asset.name)){ + Log.warn("Duplicate audio file: " + asset.name); + continue; + } Fi file = asset.getCacheFile(); Music music = Vars.headless || file == null ? new Music() : Music.create(file); loadedMusic.add(music); @@ -57,7 +66,10 @@ public class DataAudioLoader{ if(!Vars.headless){ for(String reg : registered){ - Core.assets.unload(reg); + try{ + Core.assets.unload(reg); + }catch(Exception ignored){ //unloading shouldn't throw an error, but ignore it just in case + } } }