Fixed irregularly scaled maps causing various bugs
This commit is contained in:
@@ -475,6 +475,14 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
mid.table("button", t -> {
|
||||
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
|
||||
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int) (float) f]));
|
||||
slider.update(() -> {
|
||||
for(int j = 0; j < MapEditor.brushSizes.length; j++){
|
||||
if(editor.getBrushSize() == j){
|
||||
slider.setValue(j);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
t.top();
|
||||
t.add("$text.editor.brush");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
@@ -58,7 +59,7 @@ public class MapLoadDialog extends FloatingDialog{
|
||||
for(Map map : world.maps.all()){
|
||||
|
||||
TextButton button = new TextButton(map.getDisplayName(), "toggle");
|
||||
button.add(new BorderImage(map.texture, 2f)).size(16 * 4f);
|
||||
button.add(new BorderImage(map.texture, 2f).setScaling(Scaling.fit)).size(16 * 4f);
|
||||
button.getCells().reverse();
|
||||
button.clicked(() -> selected = map);
|
||||
button.getLabelCell().grow().left().padLeft(5f);
|
||||
|
||||
@@ -295,7 +295,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
|
||||
//todo is it really math.max?
|
||||
float scaling = zoom * Math.min(width, height) / Math.max(editor.getMap().width(), editor.getMap().height());
|
||||
float scaling = zoom * Math.min(width, height) / editor.getMap().width();
|
||||
|
||||
Draw.color(Palette.accent);
|
||||
Lines.stroke(Unit.dp.scl(1f * zoom));
|
||||
|
||||
@@ -13,6 +13,7 @@ public class BorderImage extends Image{
|
||||
private float thickness = 3f;
|
||||
|
||||
public BorderImage(){
|
||||
|
||||
}
|
||||
|
||||
public BorderImage(Texture texture){
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
@@ -106,6 +107,7 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
image.label((() -> Bundles.format("text.level.highscore", Settings.getInt("hiscore" + map.name, 0)))).pad(3f);
|
||||
|
||||
BorderImage border = new BorderImage(map.texture, 3f);
|
||||
border.setScaling(Scaling.fit);
|
||||
image.replaceImage(border);
|
||||
|
||||
image.clicked(() -> {
|
||||
|
||||
@@ -93,7 +93,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
button.row();
|
||||
button.addImage("white").growX().pad(4).color(Color.GRAY);
|
||||
button.row();
|
||||
((Image) button.stack(new Image(map.texture), new BorderImage(map.texture)).size(mapsize - 20f).get().getChildren().first()).setScaling(Scaling.fit);
|
||||
button.stack(new Image(map.texture).setScaling(Scaling.fit), new BorderImage(map.texture).setScaling(Scaling.fit)).size(mapsize - 20f);
|
||||
button.row();
|
||||
button.add(map.custom ? "$text.custom" : "$text.builtin").color(Color.GRAY).padTop(3);
|
||||
|
||||
@@ -114,7 +114,7 @@ public class MapsDialog extends FloatingDialog{
|
||||
float mapsize = UIUtils.portrait() ? 160f : 300f;
|
||||
Table table = dialog.content();
|
||||
|
||||
((Image) table.stack(new Image(map.texture), new BorderImage(map.texture)).size(mapsize).get().getChildren().first()).setScaling(Scaling.fit);
|
||||
table.stack(new Image(map.texture).setScaling(Scaling.fit), new BorderImage(map.texture).setScaling(Scaling.fit)).size(mapsize);
|
||||
|
||||
table.table("clear", desc -> {
|
||||
desc.top();
|
||||
|
||||
Reference in New Issue
Block a user