Processor mission set instruction

This commit is contained in:
Anuken
2022-02-16 14:39:59 -05:00
parent 5dd75167c7
commit eaf02e8328
4 changed files with 21 additions and 9 deletions

View File

@@ -130,6 +130,8 @@ public class Rules{
public Color cloudColor = new Color(0f, 0f, 0f, 0f); public Color cloudColor = new Color(0f, 0f, 0f, 0f);
/** name of the custom mode that this ruleset describes, or null. */ /** name of the custom mode that this ruleset describes, or null. */
public @Nullable String modeName; public @Nullable String modeName;
/** Mission string displayed instead of wave/core counter. Null to disable. */
public @Nullable String mission;
/** Whether cores incinerate items when full, just like in the campaign. */ /** Whether cores incinerate items when full, just like in the campaign. */
public boolean coreIncinerates = false; public boolean coreIncinerates = false;
/** If false, borders fade out into darkness. Only use with custom backgrounds!*/ /** If false, borders fade out into darkness. Only use with custom backgrounds!*/

View File

@@ -1365,7 +1365,7 @@ public class LExecutor{
@Override @Override
public void run(LExecutor exec){ public void run(LExecutor exec){
if(headless) return; if(headless && type != MessageType.mission) return;
//skip back to self until possible //skip back to self until possible
//TODO this is guaranteed desync on servers - I don't see a good solution //TODO this is guaranteed desync on servers - I don't see a good solution
@@ -1383,6 +1383,8 @@ public class LExecutor{
case notify -> ui.hudfrag.showToast(Icon.info, text); case notify -> ui.hudfrag.showToast(Icon.info, text);
case announce -> ui.announce(text, exec.numf(duration)); case announce -> ui.announce(text, exec.numf(duration));
case toast -> ui.showInfoToast(text, exec.numf(duration)); case toast -> ui.showInfoToast(text, exec.numf(duration));
//TODO desync?
case mission -> state.rules.mission = text;
} }
exec.textBuffer.setLength(0); exec.textBuffer.setLength(0);

View File

@@ -3,7 +3,8 @@ package mindustry.logic;
public enum MessageType{ public enum MessageType{
notify, notify,
announce, announce,
toast; toast,
mission;
public static final MessageType[] all = values(); public static final MessageType[] all = values();
} }

View File

@@ -596,13 +596,14 @@ public class HudFragment extends Fragment{
StringBuilder ibuild = new StringBuilder(); StringBuilder ibuild = new StringBuilder();
IntFormat wavef = new IntFormat("wave"); IntFormat
IntFormat wavefc = new IntFormat("wave.cap"); wavef = new IntFormat("wave"),
IntFormat enemyf = new IntFormat("wave.enemy"); wavefc = new IntFormat("wave.cap"),
IntFormat enemiesf = new IntFormat("wave.enemies"); enemyf = new IntFormat("wave.enemy"),
IntFormat enemycf = new IntFormat("wave.enemycore"); enemiesf = new IntFormat("wave.enemies"),
IntFormat enemycsf = new IntFormat("wave.enemycores"); enemycf = new IntFormat("wave.enemycore"),
IntFormat waitingf = new IntFormat("wave.waiting", i -> { enemycsf = new IntFormat("wave.enemycores"),
waitingf = new IntFormat("wave.waiting", i -> {
ibuild.setLength(0); ibuild.setLength(0);
int m = i/60; int m = i/60;
int s = i % 60; int s = i % 60;
@@ -737,6 +738,12 @@ public class HudFragment extends Fragment{
table.labelWrap(() -> { table.labelWrap(() -> {
builder.setLength(0); builder.setLength(0);
//mission overrides everything
if(state.rules.mission != null){
builder.append(state.rules.mission);
return builder;
}
if(!state.rules.waves && state.rules.attackMode){ if(!state.rules.waves && state.rules.attackMode){
int sum = Math.max(state.teams.present.sum(t -> t.team != player.team() ? t.cores.size : 0), 1); int sum = Math.max(state.teams.present.sum(t -> t.team != player.team() ? t.cores.size : 0), 1);
builder.append(sum > 1 ? enemycsf.get(sum) : enemycf.get(sum)); builder.append(sum > 1 ? enemycsf.get(sum) : enemycf.get(sum));