sound id
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.logic;
|
package mindustry.logic;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.audio.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
@@ -9,6 +10,7 @@ import arc.util.*;
|
|||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.logic.LExecutor.*;
|
import mindustry.logic.LExecutor.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -36,6 +38,8 @@ public class GlobalVars{
|
|||||||
private UnlockableContent[][] logicIdToContent;
|
private UnlockableContent[][] logicIdToContent;
|
||||||
private int[][] contentIdToLogicId;
|
private int[][] contentIdToLogicId;
|
||||||
|
|
||||||
|
public static final Seq<String> soundNames = new Seq<>();
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
putEntryOnly("sectionProcessor");
|
putEntryOnly("sectionProcessor");
|
||||||
|
|
||||||
@@ -90,6 +94,16 @@ public class GlobalVars{
|
|||||||
put("@ctrlPlayer", ctrlPlayer);
|
put("@ctrlPlayer", ctrlPlayer);
|
||||||
put("@ctrlCommand", ctrlCommand);
|
put("@ctrlCommand", ctrlCommand);
|
||||||
|
|
||||||
|
//sounds
|
||||||
|
for(Sound sound : Core.assets.getAll(Sound.class, new Seq<>(Sound.class))){
|
||||||
|
if(sound != Sounds.none && sound != Sounds.swish){
|
||||||
|
String name = sound.toString();
|
||||||
|
name = name.substring(20, name.length - 4);
|
||||||
|
soundNames.put(name);
|
||||||
|
put("@sfx-" + name, Sounds.getSoundId(sound));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//store base content
|
//store base content
|
||||||
|
|
||||||
for(Team team : Team.baseTeams){
|
for(Team team : Team.baseTeams){
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.logic;
|
package mindustry.logic;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.audio.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
@@ -2025,15 +2026,14 @@ public class LExecutor{
|
|||||||
|
|
||||||
public static class PlaySoundI implements LInstruction{
|
public static class PlaySoundI implements LInstruction{
|
||||||
public boolean positional;
|
public boolean positional;
|
||||||
public LogicSound sound;
|
public int id, volume, pitch, pan, x, y;
|
||||||
public int volume, pitch, pan, x, y;
|
|
||||||
|
|
||||||
public PlaySoundI(){
|
public PlaySoundI(){
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaySoundI(boolean positional, LogicSound sound, int volume, int pitch, int pan, int x, int y){
|
public PlaySoundI(boolean positional, int id, int volume, int pitch, int pan, int x, int y){
|
||||||
this.positional = positional;
|
this.positional = positional;
|
||||||
this.sound = sound;
|
this.id = id;
|
||||||
this.volume = volume;
|
this.volume = volume;
|
||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
this.pan = pan;
|
this.pan = pan;
|
||||||
@@ -2043,10 +2043,13 @@ public class LExecutor{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(LExecutor exec){
|
public void run(LExecutor exec){
|
||||||
|
Sound sound = Sounds.getSound(exec.numi(id));
|
||||||
|
if(sound == Sounds.none || sound == Sounds.swish) sound = Sounds.pew; //no.
|
||||||
|
|
||||||
if(positional){
|
if(positional){
|
||||||
sound.sound.at(World.unconv(exec.numf(x)), World.unconv(exec.numf(y)), exec.numf(pitch), exec.numf(volume));
|
sound.at(World.unconv(exec.numf(x)), World.unconv(exec.numf(y)), exec.numf(pitch), exec.numf(volume));
|
||||||
}else{
|
}else{
|
||||||
sound.sound.play(exec.numf(volume) * (Core.settings.getInt("sfxvol") / 100f), exec.numf(pitch), exec.numf(pan));
|
sound.play(exec.numf(volume) * (Core.settings.getInt("sfxvol") / 100f), exec.numf(pitch), exec.numf(pan));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.logic;
|
package mindustry.logic;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.audio.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
@@ -2089,8 +2090,9 @@ public class LStatements{
|
|||||||
@RegisterStatement("playsound")
|
@RegisterStatement("playsound")
|
||||||
public static class PlaySoundStatement extends LStatement{
|
public static class PlaySoundStatement extends LStatement{
|
||||||
public boolean positional;
|
public boolean positional;
|
||||||
public LogicSound sound = LogicSound.pew;
|
public String id = "@sfx-pew", volume = "1", pitch = "1", pan = "0", x = "@thisx", y = "@thisy";
|
||||||
public String volume = "1", pitch = "1", pan = "0", x = "@thisx", y = "@thisy";
|
|
||||||
|
private transient TextField tfield;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table){
|
public void build(Table table){
|
||||||
@@ -2107,15 +2109,18 @@ public class LStatements{
|
|||||||
|
|
||||||
row(table);
|
row(table);
|
||||||
|
|
||||||
table.add("play");
|
table.add("play ");
|
||||||
|
|
||||||
|
tfield = field(table, id, str -> id = str).padRight(0f).get();
|
||||||
|
|
||||||
table.button(b -> {
|
table.button(b -> {
|
||||||
b.label(() -> sound.name());
|
b.image(Icon.pencilSmall);
|
||||||
b.clicked(() -> showSelect(b, LogicSound.all, sound, s -> {
|
|
||||||
sound = s;
|
b.clicked(() -> showSelect(b, GlobalVars.soundNames.toArray(String.class), id, t -> {
|
||||||
|
sid("@sfx-" + t);
|
||||||
rebuild(table);
|
rebuild(table);
|
||||||
}, 3, cell -> cell.size(150, 50)));
|
}, 4, cell -> cell.size(160, 50)));
|
||||||
}, Styles.logict, () -> {}).size(190, 40).color(table.color).left().padLeft(2);
|
}, Styles.logict, () -> {}).size(40).color(table.color).left().padLeft(-1);
|
||||||
|
|
||||||
row(table);
|
row(table);
|
||||||
|
|
||||||
@@ -2137,6 +2142,11 @@ public class LStatements{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sid(String text){
|
||||||
|
tfield.setText(text);
|
||||||
|
id = text;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean privileged(){
|
public boolean privileged(){
|
||||||
return true;
|
return true;
|
||||||
@@ -2144,7 +2154,7 @@ public class LStatements{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LInstruction build(LAssembler builder){
|
public LInstruction build(LAssembler builder){
|
||||||
return new PlaySoundI(positional, sound, builder.var(volume), builder.var(pitch), builder.var(pan), builder.var(x), builder.var(y));
|
return new PlaySoundI(positional, builder.var(id), builder.var(volume), builder.var(pitch), builder.var(pan), builder.var(x), builder.var(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user