mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-10-05 12:27:26 +03:00
World processor list in editor
This commit is contained in:
parent
19b6b60ac5
commit
b4b6b9fa44
@ -57,6 +57,9 @@ public class AssetsProcess extends BaseProcessor{
|
||||
ichtype.addField(FieldSpec.builder(ParameterizedTypeName.get(ObjectIntMap.class, String.class),
|
||||
"codes", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new ObjectIntMap<>()").build());
|
||||
|
||||
ichtype.addField(FieldSpec.builder(ParameterizedTypeName.get(IntMap.class, String.class),
|
||||
"codeToName", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new IntMap<>()").build());
|
||||
|
||||
ObjectSet<String> used = new ObjectSet<>();
|
||||
|
||||
for(Jval val : icons.get("glyphs").asArray()){
|
||||
@ -67,7 +70,9 @@ public class AssetsProcess extends BaseProcessor{
|
||||
int code = val.getInt("code", 0);
|
||||
iconcAll.append((char)code);
|
||||
ichtype.addField(FieldSpec.builder(char.class, name, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).addJavadoc(String.format("\\u%04x", code)).initializer("'" + ((char)code) + "'").build());
|
||||
|
||||
ichinit.addStatement("codes.put($S, $L)", name, code);
|
||||
ichinit.addStatement("codeToName.put($L, $S)", code, name);
|
||||
|
||||
ictype.addField(TextureRegionDrawable.class, name + "Small", Modifier.PUBLIC, Modifier.STATIC);
|
||||
icload.addStatement(name + "Small = mindustry.ui.Fonts.getGlyph(mindustry.ui.Fonts.def, (char)" + code + ")");
|
||||
|
@ -445,6 +445,11 @@ editor.rules = Rules
|
||||
editor.generation = Generation
|
||||
editor.objectives = Objectives
|
||||
editor.locales = Locale Bundles
|
||||
editor.worldprocessors = World Processors
|
||||
editor.worldprocessors.editname = Edit Name
|
||||
editor.worldprocessors.none = [lightgray]No world processor blocks found!\nAdd one in the map editor, or use the \ue813 Add button below.
|
||||
editor.worldprocessors.nospace = No free space to place a world processor!\nDid you fill the map with structures? Why would you do this?
|
||||
editor.worldprocessors.delete.confirm = Are you sure you want to delete this world processor?\n\nIf it is surrounded by walls, it will be replaced by an environmental wall.
|
||||
editor.ingame = Edit In-Game
|
||||
editor.playtest = Playtest
|
||||
editor.publish.workshop = Publish On Workshop
|
||||
@ -501,7 +506,9 @@ editor.default = [lightgray]<Default>
|
||||
details = Details...
|
||||
edit = Edit
|
||||
variables = Vars
|
||||
logic.clear.confirm = Are you sure you want to clear all code from this processor?
|
||||
logic.globals = Built-in Variables
|
||||
|
||||
editor.name = Name:
|
||||
editor.spawn = Spawn Unit
|
||||
editor.removeunit = Remove Unit
|
||||
|
@ -137,6 +137,13 @@ public class Vars implements Loadable{
|
||||
Color.valueOf("4b5ef1"),
|
||||
Color.valueOf("2cabfe"),
|
||||
};
|
||||
/** Icons available to the user for customization in certain dialogs. */
|
||||
public static final String[] accessibleIcons = {
|
||||
"effect", "power", "logic", "units", "liquid", "production", "defense", "turret", "distribution", "crafting",
|
||||
"settings", "cancel", "zoom", "ok", "star", "home", "pencil", "up", "down", "left", "right",
|
||||
"hammer", "warning", "tree", "admin", "map", "modePvp", "terrain",
|
||||
"modeSurvival", "commandRally", "commandAttack",
|
||||
};
|
||||
/** maximum TCP packet size */
|
||||
public static final int maxTcpSize = 900;
|
||||
/** default server port */
|
||||
|
@ -40,8 +40,6 @@ public class LogicAI extends AIController{
|
||||
public PosTeam posTarget = PosTeam.create();
|
||||
|
||||
private ObjectSet<Object> radars = new ObjectSet<>();
|
||||
private float lastMoveX, lastMoveY;
|
||||
private int lastPathId = 0;
|
||||
|
||||
// LogicAI state should not be reset after reading.
|
||||
@Override
|
||||
@ -51,14 +49,6 @@ public class LogicAI extends AIController{
|
||||
|
||||
@Override
|
||||
public void updateMovement(){
|
||||
if(control == LUnitControl.pathfind){
|
||||
if(!Mathf.equal(moveX, lastMoveX, 0.1f) || !Mathf.equal(moveY, lastMoveY, 0.1f)){
|
||||
lastPathId ++;
|
||||
lastMoveX = moveX;
|
||||
lastMoveY = moveY;
|
||||
}
|
||||
}
|
||||
|
||||
if(targetTimer > 0f){
|
||||
targetTimer -= Time.delta;
|
||||
}else{
|
||||
|
@ -147,6 +147,11 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
return Fonts.getUnicodeStr(name);
|
||||
}
|
||||
|
||||
public int emojiChar(){
|
||||
return Fonts.getUnicode(name);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasEmoji(){
|
||||
return Fonts.hasUnicodeStr(name);
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
@ -212,11 +211,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
margin(0);
|
||||
|
||||
update(() -> {
|
||||
if(Core.scene.getKeyboardFocus() instanceof Dialog && Core.scene.getKeyboardFocus() != this){
|
||||
return;
|
||||
}
|
||||
|
||||
if(Core.scene != null && Core.scene.getKeyboardFocus() == this){
|
||||
if(hasKeyboard()){
|
||||
doInput();
|
||||
}
|
||||
});
|
||||
|
@ -14,16 +14,15 @@ import mindustry.ui.dialogs.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapInfoDialog extends BaseDialog{
|
||||
private final WaveInfoDialog waveInfo;
|
||||
private final MapGenerateDialog generate;
|
||||
private final CustomRulesDialog ruleInfo = new CustomRulesDialog();
|
||||
private final MapObjectivesDialog objectives = new MapObjectivesDialog();
|
||||
private final MapLocalesDialog locales = new MapLocalesDialog();
|
||||
private WaveInfoDialog waveInfo = new WaveInfoDialog();
|
||||
private MapGenerateDialog generate = new MapGenerateDialog(false);
|
||||
private CustomRulesDialog ruleInfo = new CustomRulesDialog();
|
||||
private MapObjectivesDialog objectives = new MapObjectivesDialog();
|
||||
private MapLocalesDialog locales = new MapLocalesDialog();
|
||||
private MapProcessorsDialog processors = new MapProcessorsDialog();
|
||||
|
||||
public MapInfoDialog(){
|
||||
super("@editor.mapinfo");
|
||||
this.waveInfo = new WaveInfoDialog();
|
||||
this.generate = new MapGenerateDialog(false);
|
||||
|
||||
addCloseButton();
|
||||
|
||||
@ -108,7 +107,12 @@ public class MapInfoDialog extends BaseDialog{
|
||||
ui.showException(e);
|
||||
}
|
||||
hide();
|
||||
}).marginLeft(10f).width(0f).colspan(2).center().growX();
|
||||
}).marginLeft(10f);
|
||||
|
||||
r.button("@editor.worldprocessors", Icon.logic, style, () -> {
|
||||
hide();
|
||||
processors.show();
|
||||
}).marginLeft(10f);
|
||||
}).colspan(2).center();
|
||||
|
||||
name.change();
|
||||
|
155
core/src/mindustry/editor/MapProcessorsDialog.java
Normal file
155
core/src/mindustry/editor/MapProcessorsDialog.java
Normal file
@ -0,0 +1,155 @@
|
||||
package mindustry.editor;
|
||||
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.blocks.logic.*;
|
||||
import mindustry.world.blocks.logic.LogicBlock.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapProcessorsDialog extends BaseDialog{
|
||||
private IconSelectDialog iconSelect = new IconSelectDialog();
|
||||
private TextField search;
|
||||
private Seq<Building> processors = new Seq<>();
|
||||
private Table list;
|
||||
|
||||
public MapProcessorsDialog(){
|
||||
super("@editor.worldprocessors");
|
||||
|
||||
shown(this::setup);
|
||||
|
||||
addCloseButton();
|
||||
buttons.button("@add", Icon.add, () -> {
|
||||
boolean foundAny = false;
|
||||
|
||||
outer:
|
||||
for(int y = 0; y < Vars.world.height(); y++){
|
||||
for(int x = 0; x < Vars.world.width(); x++){
|
||||
Tile tile = Vars.world.rawTile(x, y);
|
||||
if(!tile.synthetic()){
|
||||
foundAny = true;
|
||||
tile.setNet(Blocks.worldProcessor, Team.sharded, 0);
|
||||
if(ui.editor.isShown()){
|
||||
Vars.editor.renderer.updatePoint(x, y);
|
||||
}
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!foundAny){
|
||||
ui.showErrorMessage("@editor.worldprocessors.nospace");
|
||||
}else{
|
||||
setup();
|
||||
}
|
||||
}).size(210f, 64f);
|
||||
|
||||
cont.top();
|
||||
getCell(cont).grow();
|
||||
|
||||
cont.table(s -> {
|
||||
s.image(Icon.zoom).padRight(8);
|
||||
search = s.field(null, text -> rebuild()).growX().get();
|
||||
search.setMessageText("@players.search");
|
||||
}).width(440f).fillX().padBottom(4).row();
|
||||
|
||||
cont.pane(t -> {
|
||||
list = t;
|
||||
});
|
||||
}
|
||||
|
||||
private void rebuild(){
|
||||
list.clearChildren();
|
||||
|
||||
if(processors.isEmpty()){
|
||||
list.add("@editor.worldprocessors.none");
|
||||
}else{
|
||||
Table t = list;
|
||||
var text = search.getText().toLowerCase();
|
||||
|
||||
t.defaults().pad(4f);
|
||||
float h = 50f;
|
||||
for(var build : processors){
|
||||
if(build instanceof LogicBuild log && (text.isEmpty() || (log.tag != null && log.tag.toLowerCase().contains(text)))){
|
||||
|
||||
t.button(log.iconTag == 0 ? Styles.none : new TextureRegionDrawable(Fonts.getLargeIcon(Fonts.unicodeToName(log.iconTag))), Styles.graySquarei, iconMed, () -> {
|
||||
iconSelect.show(ic -> {
|
||||
log.iconTag = (char)ic;
|
||||
rebuild();
|
||||
});
|
||||
}).size(h);
|
||||
|
||||
t.button((log.tag == null ? "<no name>\n" : "[accent]" + log.tag + "\n") + "[lightgray][[" + log.tile.x + ", " + log.tile.y + "]", Styles.grayt, () -> {
|
||||
//TODO: bug: if you edit name inside of the edit dialog, it won't show up in the list properly
|
||||
log.showEditDialog();
|
||||
}).size(Vars.mobile ? 390f : 450f, h).margin(10f).with(b -> {
|
||||
b.getLabel().setAlignment(Align.left, Align.left);
|
||||
});
|
||||
|
||||
t.button(Icon.pencil, Styles.graySquarei, Vars.iconMed, () -> {
|
||||
ui.showTextInput("", "@editor.name", LogicBlock.maxNameLength, log.tag == null ? "" : log.tag, tag -> {
|
||||
//bypass configuration and set it directly in case privileged checks mess things up
|
||||
log.tag = tag;
|
||||
setup();
|
||||
});
|
||||
}).size(h);
|
||||
|
||||
if(Vars.state.isGame() && state.isEditor()){
|
||||
t.button(Icon.eyeSmall, Styles.graySquarei, Vars.iconMed, () -> {
|
||||
hide();
|
||||
control.input.config.showConfig(build);
|
||||
control.input.panCamera(Tmp.v1.set(build));
|
||||
}).size(h);
|
||||
}
|
||||
|
||||
t.button(Icon.trash, Styles.graySquarei, iconMed, () -> {
|
||||
ui.showConfirm("@editor.worldprocessors.delete.confirm", () -> {
|
||||
boolean surrounded = true;
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tile other = build.tile.nearby(i);
|
||||
if(other != null && !(other.block().privileged || other.block().isStatic())){
|
||||
surrounded = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(surrounded){
|
||||
build.tile.setNet(build.tile.floor().wall instanceof StaticWall ? build.tile.floor().wall : Blocks.stoneWall);
|
||||
}else{
|
||||
build.tile.setNet(Blocks.air);
|
||||
}
|
||||
processors.remove(build);
|
||||
rebuild();
|
||||
});
|
||||
}).size(h);
|
||||
|
||||
t.row();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
|
||||
processors.clear();
|
||||
|
||||
//scan the entire world for processor (Groups.build can be empty, indexer is probably inaccurate)
|
||||
Vars.world.tiles.eachTile(t -> {
|
||||
if(t.isCenter() && t.block() == Blocks.worldProcessor){
|
||||
processors.add(t.build);
|
||||
}
|
||||
});
|
||||
|
||||
rebuild();
|
||||
}
|
||||
}
|
@ -164,6 +164,12 @@ public class LCanvas extends Table{
|
||||
this.statements.layout();
|
||||
}
|
||||
|
||||
public void clearStatements(){
|
||||
jumps.clear();
|
||||
statements.clearChildren();
|
||||
statements.layout();
|
||||
}
|
||||
|
||||
StatementElem checkHovered(){
|
||||
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||
if(e != null){
|
||||
|
@ -17,6 +17,7 @@ import mindustry.logic.LExecutor.*;
|
||||
import mindustry.logic.LStatements.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.blocks.logic.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.logic.LCanvas.*;
|
||||
@ -92,11 +93,29 @@ public class LogicDialog extends BaseDialog{
|
||||
TextButtonStyle style = Styles.flatt;
|
||||
t.defaults().size(280f, 60f).left();
|
||||
|
||||
if(privileged && executor != null && executor.build != null){// && !ui.editor.isShown()
|
||||
t.button("@editor.worldprocessors.editname", Icon.edit, style, () -> {
|
||||
ui.showTextInput("", "@editor.name", LogicBlock.maxNameLength, executor.build.tag == null ? "" : executor.build.tag, tag -> {
|
||||
if(privileged && executor != null && executor.build != null){
|
||||
executor.build.configure(tag);
|
||||
//just in case of privilege shenanigans...
|
||||
executor.build.tag = tag;
|
||||
}
|
||||
});
|
||||
dialog.hide();
|
||||
}).marginLeft(12f).row();
|
||||
}
|
||||
|
||||
t.button("@clear", Icon.cancel, style, () -> {
|
||||
ui.showConfirm("@logic.clear.confirm", () -> canvas.clearStatements());
|
||||
dialog.hide();
|
||||
}).marginLeft(12f).row();
|
||||
|
||||
t.button("@schematic.copy", Icon.copy, style, () -> {
|
||||
dialog.hide();
|
||||
Core.app.setClipboardText(canvas.save());
|
||||
}).marginLeft(12f);
|
||||
t.row();
|
||||
}).marginLeft(12f).row();
|
||||
|
||||
t.button("@schematic.copy.import", Icon.download, style, () -> {
|
||||
dialog.hide();
|
||||
try{
|
||||
|
@ -30,6 +30,7 @@ public class Fonts{
|
||||
private static final String mainFont = "fonts/font.woff";
|
||||
private static final ObjectSet<String> unscaled = ObjectSet.with("iconLarge");
|
||||
private static ObjectIntMap<String> unicodeIcons = new ObjectIntMap<>();
|
||||
private static IntMap<String> unicodeToName = new IntMap<>();
|
||||
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
|
||||
private static ObjectMap<String, TextureRegion> largeIcons = new ObjectMap<>();
|
||||
private static TextureRegion[] iconTable;
|
||||
@ -95,12 +96,16 @@ public class Fonts{
|
||||
}})).loaded = f -> Fonts.logic = f;
|
||||
}
|
||||
|
||||
public static @Nullable String unicodeToName(int unicode){
|
||||
return unicodeToName.get(unicode, () -> Iconc.codeToName.get(unicode));
|
||||
}
|
||||
|
||||
public static TextureRegion getLargeIcon(String name){
|
||||
return largeIcons.get(name, () -> {
|
||||
var region = new TextureRegion();
|
||||
int code = Iconc.codes.get(name, '\uF8D4');
|
||||
var glyph = iconLarge.getData().getGlyph((char)code);
|
||||
if(glyph == null) return Core.atlas.find("error");
|
||||
if(glyph == null) return Core.atlas.find(name);
|
||||
region.set(iconLarge.getRegion().texture);
|
||||
region.set(glyph.u, glyph.v2, glyph.u2, glyph.v);
|
||||
return region;
|
||||
@ -127,6 +132,7 @@ public class Fonts{
|
||||
|
||||
unicodeIcons.put(nametex[0], ch);
|
||||
stringIcons.put(nametex[0], ((char)ch) + "");
|
||||
unicodeToName.put(ch, texture);
|
||||
|
||||
Vec2 out = Scaling.fit.apply(region.width, region.height, size, size);
|
||||
|
||||
|
@ -73,6 +73,8 @@ public class Styles{
|
||||
geni,
|
||||
/** Gray, toggleable, no background. */
|
||||
grayi,
|
||||
/** Gray square background, standard behavior. Equivalent to grayt. */
|
||||
graySquarei,
|
||||
/** Flat, square, black background. */
|
||||
flati,
|
||||
/** Square border. */
|
||||
@ -288,6 +290,14 @@ public class Styles{
|
||||
imageUpColor = Color.lightGray;
|
||||
imageDownColor = Color.white;
|
||||
}};
|
||||
graySquarei = new ImageButtonStyle(){{
|
||||
imageUpColor = Color.white;
|
||||
imageDownColor = Color.lightGray;
|
||||
|
||||
over = flatOver;
|
||||
down = flatOver;
|
||||
up = grayPanel;
|
||||
}};
|
||||
flati = new ImageButtonStyle(){{
|
||||
down = flatOver;
|
||||
up = black;
|
||||
|
@ -45,7 +45,7 @@ public class DatabaseDialog extends BaseDialog{
|
||||
|
||||
void rebuild(){
|
||||
all.clear();
|
||||
var text = search.getText();
|
||||
var text = search.getText().toLowerCase();
|
||||
|
||||
Seq<Content>[] allContent = Vars.content.getContentMap();
|
||||
|
||||
@ -54,7 +54,7 @@ public class DatabaseDialog extends BaseDialog{
|
||||
|
||||
Seq<UnlockableContent> array = allContent[j]
|
||||
.select(c -> c instanceof UnlockableContent u && !u.isHidden() &&
|
||||
(text.isEmpty() || u.localizedName.toLowerCase().contains(text.toLowerCase()))).as();
|
||||
(text.isEmpty() || u.localizedName.toLowerCase().contains(text))).as();
|
||||
if(array.size == 0) continue;
|
||||
|
||||
all.add("@content." + type.name() + ".name").growX().left().color(Pal.accent);
|
||||
|
74
core/src/mindustry/ui/dialogs/IconSelectDialog.java
Normal file
74
core/src/mindustry/ui/dialogs/IconSelectDialog.java
Normal file
@ -0,0 +1,74 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class IconSelectDialog extends Dialog{
|
||||
private Intc consumer = i -> Log.info("you have mere seconds");
|
||||
|
||||
public IconSelectDialog(){
|
||||
closeOnBack();
|
||||
setFillParent(true);
|
||||
|
||||
cont.pane(t -> {
|
||||
resized(true, () -> {
|
||||
t.clearChildren();
|
||||
t.marginRight(19f);
|
||||
t.defaults().size(48f);
|
||||
|
||||
t.button(Icon.none, Styles.flati, () -> {
|
||||
hide();
|
||||
consumer.get(0);
|
||||
});
|
||||
|
||||
int cols = (int)Math.min(20, Core.graphics.getWidth() / Scl.scl(52f));
|
||||
|
||||
int i = 1;
|
||||
for(var key : accessibleIcons){
|
||||
var value = Icon.icons.get(key);
|
||||
|
||||
t.button(value, Styles.flati, () -> {
|
||||
hide();
|
||||
consumer.get(Iconc.codes.get(key));
|
||||
});
|
||||
|
||||
if(++i % cols == 0) t.row();
|
||||
}
|
||||
|
||||
for(ContentType ctype : defaultContentIcons){
|
||||
t.row();
|
||||
t.image().colspan(cols).growX().width(Float.NEGATIVE_INFINITY).height(3f).color(Pal.accent);
|
||||
t.row();
|
||||
|
||||
i = 0;
|
||||
for(UnlockableContent u : content.getBy(ctype).<UnlockableContent>as()){
|
||||
if(!u.isHidden() && u.unlocked()){
|
||||
t.button(new TextureRegionDrawable(u.uiIcon), Styles.flati, iconMed, () -> {
|
||||
hide();
|
||||
consumer.get(u.emojiChar());
|
||||
});
|
||||
|
||||
if(++i % cols == 0) t.row();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
buttons.button("@back", Icon.left, this::hide).size(210f, 64f);
|
||||
}
|
||||
|
||||
public void show(Intc listener){
|
||||
consumer = listener;
|
||||
super.show();
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import mindustry.editor.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PausedDialog extends BaseDialog{
|
||||
private MapProcessorsDialog processors = new MapProcessorsDialog();
|
||||
private SaveDialog save = new SaveDialog();
|
||||
private LoadDialog load = new LoadDialog();
|
||||
private boolean wasClient = false;
|
||||
@ -49,13 +51,22 @@ public class PausedDialog extends BaseDialog{
|
||||
|
||||
cont.row();
|
||||
|
||||
cont.button("@hostserver", Icon.host, () -> {
|
||||
//the button runs out of space when the editor button is added, so use the mobile text
|
||||
cont.button(state.isEditor() ? "@hostserver.mobile" : "@hostserver", Icon.host, () -> {
|
||||
if(net.server() && steam){
|
||||
platform.inviteFriends();
|
||||
}else{
|
||||
ui.host.show();
|
||||
}
|
||||
}).disabled(b -> !((steam && net.server()) || !net.active())).colspan(2).width(dw * 2 + 10f).update(e -> e.setText(net.server() && steam ? "@invitefriends" : "@hostserver"));
|
||||
}).disabled(b -> !((steam && net.server()) || !net.active())).colspan(state.isEditor() ? 1 : 2).width(state.isEditor() ? dw : dw * 2 + 10f)
|
||||
.update(e -> e.setText(net.server() && steam ? "@invitefriends" : state.isEditor() ? "@hostserver.mobile" : "@hostserver"));
|
||||
|
||||
if(state.isEditor()){
|
||||
cont.button("@editor.worldprocessors", Icon.logic, () -> {
|
||||
hide();
|
||||
processors.show();
|
||||
});
|
||||
}
|
||||
|
||||
cont.row();
|
||||
|
||||
|
@ -43,13 +43,6 @@ import static mindustry.graphics.g3d.PlanetRenderer.*;
|
||||
import static mindustry.ui.dialogs.PlanetDialog.Mode.*;
|
||||
|
||||
public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
static final String[] defaultIcons = {
|
||||
"effect", "power", "logic", "units", "liquid", "production", "defense", "turret", "distribution", "crafting",
|
||||
"settings", "cancel", "zoom", "ok", "star", "home", "pencil", "up", "down", "left", "right",
|
||||
"hammer", "warning", "tree", "admin", "map", "modePvp", "terrain",
|
||||
"modeSurvival", "commandRally", "commandAttack",
|
||||
};
|
||||
|
||||
//if true, enables launching anywhere for testing
|
||||
public static boolean debugSelect = false;
|
||||
public static float sectorShowDuration = 60f * 2.4f;
|
||||
@ -1054,6 +1047,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
Icon.icons.get(sector.info.icon + "Small");
|
||||
|
||||
title.button(icon == null ? Icon.noneSmall : icon, Styles.clearNonei, iconSmall, () -> {
|
||||
//TODO use IconSelectDialog
|
||||
new Dialog(""){{
|
||||
closeOnBack();
|
||||
setFillParent(true);
|
||||
@ -1080,7 +1074,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
int cols = (int)Math.min(20, Core.graphics.getWidth() / Scl.scl(52f));
|
||||
|
||||
int i = 1;
|
||||
for(var key : defaultIcons){
|
||||
for(var key : accessibleIcons){
|
||||
var value = Icon.icons.get(key);
|
||||
|
||||
t.button(value, Styles.squareTogglei, () -> {
|
||||
|
@ -398,6 +398,7 @@ public class SchematicsDialog extends BaseDialog{
|
||||
closeOnBack();
|
||||
setFillParent(true);
|
||||
|
||||
//TODO: use IconSelectDialog
|
||||
cont.pane(t -> {
|
||||
resized(true, () -> {
|
||||
t.clearChildren();
|
||||
@ -407,7 +408,7 @@ public class SchematicsDialog extends BaseDialog{
|
||||
int cols = (int)Math.min(20, Core.graphics.getWidth() / Scl.scl(52f));
|
||||
|
||||
int i = 0;
|
||||
for(String icon : PlanetDialog.defaultIcons){
|
||||
for(String icon : accessibleIcons){
|
||||
String out = (char)Iconc.codes.get(icon) + "";
|
||||
if(tags.contains(out)) continue;
|
||||
|
||||
|
@ -3,6 +3,8 @@ package mindustry.world.blocks.logic;
|
||||
import arc.Graphics.*;
|
||||
import arc.Graphics.Cursor.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
@ -10,6 +12,7 @@ import arc.struct.Bits;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.ai.types.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.gen.*;
|
||||
@ -31,6 +34,7 @@ import static mindustry.Vars.*;
|
||||
|
||||
public class LogicBlock extends Block{
|
||||
private static final int maxByteLen = 1024 * 100;
|
||||
public static final int maxNameLength = 32;
|
||||
|
||||
public int maxInstructionScale = 5;
|
||||
public int instructionsPerTick = 1;
|
||||
@ -56,6 +60,14 @@ public class LogicBlock extends Block{
|
||||
build.readCompressed(data, true);
|
||||
});
|
||||
|
||||
config(String.class,(LogicBuild build, String data) -> {
|
||||
if(!accessible() || !privileged) return;
|
||||
|
||||
if(data != null && data.length() < maxNameLength){
|
||||
build.tag = data;
|
||||
}
|
||||
});
|
||||
|
||||
config(Integer.class, (LogicBuild entity, Integer pos) -> {
|
||||
if(!accessible()) return;
|
||||
|
||||
@ -235,6 +247,9 @@ public class LogicBlock extends Block{
|
||||
public boolean checkedDuplicates = false;
|
||||
//dynamic only for privileged processors
|
||||
public int ipt = instructionsPerTick;
|
||||
/** Display name, for convenience. This is currently only available for world processors. */
|
||||
public @Nullable String tag;
|
||||
public char iconTag;
|
||||
|
||||
/** Block of code to run after load. */
|
||||
public @Nullable Runnable loadBlock;
|
||||
@ -563,9 +578,45 @@ public class LogicBlock extends Block{
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
if(!accessible()) return;
|
||||
|
||||
Groups.unit.each(u -> u.controller() instanceof LogicAI ai && ai.controller == this, unit -> {
|
||||
Drawf.square(unit.x, unit.y, unit.hitSize, unit.rotation + 45);
|
||||
});
|
||||
|
||||
//draw tag over processor (world processor only)
|
||||
if(!(renderer.pixelate || !privileged || tag == null || tag.isEmpty())){
|
||||
Font font = Fonts.outline;
|
||||
GlyphLayout l = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||
boolean ints = font.usesIntegerPositions();
|
||||
font.getData().setScale(1 / 4f / Scl.scl(1f));
|
||||
font.setUseIntegerPositions(false);
|
||||
|
||||
l.setText(font, tag, Color.white, 90f, Align.left, true);
|
||||
float offset = 1f;
|
||||
|
||||
//Draw.color(0f, 0f, 0f, 0.1f);
|
||||
//Fill.rect(x, y + tilesize/2f - l.height/2f - offset, l.width + offset*2f, l.height + offset*2f);
|
||||
Draw.color();
|
||||
font.setColor(1f, 1f, 1f, 0.5f);
|
||||
font.draw(tag, x - l.width/2f, y + tilesize + 2f - offset, 90f, Align.left, true);
|
||||
font.setUseIntegerPositions(ints);
|
||||
|
||||
font.getData().setScale(1f);
|
||||
|
||||
Pools.free(l);
|
||||
}
|
||||
|
||||
if(iconTag != 0){
|
||||
TextureRegion icon = Fonts.getLargeIcon(Fonts.unicodeToName(iconTag));
|
||||
if(icon.found()){
|
||||
Draw.alpha(0.5f);
|
||||
|
||||
Draw.rect(icon, x, y, tilesize, tilesize / icon.ratio());
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean validLink(Building other){
|
||||
@ -579,9 +630,11 @@ public class LogicBlock extends Block{
|
||||
|
||||
@Override
|
||||
public void buildConfiguration(Table table){
|
||||
table.button(Icon.pencil, Styles.cleari, () -> {
|
||||
ui.logic.show(code, executor, privileged, code -> configure(compress(code, relativeConnections())));
|
||||
}).size(40);
|
||||
table.button(Icon.pencil, Styles.cleari, this::showEditDialog).size(40);
|
||||
}
|
||||
|
||||
public void showEditDialog(){
|
||||
ui.logic.show(code, executor, privileged, code -> configure(compress(code, relativeConnections())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -601,7 +654,7 @@ public class LogicBlock extends Block{
|
||||
|
||||
@Override
|
||||
public byte version(){
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -638,6 +691,9 @@ public class LogicBlock extends Block{
|
||||
if(privileged){
|
||||
write.s(Mathf.clamp(ipt, 1, maxInstructionsPerTick));
|
||||
}
|
||||
|
||||
TypeIO.writeString(write, tag);
|
||||
write.s(iconTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -694,6 +750,11 @@ public class LogicBlock extends Block{
|
||||
ipt = Mathf.clamp(read.s(), 1, maxInstructionsPerTick);
|
||||
}
|
||||
|
||||
if(revision >= 3){
|
||||
tag = TypeIO.readString(read);
|
||||
iconTag = (char)read.us();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ org.gradle.caching=true
|
||||
#used for slow jitpack builds; TODO see if this actually works
|
||||
org.gradle.internal.http.socketTimeout=100000
|
||||
org.gradle.internal.http.connectionTimeout=100000
|
||||
archash=5a944efcc0
|
||||
archash=f0d4fdbf89
|
||||
|
Loading…
Reference in New Issue
Block a user