Changed map edit menu, added map info dialog
This commit is contained in:
BIN
core/assets-raw/sprites/ui/textarea.9.png
Normal file
BIN
core/assets-raw/sprites/ui/textarea.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 216 B |
@@ -151,6 +151,11 @@ text.enemies.single={0} Enemy
|
|||||||
text.loadimage=Load Image
|
text.loadimage=Load Image
|
||||||
text.saveimage=Save Image
|
text.saveimage=Save Image
|
||||||
text.oregen=Ore Generation
|
text.oregen=Ore Generation
|
||||||
|
text.unknown=Unknown
|
||||||
|
text.editor.mapinfo=Map Info
|
||||||
|
text.editor.author=Author:
|
||||||
|
text.editor.description=Description:
|
||||||
|
text.editor.name=Name:
|
||||||
text.editor.teams=Teams
|
text.editor.teams=Teams
|
||||||
text.editor.badsize=[orange]Invalid image dimensions![]\nValid map dimensions: {0}
|
text.editor.badsize=[orange]Invalid image dimensions![]\nValid map dimensions: {0}
|
||||||
text.editor.errorimageload=Error loading image file:\n[orange]{0}
|
text.editor.errorimageload=Error loading image file:\n[orange]{0}
|
||||||
|
|||||||
@@ -2477,6 +2477,14 @@ button
|
|||||||
orig: 24, 40
|
orig: 24, 40
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
textarea
|
||||||
|
rotate: false
|
||||||
|
xy: 207, 130
|
||||||
|
size: 24, 40
|
||||||
|
split: 10, 10, 9, 14
|
||||||
|
orig: 24, 40
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
button-down
|
button-down
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 721, 448
|
xy: 721, 448
|
||||||
|
|||||||
@@ -94,7 +94,9 @@ io.anuke.ucore.scene.ui.Label$LabelStyle: {
|
|||||||
},
|
},
|
||||||
io.anuke.ucore.scene.ui.TextField$TextFieldStyle: {
|
io.anuke.ucore.scene.ui.TextField$TextFieldStyle: {
|
||||||
default: {font: default-font-chat, fontColor: white, disabledFontColor: grey, selection: selection, background: button, cursor: cursor, messageFont: default-font, messageFontColor: grey }
|
default: {font: default-font-chat, fontColor: white, disabledFontColor: grey, selection: selection, background: button, cursor: cursor, messageFont: default-font, messageFontColor: grey }
|
||||||
|
textarea: {font: default-font-chat, fontColor: white, disabledFontColor: grey, selection: selection, background: textarea, cursor: cursor, messageFont: default-font, messageFontColor: grey }
|
||||||
}
|
}
|
||||||
|
|
||||||
io.anuke.ucore.scene.ui.CheckBox$CheckBoxStyle: {
|
io.anuke.ucore.scene.ui.CheckBox$CheckBoxStyle: {
|
||||||
default: {checkboxOn: check-on, checkboxOff: check-off, checkboxOnOver: check-on-over, checkboxOver: check-over, font: default-font, fontColor: white, disabledFontColor: grey }
|
default: {checkboxOn: check-on, checkboxOff: check-off, checkboxOnOver: check-on-over, checkboxOver: check-over, font: default-font, fontColor: white, disabledFontColor: grey }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.editor;
|
package io.anuke.mindustry.editor;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.editor.DrawOperation.TileOperation;
|
import io.anuke.mindustry.editor.DrawOperation.TileOperation;
|
||||||
@@ -16,6 +17,7 @@ public class MapEditor{
|
|||||||
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15};
|
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15};
|
||||||
|
|
||||||
private MapTileData map;
|
private MapTileData map;
|
||||||
|
private ObjectMap<String, String> tags = new ObjectMap<>();
|
||||||
private TileDataMarker multiWriter;
|
private TileDataMarker multiWriter;
|
||||||
private MapRenderer renderer = new MapRenderer(this);
|
private MapRenderer renderer = new MapRenderer(this);
|
||||||
|
|
||||||
@@ -32,10 +34,16 @@ public class MapEditor{
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginEdit(MapTileData map){
|
public ObjectMap<String, String> getTags() {
|
||||||
drawBlock = Blocks.stone;
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beginEdit(MapTileData map, ObjectMap<String, String> tags){
|
||||||
this.map = map;
|
this.map = map;
|
||||||
this.brushSize = 1;
|
this.brushSize = 1;
|
||||||
|
this.tags = tags;
|
||||||
|
|
||||||
|
drawBlock = Blocks.stone;
|
||||||
multiWriter = map.new TileDataMarker();
|
multiWriter = map.new TileDataMarker();
|
||||||
renderer.resize(map.width(), map.height());
|
renderer.resize(map.width(), map.height());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.badlogic.gdx.utils.ObjectMap;
|
|||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.io.MapIO;
|
import io.anuke.mindustry.io.MapIO;
|
||||||
|
import io.anuke.mindustry.io.MapMeta;
|
||||||
import io.anuke.mindustry.io.MapTileData;
|
import io.anuke.mindustry.io.MapTileData;
|
||||||
import io.anuke.mindustry.io.Platform;
|
import io.anuke.mindustry.io.Platform;
|
||||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
||||||
@@ -43,7 +44,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
public class MapEditorDialog extends Dialog{
|
public class MapEditorDialog extends Dialog{
|
||||||
private MapEditor editor;
|
private MapEditor editor;
|
||||||
private MapView view;
|
private MapView view;
|
||||||
private MapGenerateDialog dialog;
|
private MapInfoDialog infoDialog;
|
||||||
private MapLoadDialog loadDialog;
|
private MapLoadDialog loadDialog;
|
||||||
private MapSaveDialog saveDialog;
|
private MapSaveDialog saveDialog;
|
||||||
private MapResizeDialog resizeDialog;
|
private MapResizeDialog resizeDialog;
|
||||||
@@ -60,9 +61,10 @@ public class MapEditorDialog extends Dialog{
|
|||||||
if(gwt) return;
|
if(gwt) return;
|
||||||
|
|
||||||
editor = new MapEditor();
|
editor = new MapEditor();
|
||||||
dialog = new MapGenerateDialog(editor);
|
|
||||||
view = new MapView(editor);
|
view = new MapView(editor);
|
||||||
|
|
||||||
|
infoDialog = new MapInfoDialog(editor);
|
||||||
|
|
||||||
saveFile = new FileChooser("$text.saveimage", false, file -> {
|
saveFile = new FileChooser("$text.saveimage", false, file -> {
|
||||||
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
||||||
FileHandle result = file;
|
FileHandle result = file;
|
||||||
@@ -70,8 +72,10 @@ public class MapEditorDialog extends Dialog{
|
|||||||
Timers.run(3f, () -> {
|
Timers.run(3f, () -> {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
tags.put("name", result.nameWithoutExtension());
|
if(!editor.getTags().containsKey("name")){
|
||||||
MapIO.writeMap(result, tags, editor.getMap());
|
tags.put("name", result.nameWithoutExtension());
|
||||||
|
}
|
||||||
|
MapIO.writeMap(result, editor.getTags(), editor.getMap());
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
||||||
Log.err(e);
|
Log.err(e);
|
||||||
@@ -84,9 +88,12 @@ public class MapEditorDialog extends Dialog{
|
|||||||
ui.loadfrag.show();
|
ui.loadfrag.show();
|
||||||
Timers.run(3f, () -> {
|
Timers.run(3f, () -> {
|
||||||
try{
|
try{
|
||||||
MapTileData data = MapIO.readTileData(new DataInputStream(file.read()), false);
|
DataInputStream stream = new DataInputStream(file.read());
|
||||||
|
|
||||||
editor.beginEdit(data);
|
MapMeta meta = MapIO.readMapMeta(stream);
|
||||||
|
MapTileData data = MapIO.readTileData(stream, meta, false);
|
||||||
|
|
||||||
|
editor.beginEdit(data, meta.tags);
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
||||||
@@ -117,7 +124,7 @@ public class MapEditorDialog extends Dialog{
|
|||||||
try{
|
try{
|
||||||
MapTileData data = MapIO.readPixmap(new Pixmap(file));
|
MapTileData data = MapIO.readPixmap(new Pixmap(file));
|
||||||
|
|
||||||
editor.beginEdit(data);
|
editor.beginEdit(data, new ObjectMap<>());
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
||||||
@@ -130,10 +137,50 @@ public class MapEditorDialog extends Dialog{
|
|||||||
menu = new FloatingDialog("$text.menu");
|
menu = new FloatingDialog("$text.menu");
|
||||||
menu.addCloseButton();
|
menu.addCloseButton();
|
||||||
|
|
||||||
menu.content().defaults().size(280f, 60f).padBottom(5);
|
|
||||||
|
|
||||||
float isize = 16*2f;
|
float isize = 16*2f;
|
||||||
|
|
||||||
|
menu.content().table(t -> {
|
||||||
|
t.defaults().size(230f, 60f).padBottom(5).padRight(5).padLeft(5);
|
||||||
|
|
||||||
|
t.addImageTextButton("$text.editor.mapinfo", "icon-pencil", isize, () -> {
|
||||||
|
infoDialog.show();
|
||||||
|
menu.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.addImageTextButton("$text.editor.resize", "icon-resize", isize, () -> {
|
||||||
|
resizeDialog.show();
|
||||||
|
menu.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.row();
|
||||||
|
|
||||||
|
t.addImageTextButton("$text.editor.savemap", "icon-save-map", isize, () -> {
|
||||||
|
saveFile.show();
|
||||||
|
menu.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.addImageTextButton("$text.editor.loadmap", "icon-load-map", isize, () -> {
|
||||||
|
openFile.show();
|
||||||
|
menu.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.row();
|
||||||
|
|
||||||
|
t.addImageTextButton("$text.editor.saveimage", "icon-save-map", isize, () -> {
|
||||||
|
saveImage.show();
|
||||||
|
menu.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.addImageTextButton("$text.editor.loadimage", "icon-load-map", isize, () -> {
|
||||||
|
openImage.show();
|
||||||
|
menu.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.row();
|
||||||
|
});
|
||||||
|
|
||||||
|
menu.content().row();
|
||||||
|
|
||||||
menu.content().addImageTextButton("$text.quit", "icon-back", isize, () -> {
|
menu.content().addImageTextButton("$text.quit", "icon-back", isize, () -> {
|
||||||
if(!saved){
|
if(!saved){
|
||||||
ui.showConfirm("$text.confirm", "$text.editor.unsaved", this::hide);
|
ui.showConfirm("$text.confirm", "$text.editor.unsaved", this::hide);
|
||||||
@@ -141,42 +188,7 @@ public class MapEditorDialog extends Dialog{
|
|||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
menu.hide();
|
menu.hide();
|
||||||
});
|
}).size(470f, 60f);
|
||||||
|
|
||||||
menu.content().row();
|
|
||||||
|
|
||||||
menu.content().addImageTextButton("$text.editor.resize", "icon-resize", isize, () -> {
|
|
||||||
resizeDialog.show();
|
|
||||||
menu.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
menu.content().row();
|
|
||||||
|
|
||||||
menu.content().addImageTextButton("$text.editor.savemap", "icon-save-map", isize, () -> {
|
|
||||||
saveFile.show();
|
|
||||||
menu.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
menu.content().row();
|
|
||||||
|
|
||||||
menu.content().addImageTextButton("$text.editor.loadmap", "icon-load-map", isize, () -> {
|
|
||||||
openFile.show();
|
|
||||||
menu.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
menu.content().row();
|
|
||||||
|
|
||||||
menu.content().addImageTextButton("$text.editor.saveimage", "icon-save-map", isize, () -> {
|
|
||||||
saveImage.show();
|
|
||||||
menu.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
menu.content().row();
|
|
||||||
|
|
||||||
menu.content().addImageTextButton("$text.editor.loadimage", "icon-load-map", isize, () -> {
|
|
||||||
openImage.show();
|
|
||||||
menu.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -258,7 +270,7 @@ public class MapEditorDialog extends Dialog{
|
|||||||
|
|
||||||
shown(() -> {
|
shown(() -> {
|
||||||
saved = true;
|
saved = true;
|
||||||
editor.beginEdit(new MapTileData(256, 256));
|
editor.beginEdit(new MapTileData(256, 256), new ObjectMap<>());
|
||||||
blockgroup.getButtons().get(2).setChecked(true);
|
blockgroup.getButtons().get(2).setChecked(true);
|
||||||
Core.scene.setScrollFocus(view);
|
Core.scene.setScrollFocus(view);
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
|
|||||||
67
core/src/io/anuke/mindustry/editor/MapInfoDialog.java
Normal file
67
core/src/io/anuke/mindustry/editor/MapInfoDialog.java
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package io.anuke.mindustry.editor;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
import io.anuke.mindustry.io.Platform;
|
||||||
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
|
import io.anuke.ucore.core.Settings;
|
||||||
|
import io.anuke.ucore.scene.ui.TextArea;
|
||||||
|
import io.anuke.ucore.scene.ui.TextField;
|
||||||
|
|
||||||
|
public class MapInfoDialog extends FloatingDialog{
|
||||||
|
private final MapEditor editor;
|
||||||
|
|
||||||
|
private TextArea description;
|
||||||
|
private TextField author;
|
||||||
|
private TextField name;
|
||||||
|
|
||||||
|
public MapInfoDialog(MapEditor editor){
|
||||||
|
super("$text.editor.mapinfo");
|
||||||
|
this.editor = editor;
|
||||||
|
|
||||||
|
addCloseButton();
|
||||||
|
|
||||||
|
shown(this::setup);
|
||||||
|
|
||||||
|
hidden(() -> {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setup(){
|
||||||
|
content().clear();
|
||||||
|
|
||||||
|
ObjectMap<String, String> tags = editor.getTags();
|
||||||
|
|
||||||
|
content().add("$text.editor.name").padRight(8).left();
|
||||||
|
|
||||||
|
content().defaults().padTop(15);
|
||||||
|
|
||||||
|
name = content().addField(tags.get("name", ""), text -> {
|
||||||
|
tags.put("name", text);
|
||||||
|
}).size(400, 55f).get();
|
||||||
|
name.setMessageText("$text.unknown");
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
|
||||||
|
content().add("$text.editor.description").padRight(8).left();
|
||||||
|
|
||||||
|
description = content().addArea(tags.get("description", ""), "textarea", text -> {
|
||||||
|
tags.put("description", text);
|
||||||
|
}).size(400f, 130f).get();
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
|
||||||
|
content().add("$text.editor.author").padRight(8).left();
|
||||||
|
|
||||||
|
author = content().addField(tags.get("author", Settings.getString("mapAuthor", "")), text -> {
|
||||||
|
tags.put("author", text);
|
||||||
|
Settings.putString("mapAuthor", text);
|
||||||
|
Settings.save();
|
||||||
|
}).size(400, 55f).get();
|
||||||
|
author.setMessageText("$text.unknown");
|
||||||
|
|
||||||
|
Platform.instance.addDialog(name, 50);
|
||||||
|
Platform.instance.addDialog(author, 50);
|
||||||
|
Platform.instance.addDialog(description, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user