Basic logic cutscene stuff
This commit is contained in:
9
core/src/mindustry/logic/CutsceneAction.java
Normal file
9
core/src/mindustry/logic/CutsceneAction.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package mindustry.logic;
|
||||
|
||||
public enum CutsceneAction{
|
||||
pan,
|
||||
zoom,
|
||||
stop;
|
||||
|
||||
public static final CutsceneAction[] all = values();
|
||||
}
|
||||
@@ -1118,6 +1118,42 @@ public class LExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
public static class CutsceneI implements LInstruction{
|
||||
public CutsceneAction action = CutsceneAction.stop;
|
||||
public int p1, p2, p3, p4;
|
||||
|
||||
public CutsceneI(CutsceneAction action, int p1, int p2, int p3, int p4){
|
||||
this.action = action;
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.p3 = p3;
|
||||
this.p4 = p4;
|
||||
}
|
||||
|
||||
public CutsceneI(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
if(headless) return;
|
||||
|
||||
switch(action){
|
||||
case pan -> {
|
||||
control.input.logicCutscene = true;
|
||||
control.input.logicCamPan.set(World.unconv(exec.numf(p1)), World.unconv(exec.numf(p2)));
|
||||
control.input.logicCamSpeed = exec.numf(p3);
|
||||
}
|
||||
case zoom -> {
|
||||
control.input.logicCutscene = true;
|
||||
renderer.setScale(Mathf.lerp(renderer.minZoom, renderer.maxZoom, Mathf.clamp(exec.numf(p1))));
|
||||
}
|
||||
case stop -> {
|
||||
control.input.logicCutscene = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
//region privileged / world instructions
|
||||
|
||||
|
||||
@@ -1294,4 +1294,60 @@ public class LStatements{
|
||||
return new FlushNotificationI();
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("cutscene")
|
||||
public static class CutsceneStatement extends LStatement{
|
||||
public CutsceneAction action = CutsceneAction.pan;
|
||||
public String p1 = "100", p2 = "100", p3 = " 0.06", p4 = "0";
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
rebuild(table);
|
||||
}
|
||||
|
||||
void rebuild(Table table){
|
||||
table.clearChildren();
|
||||
|
||||
table.button(b -> {
|
||||
b.label(() -> action.name()).growX().wrap().labelAlign(Align.center);
|
||||
b.clicked(() -> showSelect(b, CutsceneAction.all, action, o -> {
|
||||
action = o;
|
||||
rebuild(table);
|
||||
}));
|
||||
}, Styles.logict, () -> {}).size(90f, 40f).padLeft(2).color(table.color);
|
||||
|
||||
switch(action){
|
||||
case pan -> {
|
||||
table.add(" x ");
|
||||
fields(table, p1, str -> p1 = str);
|
||||
table.add(" y ");
|
||||
fields(table, p2, str -> p2 = str);
|
||||
|
||||
row(table);
|
||||
|
||||
table.add(" speed ");
|
||||
fields(table, p3, str -> p3 = str);
|
||||
}
|
||||
case zoom -> {
|
||||
table.add(" level ");
|
||||
fields(table, p1, str -> p1 = str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean privileged(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color color(){
|
||||
return Pal.logicWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new CutsceneI(action, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user