Added bool to enable editor cliff button

This commit is contained in:
Anuken
2020-10-17 11:02:48 -04:00
parent 46ec457819
commit c99873c823
14 changed files with 60 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 825 B

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 KiB

After

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 KiB

After

Width:  |  Height:  |  Size: 429 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 KiB

After

Width:  |  Height:  |  Size: 354 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 KiB

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -36,6 +36,8 @@ public class Vars implements Loadable{
public static boolean loadLocales = true;
/** Whether the logger is loaded. */
public static boolean loadedLogger = false, loadedFileLogger = false;
/** Whether to show the cliff button in the editor*/
public static boolean addCliffButton = false;
/** Maximum extra padding around deployment schematics. */
public static final int maxLoadoutSchematicPad = 5;
/** Maximum schematic size.*/

View File

@ -4,6 +4,7 @@ import arc.files.*;
import arc.func.*;
import arc.graphics.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import mindustry.content.*;
import mindustry.editor.DrawOperation.*;
@ -180,6 +181,52 @@ public class MapEditor{
return false;
}
public void addCliffs(){
for(Tile tile : world.tiles){
if(!tile.block().isStatic() || tile.block() == Blocks.cliff) continue;
int rotation = 0;
for(int i = 0; i < 8; i++){
Tile other = world.tiles.get(tile.x + Geometry.d8[i].x, tile.y + Geometry.d8[i].y);
if(other != null && !other.block().isStatic()){
rotation |= (1 << i);
}
}
if(rotation != 0){
tile.setBlock(Blocks.cliff);
}
tile.data = (byte)rotation;
}
for(Tile tile : world.tiles){
if(tile.block() != Blocks.cliff && tile.block().isStatic()){
tile.setBlock(Blocks.air);
}
}
}
public void addFloorCliffs(){
for(Tile tile : world.tiles){
if(!tile.floor().hasSurface() || tile.block() == Blocks.cliff) continue;
int rotation = 0;
for(int i = 0; i < 8; i++){
Tile other = world.tiles.get(tile.x + Geometry.d8[i].x, tile.y + Geometry.d8[i].y);
if(other != null && !other.floor().hasSurface()){
rotation |= (1 << i);
}
}
if(rotation != 0){
tile.setBlock(Blocks.cliff);
}
tile.data = (byte)rotation;
}
}
public void drawCircle(int x, int y, Cons<Tile> drawer){
for(int rx = -brushSize; rx <= brushSize; rx++){
for(int ry = -brushSize; ry <= brushSize; ry++){

View File

@ -561,7 +561,15 @@ public class MapEditorDialog extends Dialog implements Disposable{
if(!mobile){
mid.table(t -> {
t.button("@editor.center", Icon.move, Styles.cleart, () -> view.center()).growX().margin(9f);
t.button("@editor.center", Icon.move, Styles.cleart, view::center).growX().margin(9f);
}).growX().top();
}
if(addCliffButton){
mid.row();
mid.table(t -> {
t.button("Cliffs", Icon.terrain, Styles.cleart, editor::addCliffs).growX().margin(9f);
}).growX().top();
}
}).margin(0).left().growY();

View File

@ -288,7 +288,8 @@ public class ContentParser{
//read extra default waves
if(value.has("waves")){
SpawnGroup[] groups = parser.readValue(SpawnGroup[].class, value.get("waves"));
JsonValue waves = value.remove("waves");
SpawnGroup[] groups = parser.readValue(SpawnGroup[].class, waves);
for(SpawnGroup group : groups){
group.type = unit;
}