Fixed irregularly scaled maps causing various bugs

This commit is contained in:
Anuken
2018-10-29 10:03:41 -04:00
parent 5b01d923d3
commit 381b59acd4
7 changed files with 17 additions and 5 deletions

View File

@@ -27,7 +27,7 @@ allprojects {
appName = 'Mindustry' appName = 'Mindustry'
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
roboVMVersion = '2.3.0' roboVMVersion = '2.3.0'
uCoreVersion = '95b407764765c2f1bc9775d22372edc84af2d186' uCoreVersion = '53571305f7e5b31dd07377756bb46c0f2ae2ef34'
getVersionString = { getVersionString = {
String buildVersion = getBuildVersion() String buildVersion = getBuildVersion()

View File

@@ -475,6 +475,14 @@ public class MapEditorDialog extends Dialog implements Disposable{
mid.table("button", t -> { mid.table("button", t -> {
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false); Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int) (float) f])); 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.top();
t.add("$text.editor.brush"); t.add("$text.editor.brush");

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.editor; package io.anuke.mindustry.editor;
import com.badlogic.gdx.utils.Scaling;
import io.anuke.mindustry.maps.Map; import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.ui.BorderImage; import io.anuke.mindustry.ui.BorderImage;
import io.anuke.mindustry.ui.dialogs.FloatingDialog; import io.anuke.mindustry.ui.dialogs.FloatingDialog;
@@ -58,7 +59,7 @@ public class MapLoadDialog extends FloatingDialog{
for(Map map : world.maps.all()){ for(Map map : world.maps.all()){
TextButton button = new TextButton(map.getDisplayName(), "toggle"); 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.getCells().reverse();
button.clicked(() -> selected = map); button.clicked(() -> selected = map);
button.getLabelCell().grow().left().padLeft(5f); button.getLabelCell().grow().left().padLeft(5f);

View File

@@ -295,7 +295,7 @@ public class MapView extends Element implements GestureListener{
} }
//todo is it really math.max? //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); Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(1f * zoom)); Lines.stroke(Unit.dp.scl(1f * zoom));

View File

@@ -13,6 +13,7 @@ public class BorderImage extends Image{
private float thickness = 3f; private float thickness = 3f;
public BorderImage(){ public BorderImage(){
} }
public BorderImage(Texture texture){ public BorderImage(Texture texture){

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Scaling;
import io.anuke.mindustry.game.Difficulty; import io.anuke.mindustry.game.Difficulty;
import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.game.GameMode;
import io.anuke.mindustry.maps.Map; 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); image.label((() -> Bundles.format("text.level.highscore", Settings.getInt("hiscore" + map.name, 0)))).pad(3f);
BorderImage border = new BorderImage(map.texture, 3f); BorderImage border = new BorderImage(map.texture, 3f);
border.setScaling(Scaling.fit);
image.replaceImage(border); image.replaceImage(border);
image.clicked(() -> { image.clicked(() -> {

View File

@@ -93,7 +93,7 @@ public class MapsDialog extends FloatingDialog{
button.row(); button.row();
button.addImage("white").growX().pad(4).color(Color.GRAY); button.addImage("white").growX().pad(4).color(Color.GRAY);
button.row(); 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.row();
button.add(map.custom ? "$text.custom" : "$text.builtin").color(Color.GRAY).padTop(3); 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; float mapsize = UIUtils.portrait() ? 160f : 300f;
Table table = dialog.content(); 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 -> { table.table("clear", desc -> {
desc.top(); desc.top();