debug info, tabs more well defined to be immediategui panels
parent
118f5299df
commit
afa487e78d
|
|
@ -40,6 +40,14 @@ public class HadeanGame extends Game {
|
||||||
private static Runtime runtime = Runtime.getRuntime();
|
private static Runtime runtime = Runtime.getRuntime();
|
||||||
private static Color fontColor = Color.red;
|
private static Color fontColor = Color.red;
|
||||||
|
|
||||||
|
public float getAverageFPS() {
|
||||||
|
return averageFPS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMeasuredFPS() {
|
||||||
|
return measuredFPS;
|
||||||
|
}
|
||||||
|
|
||||||
private void renderDebugInfo() {
|
private void renderDebugInfo() {
|
||||||
|
|
||||||
long allocated = runtime.totalMemory();
|
long allocated = runtime.totalMemory();
|
||||||
|
|
@ -48,11 +56,11 @@ public class HadeanGame extends Game {
|
||||||
int top = 10;
|
int top = 10;
|
||||||
|
|
||||||
List<String> strings = new ArrayList<String>();
|
List<String> strings = new ArrayList<String>();
|
||||||
strings.add(" === [ DEBUG ] ===");
|
// strings.add(" === [ DEBUG ] ===");
|
||||||
strings.add("FPS: " + Math.round(averageFPS) + "/" + measuredFPS + " | AVG/MEASURED");
|
// strings.add("FPS: " + Math.round(averageFPS) + "/" + measuredFPS + " | AVG/MEASURED");
|
||||||
strings.add("Mouse: <" + App.mouseX + ", " + App.mouseY + ">");
|
// strings.add("Mouse: <" + App.mouseX + ", " + App.mouseY + ">");
|
||||||
strings.add("MEMORY: " + (int)((allocated / (double)max) * 100) + "% (" + (allocated / (1024 * 1024)) + "/" + (max / (1024 * 1024)) + "MB)");
|
// strings.add();
|
||||||
strings.add("dTime: " + dTime);
|
// strings.add("dTime: " + dTime);
|
||||||
|
|
||||||
for(String str : strings) {
|
for(String str : strings) {
|
||||||
Assets.flat.pushColor(Color.black);
|
Assets.flat.pushColor(Color.black);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package xyz.valnet.hadean.gameobjects;
|
package xyz.valnet.hadean.gameobjects;
|
||||||
|
|
||||||
import static xyz.valnet.engine.util.Math.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import xyz.valnet.engine.App;
|
import xyz.valnet.engine.App;
|
||||||
|
|
@ -21,6 +19,8 @@ import xyz.valnet.hadean.interfaces.IWorldBoundsAdapter;
|
||||||
import xyz.valnet.hadean.util.Assets;
|
import xyz.valnet.hadean.util.Assets;
|
||||||
import xyz.valnet.hadean.util.Layers;
|
import xyz.valnet.hadean.util.Layers;
|
||||||
|
|
||||||
|
import static xyz.valnet.engine.util.Math.lerp;
|
||||||
|
|
||||||
public class Camera extends GameObject implements ITransient, IMouseCaptureArea {
|
public class Camera extends GameObject implements ITransient, IMouseCaptureArea {
|
||||||
|
|
||||||
private int tileWidth = 16;
|
private int tileWidth = 16;
|
||||||
|
|
@ -43,6 +43,7 @@ public class Camera extends GameObject implements ITransient, IMouseCaptureArea
|
||||||
return screen2world(App.mouseX, App.mouseY);
|
return screen2world(App.mouseX, App.mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(float dTime) {
|
public void update(float dTime) {
|
||||||
Vector2f direction = Vector2f.zero;
|
Vector2f direction = Vector2f.zero;
|
||||||
if(dragOrigin == null) {
|
if(dragOrigin == null) {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,7 @@ import java.util.Map;
|
||||||
import xyz.valnet.engine.graphics.Color;
|
import xyz.valnet.engine.graphics.Color;
|
||||||
import xyz.valnet.engine.graphics.Drawing;
|
import xyz.valnet.engine.graphics.Drawing;
|
||||||
import xyz.valnet.engine.math.Vector2i;
|
import xyz.valnet.engine.math.Vector2i;
|
||||||
import xyz.valnet.engine.math.Vector4f;
|
|
||||||
import xyz.valnet.engine.scenegraph.GameObject;
|
import xyz.valnet.engine.scenegraph.GameObject;
|
||||||
import xyz.valnet.engine.scenegraph.IMouseCaptureArea;
|
|
||||||
import xyz.valnet.hadean.designation.CutTreesDesignation;
|
import xyz.valnet.hadean.designation.CutTreesDesignation;
|
||||||
import xyz.valnet.hadean.designation.HaulItemDesignation;
|
import xyz.valnet.hadean.designation.HaulItemDesignation;
|
||||||
import xyz.valnet.hadean.gameobjects.BottomBar;
|
import xyz.valnet.hadean.gameobjects.BottomBar;
|
||||||
|
|
@ -23,9 +21,6 @@ import xyz.valnet.hadean.gameobjects.worldobjects.Stockpile;
|
||||||
import xyz.valnet.hadean.gameobjects.worldobjects.constructions.Bed;
|
import xyz.valnet.hadean.gameobjects.worldobjects.constructions.Bed;
|
||||||
import xyz.valnet.hadean.gameobjects.worldobjects.constructions.Quarry;
|
import xyz.valnet.hadean.gameobjects.worldobjects.constructions.Quarry;
|
||||||
import xyz.valnet.hadean.gameobjects.worldobjects.constructions.Wall;
|
import xyz.valnet.hadean.gameobjects.worldobjects.constructions.Wall;
|
||||||
import xyz.valnet.hadean.input.Button;
|
|
||||||
import xyz.valnet.hadean.input.IButtonListener;
|
|
||||||
import xyz.valnet.hadean.input.SimpleButton;
|
|
||||||
import xyz.valnet.hadean.interfaces.BuildableMetadata;
|
import xyz.valnet.hadean.interfaces.BuildableMetadata;
|
||||||
import xyz.valnet.hadean.interfaces.IBuildLayerListener;
|
import xyz.valnet.hadean.interfaces.IBuildLayerListener;
|
||||||
import xyz.valnet.hadean.interfaces.IBuildable;
|
import xyz.valnet.hadean.interfaces.IBuildable;
|
||||||
|
|
@ -33,7 +28,6 @@ import xyz.valnet.hadean.interfaces.ISelectable;
|
||||||
import xyz.valnet.hadean.interfaces.ISelectionChangeListener;
|
import xyz.valnet.hadean.interfaces.ISelectionChangeListener;
|
||||||
import xyz.valnet.hadean.util.Assets;
|
import xyz.valnet.hadean.util.Assets;
|
||||||
import xyz.valnet.hadean.util.Layers;
|
import xyz.valnet.hadean.util.Layers;
|
||||||
import xyz.valnet.hadean.util.SmartBoolean;
|
|
||||||
|
|
||||||
import static xyz.valnet.engine.util.Math.lerp;
|
import static xyz.valnet.engine.util.Math.lerp;
|
||||||
|
|
||||||
|
|
@ -43,8 +37,6 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
private BuildLayer buildLayer;
|
private BuildLayer buildLayer;
|
||||||
private Camera camera;
|
private Camera camera;
|
||||||
|
|
||||||
private boolean opened;
|
|
||||||
|
|
||||||
private int x, y;
|
private int x, y;
|
||||||
private int w, h;
|
private int w, h;
|
||||||
|
|
||||||
|
|
@ -53,8 +45,6 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
private static transient Map<String, List<BuildableRecord>> buildables = new HashMap<String, List<BuildableRecord>>();
|
private static transient Map<String, List<BuildableRecord>> buildables = new HashMap<String, List<BuildableRecord>>();
|
||||||
private transient BuildableRecord selectedBuildable = null;
|
private transient BuildableRecord selectedBuildable = null;
|
||||||
|
|
||||||
private float openness = 0;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BuildTab.registerBuildable(HaulItemDesignation.class);
|
BuildTab.registerBuildable(HaulItemDesignation.class);
|
||||||
BuildTab.registerBuildable(CutTreesDesignation.class);
|
BuildTab.registerBuildable(CutTreesDesignation.class);
|
||||||
|
|
@ -138,11 +128,6 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(float dTime) {
|
|
||||||
openness = lerp(openness, opened ? 1 : 0, dTime / 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rightClickOnWorld() {
|
public void rightClickOnWorld() {
|
||||||
if(selectedBuildable != null) {
|
if(selectedBuildable != null) {
|
||||||
selectBuildable(null);
|
selectBuildable(null);
|
||||||
|
|
@ -210,30 +195,10 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
@Override
|
@Override
|
||||||
public void selectionChanged(List<ISelectable> selected) {
|
public void selectionChanged(List<ISelectable> selected) {
|
||||||
if(selected.isEmpty()) return;
|
if(selected.isEmpty()) return;
|
||||||
opened = false;
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void reset() {
|
||||||
public void evoke() {
|
|
||||||
if(opened) close();
|
|
||||||
else open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void open() {
|
|
||||||
if(opened) return;
|
|
||||||
Assets.sndBubble.play();
|
|
||||||
opened = true;
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
if(!opened) return;
|
|
||||||
Assets.sndCancel.play();
|
|
||||||
opened = false;
|
|
||||||
buildLayer.deactiveate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
|
||||||
selectBuildable(null);
|
selectBuildable(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,22 +212,12 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
return "Build";
|
return "Build";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayer() {
|
|
||||||
return Layers.GENERAL_UI;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isButtonClickSilent() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void gui() {
|
public void gui() {
|
||||||
if(openness < 0.0001f) return;
|
if(!shouldRender()) return;
|
||||||
|
|
||||||
int height = 8 + 16 + 8 + buildables.size() * (32 + 8);
|
int height = 8 + 16 + 8 + buildables.size() * (32 + 8);
|
||||||
|
|
||||||
window((int) lerp(-180, 0, openness), 576 - BottomBar.bottomBarHeight - height + 1, 150, height, () -> {
|
window(animate(-180, 0), 576 - BottomBar.bottomBarHeight - height + 1, 150, height, () -> {
|
||||||
text("Build");
|
text("Build");
|
||||||
|
|
||||||
for(String category : buildables.keySet()) {
|
for(String category : buildables.keySet()) {
|
||||||
|
|
@ -277,7 +232,7 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window(149, (int) lerp(576 + 50, 576 - BottomBar.bottomBarHeight - 16 - 32 + 1 - 24, openness), 875, 48 + 24, () -> {
|
window(149, animate(576 + 50, 576 - BottomBar.bottomBarHeight - 16 - 32 + 1 - 24), 875, 48 + 24, () -> {
|
||||||
if(selectedCategory == null) {
|
if(selectedCategory == null) {
|
||||||
space(20);
|
space(20);
|
||||||
text(" Select a Category...");
|
text(" Select a Category...");
|
||||||
|
|
@ -295,4 +250,14 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onClose() {
|
||||||
|
buildLayer.deactiveate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onOpen() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,49 @@
|
||||||
package xyz.valnet.hadean.gameobjects.ui.tabs;
|
package xyz.valnet.hadean.gameobjects.ui.tabs;
|
||||||
|
|
||||||
|
import xyz.valnet.engine.App;
|
||||||
import xyz.valnet.hadean.HadeanGame;
|
import xyz.valnet.hadean.HadeanGame;
|
||||||
|
import xyz.valnet.hadean.gameobjects.BottomBar;
|
||||||
|
|
||||||
public class DebugTab extends Tab {
|
public class DebugTab extends Tab {
|
||||||
|
|
||||||
@Override
|
private int width = 250;
|
||||||
public void evoke() {
|
private static Runtime runtime = Runtime.getRuntime();
|
||||||
HadeanGame.debugView = !HadeanGame.debugView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTabName() {
|
public String getTabName() {
|
||||||
return "Toggle Debug";
|
return "Toggle Debug";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onClose() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onOpen() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void gui() {
|
||||||
|
if(!shouldRender()) return;
|
||||||
|
|
||||||
|
window(animate(1200, 1024 - width), 0, width, 576 - BottomBar.bottomBarHeight + 1, () -> {
|
||||||
|
text("Debug");
|
||||||
|
space(8);
|
||||||
|
|
||||||
|
text(System.getProperty("java.runtime.name"));
|
||||||
|
space(8);
|
||||||
|
text(System.getProperty("java.version"));
|
||||||
|
space(8);
|
||||||
|
|
||||||
|
long allocated = runtime.totalMemory();
|
||||||
|
long max = runtime.maxMemory();
|
||||||
|
|
||||||
|
text("MEMORY: " + (int)((allocated / (double)max) * 100) + "% (" + (allocated / (1024 * 1024)) + "/" + (max / (1024 * 1024)) + "MB)");
|
||||||
|
space(8);
|
||||||
|
|
||||||
|
if(button("Debug: " + (HadeanGame.debugView ? "on" : "off"))) {
|
||||||
|
HadeanGame.debugView = !HadeanGame.debugView;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,24 @@ package xyz.valnet.hadean.gameobjects.ui.tabs;
|
||||||
|
|
||||||
import xyz.valnet.engine.graphics.ImmediateUI;
|
import xyz.valnet.engine.graphics.ImmediateUI;
|
||||||
import xyz.valnet.engine.scenegraph.ITransient;
|
import xyz.valnet.engine.scenegraph.ITransient;
|
||||||
|
import static xyz.valnet.engine.util.Math.lerp;
|
||||||
import xyz.valnet.hadean.gameobjects.BottomBar;
|
import xyz.valnet.hadean.gameobjects.BottomBar;
|
||||||
import xyz.valnet.hadean.interfaces.IBottomBarItem;
|
import xyz.valnet.hadean.interfaces.IBottomBarItem;
|
||||||
|
import xyz.valnet.hadean.util.Assets;
|
||||||
|
import xyz.valnet.hadean.util.Layers;
|
||||||
|
|
||||||
public abstract class Tab extends ImmediateUI implements IBottomBarItem, ITransient {
|
public abstract class Tab extends ImmediateUI implements IBottomBarItem, ITransient {
|
||||||
|
|
||||||
private BottomBar bottombar;
|
private BottomBar bottombar;
|
||||||
|
|
||||||
|
protected boolean opened = false;
|
||||||
|
private float animation = 0f;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(float dTime) {
|
||||||
|
animation = lerp(animation, opened ? 1 : 0, dTime / 20);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void connect() {
|
protected void connect() {
|
||||||
bottombar = get(BottomBar.class);
|
bottombar = get(BottomBar.class);
|
||||||
|
|
@ -20,9 +31,43 @@ public abstract class Tab extends ImmediateUI implements IBottomBarItem, ITransi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isButtonClickSilent() {
|
public final boolean isButtonClickSilent() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gui() {}
|
@Override
|
||||||
|
public final float getLayer() {
|
||||||
|
return Layers.GENERAL_UI;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final boolean shouldRender() {
|
||||||
|
return opened || animation > 0.0001f;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final int animate(float a, float b) {
|
||||||
|
return (int)Math.round(lerp(a, b, animation));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void evoke() {
|
||||||
|
if(opened) close();
|
||||||
|
else open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void open() {
|
||||||
|
if(opened) return;
|
||||||
|
Assets.sndBubble.play();
|
||||||
|
opened = true;
|
||||||
|
onOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void close() {
|
||||||
|
if(!opened) return;
|
||||||
|
Assets.sndCancel.play();
|
||||||
|
opened = false;
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void onClose();
|
||||||
|
protected abstract void onOpen();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,10 @@ public class GameScene extends SceneGraph {
|
||||||
|
|
||||||
objects.add(new BottomBar());
|
objects.add(new BottomBar());
|
||||||
objects.add(new BuildTab());
|
objects.add(new BuildTab());
|
||||||
objects.add(new JobBoardTab());
|
// objects.add(new JobBoardTab());
|
||||||
objects.add(new DebugTab());
|
objects.add(new DebugTab());
|
||||||
objects.add(new SaveTab());
|
// objects.add(new SaveTab());
|
||||||
objects.add(new LoadTab());
|
// objects.add(new LoadTab());
|
||||||
|
|
||||||
// objects.add(new Popup());
|
// objects.add(new Popup());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue