diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index 1686a3cc92..01410348cc 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -266,7 +266,7 @@ public class UnitTypes implements ContentList{ }}; lich = new UnitType("lich", Revenant.class, Revenant::new){{ - health = 6000; + health = 7000; mass = 20f; hitsize = 40f; speed = 0.01f; @@ -285,7 +285,7 @@ public class UnitTypes implements ContentList{ length = 4f; reload = 180f; width = 22f; - shots = 20; + shots = 22; shotDelay = 2; inaccuracy = 10f; roundrobin = true; @@ -297,7 +297,7 @@ public class UnitTypes implements ContentList{ }}; reaper = new UnitType("reaper", Revenant.class, Revenant::new){{ - health = 12000; + health = 13000; mass = 30f; hitsize = 56f; speed = 0.01f; diff --git a/core/src/io/anuke/mindustry/type/Zone.java b/core/src/io/anuke/mindustry/type/Zone.java index 0877deb4fd..93b5208c67 100644 --- a/core/src/io/anuke/mindustry/type/Zone.java +++ b/core/src/io/anuke/mindustry/type/Zone.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.type; import io.anuke.arc.Core; import io.anuke.arc.Events; import io.anuke.arc.collection.Array; +import io.anuke.arc.function.Consumer; import io.anuke.arc.function.Supplier; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.scene.ui.layout.Table; @@ -99,22 +100,21 @@ public class Zone extends UnlockableContent{ public void updateLaunchCost(){ Array stacks = new Array<>(); - //TODO optimize - for(ItemStack stack : baseLaunchCost){ - ItemStack out = new ItemStack(stack.item, stack.amount); - for(ItemStack other : startingItems){ - if(other.item == out.item){ - out.amount += other.amount; - out.amount = Math.max(out.amount, 0); + Consumer adder = stack -> { + for(ItemStack other : stacks){ + if(other.item == stack.item){ + other.amount += stack.amount; + return; } } - stacks.add(out); - } + stacks.add(new ItemStack(stack.item, stack.amount)); + }; - for(ItemStack other : startingItems){ - if(stacks.find(s -> s.item == other.item) == null){ - stacks.add(other); - } + for(ItemStack stack : baseLaunchCost) adder.accept(stack); + for(ItemStack stack : startingItems) adder.accept(stack); + + for(ItemStack stack : stacks){ + if(stack.amount < 0) stack.amount = 0; } stacks.sort(); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java index 810bdd2e20..8b99145120 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -195,7 +195,6 @@ public class SettingsMenuDialog extends SettingsDialog{ graphics.checkPref("fps", false); graphics.checkPref("indicators", true); graphics.checkPref("lasers", true); - graphics.checkPref("minimap", !mobile); //minimap is disabled by default on mobile devices } private void back(){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java index 269d7cf58c..bb5ef324f5 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java @@ -173,7 +173,7 @@ public class ZoneInfoDialog extends FloatingDialog{ t.add(!zone.canConfigure() ? Core.bundle.format("configure.locked", zone.configureWave) : "$configure").growX().wrap(); if(zone.canConfigure()){ t.row(); - t.add(load).pad(2).growX().left(); + t.pane(load).pad(2).growX().left(); } }).width(300f).pad(4).left(); } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 271edfe646..fdba71acc9 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -15,7 +15,6 @@ import io.anuke.arc.scene.ui.ImageButton; import io.anuke.arc.scene.ui.TextButton; import io.anuke.arc.scene.ui.layout.Stack; import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.scene.utils.Elements; import io.anuke.arc.util.Align; import io.anuke.arc.util.Scaling; @@ -37,9 +36,7 @@ import static io.anuke.mindustry.Vars.*; public class HudFragment extends Fragment{ public final PlacementFragment blockfrag = new PlacementFragment(); - private ImageButton menu, flip; - private Stack wavetable; - private Table infolabel; + private ImageButton flip; private Table lastUnlockTable; private Table lastUnlockLayout; private boolean shown = true; @@ -61,7 +58,7 @@ public class HudFragment extends Fragment{ select.left(); select.defaults().size(dsize).left(); - menu = select.addImageButton("icon-menu", "clear", isize, ui.paused::show).get(); + ImageButton menu = select.addImageButton("icon-menu", "clear", isize, ui.paused::show).get(); flip = select.addImageButton("icon-arrow-up", "clear", isize, this::toggleMenus).get(); select.addImageButton("icon-pause", "clear", isize, () -> { @@ -113,53 +110,35 @@ public class HudFragment extends Fragment{ } }); - Stack stack = new Stack(); - TextButton waves = new TextButton("", "wave"); - Table btable = new Table().margin(0); + cont.table(stuff -> { + stuff.left(); + Stack stack = new Stack(); + TextButton waves = new TextButton("", "wave"); + Table btable = new Table().margin(0); - stack.add(waves); - stack.add(btable); + stack.add(waves); + stack.add(btable); - wavetable = stack; - - addWaveTable(waves); - addPlayButton(btable); - cont.add(stack).width(dsize * 4 + 6f); - - cont.row(); - - Table healthTable = cont.table("button", t -> - t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.WHITE)).grow() - ).fillX().visible(() -> world.isZone() && state.boss() != null).height(60f).update(t -> t.getTranslation().set(0, Unit.dp.scl(wavetable.getTranslation().y))).get(); - - cont.row(); - - //fps display - infolabel = new Table(); - infolabel.marginLeft(10f); - IntFormat fps = new IntFormat("fps"); - IntFormat ping = new IntFormat("ping"); - infolabel.label(() -> fps.get(Core.graphics.getFramesPerSecond())).padLeft(10).growX(); - infolabel.row(); - if(Net.hasClient()){ - infolabel.label(() -> ping.get(Net.getPing())).visible(Net::client).colspan(2); - } - infolabel.visible(() -> Core.settings.getBool("fps")).update(() -> - infolabel.setPosition(0, - healthTable.isVisible() ? healthTable.getY() + healthTable.getTranslation().y : waves.isVisible() ? Math.min(wavetable.getY(), Core.graphics.getHeight()) : Core.graphics.getHeight(), - Align.topLeft)); - - infolabel.pack(); - cont.addChild(infolabel); - - //make wave box appear below rest of menu - if(mobile){ - cont.swapActor(wavetable, menu.getParent()); - } + addWaveTable(waves); + addPlayButton(btable); + stuff.add(stack).width(dsize * 4 + 6f); + stuff.row(); + stuff.table("button", t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.WHITE)) + .grow()).fillX().visible(() -> world.isZone() && state.boss() != null).height(60f).get(); + stuff.row(); + }).visible(() -> shown); }); - //minimap - //parent.fill(t -> t.top().right().add(new Minimap()).visible(() -> !state.is(State.menu) && Core.settings.getBool("minimap"))); + + //fps display + parent.fill(info -> { + info.top().right().margin(4).visible(() -> Core.settings.getBool("fps")); + IntFormat fps = new IntFormat("fps"); + IntFormat ping = new IntFormat("ping"); + info.label(() -> fps.get(Core.graphics.getFramesPerSecond())).right(); + info.row(); + info.label(() -> ping.get(Net.getPing())).visible(Net::client).right(); + }); //spawner warning parent.fill(t -> { @@ -300,6 +279,10 @@ public class HudFragment extends Fragment{ Actions.run(() -> container.actions(Actions.translateBy(0, table.getPrefHeight(), 1f, Interpolation.fade), Actions.removeActor()))); } + public boolean shown(){ + return shown; + } + /** Show unlock notification for a new recipe. */ public void showUnlock(UnlockableContent content){ //some content may not have icons... yet @@ -399,27 +382,11 @@ public class HudFragment extends Fragment{ } private void toggleMenus(){ - wavetable.clearActions(); - infolabel.clearActions(); - - float dur = 0.3f; - Interpolation in = Interpolation.pow3Out; - if(flip != null){ flip.getStyle().imageUp = Core.scene.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up"); } - if(shown){ - shown = false; - blockfrag.toggle(dur, in); - wavetable.actions(Actions.translateBy(0, (wavetable.getHeight() + Unit.dp.scl(dsize) + Unit.dp.scl(6)) - wavetable.getTranslation().y, dur, in)); - infolabel.actions(Actions.translateBy(0, (wavetable.getHeight()) - wavetable.getTranslation().y, dur, in)); - }else{ - shown = true; - blockfrag.toggle(dur, in); - wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in)); - infolabel.actions(Actions.translateBy(0, -infolabel.getTranslation().y, dur, in)); - } + shown = !shown; } private void addWaveTable(TextButton table){ diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 43afbf6bd6..b4c93d4195 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -5,10 +5,8 @@ import io.anuke.arc.Events; import io.anuke.arc.collection.Array; import io.anuke.arc.graphics.Color; import io.anuke.arc.input.KeyCode; -import io.anuke.arc.math.Interpolation; import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.scene.Group; -import io.anuke.arc.scene.actions.Actions; import io.anuke.arc.scene.event.Touchable; import io.anuke.arc.scene.style.TextureRegionDrawable; import io.anuke.arc.scene.ui.ButtonGroup; @@ -43,7 +41,6 @@ public class PlacementFragment extends Fragment{ Tile lastHover; Tile hoverTile; Table blockTable, toggler, topTable; - boolean shown = true; boolean lastGround; //TODO make this configurable @@ -123,7 +120,7 @@ public class PlacementFragment extends Fragment{ public void build(Group parent){ parent.fill(full -> { toggler = full; - full.bottom().right().visible(() -> !state.is(State.menu)); + full.bottom().right().visible(() -> !state.is(State.menu) && ui.hudfrag.shown()); full.table(frame -> { InputHandler input = control.input(0); @@ -345,16 +342,4 @@ public class PlacementFragment extends Fragment{ Block tileDisplayBlock(){ return hoverTile == null ? null : hoverTile.block().synthetic() ? hoverTile.block() : hoverTile.floor() instanceof OreBlock ? hoverTile.floor() : null; } - - /** Show or hide the placement menu. */ - void toggle(float t, Interpolation ip){ - toggler.clearActions(); - if(shown){ - shown = false; - toggler.actions(Actions.translateBy(toggler.getTranslation().x + toggler.getWidth(), 0, t, ip)); - }else{ - shown = true; - toggler.actions(Actions.translateBy(-toggler.getTranslation().x, 0, t, ip)); - } - } } \ No newline at end of file