mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-01 18:50:27 +03:00
Fixed #12290
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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<Sound> loadedSounds = new Seq<>();
|
||||
private Seq<Music> loadedMusic = new Seq<>();
|
||||
private Seq<String> registered = new Seq<>();
|
||||
private ObjectSet<String> registered = new ObjectSet<>();
|
||||
|
||||
public void load(Seq<SoundAsset> sounds, Seq<MusicAsset> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user