Colored tile undo/fill support
This commit is contained in:
@@ -15,7 +15,9 @@ public class DrawOperation{
|
|||||||
opBlock = 1,
|
opBlock = 1,
|
||||||
opRotation = 2,
|
opRotation = 2,
|
||||||
opTeam = 3,
|
opTeam = 3,
|
||||||
opOverlay = 4;
|
opOverlay = 4,
|
||||||
|
opData = 5, //overlay/floor/data field
|
||||||
|
opDataExtra = 6; //extraData
|
||||||
|
|
||||||
private LongSeq array = new LongSeq();
|
private LongSeq array = new LongSeq();
|
||||||
|
|
||||||
@@ -45,18 +47,20 @@ public class DrawOperation{
|
|||||||
setTile(editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.value(l));
|
setTile(editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.value(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
short getTile(Tile tile, byte type){
|
int getTile(Tile tile, int type){
|
||||||
return switch(type){
|
return switch(type){
|
||||||
case opFloor -> tile.floorID();
|
case opFloor -> tile.floorID();
|
||||||
case opOverlay -> tile.overlayID();
|
case opOverlay -> tile.overlayID();
|
||||||
case opBlock -> tile.blockID();
|
case opBlock -> tile.blockID();
|
||||||
case opRotation -> tile.build == null ? 0 : (byte)tile.build.rotation;
|
case opRotation -> tile.build == null ? 0 : (byte)tile.build.rotation;
|
||||||
case opTeam -> (byte)tile.getTeamID();
|
case opTeam -> tile.getTeamID();
|
||||||
|
case opData -> TileOpData.get(tile.data, tile.floorData, tile.overlayData);
|
||||||
|
case opDataExtra -> tile.extraData;
|
||||||
default -> throw new IllegalArgumentException("Invalid type.");
|
default -> throw new IllegalArgumentException("Invalid type.");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTile(Tile tile, byte type, short to){
|
void setTile(Tile tile, int type, int to){
|
||||||
if(type == opBlock || type == opTeam || type == opRotation){
|
if(type == opBlock || type == opTeam || type == opRotation){
|
||||||
tile.getLinkedTiles(t -> {
|
tile.getLinkedTiles(t -> {
|
||||||
editor.renderer.updateBlock(t);
|
editor.renderer.updateBlock(t);
|
||||||
@@ -89,6 +93,12 @@ public class DrawOperation{
|
|||||||
if(tile.build != null) tile.build.rotation = to;
|
if(tile.build != null) tile.build.rotation = to;
|
||||||
}
|
}
|
||||||
case opTeam -> tile.setTeam(Team.get(to));
|
case opTeam -> tile.setTeam(Team.get(to));
|
||||||
|
case opData -> {
|
||||||
|
tile.data = TileOpData.data(to);
|
||||||
|
tile.floorData = TileOpData.floorData(to);
|
||||||
|
tile.overlayData = TileOpData.overlayData(to);
|
||||||
|
}
|
||||||
|
case opDataExtra -> tile.extraData = to;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -102,9 +112,17 @@ public class DrawOperation{
|
|||||||
|
|
||||||
@Struct
|
@Struct
|
||||||
class TileOpStruct{
|
class TileOpStruct{
|
||||||
short x;
|
@StructField(14)
|
||||||
short y;
|
int x;
|
||||||
byte type;
|
@StructField(14)
|
||||||
short value;
|
int y;
|
||||||
|
@StructField(3)
|
||||||
|
int type;
|
||||||
|
int value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Struct
|
||||||
|
class TileOpDataStruct{
|
||||||
|
byte data, floorData, overlayData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import arc.struct.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -46,7 +47,6 @@ public enum EditorTool{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//the "under liquid" rendering is too buggy to make public
|
|
||||||
pencil(KeyCode.b, "replace", "square", "drawteams", "underliquid"){
|
pencil(KeyCode.b, "replace", "square", "drawteams", "underliquid"){
|
||||||
{
|
{
|
||||||
edit = true;
|
edit = true;
|
||||||
@@ -139,6 +139,21 @@ public enum EditorTool{
|
|||||||
setter = t -> t.setBlock(editor.drawBlock, editor.drawTeam);
|
setter = t -> t.setBlock(editor.drawBlock, editor.drawTeam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldSetter = setter;
|
||||||
|
setter = t -> {
|
||||||
|
if(editor.drawBlock.saveData){
|
||||||
|
editor.addTileOp(TileOp.get(t.x, t.y, DrawOperation.opData, TileOpData.get(t.data, t.floorData, t.overlayData)));
|
||||||
|
editor.addTileOp(TileOp.get(t.x, t.y, DrawOperation.opDataExtra, t.extraData));
|
||||||
|
}
|
||||||
|
|
||||||
|
oldSetter.get(t);
|
||||||
|
|
||||||
|
if(!editor.drawBlock.synthetic() && editor.drawBlock.saveConfig){
|
||||||
|
editor.drawBlock.placeEnded(t, null, editor.rotation, editor.drawBlock.lastConfig);
|
||||||
|
editor.renderer.updateStatic(t.x, t.y);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//replace only when the mode is 0 using the specified functions
|
//replace only when the mode is 0 using the specified functions
|
||||||
fill(x, y, mode == 0, tester, setter);
|
fill(x, y, mode == 0, tester, setter);
|
||||||
}else if(mode == 1){ //mode 1 is team fill
|
}else if(mode == 1){ //mode 1 is team fill
|
||||||
|
|||||||
@@ -157,6 +157,11 @@ public class MapEditor{
|
|||||||
if(!tester.get(tile)) return;
|
if(!tester.get(tile)) return;
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
|
if(drawBlock.saveData){
|
||||||
|
addTileOp(TileOp.get(tile.x, tile.y, DrawOperation.opData, TileOpData.get(tile.data, tile.floorData, tile.overlayData)));
|
||||||
|
addTileOp(TileOp.get(tile.x, tile.y, DrawOperation.opDataExtra, tile.extraData));
|
||||||
|
}
|
||||||
|
|
||||||
if(isFloor){
|
if(isFloor){
|
||||||
if(forceOverlay){
|
if(forceOverlay){
|
||||||
tile.setOverlay(drawBlock.asFloor());
|
tile.setOverlay(drawBlock.asFloor());
|
||||||
|
|||||||
Reference in New Issue
Block a user