it is 3:40 am right now
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
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
package mindustry.logic;
|
|
||||||
|
|
||||||
import arc.audio.*;
|
|
||||||
import mindustry.gen.*;
|
|
||||||
|
|
||||||
public enum LogicSound{
|
|
||||||
artillery(Sounds.artillery),
|
|
||||||
bang(Sounds.bang),
|
|
||||||
bigshot(Sounds.bigshot),
|
|
||||||
blaster(Sounds.blaster),
|
|
||||||
bolt(Sounds.bolt),
|
|
||||||
boom(Sounds.boom),
|
|
||||||
breakBlock(Sounds.breaks),
|
|
||||||
buttonClick(Sounds.buttonClick),
|
|
||||||
cannon(Sounds.cannon),
|
|
||||||
cannonLarge(Sounds.largeCannon),
|
|
||||||
click(Sounds.click),
|
|
||||||
coreExplode(Sounds.corexplode),
|
|
||||||
door(Sounds.door),
|
|
||||||
drillImpact(Sounds.drillImpact),
|
|
||||||
explosion(Sounds.explosion),
|
|
||||||
explosionBig(Sounds.explosionbig),
|
|
||||||
explosionDull(Sounds.dullExplosion),
|
|
||||||
explosionLarge(Sounds.largeExplosion),
|
|
||||||
explosionTitan(Sounds.titanExplosion),
|
|
||||||
flame(Sounds.flame),
|
|
||||||
flame2(Sounds.flame2),
|
|
||||||
laser(Sounds.laser),
|
|
||||||
laserBig(Sounds.laserbig),
|
|
||||||
laserCharge(Sounds.lasercharge),
|
|
||||||
laserCharge2(Sounds.lasercharge2),
|
|
||||||
laserShoot(Sounds.lasershoot),
|
|
||||||
malignShoot(Sounds.malignShoot),
|
|
||||||
mineDeploy(Sounds.mineDeploy),
|
|
||||||
missile(Sounds.missile),
|
|
||||||
missileLarge(Sounds.missileLarge),
|
|
||||||
missileLaunch(Sounds.missileLaunch),
|
|
||||||
missileSmall(Sounds.missileSmall),
|
|
||||||
mud(Sounds.mud),
|
|
||||||
noAmmo(Sounds.noammo),
|
|
||||||
pew(Sounds.pew),
|
|
||||||
place(Sounds.place),
|
|
||||||
plantBreak(Sounds.plantBreak),
|
|
||||||
plasmaBoom(Sounds.plasmaboom),
|
|
||||||
plasmaDrop(Sounds.plasmadrop),
|
|
||||||
pulseBlast(Sounds.pulseBlast),
|
|
||||||
railgun(Sounds.railgun),
|
|
||||||
release(Sounds.release),
|
|
||||||
respawn(Sounds.respawn),
|
|
||||||
rockBreak(Sounds.rockBreak),
|
|
||||||
sap(Sounds.sap),
|
|
||||||
shockBlast(Sounds.shockBlast),
|
|
||||||
shoot(Sounds.shoot),
|
|
||||||
shootAlt(Sounds.shootAlt),
|
|
||||||
shootAltLong(Sounds.shootAltLong),
|
|
||||||
shootBig(Sounds.shootBig),
|
|
||||||
shootSmite(Sounds.shootSmite),
|
|
||||||
shootSnap(Sounds.shootSnap),
|
|
||||||
shotgun(Sounds.shotgun),
|
|
||||||
spark(Sounds.spark),
|
|
||||||
splash(Sounds.splash),
|
|
||||||
wave(Sounds.wave),
|
|
||||||
wind3(Sounds.wind3),
|
|
||||||
|
|
||||||
beamLoop(Sounds.beam),
|
|
||||||
bioLoop(Sounds.bioLoop),
|
|
||||||
buildLoop(Sounds.build),
|
|
||||||
combustionLoop(Sounds.combustion),
|
|
||||||
conveyorLoop(Sounds.conveyor),
|
|
||||||
cutterLoop(Sounds.cutter),
|
|
||||||
drillLoop(Sounds.drill),
|
|
||||||
drillChargeLoop(Sounds.drillCharge),
|
|
||||||
extractLoop(Sounds.extractLoop),
|
|
||||||
fireLoop(Sounds.fire),
|
|
||||||
fluxLoop(Sounds.flux),
|
|
||||||
glowLoop(Sounds.glow),
|
|
||||||
grindingLoop(Sounds.grinding),
|
|
||||||
humLoop(Sounds.hum),
|
|
||||||
humElectricLoop(Sounds.electricHum),
|
|
||||||
laserBeamLoop(Sounds.laserbeam),
|
|
||||||
machineLoop(Sounds.machine),
|
|
||||||
mineBeamLoop(Sounds.minebeam),
|
|
||||||
missileTrailLoop(Sounds.missileTrail),
|
|
||||||
pulseLoop(Sounds.pulse),
|
|
||||||
rainLoop(Sounds.rain),
|
|
||||||
respawnLoop(Sounds.respawning),
|
|
||||||
shieldLoop(Sounds.shield),
|
|
||||||
smelterLoop(Sounds.smelter),
|
|
||||||
spellLoop(Sounds.spellLoop),
|
|
||||||
sprayLoop(Sounds.spray),
|
|
||||||
steamLoop(Sounds.steam),
|
|
||||||
techLoop(Sounds.techloop),
|
|
||||||
thrusterLoop(Sounds.thruster),
|
|
||||||
torchLoop(Sounds.torch),
|
|
||||||
tractorBeamLoop(Sounds.tractorbeam),
|
|
||||||
windLoop(Sounds.wind),
|
|
||||||
wind2Loop(Sounds.wind2),
|
|
||||||
windHowlLoop(Sounds.windhowl),
|
|
||||||
|
|
||||||
backUi(Sounds.back),
|
|
||||||
chatMessageUi(Sounds.chatMessage),
|
|
||||||
messageUi(Sounds.message),
|
|
||||||
pressUi(Sounds.press),
|
|
||||||
unlockUi(Sounds.unlock);
|
|
||||||
|
|
||||||
public final Sound sound;
|
|
||||||
|
|
||||||
public static final LogicSound[] all = values();
|
|
||||||
|
|
||||||
LogicSound(Sound sound){
|
|
||||||
this.sound = sound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user