mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
Changed map edit menu, added map info dialog
This commit is contained in:
parent
2999694f48
commit
f0fa126e7b
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.saveimage=Save Image
|
||||
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.badsize=[orange]Invalid image dimensions![]\nValid map dimensions: {0}
|
||||
text.editor.errorimageload=Error loading image file:\n[orange]{0}
|
||||
|
@ -2477,6 +2477,14 @@ button
|
||||
orig: 24, 40
|
||||
offset: 0, 0
|
||||
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
|
||||
rotate: false
|
||||
xy: 721, 448
|
||||
|
@ -94,7 +94,9 @@ io.anuke.ucore.scene.ui.Label$LabelStyle: {
|
||||
},
|
||||
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 }
|
||||
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: {
|
||||
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;
|
||||
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
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};
|
||||
|
||||
private MapTileData map;
|
||||
private ObjectMap<String, String> tags = new ObjectMap<>();
|
||||
private TileDataMarker multiWriter;
|
||||
private MapRenderer renderer = new MapRenderer(this);
|
||||
|
||||
@ -32,10 +34,16 @@ public class MapEditor{
|
||||
return map;
|
||||
}
|
||||
|
||||
public void beginEdit(MapTileData map){
|
||||
drawBlock = Blocks.stone;
|
||||
public ObjectMap<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void beginEdit(MapTileData map, ObjectMap<String, String> tags){
|
||||
this.map = map;
|
||||
this.brushSize = 1;
|
||||
this.tags = tags;
|
||||
|
||||
drawBlock = Blocks.stone;
|
||||
multiWriter = map.new TileDataMarker();
|
||||
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.game.Team;
|
||||
import io.anuke.mindustry.io.MapIO;
|
||||
import io.anuke.mindustry.io.MapMeta;
|
||||
import io.anuke.mindustry.io.MapTileData;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
||||
@ -43,7 +44,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class MapEditorDialog extends Dialog{
|
||||
private MapEditor editor;
|
||||
private MapView view;
|
||||
private MapGenerateDialog dialog;
|
||||
private MapInfoDialog infoDialog;
|
||||
private MapLoadDialog loadDialog;
|
||||
private MapSaveDialog saveDialog;
|
||||
private MapResizeDialog resizeDialog;
|
||||
@ -60,9 +61,10 @@ public class MapEditorDialog extends Dialog{
|
||||
if(gwt) return;
|
||||
|
||||
editor = new MapEditor();
|
||||
dialog = new MapGenerateDialog(editor);
|
||||
view = new MapView(editor);
|
||||
|
||||
infoDialog = new MapInfoDialog(editor);
|
||||
|
||||
saveFile = new FileChooser("$text.saveimage", false, file -> {
|
||||
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
||||
FileHandle result = file;
|
||||
@ -70,8 +72,10 @@ public class MapEditorDialog extends Dialog{
|
||||
Timers.run(3f, () -> {
|
||||
|
||||
try{
|
||||
if(!editor.getTags().containsKey("name")){
|
||||
tags.put("name", result.nameWithoutExtension());
|
||||
MapIO.writeMap(result, tags, editor.getMap());
|
||||
}
|
||||
MapIO.writeMap(result, editor.getTags(), editor.getMap());
|
||||
}catch (Exception e){
|
||||
ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
||||
Log.err(e);
|
||||
@ -84,9 +88,12 @@ public class MapEditorDialog extends Dialog{
|
||||
ui.loadfrag.show();
|
||||
Timers.run(3f, () -> {
|
||||
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();
|
||||
}catch (Exception e){
|
||||
ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
||||
@ -117,7 +124,7 @@ public class MapEditorDialog extends Dialog{
|
||||
try{
|
||||
MapTileData data = MapIO.readPixmap(new Pixmap(file));
|
||||
|
||||
editor.beginEdit(data);
|
||||
editor.beginEdit(data, new ObjectMap<>());
|
||||
view.clearStack();
|
||||
}catch (Exception e){
|
||||
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.addCloseButton();
|
||||
|
||||
menu.content().defaults().size(280f, 60f).padBottom(5);
|
||||
|
||||
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, () -> {
|
||||
if(!saved){
|
||||
ui.showConfirm("$text.confirm", "$text.editor.unsaved", this::hide);
|
||||
@ -141,42 +188,7 @@ public class MapEditorDialog extends Dialog{
|
||||
hide();
|
||||
}
|
||||
menu.hide();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
}).size(470f, 60f);
|
||||
|
||||
|
||||
/*
|
||||
@ -258,7 +270,7 @@ public class MapEditorDialog extends Dialog{
|
||||
|
||||
shown(() -> {
|
||||
saved = true;
|
||||
editor.beginEdit(new MapTileData(256, 256));
|
||||
editor.beginEdit(new MapTileData(256, 256), new ObjectMap<>());
|
||||
blockgroup.getButtons().get(2).setChecked(true);
|
||||
Core.scene.setScrollFocus(view);
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user