Map resize dialog shift options
This commit is contained in:
@@ -284,14 +284,17 @@ public class MapEditor{
|
||||
}
|
||||
}
|
||||
|
||||
public void resize(int width, int height){
|
||||
public void resize(int width, int height, int shiftX, int shiftY){
|
||||
clearOp();
|
||||
|
||||
Tiles previous = world.tiles;
|
||||
int offsetX = (width() - width) / 2, offsetY = (height() - height) / 2;
|
||||
int offsetX = (width() - width) / 2 - shiftX, offsetY = (height() - height) / 2 - shiftY;
|
||||
loading = true;
|
||||
|
||||
Tiles tiles = world.resize(width, height);
|
||||
world.clearBuildings();
|
||||
|
||||
Tiles tiles = world.tiles = new Tiles(width, height);
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
int px = offsetX + x, py = offsetY + y;
|
||||
|
||||
@@ -188,10 +188,10 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
menu.hide();
|
||||
}).padTop(!steam && !experimental ? -3 : 1).size(swidth * 2f + 10, 60f);
|
||||
|
||||
resizeDialog = new MapResizeDialog((x, y) -> {
|
||||
if(!(editor.width() == x && editor.height() == y)){
|
||||
resizeDialog = new MapResizeDialog((width, height, shiftX, shiftY) -> {
|
||||
if(!(editor.width() == width && editor.height() == height && shiftX == 0 && shiftY == 0)){
|
||||
ui.loadAnd(() -> {
|
||||
editor.resize(x, y);
|
||||
editor.resize(width, height, shiftX, shiftY);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package mindustry.editor;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.TextField.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapResizeDialog extends BaseDialog{
|
||||
public static int minSize = 50, maxSize = 600, increment = 50;
|
||||
|
||||
int width, height;
|
||||
int width, height, shiftX, shiftY;
|
||||
|
||||
public MapResizeDialog(Intc2 cons){
|
||||
public MapResizeDialog(ResizeListener cons){
|
||||
super("@editor.resizemap");
|
||||
|
||||
closeOnBack();
|
||||
@@ -35,6 +35,19 @@ public class MapResizeDialog extends BaseDialog{
|
||||
|
||||
table.row();
|
||||
}
|
||||
|
||||
for(boolean x : Mathf.booleans){
|
||||
table.add(x ? "@editor.shiftx" : "@editor.shifty").padRight(8f);
|
||||
table.defaults().height(60f).padTop(8);
|
||||
|
||||
table.field((x ? shiftX : shiftY) + "", value -> {
|
||||
int val = Integer.parseInt(value);
|
||||
if(x) shiftX = val; else shiftY = val;
|
||||
}).valid(Strings::canParseInt).maxTextLength(3);
|
||||
|
||||
table.row();
|
||||
}
|
||||
|
||||
cont.row();
|
||||
cont.add(table);
|
||||
|
||||
@@ -43,8 +56,12 @@ public class MapResizeDialog extends BaseDialog{
|
||||
buttons.defaults().size(200f, 50f);
|
||||
buttons.button("@cancel", this::hide);
|
||||
buttons.button("@ok", () -> {
|
||||
cons.get(width, height);
|
||||
cons.get(width, height, shiftX, shiftY);
|
||||
hide();
|
||||
});
|
||||
}
|
||||
|
||||
public interface ResizeListener{
|
||||
void get(int width, int height, int shiftX, int shiftY);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user