From 198f05b112eebcde8d2288b6f20d05f815f552c5 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 9 Apr 2022 15:33:39 -0400 Subject: [PATCH] Misc fixes --- core/src/mindustry/content/Planets.java | 4 + core/src/mindustry/type/Weapon.java | 6 +- .../mindustry/type/weapons/BuildWeapon.java | 6 ++ .../mindustry/ui/dialogs/PlanetDialog.java | 91 ++++++++++--------- core/src/mindustry/world/Build.java | 2 +- 5 files changed, 63 insertions(+), 46 deletions(-) diff --git a/core/src/mindustry/content/Planets.java b/core/src/mindustry/content/Planets.java index 4a0be575d3..a314b6c0d1 100644 --- a/core/src/mindustry/content/Planets.java +++ b/core/src/mindustry/content/Planets.java @@ -102,6 +102,10 @@ public class Planets{ startSector = 10; atmosphereRadIn = -0.01f; atmosphereRadOut = 0.3f; + defaultEnv = Env.underwater | Env.terrestrial; + ruleSetter = r -> { + + }; }}; //TODO hide beryllium and others on load in rules diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 4a2a4d0e19..845b4b831c 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -140,8 +140,10 @@ public class Weapon implements Cloneable{ t.row(); t.add("[lightgray]" + Stat.inaccuracy.localized() + ": [white]" + (int)inaccuracy + " " + StatUnit.degrees.localized()); } - t.row(); - t.add("[lightgray]" + Stat.reload.localized() + ": " + (mirror ? "2x " : "") + "[white]" + Strings.autoFixed(60f / reload * shoot.shots, 2) + " " + StatUnit.perSecond.localized()); + if(reload > 0){ + t.row(); + t.add("[lightgray]" + Stat.reload.localized() + ": " + (mirror ? "2x " : "") + "[white]" + Strings.autoFixed(60f / reload * shoot.shots, 2) + " " + StatUnit.perSecond.localized()); + } StatValues.ammo(ObjectMap.of(u, bullet)).display(t); } diff --git a/core/src/mindustry/type/weapons/BuildWeapon.java b/core/src/mindustry/type/weapons/BuildWeapon.java index db5f7d42f1..29c2f416b0 100644 --- a/core/src/mindustry/type/weapons/BuildWeapon.java +++ b/core/src/mindustry/type/weapons/BuildWeapon.java @@ -1,6 +1,7 @@ package mindustry.type.weapons; import arc.math.*; +import arc.scene.ui.layout.*; import mindustry.entities.bullet.*; import mindustry.entities.units.*; import mindustry.gen.*; @@ -22,6 +23,11 @@ public class BuildWeapon extends Weapon{ bullet = new BulletType(); } + @Override + public void addStats(UnitType u, Table t){ + //no. + } + @Override public void update(Unit unit, WeaponMount mount){ //no diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 2a9473af27..dfcd8c5245 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -66,7 +66,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ public boolean showed = false, sectorsShown; public String searchText = ""; - public Table sectorTop = new Table(), notifs = new Table(); + public Table sectorTop = new Table(), notifs = new Table(), expandTable = new Table(); public Label hoverLabel = new Label(""); public PlanetDialog(){ @@ -281,6 +281,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ } selected = destSec; updateSelected(); + rebuildExpand(); } //TODO pan over to correct planet @@ -564,7 +565,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ if(state.planet != planet){ newPresets.clear(); state.planet = planet; - rebuildList(); + rebuildExpand(); } settings.put("lastplanet", planet.name); }).width(200).height(40).growX().update(bb -> bb.setChecked(state.planet == planet)); @@ -576,31 +577,39 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ }), new Table(c -> { - c.visible(() -> !(graphics.isPortrait() && mobile)); - if(state.planet.sectors.contains(Sector::hasBase)){ - int attacked = state.planet.sectors.count(Sector::isAttacked); - - //sector notifications & search - c.top().right(); - c.defaults().width(290f); - - c.button(bundle.get("sectorlist") + - (attacked == 0 ? "" : "\n[red]⚠[lightgray] " + bundle.format("sectorlist.attacked", "[red]" + attacked + "[]")), - Icon.downOpen, Styles.squareTogglet, () -> sectorsShown = !sectorsShown) - .height(60f).checked(b -> { - Image image = (Image)b.getCells().first().get(); - image.setDrawable(sectorsShown ? Icon.upOpen : Icon.downOpen); - return sectorsShown; - }).with(t -> t.left().margin(7f)).with(t -> t.getLabelCell().grow().left()).row(); - - c.collapser(t -> { - t.background(Styles.black8); - - notifs = t; - rebuildList(); - }, false, () -> sectorsShown).padBottom(64f).row(); - } + expandTable = c; })).grow(); + + rebuildExpand(); + } + + void rebuildExpand(){ + Table c = expandTable; + c.clear(); + c.visible(() -> !(graphics.isPortrait() && mobile)); + if(state.planet.sectors.contains(Sector::hasBase)){ + int attacked = state.planet.sectors.count(Sector::isAttacked); + + //sector notifications & search + c.top().right(); + c.defaults().width(290f); + + c.button(bundle.get("sectorlist") + + (attacked == 0 ? "" : "\n[red]⚠[lightgray] " + bundle.format("sectorlist.attacked", "[red]" + attacked + "[]")), + Icon.downOpen, Styles.squareTogglet, () -> sectorsShown = !sectorsShown) + .height(60f).checked(b -> { + Image image = (Image)b.getCells().first().get(); + image.setDrawable(sectorsShown ? Icon.upOpen : Icon.downOpen); + return sectorsShown; + }).with(t -> t.left().margin(7f)).with(t -> t.getLabelCell().grow().left()).row(); + + c.collapser(t -> { + t.background(Styles.black8); + + notifs = t; + rebuildList(); + }, false, () -> sectorsShown).padBottom(64f).row(); + } } void rebuildList(){ @@ -1108,25 +1117,21 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ //make sure there are no under-attack sectors (other than this one) for(Planet planet : content.planets()){ if(!planet.allowWaveSimulation && !debugSelect){ - int attackedCount = planet.sectors.count(s -> s.isAttacked() && s != sector); - //if there are two or more attacked sectors... something went wrong, don't show the dialog to prevent softlock - if(attackedCount < 2){ - Sector attacked = planet.sectors.find(s -> s.isAttacked() && s != sector); - if(attacked != null){ - BaseDialog dialog = new BaseDialog("@sector.noswitch.title"); - dialog.cont.add(bundle.format("sector.noswitch", attacked.name(), attacked.planet.localizedName)).maxWidth(400f).labelAlign(Align.center).center().wrap(); - dialog.addCloseButton(); - dialog.buttons.button("@sector.view", Icon.eyeSmall, () -> { - dialog.hide(); - lookAt(attacked); - selected = attacked; - updateSelected(); - }); - dialog.show(); + Sector attacked = planet.sectors.find(s -> s.isAttacked() && s != sector); + if(attacked != null && planet.sectors.count(s -> s.isAttacked()) < 2){ + BaseDialog dialog = new BaseDialog("@sector.noswitch.title"); + dialog.cont.add(bundle.format("sector.noswitch", attacked.name(), attacked.planet.localizedName)).maxWidth(400f).labelAlign(Align.center).center().wrap(); + dialog.addCloseButton(); + dialog.buttons.button("@sector.view", Icon.eyeSmall, () -> { + dialog.hide(); + lookAt(attacked); + selected = attacked; + updateSelected(); + }); + dialog.show(); - return; - } + return; } } } diff --git a/core/src/mindustry/world/Build.java b/core/src/mindustry/world/Build.java index 80c69f5947..4859a095fd 100644 --- a/core/src/mindustry/world/Build.java +++ b/core/src/mindustry/world/Build.java @@ -184,7 +184,7 @@ public class Build{ if( check == null || //nothing there - (state.rules.staticFog && !fogControl.isDiscovered(team, wx, wy)) || + (state.rules.staticFog && state.rules.fog && !fogControl.isDiscovered(team, wx, wy)) || (check.floor().isDeep() && !type.floating && !type.requiresWater && !type.placeableLiquid) || //deep water (type == check.block() && check.build != null && rotation == check.build.rotation && type.rotate) || //same block, same rotation !check.interactable(team) || //cannot interact