Faster sound loading

This commit is contained in:
Anuken
2022-06-26 08:35:08 -04:00
parent 4ae157d50f
commit d84b981d24
4 changed files with 140 additions and 103 deletions

View File

@ -4,6 +4,7 @@ import arc.*;
import arc.assets.*;
import arc.assets.loaders.*;
import arc.audio.*;
import arc.files.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
@ -69,7 +70,34 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
assets.setLoader(Texture.class, "." + mapExtension, new MapPreviewLoader());
tree = new FileTree();
assets.setLoader(Sound.class, new SoundLoader(tree));
assets.setLoader(Sound.class, new SoundLoader(tree){
@Override
public void loadAsync(AssetManager manager, String fileName, Fi file, SoundParameter parameter){
}
@Override
public Sound loadSync(AssetManager manager, String fileName, Fi file, SoundParameter parameter){
if(parameter != null && parameter.sound != null){
mainExecutor.submit(() -> parameter.sound.load(file));
return parameter.sound;
}else{
Sound sound = new Sound();
mainExecutor.submit(() -> {
try{
sound.load(file);
}catch(Throwable t){
Log.err("Error loading sound: " + file, t);
}
});
return sound;
}
}
});
assets.setLoader(Music.class, new MusicLoader(tree));
assets.load("sprites/error.png", Texture.class);

View File

@ -310,7 +310,6 @@ public class MapGenerateDialog extends BaseDialog{
}).grow().left().pad(6).top();
}).width(280f).pad(3).top().left().fillY();
if(++i % cols == 0){
filterTable.row();
}

View File

@ -24,9 +24,11 @@ import static mindustry.Vars.*;
public class MapObjectivesDialog extends BaseDialog{
private Seq<MapObjective> objectives = new Seq<>();
private @Nullable MapObjective selectedObjective;
private Table list = new Table();
private @Nullable MapObjective selectedObjective;
private @Nullable ObjectiveMarker selectedMarker;
public MapObjectivesDialog(){
super("@editor.objectives");
@ -163,6 +165,17 @@ public class MapObjectivesDialog extends BaseDialog{
for(var field : fields){
if((field.getModifiers() & Modifier.PUBLIC) == 0) continue;
displayField(f, field, objective);
}
}).grow();
}
}).width(340f).pad(8f).row();
}
}
void displayField(Table f, Field field, Object objective){
f.add(field.getName() + ": ");
var type = field.getType();
@ -221,7 +234,7 @@ public class MapObjectivesDialog extends BaseDialog{
strings.left().defaults().padBottom(3f).padTop(3f);
String[] array = Reflect.get(objective, field);
for(int i = 0; i < array.length; i ++){
for(int i = 0; i < array.length; i++){
int fi = i;
var str = array[i];
strings.field(str, result -> {
@ -258,6 +271,8 @@ public class MapObjectivesDialog extends BaseDialog{
f.row();
f.add(strings).colspan(2).fill();
//}else if(type == ObjectiveMarker[].class){
}else{
f.add("[red]UNFINISHED");
}
@ -265,13 +280,6 @@ public class MapObjectivesDialog extends BaseDialog{
f.row();
}
}).grow();
}
}).width(340f).pad(8f).row();
}
}
void showContentSelect(@Nullable ContentType type, Cons<UnlockableContent> cons, Boolf<UnlockableContent> check){
BaseDialog dialog = new BaseDialog("");
dialog.cont.pane(p -> {

View File

@ -1546,6 +1546,8 @@ public class LExecutor{
@Remote(called = Loc.server, unreliable = true)
public static void logicExplosion(Team team, float x, float y, float radius, float damage, boolean air, boolean ground, boolean pierce){
if(damage < 0f) return;
Damage.damage(team, x, y, radius, damage, pierce, air, ground);
if(pierce){
Fx.spawnShockwave.at(x, y, World.conv(radius));