mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-05 07:47:48 +07:00
Faster sound loading
This commit is contained in:
@ -4,6 +4,7 @@ import arc.*;
|
|||||||
import arc.assets.*;
|
import arc.assets.*;
|
||||||
import arc.assets.loaders.*;
|
import arc.assets.loaders.*;
|
||||||
import arc.audio.*;
|
import arc.audio.*;
|
||||||
|
import arc.files.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
@ -69,7 +70,34 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
|||||||
assets.setLoader(Texture.class, "." + mapExtension, new MapPreviewLoader());
|
assets.setLoader(Texture.class, "." + mapExtension, new MapPreviewLoader());
|
||||||
|
|
||||||
tree = new FileTree();
|
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.setLoader(Music.class, new MusicLoader(tree));
|
||||||
|
|
||||||
assets.load("sprites/error.png", Texture.class);
|
assets.load("sprites/error.png", Texture.class);
|
||||||
|
@ -310,7 +310,6 @@ public class MapGenerateDialog extends BaseDialog{
|
|||||||
}).grow().left().pad(6).top();
|
}).grow().left().pad(6).top();
|
||||||
}).width(280f).pad(3).top().left().fillY();
|
}).width(280f).pad(3).top().left().fillY();
|
||||||
|
|
||||||
|
|
||||||
if(++i % cols == 0){
|
if(++i % cols == 0){
|
||||||
filterTable.row();
|
filterTable.row();
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,11 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class MapObjectivesDialog extends BaseDialog{
|
public class MapObjectivesDialog extends BaseDialog{
|
||||||
private Seq<MapObjective> objectives = new Seq<>();
|
private Seq<MapObjective> objectives = new Seq<>();
|
||||||
private @Nullable MapObjective selectedObjective;
|
|
||||||
private Table list = new Table();
|
private Table list = new Table();
|
||||||
|
|
||||||
|
private @Nullable MapObjective selectedObjective;
|
||||||
|
private @Nullable ObjectiveMarker selectedMarker;
|
||||||
|
|
||||||
public MapObjectivesDialog(){
|
public MapObjectivesDialog(){
|
||||||
super("@editor.objectives");
|
super("@editor.objectives");
|
||||||
|
|
||||||
@ -163,106 +165,7 @@ public class MapObjectivesDialog extends BaseDialog{
|
|||||||
for(var field : fields){
|
for(var field : fields){
|
||||||
if((field.getModifiers() & Modifier.PUBLIC) == 0) continue;
|
if((field.getModifiers() & Modifier.PUBLIC) == 0) continue;
|
||||||
|
|
||||||
f.add(field.getName() + ": ");
|
displayField(f, field, objective);
|
||||||
|
|
||||||
var type = field.getType();
|
|
||||||
|
|
||||||
if(type == String.class){
|
|
||||||
f.field(Reflect.get(objective, field), text -> {
|
|
||||||
Reflect.set(objective, field, text);
|
|
||||||
});
|
|
||||||
}else if(type == int.class){
|
|
||||||
f.field(Reflect.<Integer>get(objective, field) + "", text -> {
|
|
||||||
if(Strings.canParseInt(text)){
|
|
||||||
Reflect.set(objective, field, Strings.parseInt(text));
|
|
||||||
}
|
|
||||||
}).valid(Strings::canParseInt);
|
|
||||||
}else if(type == float.class){
|
|
||||||
f.field(Reflect.<Float>get(objective, field) + "", text -> {
|
|
||||||
if(Strings.canParsePositiveFloat(text)){
|
|
||||||
Reflect.set(objective, field, Strings.parseFloat(text));
|
|
||||||
}
|
|
||||||
}).valid(Strings::canParseFloat);
|
|
||||||
}else if(type == UnlockableContent.class){
|
|
||||||
|
|
||||||
f.button(b -> b.image(Reflect.<UnlockableContent>get(objective, field).uiIcon).size(iconSmall), () -> {
|
|
||||||
showContentSelect(null, result -> {
|
|
||||||
Reflect.set(objective, field, result);
|
|
||||||
setup();
|
|
||||||
}, b -> b.techNode != null);
|
|
||||||
}).pad(4);
|
|
||||||
|
|
||||||
}else if(type == Block.class){
|
|
||||||
f.button(b -> b.image(Reflect.<Block>get(objective, field).uiIcon).size(iconSmall), () -> {
|
|
||||||
showContentSelect(ContentType.block, result -> {
|
|
||||||
Reflect.set(objective, field, result);
|
|
||||||
setup();
|
|
||||||
}, b -> ((Block)b).synthetic());
|
|
||||||
}).pad(4);
|
|
||||||
}else if(type == Team.class){ //TODO list of flags
|
|
||||||
f.button(b -> b.image(Tex.whiteui).color(Reflect.<Team>get(objective, field).color).size(iconSmall), () -> {
|
|
||||||
showTeamSelect(result -> {
|
|
||||||
Reflect.set(objective, field, result);
|
|
||||||
setup();
|
|
||||||
});
|
|
||||||
}).pad(4);
|
|
||||||
}else if(type == String[].class){ //TODO list of flags
|
|
||||||
|
|
||||||
Table strings = new Table();
|
|
||||||
strings.marginLeft(20f);
|
|
||||||
Runnable[] rebuild = {null};
|
|
||||||
|
|
||||||
strings.left();
|
|
||||||
|
|
||||||
float h = 40f;
|
|
||||||
|
|
||||||
rebuild[0] = () -> {
|
|
||||||
strings.clear();
|
|
||||||
strings.left().defaults().padBottom(3f).padTop(3f);
|
|
||||||
String[] array = Reflect.get(objective, field);
|
|
||||||
|
|
||||||
for(int i = 0; i < array.length; i ++){
|
|
||||||
int fi = i;
|
|
||||||
var str = array[i];
|
|
||||||
strings.field(str, result -> {
|
|
||||||
array[fi] = result;
|
|
||||||
}).maxTextLength(20).height(h);
|
|
||||||
|
|
||||||
strings.button(Icon.cancel, Styles.squarei, () -> {
|
|
||||||
|
|
||||||
String[] next = new String[array.length - 1];
|
|
||||||
System.arraycopy(array, 0, next, 0, fi);
|
|
||||||
if(fi < array.length - 1){
|
|
||||||
System.arraycopy(array, fi + 1, next, fi, array.length - 1 - fi);
|
|
||||||
}
|
|
||||||
Reflect.set(objective, field, next);
|
|
||||||
|
|
||||||
rebuild[0].run();
|
|
||||||
}).padLeft(4).size(h);
|
|
||||||
|
|
||||||
strings.row();
|
|
||||||
}
|
|
||||||
|
|
||||||
strings.button("+ Add", () -> {
|
|
||||||
String[] next = new String[array.length + 1];
|
|
||||||
next[array.length] = "";
|
|
||||||
System.arraycopy(array, 0, next, 0, array.length);
|
|
||||||
Reflect.set(objective, field, next);
|
|
||||||
|
|
||||||
rebuild[0].run();
|
|
||||||
}).height(h).width(140f).padLeft(-20f).left().row();
|
|
||||||
};
|
|
||||||
|
|
||||||
rebuild[0].run();
|
|
||||||
|
|
||||||
f.row();
|
|
||||||
f.add(strings).colspan(2).fill();
|
|
||||||
|
|
||||||
}else{
|
|
||||||
f.add("[red]UNFINISHED");
|
|
||||||
}
|
|
||||||
|
|
||||||
f.row();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}).grow();
|
}).grow();
|
||||||
@ -272,6 +175,111 @@ public class MapObjectivesDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void displayField(Table f, Field field, Object objective){
|
||||||
|
f.add(field.getName() + ": ");
|
||||||
|
|
||||||
|
var type = field.getType();
|
||||||
|
|
||||||
|
if(type == String.class){
|
||||||
|
f.field(Reflect.get(objective, field), text -> {
|
||||||
|
Reflect.set(objective, field, text);
|
||||||
|
});
|
||||||
|
}else if(type == int.class){
|
||||||
|
f.field(Reflect.<Integer>get(objective, field) + "", text -> {
|
||||||
|
if(Strings.canParseInt(text)){
|
||||||
|
Reflect.set(objective, field, Strings.parseInt(text));
|
||||||
|
}
|
||||||
|
}).valid(Strings::canParseInt);
|
||||||
|
}else if(type == float.class){
|
||||||
|
f.field(Reflect.<Float>get(objective, field) + "", text -> {
|
||||||
|
if(Strings.canParsePositiveFloat(text)){
|
||||||
|
Reflect.set(objective, field, Strings.parseFloat(text));
|
||||||
|
}
|
||||||
|
}).valid(Strings::canParseFloat);
|
||||||
|
}else if(type == UnlockableContent.class){
|
||||||
|
|
||||||
|
f.button(b -> b.image(Reflect.<UnlockableContent>get(objective, field).uiIcon).size(iconSmall), () -> {
|
||||||
|
showContentSelect(null, result -> {
|
||||||
|
Reflect.set(objective, field, result);
|
||||||
|
setup();
|
||||||
|
}, b -> b.techNode != null);
|
||||||
|
}).pad(4);
|
||||||
|
|
||||||
|
}else if(type == Block.class){
|
||||||
|
f.button(b -> b.image(Reflect.<Block>get(objective, field).uiIcon).size(iconSmall), () -> {
|
||||||
|
showContentSelect(ContentType.block, result -> {
|
||||||
|
Reflect.set(objective, field, result);
|
||||||
|
setup();
|
||||||
|
}, b -> ((Block)b).synthetic());
|
||||||
|
}).pad(4);
|
||||||
|
}else if(type == Team.class){ //TODO list of flags
|
||||||
|
f.button(b -> b.image(Tex.whiteui).color(Reflect.<Team>get(objective, field).color).size(iconSmall), () -> {
|
||||||
|
showTeamSelect(result -> {
|
||||||
|
Reflect.set(objective, field, result);
|
||||||
|
setup();
|
||||||
|
});
|
||||||
|
}).pad(4);
|
||||||
|
}else if(type == String[].class){ //TODO list of flags
|
||||||
|
|
||||||
|
Table strings = new Table();
|
||||||
|
strings.marginLeft(20f);
|
||||||
|
Runnable[] rebuild = {null};
|
||||||
|
|
||||||
|
strings.left();
|
||||||
|
|
||||||
|
float h = 40f;
|
||||||
|
|
||||||
|
rebuild[0] = () -> {
|
||||||
|
strings.clear();
|
||||||
|
strings.left().defaults().padBottom(3f).padTop(3f);
|
||||||
|
String[] array = Reflect.get(objective, field);
|
||||||
|
|
||||||
|
for(int i = 0; i < array.length; i++){
|
||||||
|
int fi = i;
|
||||||
|
var str = array[i];
|
||||||
|
strings.field(str, result -> {
|
||||||
|
array[fi] = result;
|
||||||
|
}).maxTextLength(20).height(h);
|
||||||
|
|
||||||
|
strings.button(Icon.cancel, Styles.squarei, () -> {
|
||||||
|
|
||||||
|
String[] next = new String[array.length - 1];
|
||||||
|
System.arraycopy(array, 0, next, 0, fi);
|
||||||
|
if(fi < array.length - 1){
|
||||||
|
System.arraycopy(array, fi + 1, next, fi, array.length - 1 - fi);
|
||||||
|
}
|
||||||
|
Reflect.set(objective, field, next);
|
||||||
|
|
||||||
|
rebuild[0].run();
|
||||||
|
}).padLeft(4).size(h);
|
||||||
|
|
||||||
|
strings.row();
|
||||||
|
}
|
||||||
|
|
||||||
|
strings.button("+ Add", () -> {
|
||||||
|
String[] next = new String[array.length + 1];
|
||||||
|
next[array.length] = "";
|
||||||
|
System.arraycopy(array, 0, next, 0, array.length);
|
||||||
|
Reflect.set(objective, field, next);
|
||||||
|
|
||||||
|
rebuild[0].run();
|
||||||
|
}).height(h).width(140f).padLeft(-20f).left().row();
|
||||||
|
};
|
||||||
|
|
||||||
|
rebuild[0].run();
|
||||||
|
|
||||||
|
f.row();
|
||||||
|
f.add(strings).colspan(2).fill();
|
||||||
|
|
||||||
|
//}else if(type == ObjectiveMarker[].class){
|
||||||
|
|
||||||
|
}else{
|
||||||
|
f.add("[red]UNFINISHED");
|
||||||
|
}
|
||||||
|
|
||||||
|
f.row();
|
||||||
|
}
|
||||||
|
|
||||||
void showContentSelect(@Nullable ContentType type, Cons<UnlockableContent> cons, Boolf<UnlockableContent> check){
|
void showContentSelect(@Nullable ContentType type, Cons<UnlockableContent> cons, Boolf<UnlockableContent> check){
|
||||||
BaseDialog dialog = new BaseDialog("");
|
BaseDialog dialog = new BaseDialog("");
|
||||||
dialog.cont.pane(p -> {
|
dialog.cont.pane(p -> {
|
||||||
|
@ -1546,6 +1546,8 @@ public class LExecutor{
|
|||||||
|
|
||||||
@Remote(called = Loc.server, unreliable = true)
|
@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){
|
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);
|
Damage.damage(team, x, y, radius, damage, pierce, air, ground);
|
||||||
if(pierce){
|
if(pierce){
|
||||||
Fx.spawnShockwave.at(x, y, World.conv(radius));
|
Fx.spawnShockwave.at(x, y, World.conv(radius));
|
||||||
|
Reference in New Issue
Block a user