Kiln texture fix / New map resize dialog
|
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 179 B |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
@@ -202,7 +202,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
view.clearStack();
|
view.clearStack();
|
||||||
Core.scene.setScrollFocus(view);
|
Core.scene.setScrollFocus(view);
|
||||||
if(!shownWithMap){
|
if(!shownWithMap){
|
||||||
editor.beginEdit(new MapTileData(256, 256), new ObjectMap<>(), true);
|
editor.beginEdit(new MapTileData(200, 200), new ObjectMap<>(), true);
|
||||||
}
|
}
|
||||||
shownWithMap = false;
|
shownWithMap = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package io.anuke.mindustry.editor;
|
package io.anuke.mindustry.editor;
|
||||||
|
|
||||||
|
import io.anuke.arc.function.BiConsumer;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
import io.anuke.mindustry.maps.MapTileData;
|
import io.anuke.mindustry.maps.MapTileData;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
import io.anuke.arc.function.BiConsumer;
|
|
||||||
import io.anuke.arc.scene.ui.ButtonGroup;
|
|
||||||
import io.anuke.arc.scene.ui.TextButton;
|
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
|
|
||||||
public class MapResizeDialog extends FloatingDialog{
|
public class MapResizeDialog extends FloatingDialog{
|
||||||
int[] validMapSizes = {200, 300, 400, 500};
|
private static final int minSize = 50, maxSize = 500, increment = 50;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
public MapResizeDialog(MapEditor editor, BiConsumer<Integer, Integer> cons){
|
public MapResizeDialog(MapEditor editor, BiConsumer<Integer, Integer> cons){
|
||||||
@@ -23,28 +21,23 @@ public class MapResizeDialog extends FloatingDialog{
|
|||||||
Table table = new Table();
|
Table table = new Table();
|
||||||
|
|
||||||
for(boolean w : Mathf.booleans){
|
for(boolean w : Mathf.booleans){
|
||||||
int curr = w ? data.width() : data.height();
|
|
||||||
int idx = 0;
|
|
||||||
for(int i = 0; i < validMapSizes.length; i++){
|
|
||||||
if(validMapSizes[i] == curr) idx = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.add(w ? "$width" : "$height").padRight(8f);
|
table.add(w ? "$width" : "$height").padRight(8f);
|
||||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
table.defaults().height(60f).padTop(8);
|
||||||
for(int i = 0; i < validMapSizes.length; i++){
|
table.addButton("<", () -> {
|
||||||
int size = validMapSizes[i];
|
if(w)
|
||||||
TextButton button = new TextButton(size + "", "toggle");
|
width = move(width, -1);
|
||||||
button.clicked(() -> {
|
else
|
||||||
if(w)
|
height = move(height, -1);
|
||||||
width = size;
|
}).size(60f);
|
||||||
else
|
|
||||||
height = size;
|
|
||||||
});
|
|
||||||
group.add(button);
|
|
||||||
if(i == idx) button.setChecked(true);
|
|
||||||
table.add(button).size(100f, 54f).pad(2f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
table.table("button", t -> t.label(() -> (w ? width : height) + "")).width(200);
|
||||||
|
|
||||||
|
table.addButton(">", () -> {
|
||||||
|
if(w)
|
||||||
|
width = move(width, 1);
|
||||||
|
else
|
||||||
|
height = move(height, 1);
|
||||||
|
}).size(60f);
|
||||||
table.row();
|
table.row();
|
||||||
}
|
}
|
||||||
cont.row();
|
cont.row();
|
||||||
@@ -58,6 +51,9 @@ public class MapResizeDialog extends FloatingDialog{
|
|||||||
cons.accept(width, height);
|
cons.accept(width, height);
|
||||||
hide();
|
hide();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static int move(int value, int direction){
|
||||||
|
return Mathf.clamp((value / increment + direction) * increment, minSize, maxSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||