Added message blocks for Erekir and the editor

This commit is contained in:
Anuken 2022-10-30 09:01:42 -04:00
parent d16a11f18f
commit 76c99400a4
12 changed files with 91 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

View file

@ -1452,6 +1452,8 @@ block.distributor.name = Distributor
block.sorter.name = Sorter
block.inverted-sorter.name = Inverted Sorter
block.message.name = Message
block.reinforced-message.name = Reinforced Message
block.world-message.name = World Message
block.illuminator.name = Illuminator
block.overflow-gate.name = Overflow Gate
block.underflow-gate.name = Underflow Gate
@ -1863,6 +1865,8 @@ block.derelict = \uF77E [lightgray]Derelict
block.armored-conveyor.description = Moves items forward. Does not accept non-conveyor inputs from the sides.
block.illuminator.description = Emits light.
block.message.description = Stores a message for communication between allies.
block.reinforced-message.description = Stores a message for communication between allies.
block.world-message.description = A message block for use in mapmaking. Cannot be destroyed.
block.graphite-press.description = Compresses coal into graphite.
block.multi-press.description = Compresses coal into graphite. Requires water as coolant.
block.silicon-smelter.description = Refines silicon from sand and coal.

View file

@ -581,3 +581,5 @@
63101=crystalline-vent|block-crystalline-vent-ui
63100=heat-router|block-heat-router-ui
63099=large-payload-mass-driver|block-large-payload-mass-driver-ui
63098=reinforced-message|block-reinforced-message-ui
63097=world-message|block-world-message-ui

Binary file not shown.

View file

@ -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
}
}

View file

@ -93,6 +93,10 @@ public class ErekirTechTree{
});
});
});
node(reinforcedMessage, Seq.with(new OnSector(aegis)), () -> {
node(canvas);
});
});
node(reinforcedPayloadConveyor, Seq.with(new OnSector(atlas)), () -> {

View file

@ -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);
});
}
});

View file

@ -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){

View file

@ -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();
}
}

View file

@ -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);