diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index f3ed7aeefc..b282689e8e 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -565,7 +565,7 @@ liquid.oil.name = Oil liquid.cryofluid.name = Cryofluid mech.alpha-mech.name = Alpha mech.alpha-mech.weapon = Heavy Repeater -mech.alpha-mech.ability = None +mech.alpha-mech.ability = Regeneration mech.alpha-mech.description = The standard mech. Has decent speed and damage output. mech.delta-mech.name = Delta mech.delta-mech.weapon = Arc Generator @@ -600,9 +600,10 @@ unit.speed = [LIGHT_GRAY]Speed: {0} mech.weapon = [LIGHT_GRAY]Weapon: {0} mech.health = [LIGHT_GRAY]Health: {0} mech.itemcapacity = [LIGHT_GRAY]Item Capacity: {0} -mech.minespeed = [LIGHT_GRAY]Mining Speed: {0} +mech.minespeed = [LIGHT_GRAY]Mining Speed: {0}% mech.minepower = [LIGHT_GRAY]Mining Power: {0} mech.ability = [LIGHT_GRAY]Ability: {0} +mech.buildspeed = [LIGHT_GRAY]Building Speed: {0}% liquid.heatcapacity = [LIGHT_GRAY]Heat Capacity: {0} liquid.viscosity = [LIGHT_GRAY]Viscosity: {0} liquid.temperature = [LIGHT_GRAY]Temperature: {0} diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index cc96e1ece2..8af4eb74f6 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -35,6 +35,7 @@ public class Mechs implements ContentList{ mass = 1.2f; speed = 0.5f; boostSpeed = 0.85f; + buildPower = 1.2f; engineColor = Color.valueOf("ffd37f"); health = 300f; @@ -47,6 +48,11 @@ public class Mechs implements ContentList{ }}; } + @Override + public void updateAlt(Player player){ + player.healBy(Time.delta() * 0.4f); + } + @Override public boolean alwaysUnlocked(){ return true; @@ -63,6 +69,7 @@ public class Mechs implements ContentList{ itemCapacity = 15; mass = 0.9f; health = 250f; + buildPower = 0.9f; weaponOffsetX = -1; weaponOffsetY = -1; engineColor = Color.valueOf("d3ddff"); @@ -110,6 +117,7 @@ public class Mechs implements ContentList{ boostSpeed = 0.8f; canHeal = true; health = 200f; + buildPower = 1.6f; engineColor = Pal.heal; weapon = new Weapon("heal-blaster"){{ @@ -161,6 +169,7 @@ public class Mechs implements ContentList{ weaponOffsetY = 0; engineColor = Color.valueOf("feb380"); health = 300f; + buildPower = 1.5f; weapon = new Weapon("swarmer"){{ length = 1.5f; recoil = 4f; @@ -227,6 +236,7 @@ public class Mechs implements ContentList{ weaponOffsetY = -1; engineColor = Pal.lightTrail; cellTrnsY = 1f; + buildPower = 1.1f; weapon = new Weapon("blaster"){{ length = 1.5f; reload = 20f; @@ -315,6 +325,7 @@ public class Mechs implements ContentList{ itemCapacity = 30; engineColor = Color.valueOf("84f491"); cellTrnsY = 1f; + buildPower = 2f; weapon = new Weapon("bomber"){{ length = 0f; width = 2f; @@ -346,6 +357,7 @@ public class Mechs implements ContentList{ itemCapacity = 60; engineColor = Color.valueOf("feb380"); cellTrnsY = 1f; + buildPower = 1.2f; weapon = new Weapon("bomber"){{ length = 1.5f; diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 2c650ad2cf..b29c912173 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -8,6 +8,7 @@ import io.anuke.arc.graphics.GL20; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureAtlas; import io.anuke.arc.input.KeyCode; +import io.anuke.arc.scene.ui.TextField; import io.anuke.arc.util.BufferUtils; import io.anuke.arc.util.Interval; import io.anuke.arc.util.Strings; @@ -301,6 +302,10 @@ public class Control implements ApplicationListener{ } } + if(!mobile && Core.input.keyTap(Binding.screenshot) && !(scene.getKeyboardFocus() instanceof TextField) && !ui.chatfrag.chatOpen()){ + renderer.takeMapScreenshot(); + } + }else{ if(!state.isPaused()){ Time.update(); diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index baab923078..d3c63af7f3 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -2,10 +2,13 @@ package io.anuke.mindustry.core; import io.anuke.arc.ApplicationListener; import io.anuke.arc.Core; +import io.anuke.arc.files.FileHandle; import io.anuke.arc.function.Consumer; import io.anuke.arc.function.Predicate; import io.anuke.arc.graphics.Camera; import io.anuke.arc.graphics.Color; +import io.anuke.arc.graphics.Pixmap; +import io.anuke.arc.graphics.PixmapIO; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Lines; import io.anuke.arc.graphics.g2d.SpriteBatch; @@ -13,6 +16,8 @@ import io.anuke.arc.graphics.glutils.FrameBuffer; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Vector2; +import io.anuke.arc.util.BufferUtils; +import io.anuke.arc.util.ScreenUtils; import io.anuke.arc.util.Time; import io.anuke.arc.util.Tmp; import io.anuke.arc.util.pooling.Pools; @@ -296,10 +301,6 @@ public class Renderer implements ApplicationListener{ EntityDraw.drawWith(group, toDraw, drawer); } - public float cameraScale(){ - return camerascale; - } - public void scaleCamera(float amount){ targetscale += amount; clampScale(); @@ -310,4 +311,47 @@ public class Renderer implements ApplicationListener{ targetscale = Mathf.clamp(targetscale, s * 1.5f, Math.round(s * 6)); } + public void takeMapScreenshot(){ + drawGroundShadows(); + + int w = world.width()*tilesize, h = world.height()*tilesize; + + boolean isWater = settings.getBool("animatedwater"); + settings.put("animatedwater", false); + + FrameBuffer buffer = new FrameBuffer(w, h); + + float vpW = camera.width, vpH = camera.height, px = camera.position.x, py = camera.position.y; + disableUI = true; + camera.width = w; + camera.height = h; + camera.position.x = w/2f + tilesize/2f; + camera.position.y = h/2f + tilesize/2f; + Draw.flush(); + buffer.begin(); + draw(); + Draw.flush(); + buffer.end(); + disableUI = false; + camera.width = vpW; + camera.height = vpH; + camera.position.set(px, py); + buffer.begin(); + byte[] lines = ScreenUtils.getFrameBufferPixels(0, 0, w, h, true); + for(int i = 0; i < lines.length; i+= 4){ + lines[i + 3] = (byte)255; + } + buffer.end(); + Pixmap fullPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888); + BufferUtils.copy(lines, 0, fullPixmap.getPixels(), lines.length); + FileHandle file = screenshotDirectory.child("screenshot-" + Time.millis() + ".png"); + PixmapIO.writePNG(file, fullPixmap); + fullPixmap.dispose(); + ui.showInfoFade(Core.bundle.format("screenshot", file.toString())); + + buffer.dispose(); + + settings.put("animatedwater", isWater); + } + } diff --git a/core/src/io/anuke/mindustry/input/Binding.java b/core/src/io/anuke/mindustry/input/Binding.java index dc23e9f7dd..7e6a73eff6 100644 --- a/core/src/io/anuke/mindustry/input/Binding.java +++ b/core/src/io/anuke/mindustry/input/Binding.java @@ -25,6 +25,7 @@ public enum Binding implements KeyBind{ menu(Core.app.getType() == ApplicationType.Android ? KeyCode.BACK : KeyCode.ESCAPE), pause(KeyCode.SPACE), toggle_menus(KeyCode.C), + screenshot(KeyCode.P), player_list(KeyCode.TAB, "multiplayer"), chat(KeyCode.ENTER), chat_history_prev(KeyCode.UP), diff --git a/core/src/io/anuke/mindustry/ui/ContentDisplay.java b/core/src/io/anuke/mindustry/ui/ContentDisplay.java index 62e571449e..3f80784724 100644 --- a/core/src/io/anuke/mindustry/ui/ContentDisplay.java +++ b/core/src/io/anuke/mindustry/ui/ContentDisplay.java @@ -134,6 +134,7 @@ public class ContentDisplay{ title.addImage(mech.getContentIcon()).size(8 * 6); title.add("[accent]" + mech.localizedName()).padLeft(5); }); + table.left().defaults().left(); table.row(); @@ -159,13 +160,17 @@ public class ContentDisplay{ table.add(Core.bundle.format("mech.ability", Core.bundle.get("mech." + mech.name + ".ability"))); table.row(); } + + table.add(Core.bundle.format("mech.buildspeed", (int)(mech.buildPower * 100f))); + table.row(); + table.add(Core.bundle.format("mech.health", (int)mech.health)); table.row(); table.add(Core.bundle.format("mech.itemcapacity", mech.itemCapacity)); table.row(); if(mech.drillPower > 0){ - table.add(Core.bundle.format("mech.minespeed", (int) (mech.mineSpeed * 10))); + table.add(Core.bundle.format("mech.minespeed", (int)(mech.mineSpeed * 100f))); table.row(); table.add(Core.bundle.format("mech.minepower", mech.drillPower)); table.row(); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index af923331ec..ab63473325 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -163,7 +163,7 @@ public class Block extends BlockStorage{ if(tile == null || tile.entity == null || tile.entity.power == null) return out; for(Tile other : tile.entity.proximity()){ - if(other.entity.power != null && !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower) + if(other != null && other.entity != null && other.entity.power != null && !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower) && !tile.entity.power.links.contains(other.pos())){ out.add(other); } diff --git a/tests/src/test/java/WorldTests.java b/tests/src/test/java/WorldTests.java index 91c8fdce81..ab89865ecf 100644 --- a/tests/src/test/java/WorldTests.java +++ b/tests/src/test/java/WorldTests.java @@ -1,16 +1,13 @@ -import static io.anuke.mindustry.Vars.logic; -import static io.anuke.mindustry.Vars.state; -import static io.anuke.mindustry.Vars.world; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.world.Tile; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static io.anuke.mindustry.Vars.*; +import static org.junit.jupiter.api.Assertions.assertEquals; public class WorldTests { static Tile[][] tiles; @@ -30,7 +27,7 @@ public class WorldTests { } @Test - void addDarkness_allSolid_maxDarkness(){ + void addDarknessAllSolidMaxDarkness(){ fillWith(Blocks.rocks.id); world.addDarkness(tiles); @@ -42,7 +39,7 @@ public class WorldTests { } @Test - void addDarkness_allSyntethic_noDarkness(){ + void addDarknessAllSyntethicNoDarkness(){ fillWith(Blocks.copperWall.id); world.addDarkness(tiles); @@ -54,7 +51,7 @@ public class WorldTests { } @Test - void addDarkness_allNotSolid_noDarkness(){ + void addDarknessAllNotSolidNoDarkness(){ fillWith(Blocks.air.id); world.addDarkness(tiles); @@ -66,7 +63,7 @@ public class WorldTests { } @Test - void addDarkness_allNotFilled_noDarkness(){ + void addDarknessAllNotFilledNoDarkness(){ fillWith(Blocks.cliffs.id); world.addDarkness(tiles); @@ -78,7 +75,7 @@ public class WorldTests { } @Test - void addDarkness_oneNotSolidMiddle_noDarkness(){ + void addDarknessOneNotSolidMiddleNoDarkness(){ fillWith(Blocks.rocks.id); tiles[5][5] = new Tile(5, 5, (byte)0, Blocks.copperWall.id, (byte)0, (byte)0); world.addDarkness(tiles); @@ -93,7 +90,7 @@ public class WorldTests { } @Test - void addDarkness_oneNotSolidCorner_noDarkness(){ + void addDarknessOneNotSolidCornerNoDarkness(){ fillWith(Blocks.rocks.id); tiles[7][7] = new Tile(5, 5, (byte)0, Blocks.copperWall.id, (byte)0, (byte)0); world.addDarkness(tiles);