From f0e5477346d15c51a6669730b8652a39ff2b4b45 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 21 Nov 2017 22:07:36 -0500 Subject: [PATCH] More description changes, changed profiler, core refactoring --- build.gradle | 2 +- core/src/io/anuke/mindustry/Mindustry.java | 11 ++-- core/src/io/anuke/mindustry/Profiler.java | 9 --- core/src/io/anuke/mindustry/Tutorial.java | 3 +- core/src/io/anuke/mindustry/Vars.java | 5 +- core/src/io/anuke/mindustry/ai/Pathfind.java | 8 +-- .../anuke/mindustry/{ => core}/Control.java | 18 ++++-- .../anuke/mindustry/{ => core}/GameState.java | 2 +- .../anuke/mindustry/{ => core}/Renderer.java | 30 +++++----- .../src/io/anuke/mindustry/{ => core}/UI.java | 34 ++--------- .../anuke/mindustry/entities/BulletType.java | 2 +- .../io/anuke/mindustry/entities/Player.java | 2 +- .../anuke/mindustry/entities/TileEntity.java | 2 +- .../anuke/mindustry/entities/effect/EMP.java | 1 - .../mindustry/{ => entities/effect}/Fx.java | 3 +- .../mindustry/entities/effect/TeslaOrb.java | 1 - .../mindustry/entities/enemies/Enemy.java | 2 +- .../io/anuke/mindustry/resource/Weapon.java | 2 +- .../src/io/anuke/mindustry/ui/LoadDialog.java | 4 +- .../src/io/anuke/mindustry/ui/MenuDialog.java | 4 +- .../io/anuke/mindustry/ui/UpgradeDialog.java | 4 +- .../ui/fragments/BlocksFragment.java | 4 +- .../mindustry/ui/fragments/HudFragment.java | 60 ++++++++++++++++++- .../mindustry/ui/fragments/MenuFragment.java | 4 +- .../ui/fragments/PlacementFragment.java | 4 +- .../ui/fragments/ProfilerFragment.java | 48 --------------- .../mindustry/ui/fragments/ToolFragment.java | 4 +- .../ui/fragments/WeaponFragment.java | 4 +- core/src/io/anuke/mindustry/world/Block.java | 6 +- core/src/io/anuke/mindustry/world/World.java | 2 +- .../anuke/mindustry/world/blocks/Blocks.java | 6 +- .../world/blocks/ProductionBlocks.java | 2 +- .../mindustry/world/blocks/WeaponBlocks.java | 2 +- .../blocks/types/defense/LaserTurret.java | 2 +- .../world/blocks/types/defense/Turret.java | 2 +- .../blocks/types/production/Crafter.java | 2 +- .../world/blocks/types/production/Drill.java | 2 +- .../blocks/types/production/Generator.java | 2 +- .../types/production/ItemPowerGenerator.java | 2 +- .../types/production/LiquidCrafter.java | 2 +- .../production/LiquidPowerGenerator.java | 2 +- 41 files changed, 147 insertions(+), 164 deletions(-) delete mode 100644 core/src/io/anuke/mindustry/Profiler.java rename core/src/io/anuke/mindustry/{ => core}/Control.java (96%) rename core/src/io/anuke/mindustry/{ => core}/GameState.java (88%) rename core/src/io/anuke/mindustry/{ => core}/Renderer.java (95%) rename core/src/io/anuke/mindustry/{ => core}/UI.java (91%) rename core/src/io/anuke/mindustry/{ => entities/effect}/Fx.java (99%) delete mode 100644 core/src/io/anuke/mindustry/ui/fragments/ProfilerFragment.java diff --git a/build.gradle b/build.gradle index a43edb8424..af0ce077b0 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.anuken:ucore:eb772dd77d' + compile 'com.github.Anuken:ucore:9d84d75ee1' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/src/io/anuke/mindustry/Mindustry.java b/core/src/io/anuke/mindustry/Mindustry.java index a877786a25..172d84d5e9 100644 --- a/core/src/io/anuke/mindustry/Mindustry.java +++ b/core/src/io/anuke/mindustry/Mindustry.java @@ -1,20 +1,19 @@ package io.anuke.mindustry; -import static io.anuke.mindustry.Vars.profileTime; - import java.util.Date; import com.badlogic.gdx.graphics.profiling.GLProfiler; import com.badlogic.gdx.utils.Array; -import com.badlogic.gdx.utils.TimeUtils; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.core.*; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.io.Formatter; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.*; import io.anuke.ucore.core.Inputs; import io.anuke.ucore.core.Timers; import io.anuke.ucore.modules.ModuleCore; +import io.anuke.ucore.util.Profiler; public class Mindustry extends ModuleCore { public static Array args = new Array<>(); @@ -57,7 +56,7 @@ public class Mindustry extends ModuleCore { @Override public void render(){ - long time = TimeUtils.nanoTime(); + Profiler.begin("total"); try{ super.render(); @@ -73,6 +72,6 @@ public class Mindustry extends ModuleCore { Inputs.update(); - if(Timers.get("profilet", profileTime)) Profiler.total = TimeUtils.timeSinceNanos(time); + Profiler.end("total"); } } diff --git a/core/src/io/anuke/mindustry/Profiler.java b/core/src/io/anuke/mindustry/Profiler.java deleted file mode 100644 index 8a35cd7279..0000000000 --- a/core/src/io/anuke/mindustry/Profiler.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.anuke.mindustry; - -public class Profiler{ - public static long total; - public static long draw; - public static long blockDraw; - public static long entityDraw; - public static long entityUpdate; -} diff --git a/core/src/io/anuke/mindustry/Tutorial.java b/core/src/io/anuke/mindustry/Tutorial.java index 3fabf445e6..2d6090b8ae 100644 --- a/core/src/io/anuke/mindustry/Tutorial.java +++ b/core/src/io/anuke/mindustry/Tutorial.java @@ -2,7 +2,8 @@ package io.anuke.mindustry; import com.badlogic.gdx.math.GridPoint2; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.*; diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 4810113676..b2a9d05a4b 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -3,6 +3,9 @@ package io.anuke.mindustry; import com.badlogic.gdx.Application.ApplicationType; import com.badlogic.gdx.Gdx; +import io.anuke.mindustry.core.Control; +import io.anuke.mindustry.core.Renderer; +import io.anuke.mindustry.core.UI; import io.anuke.mindustry.entities.Player; import io.anuke.ucore.scene.ui.layout.Unit; @@ -41,8 +44,6 @@ public class Vars{ //TODO named save slots, possibly with a scroll dialog public static final int saveSlots = 4; - public static final int profileTime = 30; - //only if smoothCamera public static boolean snapCamera = true; diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index 4ff780f182..cc2b36837b 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -1,14 +1,13 @@ package io.anuke.mindustry.ai; import com.badlogic.gdx.ai.pfa.PathFinder; -import com.badlogic.gdx.ai.pfa.PathFinderRequest; import com.badlogic.gdx.ai.pfa.PathSmoother; import com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.World; @@ -68,11 +67,12 @@ public class Pathfind{ } } - //TODO + //TODO make this work? + /* PathFinderRequest request = new PathFinderRequest(); request.startNode = World.spawnpoints.get(0); request.endNode = World.core; - passpathfinder.search(request, 1000); + passpathfinder.search(request, 1000); */ for(int i = 0; i < paths.size; i ++){ SmoothGraphPath path = paths.get(i); diff --git a/core/src/io/anuke/mindustry/Control.java b/core/src/io/anuke/mindustry/core/Control.java similarity index 96% rename from core/src/io/anuke/mindustry/Control.java rename to core/src/io/anuke/mindustry/core/Control.java index 9b6e040870..7dcfeb4791 100644 --- a/core/src/io/anuke/mindustry/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -1,4 +1,4 @@ -package io.anuke.mindustry; +package io.anuke.mindustry.core; import static io.anuke.mindustry.Vars.*; @@ -8,14 +8,17 @@ import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.input.GestureDetector; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.ObjectMap; -import com.badlogic.gdx.utils.TimeUtils; import com.badlogic.gdx.utils.reflect.ClassReflection; import com.badlogic.gdx.utils.reflect.Constructor; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.Mindustry; +import io.anuke.mindustry.Tutorial; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.ai.Pathfind; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.EnemySpawn; import io.anuke.mindustry.entities.Player; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.enemies.*; import io.anuke.mindustry.input.AndroidInput; import io.anuke.mindustry.input.GestureHandler; @@ -31,6 +34,7 @@ import io.anuke.ucore.entities.Entity; import io.anuke.ucore.graphics.Atlas; import io.anuke.ucore.modules.Module; import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Profiler; public class Control extends Module{ int targetscale = baseCameraScale; @@ -230,7 +234,7 @@ public class Control extends Module{ this.extrawavetime = maxwavespace; } - void runWave(){ + public void runWave(){ Sounds.play("spawn"); Pathfind.updatePath(); @@ -473,9 +477,11 @@ public class Control extends Module{ runWave(); } - long time = TimeUtils.nanoTime(); + Profiler.begin("entityUpdate"); + Entities.update(); - if(Timers.get("profileeu", profileTime)) Profiler.entityUpdate = TimeUtils.timeSinceNanos(time); + + Profiler.end("entityUpdate"); } if(!android){ diff --git a/core/src/io/anuke/mindustry/GameState.java b/core/src/io/anuke/mindustry/core/GameState.java similarity index 88% rename from core/src/io/anuke/mindustry/GameState.java rename to core/src/io/anuke/mindustry/core/GameState.java index d859460252..186265c9b0 100644 --- a/core/src/io/anuke/mindustry/GameState.java +++ b/core/src/io/anuke/mindustry/core/GameState.java @@ -1,4 +1,4 @@ -package io.anuke.mindustry; +package io.anuke.mindustry.core; public class GameState{ private static State state = State.menu; diff --git a/core/src/io/anuke/mindustry/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java similarity index 95% rename from core/src/io/anuke/mindustry/Renderer.java rename to core/src/io/anuke/mindustry/core/Renderer.java index 304e0e826e..c828090861 100644 --- a/core/src/io/anuke/mindustry/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -1,4 +1,4 @@ -package io.anuke.mindustry; +package io.anuke.mindustry.core; import static io.anuke.mindustry.Vars.*; import static io.anuke.ucore.core.Core.camera; @@ -11,9 +11,10 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.profiling.GLProfiler; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.utils.TimeUtils; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.Shaders; +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.enemies.Enemy; @@ -34,9 +35,7 @@ import io.anuke.ucore.graphics.Caches; import io.anuke.ucore.modules.RendererModule; import io.anuke.ucore.scene.ui.layout.Unit; import io.anuke.ucore.scene.utils.Cursors; -import io.anuke.ucore.util.Angles; -import io.anuke.ucore.util.Mathf; -import io.anuke.ucore.util.Tmp; +import io.anuke.ucore.util.*; public class Renderer extends RendererModule{ int targetscale = baseCameraScale; @@ -124,10 +123,11 @@ public class Renderer extends RendererModule{ camera.position.add(-0.5f, 0, 0); } - long time = TimeUtils.nanoTime(); + Profiler.begin("draw"); + drawDefault(); - if(Timers.get("profiled", profileTime)) - Profiler.draw = TimeUtils.timeSinceNanos(time); + + Profiler.end("draw"); if(Vars.debug && Vars.debugGL && Timers.get("profile", 60)){ UCore.log("shaders: " + GLProfiler.shaderSwitches, "calls: " + GLProfiler.drawCalls, "bindings: " + GLProfiler.textureBindings, "vertices: " + GLProfiler.vertexCount.average); @@ -146,15 +146,15 @@ public class Renderer extends RendererModule{ Graphics.surface("shield"); Graphics.surface(); - long time = TimeUtils.nanoTime(); + Profiler.begin("blockDraw"); + renderTiles(); - if(Timers.get("profilebd", profileTime)) - Profiler.blockDraw = TimeUtils.timeSinceNanos(time); + + Profiler.end("blockDraw"); - time = TimeUtils.nanoTime(); + Profiler.begin("entityDraw"); Entities.draw(); - if(Timers.get("profileed", profileTime)) - Profiler.entityDraw = TimeUtils.timeSinceNanos(time); + Profiler.end("entityDraw"); drawShield(); diff --git a/core/src/io/anuke/mindustry/UI.java b/core/src/io/anuke/mindustry/core/UI.java similarity index 91% rename from core/src/io/anuke/mindustry/UI.java rename to core/src/io/anuke/mindustry/core/UI.java index f6586bcf7f..0914b421b4 100644 --- a/core/src/io/anuke/mindustry/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -1,4 +1,4 @@ -package io.anuke.mindustry; +package io.anuke.mindustry.core; import static io.anuke.mindustry.Vars.*; import static io.anuke.ucore.scene.actions.Actions.*; @@ -12,8 +12,8 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.GameState.State; -import io.anuke.mindustry.resource.Item; +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.ui.*; import io.anuke.mindustry.ui.fragments.*; import io.anuke.mindustry.world.Tile; @@ -24,7 +24,6 @@ import io.anuke.ucore.function.VisibilityProvider; import io.anuke.ucore.modules.SceneModule; import io.anuke.ucore.scene.Element; import io.anuke.ucore.scene.Skin; -import io.anuke.ucore.scene.actions.Actions; import io.anuke.ucore.scene.builders.build; import io.anuke.ucore.scene.builders.label; import io.anuke.ucore.scene.builders.table; @@ -35,7 +34,7 @@ import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Unit; public class UI extends SceneModule{ - Table itemtable, weapontable, loadingtable, desctable, respawntable, configtable; + Table loadingtable, desctable, configtable; MindustrySettingsDialog prefs; MindustryKeybindDialog keys; Dialog about, restart, levels, upgrades, load, settingserror; @@ -47,7 +46,6 @@ public class UI extends SceneModule{ private Fragment blockfrag = new BlocksFragment(), menufrag = new MenuFragment(), - profilefrag = new ProfilerFragment(), toolfrag = new ToolFragment(), hudfrag = new HudFragment(), placefrag = new PlacementFragment(), @@ -55,8 +53,6 @@ public class UI extends SceneModule{ VisibilityProvider play = () -> !GameState.is(State.menu); VisibilityProvider nplay = () -> GameState.is(State.menu); - - private Array tempItems = new Array<>(); public UI() { Dialog.setShowAction(()-> sequence( @@ -258,8 +254,6 @@ public class UI extends SceneModule{ menufrag.build(); - profilefrag.build(); - placefrag.build(); loadingtable = new table("loadDim"){{ @@ -289,7 +283,7 @@ public class UI extends SceneModule{ } public void fadeRespawn(boolean in){ - respawntable.addAction(Actions.color(in ? new Color(0, 0, 0, 0.3f) : Color.CLEAR, 0.3f)); + ((HudFragment)hudfrag).fadeRespawn(in); } public void showConfig(Tile tile){ @@ -388,23 +382,7 @@ public class UI extends SceneModule{ } public void updateItems(){ - itemtable.clear(); - itemtable.left(); - - tempItems.clear(); - for(Item item : control.getItems().keys()){ - tempItems.add(item); - } - tempItems.sort(); - - for(Item stack : tempItems){ - Image image = new Image(Draw.region("icon-" + stack.name())); - Label label = new Label("" + Mindustry.formatter.format(control.getAmount(stack))); - label.setFontScale(fontscale*1.5f); - itemtable.add(image).size(8*3).units(Unit.dp); - itemtable.add(label).left(); - itemtable.row(); - } + ((HudFragment)hudfrag).updateItems(); } } diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java index 16f6812e2b..7f7a0cb445 100644 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/BulletType.java @@ -2,9 +2,9 @@ package io.anuke.mindustry.entities; import com.badlogic.gdx.graphics.Color; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.entities.effect.DamageArea; import io.anuke.mindustry.entities.effect.EMP; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index fb815137a5..5286def09b 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -7,8 +7,8 @@ import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Recipe; import io.anuke.mindustry.resource.Weapon; import io.anuke.ucore.core.*; diff --git a/core/src/io/anuke/mindustry/entities/TileEntity.java b/core/src/io/anuke/mindustry/entities/TileEntity.java index 887bdf65b2..e7a307935d 100644 --- a/core/src/io/anuke/mindustry/entities/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/TileEntity.java @@ -6,8 +6,8 @@ import java.io.IOException; import com.badlogic.gdx.utils.ObjectMap; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.world.Block; diff --git a/core/src/io/anuke/mindustry/entities/effect/EMP.java b/core/src/io/anuke/mindustry/entities/effect/EMP.java index 2f2a11e859..2f0847c924 100644 --- a/core/src/io/anuke/mindustry/entities/effect/EMP.java +++ b/core/src/io/anuke/mindustry/entities/effect/EMP.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.World; diff --git a/core/src/io/anuke/mindustry/Fx.java b/core/src/io/anuke/mindustry/entities/effect/Fx.java similarity index 99% rename from core/src/io/anuke/mindustry/Fx.java rename to core/src/io/anuke/mindustry/entities/effect/Fx.java index 159ea33268..f305b020a0 100644 --- a/core/src/io/anuke/mindustry/Fx.java +++ b/core/src/io/anuke/mindustry/entities/effect/Fx.java @@ -1,7 +1,8 @@ -package io.anuke.mindustry; +package io.anuke.mindustry.entities.effect; import com.badlogic.gdx.graphics.Color; +import io.anuke.mindustry.Vars; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.graphics.Hue; diff --git a/core/src/io/anuke/mindustry/entities/effect/TeslaOrb.java b/core/src/io/anuke/mindustry/entities/effect/TeslaOrb.java index 1572a21c50..aa8a87e4a8 100644 --- a/core/src/io/anuke/mindustry/entities/effect/TeslaOrb.java +++ b/core/src/io/anuke/mindustry/entities/effect/TeslaOrb.java @@ -5,7 +5,6 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.ObjectSet; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 096bbe84d2..18d4cce344 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -5,13 +5,13 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.reflect.ClassReflection; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Shaders; import io.anuke.mindustry.Vars; import io.anuke.mindustry.ai.Pathfind; import io.anuke.mindustry.entities.Bullet; import io.anuke.mindustry.entities.BulletType; import io.anuke.mindustry.entities.Player; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.World; import io.anuke.ucore.core.*; diff --git a/core/src/io/anuke/mindustry/resource/Weapon.java b/core/src/io/anuke/mindustry/resource/Weapon.java index 5fe88c67eb..395ceb5021 100644 --- a/core/src/io/anuke/mindustry/resource/Weapon.java +++ b/core/src/io/anuke/mindustry/resource/Weapon.java @@ -4,11 +4,11 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.Bullet; import io.anuke.mindustry.entities.BulletType; import io.anuke.mindustry.entities.Player; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.ucore.core.Effects; import io.anuke.ucore.entities.Entity; import io.anuke.ucore.util.Angles; diff --git a/core/src/io/anuke/mindustry/ui/LoadDialog.java b/core/src/io/anuke/mindustry/ui/LoadDialog.java index b7df1b8ee1..0dccf8e5a7 100644 --- a/core/src/io/anuke/mindustry/ui/LoadDialog.java +++ b/core/src/io/anuke/mindustry/ui/LoadDialog.java @@ -4,9 +4,9 @@ import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer.Task; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.io.SaveIO; import io.anuke.ucore.scene.ui.Label; import io.anuke.ucore.scene.ui.TextButton; diff --git a/core/src/io/anuke/mindustry/ui/MenuDialog.java b/core/src/io/anuke/mindustry/ui/MenuDialog.java index d4a48894ef..38a691a062 100644 --- a/core/src/io/anuke/mindustry/ui/MenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/MenuDialog.java @@ -5,9 +5,9 @@ import static io.anuke.mindustry.Vars.ui; import com.badlogic.gdx.Application.ApplicationType; import com.badlogic.gdx.Gdx; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.ucore.scene.ui.ConfirmDialog; import io.anuke.ucore.scene.ui.layout.Cell; import io.anuke.ucore.scene.ui.layout.Unit; diff --git a/core/src/io/anuke/mindustry/ui/UpgradeDialog.java b/core/src/io/anuke/mindustry/ui/UpgradeDialog.java index 63e649a2d2..954b172932 100644 --- a/core/src/io/anuke/mindustry/ui/UpgradeDialog.java +++ b/core/src/io/anuke/mindustry/ui/UpgradeDialog.java @@ -4,9 +4,9 @@ import static io.anuke.mindustry.Vars.*; import com.badlogic.gdx.graphics.Color; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Weapon; import io.anuke.ucore.core.Draw; diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java index 7cbe121784..f7f7ab3261 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java @@ -7,8 +7,8 @@ import com.badlogic.gdx.graphics.Colors; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Recipe; import io.anuke.mindustry.resource.Section; diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 4e3184632a..da90f16e4e 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -4,22 +4,33 @@ import static io.anuke.mindustry.Vars.*; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.Mindustry; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.resource.Item; import io.anuke.ucore.core.Core; +import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Settings; +import io.anuke.ucore.entities.Entities; +import io.anuke.ucore.function.StringSupplier; +import io.anuke.ucore.scene.actions.Actions; import io.anuke.ucore.scene.builders.imagebutton; import io.anuke.ucore.scene.builders.label; import io.anuke.ucore.scene.builders.table; +import io.anuke.ucore.scene.ui.Image; import io.anuke.ucore.scene.ui.Label; import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Unit; +import io.anuke.ucore.util.Profiler; public class HudFragment implements Fragment{ private Table itemtable, respawntable; + private Array tempItems = new Array<>(); public void build(){ + //menu at top left new table(){{ atop(); aleft(); @@ -122,5 +133,50 @@ public class HudFragment implements Fragment{ }}.end(); }}.end(); + + //profiling table + if(debug){ + new table(){{ + abottom(); + aleft(); + new label((StringSupplier)()->"[purple]entities: " + Entities.amount()).left(); + row(); + new label("[red]DEBUG MODE").scale(0.5f).left(); + }}.end(); + + new table(){{ + atop(); + new table("button"){{ + defaults().left().growX(); + atop(); + aleft(); + new label((StringSupplier)()->Profiler.formatDisplayTimes()); + }}.width(400f).end(); + }}.end(); + } + } + + public void updateItems(){ + itemtable.clear(); + itemtable.left(); + + tempItems.clear(); + for(Item item : control.getItems().keys()){ + tempItems.add(item); + } + tempItems.sort(); + + for(Item stack : tempItems){ + Image image = new Image(Draw.region("icon-" + stack.name())); + Label label = new Label("" + Mindustry.formatter.format(control.getAmount(stack))); + label.setFontScale(fontscale*1.5f); + itemtable.add(image).size(8*3).units(Unit.dp); + itemtable.add(label).left(); + itemtable.row(); + } + } + + public void fadeRespawn(boolean in){ + respawntable.addAction(Actions.color(in ? new Color(0, 0, 0, 0.3f) : Color.CLEAR, 0.3f)); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index 9f95337639..0b880c9836 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -4,8 +4,8 @@ import static io.anuke.mindustry.Vars.*; import com.badlogic.gdx.Gdx; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.ui.MenuButton; import io.anuke.mindustry.world.Map; import io.anuke.ucore.scene.builders.imagebutton; diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index a2834b5af0..9d30a0ce45 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -4,8 +4,8 @@ import static io.anuke.mindustry.Vars.*; import com.badlogic.gdx.utils.Align; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.input.AndroidInput; import io.anuke.mindustry.input.PlaceMode; import io.anuke.ucore.scene.builders.imagebutton; diff --git a/core/src/io/anuke/mindustry/ui/fragments/ProfilerFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ProfilerFragment.java deleted file mode 100644 index f8c11fa164..0000000000 --- a/core/src/io/anuke/mindustry/ui/fragments/ProfilerFragment.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.anuke.mindustry.ui.fragments; - -import static io.anuke.mindustry.Vars.debug; - -import io.anuke.mindustry.Profiler; -import io.anuke.ucore.entities.Entities; -import io.anuke.ucore.function.StringSupplier; -import io.anuke.ucore.scene.builders.label; -import io.anuke.ucore.scene.builders.table; - -public class ProfilerFragment implements Fragment{ - - public void build(){ - if(debug){ - new table(){{ - abottom(); - aleft(); - new label((StringSupplier)()->"[purple]entities: " + Entities.amount()).left(); - row(); - new label("[red]DEBUG MODE").scale(0.5f).left(); - }}.end(); - - new table(){{ - atop(); - new table("button"){{ - defaults().left().growX(); - atop(); - aleft(); - new label((StringSupplier)()->"[red]total: " - + String.format("%.1f", (float)Profiler.total/Profiler.total*100f)+ "% - " + Profiler.total).left(); - row(); - new label((StringSupplier)()->"[yellow]draw: " - + String.format("%.1f", (float)Profiler.draw/Profiler.total*100f)+ "% - " + Profiler.draw).left(); - row(); - new label((StringSupplier)()->"[green]blockDraw: " - + String.format("%.1f", (float)Profiler.blockDraw/Profiler.total*100f)+ "% - " + Profiler.blockDraw).left(); - row(); - new label((StringSupplier)()->"[blue]entityDraw: " - + String.format("%.1f", (float)Profiler.entityDraw/Profiler.total*100f)+ "% - " + Profiler.entityDraw).left(); - row(); - new label((StringSupplier)()->"[purple]entityUpdate: " - + String.format("%.1f", (float)Profiler.entityUpdate/Profiler.total*100f)+ "% - " + Profiler.entityUpdate).left(); - row(); - }}.width(400f).end(); - }}.end(); - } - } -} diff --git a/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java index 7a572ae4e8..149719e5d7 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ToolFragment.java @@ -5,8 +5,8 @@ import static io.anuke.mindustry.Vars.*; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.utils.Align; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.input.AndroidInput; import io.anuke.mindustry.input.PlaceMode; import io.anuke.ucore.core.Core; diff --git a/core/src/io/anuke/mindustry/ui/fragments/WeaponFragment.java b/core/src/io/anuke/mindustry/ui/fragments/WeaponFragment.java index 635f3f5503..788b94ff94 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/WeaponFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/WeaponFragment.java @@ -2,8 +2,8 @@ package io.anuke.mindustry.ui.fragments; import static io.anuke.mindustry.Vars.*; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.Weapon; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Draw; diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 32fadbf841..6d2e4dda46 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -4,11 +4,11 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Liquid; diff --git a/core/src/io/anuke/mindustry/world/World.java b/core/src/io/anuke/mindustry/world/World.java index c0b2b5320a..a5fa41e177 100644 --- a/core/src/io/anuke/mindustry/world/World.java +++ b/core/src/io/anuke/mindustry/world/World.java @@ -8,10 +8,10 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.math.*; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; import io.anuke.mindustry.ai.Pathfind; import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.world.blocks.*; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Sounds; diff --git a/core/src/io/anuke/mindustry/world/blocks/Blocks.java b/core/src/io/anuke/mindustry/world/blocks/Blocks.java index bfd48c6914..2dc1cd8612 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Blocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/Blocks.java @@ -1,8 +1,8 @@ package io.anuke.mindustry.world.blocks; -import io.anuke.mindustry.Fx; -import io.anuke.mindustry.GameState; -import io.anuke.mindustry.GameState.State; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Liquid; diff --git a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java index 2ab282f0c7..0104cc81fc 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.world.blocks; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.world.Block; diff --git a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java index d7b3f6fc05..b205926b2d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java @@ -3,9 +3,9 @@ package io.anuke.mindustry.world.blocks; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.effect.TeslaOrb; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.world.Block; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/LaserTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/LaserTurret.java index 7387290ab7..251382ba0c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/LaserTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/LaserTurret.java @@ -3,7 +3,7 @@ package io.anuke.mindustry.world.blocks.types.defense; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.MathUtils; -import io.anuke.mindustry.Fx; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Draw; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java index cb6b26da0e..6fcfbc4a1f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java @@ -8,11 +8,11 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.Bullet; import io.anuke.mindustry.entities.BulletType; import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.world.Block; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java index 87db4f58d6..09b398af2d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java @@ -4,7 +4,7 @@ import java.util.Arrays; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java index 9e51736c4e..9ba52183bb 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java @@ -1,6 +1,6 @@ package io.anuke.mindustry.world.blocks.types.production; -import io.anuke.mindustry.Fx; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java index 2e458f91f9..5217160616 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java @@ -5,8 +5,8 @@ import com.badlogic.gdx.math.GridPoint2; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.World; import io.anuke.mindustry.world.blocks.types.PowerAcceptor; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/ItemPowerGenerator.java b/core/src/io/anuke/mindustry/world/blocks/types/production/ItemPowerGenerator.java index 18be8f261b..3682b51624 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/ItemPowerGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/ItemPowerGenerator.java @@ -2,9 +2,9 @@ package io.anuke.mindustry.world.blocks.types.production; import com.badlogic.gdx.graphics.Color; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Effects; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/LiquidCrafter.java b/core/src/io/anuke/mindustry/world/blocks/types/production/LiquidCrafter.java index 41237c469a..bcb6945e7b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/LiquidCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/LiquidCrafter.java @@ -3,9 +3,9 @@ package io.anuke.mindustry.world.blocks.types.production; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.world.Tile; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/LiquidPowerGenerator.java b/core/src/io/anuke/mindustry/world/blocks/types/production/LiquidPowerGenerator.java index a1c7746f8e..e0a6727d1d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/LiquidPowerGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/LiquidPowerGenerator.java @@ -7,8 +7,8 @@ import java.io.IOException; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Fx; import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.LiquidAcceptor;