mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-11 07:39:39 +07:00
Merge pull request #2821 from summetdev/schems-description
Descriptions for schematics.
This commit is contained in:
commit
a3e42b28bd
@ -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.*;
|
||||
@ -531,6 +532,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
});
|
||||
}else{
|
||||
lastSchematic.tags.put("name", text);
|
||||
lastSchematic.tags.put("description", "");
|
||||
schematics.add(lastSchematic);
|
||||
ui.showInfoFade("@schematic.saved");
|
||||
ui.schematics.showInfo(lastSchematic);
|
||||
|
@ -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(400f, 55f).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.area(s.description(), Styles.areaField, t -> {}).size(400f, 140f).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() && Core.scene.getKeyboardFocus() != descripionField){
|
||||
accept.run();
|
||||
}
|
||||
});
|
||||
keyDown(KeyCode.escape, this::hide);
|
||||
keyDown(KeyCode.back, this::hide);
|
||||
show();
|
||||
}};
|
||||
});
|
||||
|
||||
if(s.hasSteamID()){
|
||||
|
Loading…
Reference in New Issue
Block a user