Format bugfixes
This commit is contained in:
@@ -21,31 +21,34 @@ public class DrawOperation{
|
||||
}
|
||||
|
||||
public void undo(MapEditor editor){
|
||||
for(int i = 0; i < array.size; i++){
|
||||
for(int i = array.size - 1; i >= 0; i--){
|
||||
long l = array.get(i);
|
||||
set(editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.from(l));
|
||||
set(editor, editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.from(l));
|
||||
}
|
||||
}
|
||||
|
||||
public void redo(MapEditor editor){
|
||||
for(int i = 0; i < array.size; i++){
|
||||
long l = array.get(i);
|
||||
set(editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.to(l));
|
||||
set(editor, editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.to(l));
|
||||
}
|
||||
}
|
||||
|
||||
void set(Tile tile, byte type, byte to){
|
||||
if(type == OpType.floor.ordinal()){
|
||||
tile.setFloor((Floor)content.block(to));
|
||||
}else if(type == OpType.block.ordinal()){
|
||||
tile.setBlock(content.block(to));
|
||||
}else if(type == OpType.rotation.ordinal()){
|
||||
tile.setRotation(to);
|
||||
}else if(type == OpType.team.ordinal()){
|
||||
tile.setTeam(Team.all[to]);
|
||||
}else if(type == OpType.ore.ordinal()){
|
||||
tile.setOre(to);
|
||||
}
|
||||
void set(MapEditor editor, Tile tile, byte type, byte to){
|
||||
editor.load(() -> {
|
||||
if(type == OpType.floor.ordinal()){
|
||||
tile.setFloor((Floor)content.block(to));
|
||||
}else if(type == OpType.block.ordinal()){
|
||||
tile.setBlock(content.block(to));
|
||||
}else if(type == OpType.rotation.ordinal()){
|
||||
tile.setRotation(to);
|
||||
}else if(type == OpType.team.ordinal()){
|
||||
tile.setTeam(Team.all[to]);
|
||||
}else if(type == OpType.ore.ordinal()){
|
||||
tile.setOre(to);
|
||||
}
|
||||
});
|
||||
editor.renderer().updatePoint(tile.x, tile.y);
|
||||
}
|
||||
|
||||
@Struct
|
||||
|
||||
@@ -10,22 +10,20 @@ import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Pos;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public enum EditorTool{
|
||||
pick{
|
||||
public void touched(MapEditor editor, int x, int y){
|
||||
if(!Structs.inBounds(x, y, world.width(), world.height())) return;
|
||||
if(!Structs.inBounds(x, y, editor.width(), editor.height())) return;
|
||||
|
||||
Tile tile = editor.tile(x, y);
|
||||
|
||||
Block floor = tile.floor(), block = tile.block();
|
||||
byte link = tile.getLinkByte();
|
||||
|
||||
if(link != 0){
|
||||
if(block instanceof BlockPart && link != 0){
|
||||
x -= (Pack.leftByte(link) - 8);
|
||||
y -= (Pack.rightByte(link) - 8);
|
||||
|
||||
@@ -34,7 +32,6 @@ public enum EditorTool{
|
||||
}
|
||||
|
||||
editor.drawBlock = block == Blocks.air ? floor : block;
|
||||
ui.editor.updateSelectedBlock();
|
||||
}
|
||||
},
|
||||
pencil{
|
||||
@@ -86,7 +83,7 @@ public enum EditorTool{
|
||||
MapEditor data;
|
||||
|
||||
public void touched(MapEditor editor, int x, int y){
|
||||
if(!Structs.inBounds(x, y, world.width(), world.height())) return;
|
||||
if(!Structs.inBounds(x, y, editor.width(), editor.height())) return;
|
||||
Tile tile = editor.tile(x, y);
|
||||
|
||||
if(editor.drawBlock.isMultiblock()){
|
||||
@@ -109,8 +106,8 @@ public enum EditorTool{
|
||||
return;
|
||||
}
|
||||
|
||||
int width = world.width();
|
||||
int height = world.height();
|
||||
int width = editor.width();
|
||||
int height = editor.height();
|
||||
|
||||
IntPositionConsumer writer = (px, py) -> {
|
||||
Tile write = editor.tile(px, py);
|
||||
|
||||
@@ -43,8 +43,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
private boolean shownWithMap = false;
|
||||
private Array<Block> blocksOut = new Array<>();
|
||||
|
||||
private ButtonGroup<ImageButton> blockgroup;
|
||||
|
||||
public MapEditorDialog(){
|
||||
super("", "dialog");
|
||||
|
||||
@@ -295,15 +293,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
saved = false;
|
||||
}
|
||||
|
||||
public void updateSelectedBlock(){
|
||||
for(int j = 0; j < Vars.content.blocks().size; j++){
|
||||
if(editor.drawBlock.id == j && j < blockgroup.getButtons().size){
|
||||
blockgroup.getButtons().get(j).setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPane(){
|
||||
return Core.scene.getScrollFocus() == pane || Core.scene.getKeyboardFocus() != this;
|
||||
}
|
||||
@@ -475,7 +464,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
pane.setFadeScrollBars(false);
|
||||
pane.setOverscroll(true, false);
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
blockgroup = group;
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
||||
@@ -59,13 +59,20 @@ public class MapIO{
|
||||
}
|
||||
}
|
||||
|
||||
//TODO implement
|
||||
public static Pixmap generatePreview(Map map) throws IOException{
|
||||
Pixmap pixmap = new Pixmap(map.width, map.height, Format.RGBA8888);
|
||||
Pixmap floor = new Pixmap(map.width, map.height, Format.RGBA8888);
|
||||
Pixmap wall = new Pixmap(map.width, map.height, Format.RGBA8888);
|
||||
int black = Color.rgba8888(Color.BLACK);
|
||||
CachedTile tile = new CachedTile(){
|
||||
@Override
|
||||
public void setFloor(Floor type){
|
||||
floor.drawPixel(x, floor.getHeight() - 1 - y, colorFor(type, Blocks.air, getTeam()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void changed(){
|
||||
pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, colorFor(floor(), block(), getTeam()));
|
||||
int c = colorFor(Blocks.air, block(), getTeam());
|
||||
if(c != black) wall.drawPixel(x, floor.getHeight() - 1 - y, c);
|
||||
}
|
||||
};
|
||||
readTiles(map, (x, y) -> {
|
||||
@@ -73,7 +80,9 @@ public class MapIO{
|
||||
tile.y = (short)y;
|
||||
return tile;
|
||||
});
|
||||
return pixmap;
|
||||
floor.drawPixmap(wall, 0, 0);
|
||||
wall.dispose();
|
||||
return floor;
|
||||
}
|
||||
|
||||
public static Pixmap generatePreview(Tile[][] tiles){
|
||||
@@ -227,8 +236,8 @@ public class MapIO{
|
||||
byte tagAmount = stream.readByte();
|
||||
|
||||
for(int i = 0; i < tagAmount; i++){
|
||||
stream.readUTF();
|
||||
stream.readUTF();
|
||||
stream.readUTF(); //key
|
||||
stream.readUTF(); //val
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +353,6 @@ public class MapIO{
|
||||
readLegacyMmapTiles(file, (x, y) -> tiles[x][y]);
|
||||
}
|
||||
|
||||
//TODO implement
|
||||
/**Reads a mmap in the old 4.0 .mmap format.*/
|
||||
private static void readLegacyMmapTiles(FileHandle file, TileProvider tiles) throws IOException{
|
||||
try(DataInputStream stream = new DataInputStream(file.read(bufferSize))){
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.anuke.arc.files.FileHandle;
|
||||
import io.anuke.arc.graphics.Texture;
|
||||
import io.anuke.arc.util.Disposable;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.io.MapIO;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
@@ -55,6 +56,7 @@ public class Maps implements Disposable{
|
||||
|
||||
/** Load all maps. Should be called at application start. */
|
||||
public void load(){
|
||||
Time.mark();
|
||||
try{
|
||||
for(String name : defaultMapNames){
|
||||
FileHandle file = Core.files.internal("maps/" + name + "." + mapExtension);
|
||||
@@ -65,6 +67,7 @@ public class Maps implements Disposable{
|
||||
}
|
||||
|
||||
loadCustomMaps();
|
||||
Log.info("Time to load maps: {0}", Time.elapsed());
|
||||
}
|
||||
|
||||
/** Save a custom map to the directory. This updates all values and stored data necessary.
|
||||
|
||||
Reference in New Issue
Block a user