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