mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-09-22 13:01:12 +03:00
Made small data patch sounds load as one-shot wavs instead of streams
This commit is contained in:
@@ -38,10 +38,15 @@ public class MapAudioView implements AssetView{
|
||||
Fi file = asset.getCacheFile();
|
||||
var audioSource = (AudioSource)Core.assets.getOrNull(DataAudioLoader.prefix + asset.name, (Class<?>)(type == DataAssetType.music ? Music.class : Sound.class));
|
||||
|
||||
if(file == null || audioSource == null || !audioSource.valid()){
|
||||
if(file == null || audioSource == null || (!audioSource.valid() && !audioSource.isLazy())){
|
||||
list.button(Icon.warning, Styles.graySquarei, iconMed, () -> ui.showInfo(file == null ? "@asset.broken" : "@asset.audio.invalid")).size(h);
|
||||
}else{
|
||||
list.button(Icon.play, Styles.graySquarei, iconMed, () -> {
|
||||
if(!audioSource.valid() && !audioSource.isLazy()){
|
||||
ui.showInfo("@asset.audio.invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
if(lastPlaying != null && lastPlaying.countPlaying() > 0){
|
||||
lastPlaying.stop();
|
||||
if(lastPlaying == audioSource){
|
||||
@@ -56,16 +61,26 @@ public class MapAudioView implements AssetView{
|
||||
lastPlaying = s;
|
||||
s.play(control.sound.uiBus);
|
||||
}
|
||||
}).update(i -> i.getStyle().imageUp = audioSource != null && audioSource.countPlaying() > 0 ? Icon.pause : Icon.play).size(h);
|
||||
}).update(i -> i.getStyle().imageUp = (!audioSource.isLazy() && !audioSource.valid()) ? Icon.warning : audioSource.countPlaying() > 0 ? Icon.pause : Icon.play).size(h);
|
||||
}
|
||||
|
||||
float w = (mobile ? 390f : 450f);
|
||||
list.table(Styles.grayPanel, in -> {
|
||||
in.left();
|
||||
in.table(v -> {
|
||||
v.left();
|
||||
v.add("[accent]" + asset.name).labelAlign(Align.left).left().ellipsis(true).width(w / 2f);
|
||||
v.add("[accent]" + asset.name).labelAlign(Align.left).left().ellipsis(true).width(audioSource instanceof Music ? w / 2f : w * 0.8f);
|
||||
v.row();
|
||||
v.add("[lightgray][[" + (audioSource == null ? "?" : UI.formatTime(audioSource.getLength() * 60f)) + "]").left();
|
||||
if(audioSource != null){
|
||||
Runnable addTime = () -> v.add("[lightgray][[" + UI.formatTime(audioSource.getLength() * 60f) + "]").left();
|
||||
|
||||
if(audioSource.valid()){
|
||||
addTime.run();
|
||||
}else if(audioSource instanceof Sound s){
|
||||
//force-load sounds when viewing so that length/invalid status is shown
|
||||
s.checkLazyLoad(addTime);
|
||||
}
|
||||
}
|
||||
}).width(w / 2f).tooltip("dp-" + asset.name.replace(' ', '_'));
|
||||
|
||||
if(audioSource instanceof Music m){
|
||||
|
||||
@@ -2394,7 +2394,7 @@ public class LStatements{
|
||||
private static String soundCategory(String entryName){
|
||||
String normalized = entryName.replace('\\', '/');
|
||||
int end = normalized.lastIndexOf('/');
|
||||
if(end < 0) return "Data Patch";
|
||||
if(end < 0) return "data patch";
|
||||
|
||||
int start = normalized.lastIndexOf('/', end - 1);
|
||||
return normalized.substring(start + 1, end);
|
||||
|
||||
@@ -30,7 +30,8 @@ public class DataAudioLoader{
|
||||
}
|
||||
|
||||
Fi file = asset.getCacheFile();
|
||||
Sound sound = Vars.headless || file == null ? new Sound() : Sound.createStream(file);
|
||||
//large sounds become streams, standard ones don't
|
||||
Sound sound = Vars.headless || file == null ? new Sound() : file.length() > 100_000 ? Sound.createStream(file) : Sound.createLazy(file);
|
||||
loadedSounds.add(sound);
|
||||
|
||||
Sounds.registerSound(sound, nextSoundId ++);
|
||||
|
||||
@@ -26,4 +26,4 @@ org.gradle.caching=true
|
||||
org.gradle.internal.http.socketTimeout=100000
|
||||
org.gradle.internal.http.connectionTimeout=100000
|
||||
android.enableR8.fullMode=false
|
||||
archash=5f58c6eda0
|
||||
archash=68a04fab6e
|
||||
|
||||
Reference in New Issue
Block a user