Added message blocks for Erekir and the editor
This commit is contained in:
@@ -159,8 +159,8 @@ public class Blocks{
|
||||
|
||||
//logic
|
||||
message, switchBlock, microProcessor, logicProcessor, hyperProcessor, largeLogicDisplay, logicDisplay, memoryCell, memoryBank,
|
||||
canvas,
|
||||
worldProcessor, worldCell,
|
||||
canvas, reinforcedMessage,
|
||||
worldProcessor, worldCell, worldMessage,
|
||||
|
||||
//campaign
|
||||
launchPad, interplanetaryAccelerator
|
||||
@@ -5834,6 +5834,11 @@ public class Blocks{
|
||||
size = 2;
|
||||
}};
|
||||
|
||||
reinforcedMessage = new MessageBlock("reinforced-message"){{
|
||||
requirements(Category.logic, with(Items.graphite, 10, Items.beryllium, 5));
|
||||
health = 100;
|
||||
}};
|
||||
|
||||
worldProcessor = new LogicBlock("world-processor"){{
|
||||
requirements(Category.logic, BuildVisibility.editorOnly, with());
|
||||
|
||||
@@ -5856,6 +5861,11 @@ public class Blocks{
|
||||
forceDark = true;
|
||||
}};
|
||||
|
||||
worldMessage = new MessageBlock("world-message"){{
|
||||
requirements(Category.logic, BuildVisibility.editorOnly, with());
|
||||
privileged = true;
|
||||
}};
|
||||
|
||||
//endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,10 @@ public class ErekirTechTree{
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
node(reinforcedMessage, Seq.with(new OnSector(aegis)), () -> {
|
||||
node(canvas);
|
||||
});
|
||||
});
|
||||
|
||||
node(reinforcedPayloadConveyor, Seq.with(new OnSector(atlas)), () -> {
|
||||
|
||||
@@ -163,7 +163,9 @@ public class Control implements ApplicationListener, Loadable{
|
||||
app.post(this::checkAutoUnlocks);
|
||||
|
||||
if(e.sector.preset != null && e.sector.preset.isLastSector && e.initialCapture){
|
||||
ui.campaignComplete.show(e.sector.planet);
|
||||
Time.run(60f * 2f, () -> {
|
||||
ui.campaignComplete.show(e.sector.planet);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -603,11 +603,19 @@ public class UI implements ApplicationListener, Loadable{
|
||||
}}.show();
|
||||
}
|
||||
|
||||
/** Formats time with hours:minutes:seconds. */
|
||||
public static String formatTime(float ticks){
|
||||
int time = (int)(ticks / 60);
|
||||
if(time < 60) return "0:" + (time < 10 ? "0" : "") + time;
|
||||
int mod = time % 60;
|
||||
return (time / 60) + ":" + (mod < 10 ? "0" : "") + mod;
|
||||
int seconds = (int)(ticks / 60);
|
||||
if(seconds < 60) return "0:" + (seconds < 10 ? "0" : "") + seconds;
|
||||
|
||||
int minutes = seconds / 60;
|
||||
int modSec = seconds % 60;
|
||||
if(minutes < 60) return minutes + ":" + (modSec < 10 ? "0" : "") + modSec;
|
||||
|
||||
int hours = minutes / 60;
|
||||
int modMinute = minutes % 60;
|
||||
|
||||
return hours + ":" + (modMinute < 10 ? "0" : "") + modMinute + ":" + (modSec < 10 ? "0" : "") + modSec;
|
||||
}
|
||||
|
||||
public static String formatAmount(long number){
|
||||
@@ -618,7 +626,7 @@ public class UI implements ApplicationListener, Loadable{
|
||||
long mag = Math.abs(number);
|
||||
String sign = number < 0 ? "-" : "";
|
||||
if(mag >= 1_000_000_000){
|
||||
return sign + Strings.fixed(mag / 1_000_000_000f, 1) + "[gray]" + billions+ "[]";
|
||||
return sign + Strings.fixed(mag / 1_000_000_000f, 1) + "[gray]" + billions + "[]";
|
||||
}else if(mag >= 1_000_000){
|
||||
return sign + Strings.fixed(mag / 1_000_000f, 1) + "[gray]" + millions + "[]";
|
||||
}else if(mag >= 10_000){
|
||||
|
||||
@@ -13,9 +13,12 @@ public class CampaignCompleteDialog extends BaseDialog{
|
||||
shouldPause = true;
|
||||
|
||||
buttons.defaults().size(210f, 64f);
|
||||
buttons.button("@menu", Icon.left, () -> Vars.ui.paused.runExitSave());
|
||||
buttons.button("@menu", Icon.left, () -> {
|
||||
hide();
|
||||
Vars.ui.paused.runExitSave();
|
||||
});
|
||||
|
||||
buttons.button("@continue", Icon.left, this::hide);
|
||||
buttons.button("@continue", Icon.ok, this::hide);
|
||||
}
|
||||
|
||||
public void show(Planet planet){
|
||||
@@ -24,6 +27,9 @@ public class CampaignCompleteDialog extends BaseDialog{
|
||||
|
||||
cont.add("[accent]Congrations. You done it.[]\n\nThe enemy on " + planet.localizedName + " has been defeated.");
|
||||
|
||||
float playtime = planet.sectors.sumf(s -> s.hasSave() ? s.save.meta.timePlayed : 0) / 1000f;
|
||||
|
||||
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mindustry.world.blocks.logic;
|
||||
|
||||
import arc.*;
|
||||
import arc.Graphics.*;
|
||||
import arc.Graphics.Cursor.*;
|
||||
import arc.Input.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
@@ -22,6 +24,7 @@ public class MessageBlock extends Block{
|
||||
//don't change this too much unless you want to run into issues with packet sizes
|
||||
public int maxTextLength = 220;
|
||||
public int maxNewlines = 24;
|
||||
public boolean privileged = false;
|
||||
|
||||
public MessageBlock(String name){
|
||||
super(name);
|
||||
@@ -33,7 +36,7 @@ public class MessageBlock extends Block{
|
||||
envEnabled = Env.any;
|
||||
|
||||
config(String.class, (MessageBuild tile, String text) -> {
|
||||
if(text.length() > maxTextLength){
|
||||
if(text.length() > maxTextLength || !accessible()){
|
||||
return; //no.
|
||||
}
|
||||
|
||||
@@ -55,6 +58,15 @@ public class MessageBlock extends Block{
|
||||
});
|
||||
}
|
||||
|
||||
public boolean accessible(){
|
||||
return !privileged || state.rules.editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreak(Tile tile){
|
||||
return accessible();
|
||||
}
|
||||
|
||||
public class MessageBuild extends Building{
|
||||
public StringBuilder message = new StringBuilder();
|
||||
|
||||
@@ -87,6 +99,11 @@ public class MessageBlock extends Block{
|
||||
|
||||
@Override
|
||||
public void buildConfiguration(Table table){
|
||||
if(!accessible()){
|
||||
deselect();
|
||||
return;
|
||||
}
|
||||
|
||||
table.button(Icon.pencil, Styles.cleari, () -> {
|
||||
if(mobile){
|
||||
Core.input.getTextInput(new TextInput(){{
|
||||
@@ -134,7 +151,7 @@ public class MessageBlock extends Block{
|
||||
|
||||
@Override
|
||||
public boolean onConfigureBuildTapped(Building other){
|
||||
if(this == other){
|
||||
if(this == other || !accessible()){
|
||||
deselect();
|
||||
return false;
|
||||
}
|
||||
@@ -142,6 +159,32 @@ public class MessageBlock extends Block{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor getCursor(){
|
||||
return !accessible() ? SystemCursor.arrow : super.getCursor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(float damage){
|
||||
if(privileged) return;
|
||||
super.damage(damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPickup(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean collide(Bullet other){
|
||||
return !privileged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayable(){
|
||||
return accessible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleString(Object value){
|
||||
message.setLength(0);
|
||||
|
||||
Reference in New Issue
Block a user