mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-11-11 14:56:10 +03:00
More description changes, changed profiler, core refactoring
This commit is contained in:
parent
a71a82c10b
commit
f0e5477346
@ -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"
|
||||
}
|
||||
|
@ -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<String> 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");
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -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.*;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<Tile> request = new PathFinderRequest<Tile>();
|
||||
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);
|
||||
|
@ -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){
|
@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry;
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
public class GameState{
|
||||
private static State state = State.menu;
|
@ -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();
|
||||
|
@ -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<Item> 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();
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
@ -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.*;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
@ -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;
|
||||
|
@ -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.*;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<Item> 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));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user