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.sorter.name = Sorter
block.inverted-sorter.name = Inverted Sorter block.inverted-sorter.name = Inverted Sorter
block.message.name = Message block.message.name = Message
block.reinforced-message.name = Reinforced Message
block.world-message.name = World Message
block.illuminator.name = Illuminator block.illuminator.name = Illuminator
block.overflow-gate.name = Overflow Gate block.overflow-gate.name = Overflow Gate
block.underflow-gate.name = Underflow 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.armored-conveyor.description = Moves items forward. Does not accept non-conveyor inputs from the sides.
block.illuminator.description = Emits light. block.illuminator.description = Emits light.
block.message.description = Stores a message for communication between allies. 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.graphite-press.description = Compresses coal into graphite.
block.multi-press.description = Compresses coal into graphite. Requires water as coolant. block.multi-press.description = Compresses coal into graphite. Requires water as coolant.
block.silicon-smelter.description = Refines silicon from sand and coal. block.silicon-smelter.description = Refines silicon from sand and coal.

View File

@@ -581,3 +581,5 @@
63101=crystalline-vent|block-crystalline-vent-ui 63101=crystalline-vent|block-crystalline-vent-ui
63100=heat-router|block-heat-router-ui 63100=heat-router|block-heat-router-ui
63099=large-payload-mass-driver|block-large-payload-mass-driver-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 //logic
message, switchBlock, microProcessor, logicProcessor, hyperProcessor, largeLogicDisplay, logicDisplay, memoryCell, memoryBank, message, switchBlock, microProcessor, logicProcessor, hyperProcessor, largeLogicDisplay, logicDisplay, memoryCell, memoryBank,
canvas, canvas, reinforcedMessage,
worldProcessor, worldCell, worldProcessor, worldCell, worldMessage,
//campaign //campaign
launchPad, interplanetaryAccelerator launchPad, interplanetaryAccelerator
@@ -5834,6 +5834,11 @@ public class Blocks{
size = 2; size = 2;
}}; }};
reinforcedMessage = new MessageBlock("reinforced-message"){{
requirements(Category.logic, with(Items.graphite, 10, Items.beryllium, 5));
health = 100;
}};
worldProcessor = new LogicBlock("world-processor"){{ worldProcessor = new LogicBlock("world-processor"){{
requirements(Category.logic, BuildVisibility.editorOnly, with()); requirements(Category.logic, BuildVisibility.editorOnly, with());
@@ -5856,6 +5861,11 @@ public class Blocks{
forceDark = true; forceDark = true;
}}; }};
worldMessage = new MessageBlock("world-message"){{
requirements(Category.logic, BuildVisibility.editorOnly, with());
privileged = true;
}};
//endregion //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)), () -> { node(reinforcedPayloadConveyor, Seq.with(new OnSector(atlas)), () -> {

View File

@@ -163,7 +163,9 @@ public class Control implements ApplicationListener, Loadable{
app.post(this::checkAutoUnlocks); app.post(this::checkAutoUnlocks);
if(e.sector.preset != null && e.sector.preset.isLastSector && e.initialCapture){ if(e.sector.preset != null && e.sector.preset.isLastSector && e.initialCapture){
Time.run(60f * 2f, () -> {
ui.campaignComplete.show(e.sector.planet); ui.campaignComplete.show(e.sector.planet);
});
} }
}); });

View File

@@ -603,11 +603,19 @@ public class UI implements ApplicationListener, Loadable{
}}.show(); }}.show();
} }
/** Formats time with hours:minutes:seconds. */
public static String formatTime(float ticks){ public static String formatTime(float ticks){
int time = (int)(ticks / 60); int seconds = (int)(ticks / 60);
if(time < 60) return "0:" + (time < 10 ? "0" : "") + time; if(seconds < 60) return "0:" + (seconds < 10 ? "0" : "") + seconds;
int mod = time % 60;
return (time / 60) + ":" + (mod < 10 ? "0" : "") + mod; 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){ public static String formatAmount(long number){

View File

@@ -13,9 +13,12 @@ public class CampaignCompleteDialog extends BaseDialog{
shouldPause = true; shouldPause = true;
buttons.defaults().size(210f, 64f); 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){ 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."); 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(); show();
} }
} }

View File

@@ -1,6 +1,8 @@
package mindustry.world.blocks.logic; package mindustry.world.blocks.logic;
import arc.*; import arc.*;
import arc.Graphics.*;
import arc.Graphics.Cursor.*;
import arc.Input.*; import arc.Input.*;
import arc.graphics.*; import arc.graphics.*;
import arc.graphics.g2d.*; 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 //don't change this too much unless you want to run into issues with packet sizes
public int maxTextLength = 220; public int maxTextLength = 220;
public int maxNewlines = 24; public int maxNewlines = 24;
public boolean privileged = false;
public MessageBlock(String name){ public MessageBlock(String name){
super(name); super(name);
@@ -33,7 +36,7 @@ public class MessageBlock extends Block{
envEnabled = Env.any; envEnabled = Env.any;
config(String.class, (MessageBuild tile, String text) -> { config(String.class, (MessageBuild tile, String text) -> {
if(text.length() > maxTextLength){ if(text.length() > maxTextLength || !accessible()){
return; //no. 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 class MessageBuild extends Building{
public StringBuilder message = new StringBuilder(); public StringBuilder message = new StringBuilder();
@@ -87,6 +99,11 @@ public class MessageBlock extends Block{
@Override @Override
public void buildConfiguration(Table table){ public void buildConfiguration(Table table){
if(!accessible()){
deselect();
return;
}
table.button(Icon.pencil, Styles.cleari, () -> { table.button(Icon.pencil, Styles.cleari, () -> {
if(mobile){ if(mobile){
Core.input.getTextInput(new TextInput(){{ Core.input.getTextInput(new TextInput(){{
@@ -134,7 +151,7 @@ public class MessageBlock extends Block{
@Override @Override
public boolean onConfigureBuildTapped(Building other){ public boolean onConfigureBuildTapped(Building other){
if(this == other){ if(this == other || !accessible()){
deselect(); deselect();
return false; return false;
} }
@@ -142,6 +159,32 @@ public class MessageBlock extends Block{
return true; 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 @Override
public void handleString(Object value){ public void handleString(Object value){
message.setLength(0); message.setLength(0);