mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-26 08:41:12 -07:00
description for schematics
This commit is contained in:
parent
2604a2d649
commit
5ffff9c151
3 changed files with 67 additions and 14 deletions
|
|
@ -62,6 +62,10 @@ public class Schematic implements Publishable, Comparable<Schematic>{
|
|||
return tags.get("name", "unknown");
|
||||
}
|
||||
|
||||
public String description(){
|
||||
return tags.get("description", "");
|
||||
}
|
||||
|
||||
public void save(){
|
||||
schematics.saveChanges(this);
|
||||
}
|
||||
|
|
@ -90,7 +94,7 @@ public class Schematic implements Publishable, Comparable<Schematic>{
|
|||
|
||||
@Override
|
||||
public String steamDescription(){
|
||||
return null;
|
||||
return description();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import arc.math.*;
|
|||
import arc.math.geom.*;
|
||||
import arc.scene.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
|
|
@ -489,7 +490,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
protected void showSchematicSave(){
|
||||
if(lastSchematic == null) return;
|
||||
|
||||
ui.showTextInput("@schematic.add", "@name", "", text -> {
|
||||
Cons2<String, String> saveSchematic = (text, description) -> {
|
||||
Schematic replacement = schematics.all().find(s -> s.name().equals(text));
|
||||
if(replacement != null){
|
||||
ui.showConfirm("@confirm", "@schematic.replace", () -> {
|
||||
|
|
@ -499,11 +500,40 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
});
|
||||
}else{
|
||||
lastSchematic.tags.put("name", text);
|
||||
lastSchematic.tags.put("description", description);
|
||||
schematics.add(lastSchematic);
|
||||
ui.showInfoFade("@schematic.saved");
|
||||
ui.schematics.showInfo(lastSchematic);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
new Dialog("@schematic.add"){{
|
||||
cont.margin(30).add("@name").padRight(6f);
|
||||
TextField nameField = cont.field("", t -> {}).size(330f, 50f).addInputDialog().get();
|
||||
|
||||
cont.row();
|
||||
|
||||
cont.margin(30).add("@editor.description").padRight(6f);
|
||||
TextField descripionField = cont.field("", t -> {}).size(330f, 50f).addInputDialog().get();
|
||||
|
||||
buttons.defaults().size(120, 54).pad(4);
|
||||
buttons.button("@ok", () -> {
|
||||
saveSchematic.get(nameField.getText(), descripionField.getText());
|
||||
hide();
|
||||
}).disabled(b -> nameField.getText().isEmpty());
|
||||
buttons.button("@cancel", this::hide);
|
||||
|
||||
keyDown(KeyCode.enter, () -> {
|
||||
String text = nameField.getText();
|
||||
if(!text.isEmpty()){
|
||||
saveSchematic.get(text, descripionField.getText());
|
||||
hide();
|
||||
}
|
||||
});
|
||||
keyDown(KeyCode.escape, this::hide);
|
||||
keyDown(KeyCode.back, this::hide);
|
||||
show();
|
||||
}};
|
||||
}
|
||||
|
||||
public void rotateRequests(Seq<BuildPlan> requests, int direction){
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import arc.*;
|
|||
import arc.graphics.*;
|
||||
import arc.graphics.Texture.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
|
|
@ -106,18 +107,36 @@ public class SchematicsDialog extends BaseDialog{
|
|||
});
|
||||
|
||||
buttons.button(Icon.pencil, style, () -> {
|
||||
ui.showTextInput("@schematic.rename", "@name", s.name(), res -> {
|
||||
Schematic replacement = schematics.all().find(other -> other.name().equals(res) && other != s);
|
||||
if(replacement != null){
|
||||
//renaming to an existing schematic is not allowed, as it is not clear how the tags would be merged, and which one should be removed
|
||||
ui.showErrorMessage("@schematic.exists");
|
||||
return;
|
||||
}
|
||||
new Dialog("@schematic.rename"){{
|
||||
cont.margin(30).add("@name").padRight(6f);
|
||||
TextField nameField = cont.field(s.name(), null).size(330f, 50f).addInputDialog().get();
|
||||
|
||||
s.tags.put("name", res);
|
||||
s.save();
|
||||
rebuildPane[0].run();
|
||||
});
|
||||
cont.row();
|
||||
|
||||
cont.margin(30).add("@editor.description").padRight(6f);
|
||||
TextField descripionField = cont.field(s.description(), null).size(330f, 50f).addInputDialog().get();
|
||||
|
||||
Runnable accept = () -> {
|
||||
s.tags.put("name", nameField.getText());
|
||||
s.tags.put("description", descripionField.getText());
|
||||
s.save();
|
||||
hide();
|
||||
rebuildPane[0].run();
|
||||
};
|
||||
|
||||
buttons.defaults().size(120, 54).pad(4);
|
||||
buttons.button("@ok", accept).disabled(b -> nameField.getText().isEmpty());
|
||||
buttons.button("@cancel", this::hide);
|
||||
|
||||
keyDown(KeyCode.enter, () -> {
|
||||
if(!nameField.getText().isEmpty()){
|
||||
accept.run();
|
||||
}
|
||||
});
|
||||
keyDown(KeyCode.escape, this::hide);
|
||||
keyDown(KeyCode.back, this::hide);
|
||||
show();
|
||||
}};
|
||||
});
|
||||
|
||||
if(s.hasSteamID()){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue