WIP map info dialog changes
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
package mindustry.editor;
|
package mindustry.editor;
|
||||||
|
|
||||||
import arc.*;
|
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.io.*;
|
import mindustry.io.*;
|
||||||
import mindustry.maps.filters.*;
|
import mindustry.maps.filters.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@@ -16,6 +16,7 @@ public class MapInfoDialog extends BaseDialog{
|
|||||||
private final WaveInfoDialog waveInfo;
|
private final WaveInfoDialog waveInfo;
|
||||||
private final MapGenerateDialog generate;
|
private final MapGenerateDialog generate;
|
||||||
private final CustomRulesDialog ruleInfo = new CustomRulesDialog();
|
private final CustomRulesDialog ruleInfo = new CustomRulesDialog();
|
||||||
|
private final MapObjectivesDialog objectives = new MapObjectivesDialog();
|
||||||
|
|
||||||
public MapInfoDialog(){
|
public MapInfoDialog(){
|
||||||
super("@editor.mapinfo");
|
super("@editor.mapinfo");
|
||||||
@@ -51,29 +52,36 @@ public class MapInfoDialog extends BaseDialog{
|
|||||||
t.row();
|
t.row();
|
||||||
t.add("@editor.author").padRight(8).left();
|
t.add("@editor.author").padRight(8).left();
|
||||||
|
|
||||||
TextField author = t.field(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> {
|
TextField author = t.field(tags.get("author", ""), text -> {
|
||||||
tags.put("author", text);
|
tags.put("author", text);
|
||||||
Core.settings.put("mapAuthor", text);
|
|
||||||
}).size(400, 55f).maxTextLength(50).get();
|
}).size(400, 55f).maxTextLength(50).get();
|
||||||
author.setMessageText("@unknown");
|
author.setMessageText("@unknown");
|
||||||
|
|
||||||
t.row();
|
t.row();
|
||||||
t.add("@editor.rules").padRight(8).left();
|
|
||||||
t.button("@edit", () -> {
|
t.table(Tex.button, r -> {
|
||||||
|
r.defaults().width(230f).height(60f);
|
||||||
|
|
||||||
|
var style = Styles.flatt;
|
||||||
|
|
||||||
|
r.button("@editor.rules", Icon.list, style, () -> {
|
||||||
ruleInfo.show(Vars.state.rules, () -> Vars.state.rules = new Rules());
|
ruleInfo.show(Vars.state.rules, () -> Vars.state.rules = new Rules());
|
||||||
hide();
|
hide();
|
||||||
}).left().width(200f);
|
}).marginLeft(10f);
|
||||||
|
|
||||||
t.row();
|
r.button("@editor.waves", Icon.units, style, () -> {
|
||||||
t.add("@editor.waves").padRight(8).left();
|
|
||||||
t.button("@edit", () -> {
|
|
||||||
waveInfo.show();
|
waveInfo.show();
|
||||||
hide();
|
hide();
|
||||||
}).left().width(200f);
|
}).marginLeft(10f);
|
||||||
|
|
||||||
t.row();
|
r.row();
|
||||||
t.add("@editor.generation").padRight(8).left();
|
|
||||||
t.button("@edit", () -> {
|
r.button("@editor.objectives", Icon.info, style, () -> {
|
||||||
|
objectives.show(state.rules.objectives);
|
||||||
|
hide();
|
||||||
|
}).marginLeft(10f);
|
||||||
|
|
||||||
|
r.button("@editor.generation", Icon.terrain, style, () -> {
|
||||||
//randomize so they're not all the same seed
|
//randomize so they're not all the same seed
|
||||||
var res = maps.readFilters(editor.tags.get("genfilters", ""));
|
var res = maps.readFilters(editor.tags.get("genfilters", ""));
|
||||||
res.each(GenerateFilter::randomize);
|
res.each(GenerateFilter::randomize);
|
||||||
@@ -85,7 +93,8 @@ public class MapInfoDialog extends BaseDialog{
|
|||||||
editor.tags.put("genfilters", JsonIO.write(filters));
|
editor.tags.put("genfilters", JsonIO.write(filters));
|
||||||
});
|
});
|
||||||
hide();
|
hide();
|
||||||
}).left().width(200f);
|
}).marginLeft(10f);
|
||||||
|
}).colspan(2).center();
|
||||||
|
|
||||||
name.change();
|
name.change();
|
||||||
description.change();
|
description.change();
|
||||||
|
|||||||
70
core/src/mindustry/editor/MapObjectivesDialog.java
Normal file
70
core/src/mindustry/editor/MapObjectivesDialog.java
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
package mindustry.editor;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.struct.*;
|
||||||
|
import mindustry.game.MapObjectives.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.io.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
|
import mindustry.ui.dialogs.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
public class MapObjectivesDialog extends BaseDialog{
|
||||||
|
private Seq<MapObjective> objectives = new Seq<>();
|
||||||
|
|
||||||
|
public MapObjectivesDialog(){
|
||||||
|
super("@editor.objectives");
|
||||||
|
|
||||||
|
buttons.defaults().size(180f, 64f).pad(2f);
|
||||||
|
buttons.button("@back", Icon.left, this::hide);
|
||||||
|
|
||||||
|
buttons.button("@edit", Icon.edit, () -> {
|
||||||
|
BaseDialog dialog = new BaseDialog("@editor.export");
|
||||||
|
dialog.cont.pane(p -> {
|
||||||
|
p.margin(10f);
|
||||||
|
p.table(Tex.button, in -> {
|
||||||
|
var style = Styles.flatt;
|
||||||
|
|
||||||
|
in.defaults().size(280f, 60f).left();
|
||||||
|
|
||||||
|
in.button("@waves.copy", Icon.copy, style, () -> {
|
||||||
|
dialog.hide();
|
||||||
|
|
||||||
|
Core.app.setClipboardText(JsonIO.write(objectives));
|
||||||
|
}).marginLeft(12f).row();
|
||||||
|
in.button("@waves.load", Icon.download, style, () -> {
|
||||||
|
dialog.hide();
|
||||||
|
try{
|
||||||
|
objectives.set(JsonIO.read(Seq.class, Core.app.getClipboardText()));
|
||||||
|
|
||||||
|
setup();
|
||||||
|
}catch(Throwable e){
|
||||||
|
ui.showException(e);
|
||||||
|
}
|
||||||
|
}).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null).row();
|
||||||
|
in.button("@clear", Icon.none, style, () -> {
|
||||||
|
dialog.hide();
|
||||||
|
objectives.clear();
|
||||||
|
setup();
|
||||||
|
}).marginLeft(12f).row();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.addCloseButton();
|
||||||
|
dialog.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(Seq<MapObjective> objectives){
|
||||||
|
super.show();
|
||||||
|
|
||||||
|
this.objectives = objectives;
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
cont.clear();
|
||||||
|
cont.add("This editor doesn't work yet. Come back later.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.io;
|
package mindustry.io;
|
||||||
|
|
||||||
|
import arc.graphics.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.serialization.*;
|
import arc.util.serialization.*;
|
||||||
import arc.util.serialization.Json.*;
|
import arc.util.serialization.Json.*;
|
||||||
@@ -72,6 +73,23 @@ public class JsonIO{
|
|||||||
json.setElementType(Rules.class, "spawns", SpawnGroup.class);
|
json.setElementType(Rules.class, "spawns", SpawnGroup.class);
|
||||||
json.setElementType(Rules.class, "loadout", ItemStack.class);
|
json.setElementType(Rules.class, "loadout", ItemStack.class);
|
||||||
|
|
||||||
|
json.setSerializer(Color.class, new Serializer<>(){
|
||||||
|
@Override
|
||||||
|
public void write(Json json, Color object, Class knownType){
|
||||||
|
json.writeValue(object.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Color read(Json json, JsonValue jsonData, Class type){
|
||||||
|
if(jsonData.isString()){
|
||||||
|
return Color.valueOf(jsonData.asString());
|
||||||
|
}
|
||||||
|
Color out = new Color();
|
||||||
|
json.readFields(out, jsonData);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
json.setSerializer(Sector.class, new Serializer<>(){
|
json.setSerializer(Sector.class, new Serializer<>(){
|
||||||
@Override
|
@Override
|
||||||
public void write(Json json, Sector object, Class knownType){
|
public void write(Json json, Sector object, Class knownType){
|
||||||
|
|||||||
Reference in New Issue
Block a user