diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 56ad5d4ddc..d8df347bca 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="9" + android:versionName="1.2" > diff --git a/build.gradle b/build.gradle index bdec592689..43dd1c75d7 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.anuken:ucore:073aa61a1c' + compile 'com.github.anuken:ucore:42a04f8cb4' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/assets/sprites/icon.png b/core/assets/sprites/icon.png new file mode 100644 index 0000000000..2268830701 Binary files /dev/null and b/core/assets/sprites/icon.png differ diff --git a/core/src/io/anuke/mindustry/Control.java b/core/src/io/anuke/mindustry/Control.java index dd3e373bed..d6800908d1 100644 --- a/core/src/io/anuke/mindustry/Control.java +++ b/core/src/io/anuke/mindustry/Control.java @@ -25,11 +25,11 @@ import io.anuke.ucore.entities.Entities; import io.anuke.ucore.entities.Entity; import io.anuke.ucore.graphics.Atlas; import io.anuke.ucore.modules.ControlModule; +import io.anuke.ucore.scene.ui.layout.Unit; import io.anuke.ucore.util.Mathf; public class Control extends ControlModule{ - public int rangex = 10, rangey = 10; - public float targetzoom = 1f; + int targetscale = baseCameraScale; boolean showedTutorial; boolean hiscore = false; @@ -86,12 +86,13 @@ public class Control extends ControlModule{ Settings.loadAll("io.anuke.moment"); - for(String map : maps) + for(String map : maps){ Settings.defaults("hiscore"+map, 0); + } player = new Player(); } - + /* public void setCameraScale(int scale){ Core.cameraScale = scale; resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); @@ -99,7 +100,7 @@ public class Control extends ControlModule{ Draw.getSurface("pixel").setScale(Core.cameraScale); Draw.getSurface("shadow").setScale(Core.cameraScale); } - + */ public void reset(){ weapons.clear(); Renderer.clearTiles(); @@ -238,11 +239,6 @@ public class Control extends ControlModule{ return wavespace*out; } - public void clampZoom(){ - targetzoom = Mathf.clamp(targetzoom, 0.5f, 2f); - camera.zoom = Mathf.clamp(camera.zoom, 0.5f, 2f); - } - public boolean isHighScore(){ return hiscore; } @@ -267,6 +263,21 @@ public class Control extends ControlModule{ return wave; } + public void setCameraScale(int amount){ + targetscale = amount; + clampScale(); + Draw.getSurface("pixel").setScale(targetscale); + Draw.getSurface("shadow").setScale(targetscale); + } + + public void scaleCamera(int amount){ + setCameraScale(targetscale + amount); + } + + public void clampScale(){ + targetscale = Mathf.clamp(targetscale, Math.round(Unit.dp.inPixels(3)), Math.round(Unit.dp.inPixels((5)))); + } + @Override public void init(){ Musics.shuffleAll(); @@ -284,6 +295,15 @@ public class Control extends ControlModule{ public void update(){ if(debug){ + + if(Inputs.keyUp(Keys.PLUS)){ + scaleCamera(1); + } + + if(Inputs.keyUp(Keys.MINUS)){ + scaleCamera(-1); + } + if(Inputs.keyUp(Keys.SPACE)) Effects.sound("shoot", World.core.worldx(), World.core.worldy()); @@ -316,6 +336,22 @@ public class Control extends ControlModule{ } } + if(Core.cameraScale != targetscale){ + float targetzoom = (float)Core.cameraScale / targetscale; + camera.zoom = Mathf.lerp(camera.zoom, targetzoom, 0.2f*Timers.delta()); + + if(Mathf.in(camera.zoom, targetzoom, 0.005f)){ + camera.zoom = 1f; + Core.cameraScale = targetscale; + //super.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + camera.viewportWidth = Gdx.graphics.getWidth() / Core.cameraScale; + camera.viewportHeight = Gdx.graphics.getHeight() / Core.cameraScale; + + AndroidInput.mousex = Gdx.graphics.getWidth()/2; + AndroidInput.mousey = Gdx.graphics.getHeight()/2; + } + } + if(GameState.is(State.menu)){ clearScreen(); }else{ @@ -423,9 +459,6 @@ public class Control extends ControlModule{ public void resize(int width, int height){ super.resize(width, height); - rangex = (int) (width / tilesize / Core.cameraScale/2)+2; - rangey = (int) (height / tilesize / Core.cameraScale/2)+2; - AndroidInput.mousex = Gdx.graphics.getWidth()/2; AndroidInput.mousey = Gdx.graphics.getHeight()/2; camera.position.set(player.x, player.y, 0); diff --git a/core/src/io/anuke/mindustry/Renderer.java b/core/src/io/anuke/mindustry/Renderer.java index 5faa7487e6..b81f7c4a5d 100644 --- a/core/src/io/anuke/mindustry/Renderer.java +++ b/core/src/io/anuke/mindustry/Renderer.java @@ -68,7 +68,8 @@ public class Renderer{ Draw.begin(); Draw.reset(); - int rangex = control.rangex, rangey = control.rangey; + int rangex = (int) (camera.viewportWidth * camera.zoom / tilesize / 2)+2; + int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2)+2; boolean noshadows = Settings.getBool("noshadows"); diff --git a/core/src/io/anuke/mindustry/UI.java b/core/src/io/anuke/mindustry/UI.java index 117a67ff52..ffa1ec3a79 100644 --- a/core/src/io/anuke/mindustry/UI.java +++ b/core/src/io/anuke/mindustry/UI.java @@ -75,7 +75,7 @@ public class UI extends SceneModule{ Draw.color(); Texture back = Textures.get("background"); - int backscl = 5; + float backscl = 5; Draw.batch().draw(back, w/2 - back.getWidth()*backscl/2, h/2 - back.getHeight()*backscl/2, back.getWidth()*backscl, back.getHeight()*backscl); @@ -98,14 +98,14 @@ public class UI extends SceneModule{ } */ - int logoscl = 7; + float logoscl = (int)Unit.dp.inPixels(7); TextureRegion logo = skin.getRegion("logotext"); - int logow = logo.getRegionWidth()*logoscl; - int logoh = logo.getRegionHeight()*logoscl; + float logow = logo.getRegionWidth()*logoscl; + float logoh = logo.getRegionHeight()*logoscl; Draw.color(); //Draw.color(Color.CORAL); - Draw.batch().draw(logo, w/2 - logow/2, h - logoh + 10, logow, logoh); + Draw.batch().draw(logo, w/2 - logow/2, h - logoh + 15, logow, logoh); Draw.color(); @@ -167,7 +167,7 @@ public class UI extends SceneModule{ restart.content().add("[YELLOW]New highscore!").pad(6); restart.content().row(); } - restart.content().add("You lasted until wave [GREEN]" + control.getWave() + "[].").pad(6); + restart.content().add("You lasted until wave [GREEN]" + control.getWave() + "[].").pad(12).units(Unit.dp).get(); restart.pack(); }); @@ -175,10 +175,10 @@ public class UI extends SceneModule{ restart.hide(); GameState.set(State.menu); control.reset(); - }); + }).size(200, 50).pad(3).units(Unit.dp); weapontable = fill(); - weapontable.bottom(); + weapontable.bottom().left(); weapontable.setVisible(play); if(android){ @@ -265,7 +265,7 @@ public class UI extends SceneModule{ } //additional padding - for(int j = 0; j < maxcol - (int)((float)recipes.size/rows+1); j ++){ + for(int j = 0; j < maxcol - (int)((float)recipes.size/rows+2); j ++){ table.row(); table.add().size(size); } @@ -304,16 +304,17 @@ public class UI extends SceneModule{ new table(){{ left(); defaults().size(66).units(Unit.dp).left(); + float isize = Unit.dp.inPixels(40); - new imagebutton("icon-menu", 40, ()->{ + new imagebutton("icon-menu", isize, ()->{ showMenu(); }); - new imagebutton("icon-settings", 40, ()->{ + new imagebutton("icon-settings", isize, ()->{ prefs.show(); }); - new imagebutton("icon-pause", 40, ()->{ + new imagebutton("icon-pause", isize, ()->{ //TODO pause }); }}.end(); @@ -351,30 +352,6 @@ public class UI extends SceneModule{ get().setVisible(play); }}.end(); - - - //+- table - //TODO refactor to make this less messy? - new table(){{ - aleft(); - abottom(); - int base = baseCameraScale; - int min = base-zoomScale*2; - int max = base+zoomScale; - new button("+", ()->{ - if(Core.cameraScale < max){ - control.setCameraScale(Core.cameraScale+zoomScale); - } - }).size(Unit.dp.inPixels(40)); - - new button("-", ()->{ - if(Core.cameraScale > min){ - control.setCameraScale(Core.cameraScale-zoomScale); - } - }).size(Unit.dp.inPixels(40)); - - get().setVisible(play); - }}.end(); //menu table new table(){{ @@ -498,7 +475,7 @@ public class UI extends SceneModule{ desctable.defaults().left(); desctable.left(); - desctable.pad(12); + desctable.pad(Unit.dp.inPixels(12)); Table header = new Table(); @@ -507,10 +484,10 @@ public class UI extends SceneModule{ desctable.row(); - header.addImage(Draw.region(recipe.result.name)).size(8*5).padTop(4); - header.add(recipe.result.formalName).padLeft(4); + header.addImage(Draw.region(recipe.result.name)).size(8*5).padTop(4).units(Unit.dp); + header.add(recipe.result.formalName).padLeft(4).units(Unit.dp); - desctable.add().pad(2); + desctable.add().pad(2).units(Unit.dp); Table requirements = new Table(); @@ -521,7 +498,7 @@ public class UI extends SceneModule{ for(ItemStack stack : recipe.requirements){ ItemStack fs = stack; - requirements.addImage(Draw.region("icon-"+stack.item.name())).size(8*3); + requirements.addImage(Draw.region("icon-"+stack.item.name())).size(8*3).units(Unit.dp); Label reqlabel = new Label(""); reqlabel.update(()->{ @@ -542,7 +519,7 @@ public class UI extends SceneModule{ Label label = new Label("[health]health: " + recipe.result.health + (recipe.result.description() == null ? "" : ("\n[]" + recipe.result.description()))); label.setWrap(true); - desctable.add(label).width(200).padTop(4).padBottom(2); + desctable.add(label).width(200).padTop(4).padBottom(2).units(Unit.dp); } diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 9fd12159b6..4dc2972071 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -135,6 +135,7 @@ public class Enemy extends DestructibleEntity{ @Override public void draw(){ + Draw.color(); Draw.rect("mech1", x, y, direction.angle()-90); } } diff --git a/core/src/io/anuke/mindustry/input/GestureHandler.java b/core/src/io/anuke/mindustry/input/GestureHandler.java index c203981f91..acaf1f62df 100644 --- a/core/src/io/anuke/mindustry/input/GestureHandler.java +++ b/core/src/io/anuke/mindustry/input/GestureHandler.java @@ -10,11 +10,13 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.World; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.ucore.core.*; +import io.anuke.ucore.scene.ui.layout.Unit; public class GestureHandler extends GestureAdapter{ Vector2 pinch1 = new Vector2(-1, -1), pinch2 = pinch1.cpy(); Vector2 vector = new Vector2(); float initzoom = -1; + boolean zoomed = false; @Override public boolean longPress(float x, float y){ @@ -66,15 +68,17 @@ public class GestureHandler extends GestureAdapter{ @Override public boolean zoom(float initialDistance, float distance){ - - if(initzoom <= 0) + if(initzoom < 0){ initzoom = initialDistance; + } - control.targetzoom /= (distance/initzoom); - control.clampZoom(); - control.camera.update(); - - initzoom = distance; + if(Math.abs(distance - initzoom) > Unit.dp.inPixels(100f) && !zoomed){ + int amount = (distance > initzoom ? 1 : -1); + control.scaleCamera(Math.round(Unit.dp.inPixels(amount))); + initzoom = distance; + zoomed = true; + return true; + } return false; } @@ -83,6 +87,7 @@ public class GestureHandler extends GestureAdapter{ public void pinchStop () { initzoom = -1; pinch2.set(pinch1.set(-1, -1)); + zoomed = false; } int touches(){ diff --git a/core/src/io/anuke/mindustry/input/Input.java b/core/src/io/anuke/mindustry/input/Input.java index ae3da19b12..348af0a764 100644 --- a/core/src/io/anuke/mindustry/input/Input.java +++ b/core/src/io/anuke/mindustry/input/Input.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.Input.Keys; import io.anuke.mindustry.Inventory; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.Tile; @@ -14,7 +15,6 @@ import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.ProductionBlocks; import io.anuke.ucore.core.*; import io.anuke.ucore.scene.utils.Cursors; -import io.anuke.ucore.util.Mathf; public class Input{ @@ -23,12 +23,16 @@ public class Input{ if(player.health <= 0) return; if(Inputs.scrolled()){ + Vars.control.scaleCamera(Inputs.scroll()); + //TODO + /* int index = currentWeapon(); index -= Inputs.scroll(); player.weapon = control.getWeapons().get(Mathf.clamp(index, 0, control.getWeapons().size-1)); ui.updateWeapons(); + */ } if(Inputs.keyUp("rotate")) diff --git a/core/src/io/anuke/mindustry/resource/Recipe.java b/core/src/io/anuke/mindustry/resource/Recipe.java index 4268eb58a2..8c7e5a6ad3 100644 --- a/core/src/io/anuke/mindustry/resource/Recipe.java +++ b/core/src/io/anuke/mindustry/resource/Recipe.java @@ -37,7 +37,7 @@ public enum Recipe{ irondrill(production, ProductionBlocks.irondrill, stack(Item.stone, 40)), coaldrill(production, ProductionBlocks.coaldrill, stack(Item.stone, 40), stack(Item.iron, 40)), titaniumdrill(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)), - omnidrill(production, ProductionBlocks.omnidrill, stack(Item.steel, 50), stack(Item.titanium, 50)), + omnidrill(production, ProductionBlocks.omnidrill, stack(Item.titanium, 40), stack(Item.dirium, 40)), smelter(production, ProductionBlocks.smelter, stack(Item.stone, 80), stack(Item.iron, 80)), crucible(production, ProductionBlocks.crucible, stack(Item.titanium, 80), stack(Item.steel, 80)), coalpurifier(production, ProductionBlocks.coalpurifier, stack(Item.steel, 20), stack(Item.iron, 20)), diff --git a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java index 8dfdcfc8cb..fe1e2f64b0 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java @@ -195,7 +195,7 @@ public class ProductionBlocks{ omnidrill = new Drill("omnidrill"){ { - time = 4; + time = 3; formalName = "omnidrill"; } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Pump.java b/core/src/io/anuke/mindustry/world/blocks/types/Pump.java index 1d4577a251..705da5655f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Pump.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Pump.java @@ -13,6 +13,11 @@ public class Pump extends Conduit{ rotate = false; } + @Override + public String description(){ + return "Pumps liquids from blocks into conduits."; + } + @Override public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ return false; diff --git a/desktop/gifexport/recording1506040406.gif b/desktop/gifexport/recording1506040406.gif new file mode 100644 index 0000000000..26dd3ff94b Binary files /dev/null and b/desktop/gifexport/recording1506040406.gif differ diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java index 5c5c164255..1ccc698348 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java @@ -18,6 +18,7 @@ public class DesktopLauncher { config.setMaximized(true); //config.useVsync(false); config.setWindowedMode(800, 600); + config.setWindowIcon("sprites/icon.png"); SaveIO.setFormatProvider(new FormatProvider(){ SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");