Many editor bugfixes, server additions
This commit is contained in:
@@ -22,6 +22,7 @@ public class Maps implements Disposable{
|
||||
private Map networkMap;
|
||||
private int lastID;
|
||||
private Json json = new Json();
|
||||
private Array<Map> array = new Array<>();
|
||||
|
||||
public Maps() {
|
||||
json.setOutputType(OutputType.json);
|
||||
@@ -37,6 +38,14 @@ public class Maps implements Disposable{
|
||||
return defaultMaps;
|
||||
}
|
||||
|
||||
public Array<Map> getAllMaps(){
|
||||
array.clear();
|
||||
for(Map map : list()){
|
||||
array.add(map);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public void setNetworkMap(Map map){
|
||||
if(networkMap != null){
|
||||
networkMap.pixmap.dispose();
|
||||
|
||||
@@ -5,13 +5,11 @@ import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.ucore.graphics.Pixmaps;
|
||||
import io.anuke.ucore.util.Log;
|
||||
|
||||
public class MapEditor{
|
||||
public static final int[] validMapSizes = {128, 256, 512};
|
||||
@@ -104,7 +102,6 @@ public class MapEditor{
|
||||
}
|
||||
|
||||
public void setDrawBlock(Block block){
|
||||
Log.info("Setting draw block {0}", block);
|
||||
this.drawBlock = block;
|
||||
pixmap.setColor(ColorMapper.getColor(block));
|
||||
}
|
||||
|
||||
@@ -124,13 +124,25 @@ public class MapEditorDialog extends Dialog{
|
||||
ui.loadfrag.show();
|
||||
if(verifyMap()){
|
||||
saved = true;
|
||||
String before = editor.getMap().name;
|
||||
editor.getMap().name = name;
|
||||
Timers.run(10f, () -> {
|
||||
world.maps().saveAndReload(editor.getMap(), editor.pixmap());
|
||||
loadDialog.rebuild();
|
||||
ui.loadfrag.hide();
|
||||
view.clearStack();
|
||||
|
||||
if(!name.equals(before)) {
|
||||
Map map = new Map();
|
||||
map.name = editor.getMap().name;
|
||||
map.oreGen = editor.getMap().oreGen;
|
||||
map.pixmap = Pixmaps.copy(editor.getMap().pixmap);
|
||||
map.texture = new Texture(map.pixmap);
|
||||
map.custom = true;
|
||||
editor.beginEdit(map);
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
ui.loadfrag.hide();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.mapeditor;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
@@ -10,12 +9,15 @@ import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class MapLoadDialog extends FloatingDialog{
|
||||
private Map selected = world.maps().getMap(0);
|
||||
|
||||
public MapLoadDialog(Consumer<Map> loader) {
|
||||
super("$text.editor.loadmap");
|
||||
|
||||
shown(this::rebuild);
|
||||
rebuild();
|
||||
|
||||
TextButton button = new TextButton("$text.load");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.mapeditor;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
@@ -177,7 +178,8 @@ public class MapView extends Element implements GestureListener{
|
||||
public void act(float delta){
|
||||
super.act(delta);
|
||||
|
||||
if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField)) {
|
||||
if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField) &&
|
||||
!Inputs.keyDown(Keys.CONTROL_LEFT)) {
|
||||
float ax = Inputs.getAxis("move_x");
|
||||
float ay = Inputs.getAxis("move_y");
|
||||
offsetx -= ax * 15f / zoom;
|
||||
|
||||
@@ -95,16 +95,18 @@ public class LevelDialog extends FloatingDialog{
|
||||
if(i % maxwidth == 0){
|
||||
maps.row();
|
||||
}
|
||||
|
||||
//TODO this is a hack
|
||||
if(!Settings.has("hiscore" + map.name)){
|
||||
Settings.defaults("hiscore" + map.name, 1);
|
||||
}
|
||||
|
||||
Table inset = new Table("pane-button");
|
||||
inset.add("[accent]" + Bundles.get("map."+map.name+".name", map.name)).pad(3f);
|
||||
inset.row();
|
||||
inset.label((() -> Bundles.format("text.level.highscore", Settings.getInt("hiscore" + map.name))))
|
||||
inset.label((() ->{
|
||||
try{
|
||||
return Bundles.format("text.level.highscore", Settings.getInt("hiscore" + map.name));
|
||||
}catch (Exception e){
|
||||
Settings.defaults("hiscore" + map.name, 1);
|
||||
return Bundles.format("text.level.highscore", 0);
|
||||
}
|
||||
}))
|
||||
.pad(3f);
|
||||
inset.pack();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user