From 85e0103ff8c52ab694f1ae84b8e99eefd6317e7a Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 22 Jan 2020 11:13:27 -0500 Subject: [PATCH] UI fixes --- core/src/mindustry/input/MobileInput.java | 2 +- core/src/mindustry/ui/Fonts.java | 14 +++++++++++++- core/src/mindustry/ui/dialogs/JoinDialog.java | 19 ++++++++++++------- .../ui/fragments/PlacementFragment.java | 7 +++++-- gradle.properties | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 8e0ed53d06..efdc8100a5 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -258,7 +258,7 @@ public class MobileInput extends InputHandler implements GestureListener{ selectRequests.clear(); mode = none; block = null; - }).width(155f); + }).width(155f).margin(16f); }); group.fill(t -> { diff --git a/core/src/mindustry/ui/Fonts.java b/core/src/mindustry/ui/Fonts.java index 1c4cfe7d56..72f5c45727 100644 --- a/core/src/mindustry/ui/Fonts.java +++ b/core/src/mindustry/ui/Fonts.java @@ -162,7 +162,6 @@ public class Fonts{ if(g == null) throw new IllegalArgumentException("No glyph: " + glyph + " (" + (int)glyph + ")"); float size = Math.max(g.width, g.height); - float aspect = (float)g.height / g.width; TextureRegionDrawable draw = new TextureRegionDrawable(new TextureRegion(font.getRegion().getTexture(), g.u, g.v2, g.u2, g.v)){ @Override public void draw(float x, float y, float width, float height){ @@ -173,6 +172,19 @@ public class Fonts{ Draw.rect(region, cx + g.width/2f, cy + g.height/2f, g.width, g.height); } + @Override + public void draw(float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation){ + width *= scaleX; + height *= scaleY; + Draw.color(Tmp.c1.set(tint).mul(Draw.getColor()).toFloatBits()); + float cx = x + width/2f - g.width/2f, cy = y + height/2f - g.height/2f; + cx = (int)cx; + cy = (int)cy; + originX = g.width/2f; + originY = g.height/2f; + Draw.rect(region, cx + g.width/2f, cy + g.height/2f, g.width, g.height, originX, originY, rotation); + } + @Override public float imageSize(){ return size; diff --git a/core/src/mindustry/ui/dialogs/JoinDialog.java b/core/src/mindustry/ui/dialogs/JoinDialog.java index 397fee4f64..429b27f5fb 100644 --- a/core/src/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/mindustry/ui/dialogs/JoinDialog.java @@ -95,11 +95,16 @@ public class JoinDialog extends FloatingDialog{ } }); - onResize(this::setup); + onResize(() -> { + setup(); + refreshLocal(); + refreshRemote(); + }); } void setupRemote(){ remote.clear(); + for(Server server : servers){ //why are java lambdas this bad TextButton[] buttons = {null}; @@ -139,16 +144,16 @@ public class JoinDialog extends FloatingDialog{ } } - }).margin(3f).pad(2).padTop(6f).top().right(); + }).margin(3f).padTop(6f).top().right(); inner.addImageButton(Icon.refresh, Styles.emptyi, () -> { refreshServer(server); - }).margin(3f).pad(2).padTop(6f).top().right(); + }).margin(3f).padTop(6f).top().right(); inner.addImageButton(Icon.pencil, Styles.emptyi, () -> { renaming = server; add.show(); - }).margin(3f).pad(2).padTop(6f).top().right(); + }).margin(3f).padTop(6f).top().right(); inner.addImageButton(Icon.trash, Styles.emptyi, () -> { ui.showConfirm("$confirm", "$server.delete", () -> { @@ -157,7 +162,7 @@ public class JoinDialog extends FloatingDialog{ setupRemote(); refreshRemote(); }); - }).margin(3f).pad(2).pad(6).top().right(); + }).margin(3f).pad(6).top().right(); button.row(); @@ -266,7 +271,7 @@ public class JoinDialog extends FloatingDialog{ cont.addCenteredImageTextButton("$server.add", Icon.add, () -> { renaming = null; add.show(); - }).marginLeft(6).width(w).height(80f).update(button -> { + }).marginLeft(10).width(w).height(80f).update(button -> { float pw = w; float pad = 0f; if(pane.getChildren().first().getPrefHeight() > pane.getHeight()){ @@ -363,7 +368,7 @@ public class JoinDialog extends FloatingDialog{ } float targetWidth(){ - return Core.graphics.isPortrait() ? 350f : 500f; + return Math.min(Core.graphics.getWidth() / Scl.scl() * 0.9f, 500f);//Core.graphics.isPortrait() ? 350f : 500f; } @SuppressWarnings("unchecked") diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index b4bf78cfd8..e81e443126 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -244,9 +244,12 @@ public class PlacementFragment extends Fragment{ } } blockTable.act(0f); - blockPane.act(0f); blockPane.setScrollYForce(scrollPositions.get(currentCategory, 0)); - Core.app.post(() -> blockPane.setScrollYForce(scrollPositions.get(currentCategory, 0))); + Core.app.post(() -> { + blockPane.setScrollYForce(scrollPositions.get(currentCategory, 0)); + blockPane.act(0f); + blockPane.layout(); + }); }; //top table with hover info diff --git a/gradle.properties b/gradle.properties index 1c66a6adfe..4bccd74700 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=ca797d336b86bfe091162b5e5dc73521e04e4817 +archash=bf5f253d458e0b8bddf9efcc3642a644f4b48fb6