debug logger
parent
b1171ed4eb
commit
8bcc7b0714
|
|
@ -92,7 +92,6 @@ public class App {
|
||||||
});
|
});
|
||||||
|
|
||||||
glfwSetScrollCallback(window, (long window, double xOffset, double yOffset) -> {
|
glfwSetScrollCallback(window, (long window, double xOffset, double yOffset) -> {
|
||||||
DebugTab.log("Scroll " + yOffset);
|
|
||||||
if(yOffset > 0)
|
if(yOffset > 0)
|
||||||
game.scrollUp();
|
game.scrollUp();
|
||||||
else if(yOffset < 0)
|
else if(yOffset < 0)
|
||||||
|
|
@ -114,7 +113,8 @@ public class App {
|
||||||
if(button == GLFW_MOUSE_BUTTON_LEFT) { mouseLeft = action == 1; return; }
|
if(button == GLFW_MOUSE_BUTTON_LEFT) { mouseLeft = action == 1; return; }
|
||||||
if(button == GLFW_MOUSE_BUTTON_RIGHT) { mouseRight = action == 1; return; }
|
if(button == GLFW_MOUSE_BUTTON_RIGHT) { mouseRight = action == 1; return; }
|
||||||
if(button == GLFW_MOUSE_BUTTON_MIDDLE) { mouseMiddle = action == 1; return ; }
|
if(button == GLFW_MOUSE_BUTTON_MIDDLE) { mouseMiddle = action == 1; return ; }
|
||||||
System.out.println("Mouse: action " + action + " : button " + button);
|
|
||||||
|
DebugTab.log("Mouse: action " + action + " : button " + button);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the thread stack and push a new frame
|
// Get the thread stack and push a new frame
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package xyz.valnet.engine.graphics;
|
package xyz.valnet.engine.graphics;
|
||||||
|
|
||||||
public class Color {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Color implements Serializable {
|
||||||
public final float r, g, b, a;
|
public final float r, g, b, a;
|
||||||
|
|
||||||
public static Color black = new Color(0, 0, 0);
|
public static Color black = new Color(0, 0, 0);
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ public abstract class ImmediateUI extends GameObject implements IMouseCaptureAre
|
||||||
|
|
||||||
private Button getButton(String id) {
|
private Button getButton(String id) {
|
||||||
if(hasButton(id)) return buttons.get(id);
|
if(hasButton(id)) return buttons.get(id);
|
||||||
System.out.println("Created new Button");
|
|
||||||
Button btn = new Button(Assets.uiFrame, "", 0, 0, 0, 0, 0);
|
Button btn = new Button(Assets.uiFrame, "", 0, 0, 0, 0, 0);
|
||||||
btn.registerClickListener((target) -> {
|
btn.registerClickListener((target) -> {
|
||||||
if(!clicks.containsKey(target)) clicks.put(target, 0);
|
if(!clicks.containsKey(target)) clicks.put(target, 0);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package xyz.valnet.engine.math;
|
package xyz.valnet.engine.math;
|
||||||
|
|
||||||
public class Box {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Box implements Serializable {
|
||||||
|
|
||||||
public final float x, y, w, h, x2, y2;
|
public final float x, y, w, h, x2, y2;
|
||||||
public final Vector2f a, b;
|
public final Vector2f a, b;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import java.io.InputStream;
|
||||||
import java.io.InvalidClassException;
|
import java.io.InvalidClassException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectStreamClass;
|
import java.io.ObjectStreamClass;
|
||||||
|
|
||||||
|
import xyz.valnet.hadean.gameobjects.ui.tabs.DebugTab;
|
||||||
|
|
||||||
public class CustomObjectDeserializer extends ObjectInputStream {
|
public class CustomObjectDeserializer extends ObjectInputStream {
|
||||||
|
|
||||||
|
|
@ -20,8 +22,8 @@ public class CustomObjectDeserializer extends ObjectInputStream {
|
||||||
try {
|
try {
|
||||||
localClass = Class.forName(resultClassDescriptor.getName());
|
localClass = Class.forName(resultClassDescriptor.getName());
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
System.out.println("No local class for " + resultClassDescriptor.getName());
|
DebugTab.log("No local class for " + resultClassDescriptor.getName());
|
||||||
System.out.println(e);
|
DebugTab.log(e);
|
||||||
return resultClassDescriptor;
|
return resultClassDescriptor;
|
||||||
}
|
}
|
||||||
ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
|
ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
|
||||||
|
|
@ -33,8 +35,8 @@ public class CustomObjectDeserializer extends ObjectInputStream {
|
||||||
s.append("local serialVersionUID = ").append(localSUID);
|
s.append("local serialVersionUID = ").append(localSUID);
|
||||||
s.append(" stream serialVersionUID = ").append(streamSUID);
|
s.append(" stream serialVersionUID = ").append(streamSUID);
|
||||||
Exception e = new InvalidClassException(s.toString());
|
Exception e = new InvalidClassException(s.toString());
|
||||||
System.out.println("Potentially Fatal Deserialization Operation.");
|
DebugTab.log("Potentially Fatal Deserialization Operation.");
|
||||||
System.out.println(e);
|
DebugTab.log(e);
|
||||||
resultClassDescriptor = localClassDescriptor; // Use local class descriptor for deserialization
|
resultClassDescriptor = localClassDescriptor; // Use local class descriptor for deserialization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import java.util.stream.Collectors;
|
||||||
import xyz.valnet.engine.App;
|
import xyz.valnet.engine.App;
|
||||||
import xyz.valnet.engine.math.Box;
|
import xyz.valnet.engine.math.Box;
|
||||||
import xyz.valnet.engine.math.Vector4f;
|
import xyz.valnet.engine.math.Vector4f;
|
||||||
|
import xyz.valnet.hadean.gameobjects.ui.tabs.DebugTab;
|
||||||
|
|
||||||
public abstract class SceneGraph implements IScene {
|
public abstract class SceneGraph implements IScene {
|
||||||
protected final List<GameObject> objects = new ArrayList<GameObject>();
|
protected final List<GameObject> objects = new ArrayList<GameObject>();
|
||||||
|
|
@ -159,7 +160,7 @@ public abstract class SceneGraph implements IScene {
|
||||||
|
|
||||||
public void dump() {
|
public void dump() {
|
||||||
for(GameObject go : objects)
|
for(GameObject go : objects)
|
||||||
System.out.println(go);
|
DebugTab.log(go);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dump(List<GameObject> objects) {
|
private void dump(List<GameObject> objects) {
|
||||||
|
|
@ -171,7 +172,7 @@ public abstract class SceneGraph implements IScene {
|
||||||
count.put(clazz, count.get(clazz) + 1);
|
count.put(clazz, count.get(clazz) + 1);
|
||||||
}
|
}
|
||||||
for(Entry<Class<? extends GameObject>, Integer> entry : count.entrySet()) {
|
for(Entry<Class<? extends GameObject>, Integer> entry : count.entrySet()) {
|
||||||
System.out.println("" + entry.getValue() + "x " + entry.getKey().getSimpleName());
|
DebugTab.log("" + entry.getValue() + "x " + entry.getKey().getSimpleName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,15 +187,15 @@ public abstract class SceneGraph implements IScene {
|
||||||
FileOutputStream file = new FileOutputStream("SAVE_DATA.TXT");
|
FileOutputStream file = new FileOutputStream("SAVE_DATA.TXT");
|
||||||
ObjectOutputStream out = new ObjectOutputStream(file);
|
ObjectOutputStream out = new ObjectOutputStream(file);
|
||||||
ArrayList<GameObject> toSave = getNonTransientObjects();
|
ArrayList<GameObject> toSave = getNonTransientObjects();
|
||||||
System.out.println("=== [ SAVING ] ===");
|
DebugTab.log("=== [ SAVING ] ===");
|
||||||
dump(toSave);
|
dump(toSave);
|
||||||
out.writeObject(toSave);
|
out.writeObject(toSave);
|
||||||
out.close();
|
out.close();
|
||||||
file.close();
|
file.close();
|
||||||
System.out.println("=== [ SAVED ] ===");
|
DebugTab.log("=== [ SAVED ] ===");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("=== [ FAILED ] ===");
|
DebugTab.log("=== [ FAILED ] ===");
|
||||||
}
|
}
|
||||||
saveFlag = false;
|
saveFlag = false;
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +208,7 @@ public abstract class SceneGraph implements IScene {
|
||||||
List<GameObject> newObjects = (List<GameObject>) input.readObject();
|
List<GameObject> newObjects = (List<GameObject>) input.readObject();
|
||||||
input.close();
|
input.close();
|
||||||
file.close();
|
file.close();
|
||||||
System.out.println("imported " + newObjects.size() + " objects");
|
DebugTab.log("imported " + newObjects.size() + " objects");
|
||||||
ArrayList<GameObject> toRemove = getNonTransientObjects();
|
ArrayList<GameObject> toRemove = getNonTransientObjects();
|
||||||
|
|
||||||
for(GameObject obj : toRemove) {
|
for(GameObject obj : toRemove) {
|
||||||
|
|
@ -251,7 +252,7 @@ public abstract class SceneGraph implements IScene {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void keyPress(int key) {
|
public final void keyPress(int key) {
|
||||||
System.out.println("keyCode: " + key);
|
DebugTab.log("keyCode: " + key);
|
||||||
keys.add(key);
|
keys.add(key);
|
||||||
for(IKeyboardListener ikbl : getAll(IKeyboardListener.class)) {
|
for(IKeyboardListener ikbl : getAll(IKeyboardListener.class)) {
|
||||||
ikbl.keyPress(key);
|
ikbl.keyPress(key);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package xyz.valnet.hadean;
|
||||||
|
|
||||||
|
public class Constants {
|
||||||
|
public static final float animationSpeed = 20;
|
||||||
|
}
|
||||||
|
|
@ -61,8 +61,7 @@ public class Camera extends GameObject implements ITransient, IMouseCaptureArea
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2f move = direction.normalize().multiply(dTime / 5f);
|
Vector2f move = direction.normalize().multiply(dTime / 5f);
|
||||||
// move = Vector2f.east;
|
|
||||||
// System.out.println(move);
|
|
||||||
focus = focus.add(move);
|
focus = focus.add(move);
|
||||||
} else {
|
} else {
|
||||||
Vector2f dragDifference = screen2world(App.mouseX, App.mouseY).subtract(focus);
|
Vector2f dragDifference = screen2world(App.mouseX, App.mouseY).subtract(focus);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package xyz.valnet.hadean.gameobjects;
|
package xyz.valnet.hadean.gameobjects;
|
||||||
|
|
||||||
|
import static xyz.valnet.engine.util.Math.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
@ -9,16 +11,16 @@ import java.util.Set;
|
||||||
import xyz.valnet.engine.graphics.IModalUI;
|
import xyz.valnet.engine.graphics.IModalUI;
|
||||||
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 xyz.valnet.hadean.Constants;
|
||||||
import xyz.valnet.hadean.gameobjects.inputlayer.SelectionLayer;
|
import xyz.valnet.hadean.gameobjects.inputlayer.SelectionLayer;
|
||||||
import xyz.valnet.hadean.gameobjects.ui.ExclusivityManager;
|
import xyz.valnet.hadean.gameobjects.ui.ExclusivityManager;
|
||||||
import xyz.valnet.hadean.interfaces.ISelectable;
|
import xyz.valnet.hadean.interfaces.ISelectable;
|
||||||
import xyz.valnet.hadean.interfaces.ISelectionChangeListener;
|
import xyz.valnet.hadean.interfaces.ISelectionChangeListener;
|
||||||
import xyz.valnet.hadean.util.Action;
|
import xyz.valnet.hadean.util.Action;
|
||||||
|
import xyz.valnet.hadean.util.Assets;
|
||||||
import xyz.valnet.hadean.util.Layers;
|
import xyz.valnet.hadean.util.Layers;
|
||||||
import xyz.valnet.hadean.util.detail.Detail;
|
import xyz.valnet.hadean.util.detail.Detail;
|
||||||
|
|
||||||
import static xyz.valnet.engine.util.Math.lerp;
|
|
||||||
|
|
||||||
public class SelectionUI extends ImmediateUI implements ISelectionChangeListener, ITransient, IModalUI {
|
public class SelectionUI extends ImmediateUI implements ISelectionChangeListener, ITransient, IModalUI {
|
||||||
|
|
||||||
private class SelectedByType extends HashMap<Class<? extends ISelectable>, List<ISelectable>> {}
|
private class SelectedByType extends HashMap<Class<? extends ISelectable>, List<ISelectable>> {}
|
||||||
|
|
@ -33,7 +35,7 @@ public class SelectionUI extends ImmediateUI implements ISelectionChangeListener
|
||||||
private SelectionLayer selectionManager;
|
private SelectionLayer selectionManager;
|
||||||
|
|
||||||
private final int width = 300, height = 200;
|
private final int width = 300, height = 200;
|
||||||
private final int padding = 10;
|
private final int padding = 0;
|
||||||
|
|
||||||
private boolean opened = false;
|
private boolean opened = false;
|
||||||
private float openness = 0f;
|
private float openness = 0f;
|
||||||
|
|
@ -55,7 +57,7 @@ public class SelectionUI extends ImmediateUI implements ISelectionChangeListener
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float dTime) {
|
public void update(float dTime) {
|
||||||
openness = lerp(openness, opened ? 1 : 0, dTime / 20);
|
openness = lerp(openness, opened ? 1 : 0, dTime / Constants.animationSpeed);
|
||||||
if(newSelection != null) {
|
if(newSelection != null) {
|
||||||
selectionManager.updateSelection(newSelection);
|
selectionManager.updateSelection(newSelection);
|
||||||
newSelection = null;
|
newSelection = null;
|
||||||
|
|
@ -75,6 +77,10 @@ public class SelectionUI extends ImmediateUI implements ISelectionChangeListener
|
||||||
@Override
|
@Override
|
||||||
public void selectionChanged(List<ISelectable> newSelection) {
|
public void selectionChanged(List<ISelectable> newSelection) {
|
||||||
|
|
||||||
|
if(selected.size() != 0 && newSelection.size() != 0) {
|
||||||
|
Assets.sndBubble.play();
|
||||||
|
}
|
||||||
|
|
||||||
if(newSelection.size() == 0) {
|
if(newSelection.size() == 0) {
|
||||||
close();
|
close();
|
||||||
return;
|
return;
|
||||||
|
|
@ -109,7 +115,6 @@ public class SelectionUI extends ImmediateUI implements ISelectionChangeListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private int animate(int a, int b) {
|
private int animate(int a, int b) {
|
||||||
System.out.println(openness);
|
|
||||||
return (int) Math.round(lerp(a, b, openness));
|
return (int) Math.round(lerp(a, b, openness));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +123,8 @@ public class SelectionUI extends ImmediateUI implements ISelectionChangeListener
|
||||||
// if(selected.isEmpty()) return;
|
// if(selected.isEmpty()) return;
|
||||||
if(!opened && openness <= 0.0001f) return;
|
if(!opened && openness <= 0.0001f) return;
|
||||||
|
|
||||||
window(animate(-width - 50, padding), 576 - padding - height - BottomBar.bottomBarHeight, width, height, () -> {
|
// main window
|
||||||
|
window(animate(-width - 50, 0), 576 - height - BottomBar.bottomBarHeight + 1, width, height, () -> {
|
||||||
if(selectedByType.size() == 1) {
|
if(selectedByType.size() == 1) {
|
||||||
if(selectedCount == 1) {
|
if(selectedCount == 1) {
|
||||||
text(properName);
|
text(properName);
|
||||||
|
|
@ -151,8 +157,9 @@ public class SelectionUI extends ImmediateUI implements ISelectionChangeListener
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(selectedByType.size() == 1) {
|
// actions
|
||||||
root(padding * 2 + width, 576 - 32 - padding - BottomBar.bottomBarHeight, 1000, 32, () -> {
|
window(width - 1, animate(576 + 50, 576 - 48 - BottomBar.bottomBarHeight + 1), 1024 - width + 1, 48, () -> {
|
||||||
|
if(selectedByType.size() == 1) {
|
||||||
horizontal(() -> {
|
horizontal(() -> {
|
||||||
for(Action action : actions) {
|
for(Action action : actions) {
|
||||||
if(button(action.name)) {
|
if(button(action.name)) {
|
||||||
|
|
@ -163,8 +170,11 @@ public class SelectionUI extends ImmediateUI implements ISelectionChangeListener
|
||||||
space(8);
|
space(8);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
}
|
space(8);
|
||||||
|
text(" Select an Item Type");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,6 @@ public class SelectionLayer extends GameObject implements IMouseCaptureArea, ITr
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastSelectionChanged() {
|
private void broadcastSelectionChanged() {
|
||||||
// Assets.sndSelectionChanged.play();
|
|
||||||
if(selected.size() > 0) Assets.sndBubble.play();
|
|
||||||
if(selected.size() == 0) Assets.sndCancel.play();
|
|
||||||
|
|
||||||
for(ISelectionChangeListener listener : listeners) {
|
for(ISelectionChangeListener listener : listeners) {
|
||||||
listener.selectionChanged(selected);
|
listener.selectionChanged(selected);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.valnet.hadean.gameobjects.ui;
|
package xyz.valnet.hadean.gameobjects.ui;
|
||||||
|
|
||||||
import xyz.valnet.engine.graphics.ImmediateUI;
|
import xyz.valnet.engine.graphics.ImmediateUI;
|
||||||
|
import xyz.valnet.hadean.gameobjects.ui.tabs.DebugTab;
|
||||||
|
|
||||||
public class Popup extends ImmediateUI {
|
public class Popup extends ImmediateUI {
|
||||||
|
|
||||||
|
|
@ -24,7 +25,7 @@ public class Popup extends ImmediateUI {
|
||||||
text("But not this...");
|
text("But not this...");
|
||||||
|
|
||||||
if(button("Click Me!")) {
|
if(button("Click Me!")) {
|
||||||
System.out.println("The Event!");
|
DebugTab.log("The Event!");
|
||||||
}
|
}
|
||||||
|
|
||||||
text("This after button...");
|
text("This after button...");
|
||||||
|
|
|
||||||
|
|
@ -69,13 +69,13 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
try {
|
try {
|
||||||
BuildableMetadata annotation = clazz.getAnnotation(BuildableMetadata.class);
|
BuildableMetadata annotation = clazz.getAnnotation(BuildableMetadata.class);
|
||||||
if(annotation == null) {
|
if(annotation == null) {
|
||||||
System.out.println(clazz + " has no buildable data annotation");
|
DebugTab.log(clazz + " has no buildable data annotation");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Constructor<? extends IBuildable> constructor = (Constructor<? extends IBuildable>) clazz.getConstructor();
|
Constructor<? extends IBuildable> constructor = (Constructor<? extends IBuildable>) clazz.getConstructor();
|
||||||
if(constructor.getParameterCount() != 0) {
|
if(constructor.getParameterCount() != 0) {
|
||||||
System.out.println(clazz + " has no default constructor (no params)");
|
DebugTab.log(clazz + " has no default constructor (no params)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
String name = annotation.name();
|
String name = annotation.name();
|
||||||
BuildableMetadata.Type type = annotation.type();
|
BuildableMetadata.Type type = annotation.type();
|
||||||
|
|
||||||
System.out.println("Added " + category + " / " + name);
|
DebugTab.log("Added " + category + " / " + name);
|
||||||
|
|
||||||
if(!buildables.containsKey(category))
|
if(!buildables.containsKey(category))
|
||||||
buildables.put(category, new ArrayList<BuildableRecord>());
|
buildables.put(category, new ArrayList<BuildableRecord>());
|
||||||
|
|
@ -166,7 +166,7 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
}
|
}
|
||||||
building.buildAt(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
|
building.buildAt(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e);
|
DebugTab.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,7 +180,7 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IBuildLay
|
||||||
}
|
}
|
||||||
building.buildAt(x1, y1);
|
building.buildAt(x1, y1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e);
|
DebugTab.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class DebugTab extends Tab implements IKeyboardListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTabName() {
|
public String getTabName() {
|
||||||
return "Toggle Debug";
|
return "Debug";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -67,6 +67,10 @@ public class DebugTab extends Tab implements IKeyboardListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void log(Object obj) {
|
||||||
|
log(obj.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyPress(int code) {
|
public void keyPress(int code) {
|
||||||
if(code == 96) { // tilde
|
if(code == 96) { // tilde
|
||||||
|
|
|
||||||
|
|
@ -72,4 +72,22 @@ public class JobBoardTab extends Tab implements ISelectionChangeListener {
|
||||||
public String getTabName() {
|
public String getTabName() {
|
||||||
return "Jobs";
|
return "Jobs";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onClose() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onOpen() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void gui() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package xyz.valnet.hadean.gameobjects.ui.tabs;
|
|
||||||
|
|
||||||
public class LoadTab extends Tab {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void evoke() {
|
|
||||||
load();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTabName() {
|
|
||||||
return "Load";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -2,28 +2,51 @@ package xyz.valnet.hadean.gameobjects.ui.tabs;
|
||||||
|
|
||||||
public class MenuTab extends Tab {
|
public class MenuTab extends Tab {
|
||||||
|
|
||||||
|
private int width = 300;
|
||||||
|
private int height = 6 * 32 + 9 * 8;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onClose() {
|
protected void onClose() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onOpen() {
|
protected void onOpen() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void gui() {
|
protected void gui() {
|
||||||
// TODO Auto-generated method stub
|
window(1024 / 2 - width / 2, animate(-height - 50, 576 / 2 - height / 2), width, height, () -> {
|
||||||
|
if(button("Options")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
space(8);
|
||||||
|
if(button("Debug")) {
|
||||||
|
get(DebugTab.class).open();
|
||||||
|
}
|
||||||
|
space(8);
|
||||||
|
if(button("Save")) {
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
space(8);
|
||||||
|
if(button("Load")) {
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
space(24);
|
||||||
|
if(button("Main Menu")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
space(8);
|
||||||
|
if(button("Quit to Desktop")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTabName() {
|
public String getTabName() {
|
||||||
// TODO Auto-generated method stub
|
return "Menu";
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package xyz.valnet.hadean.gameobjects.ui.tabs;
|
|
||||||
|
|
||||||
public class SaveTab extends Tab {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void evoke() {
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTabName() {
|
|
||||||
return "Save";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -5,6 +5,7 @@ import static xyz.valnet.engine.util.Math.lerp;
|
||||||
import xyz.valnet.engine.graphics.IModalUI;
|
import xyz.valnet.engine.graphics.IModalUI;
|
||||||
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 xyz.valnet.hadean.Constants;
|
||||||
import xyz.valnet.hadean.gameobjects.BottomBar;
|
import xyz.valnet.hadean.gameobjects.BottomBar;
|
||||||
import xyz.valnet.hadean.gameobjects.ui.ExclusivityManager;
|
import xyz.valnet.hadean.gameobjects.ui.ExclusivityManager;
|
||||||
import xyz.valnet.hadean.interfaces.IBottomBarItem;
|
import xyz.valnet.hadean.interfaces.IBottomBarItem;
|
||||||
|
|
@ -21,7 +22,7 @@ public abstract class Tab extends ImmediateUI implements IBottomBarItem, ITransi
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float dTime) {
|
public void update(float dTime) {
|
||||||
animation = lerp(animation, opened ? 1 : 0, dTime / 20);
|
animation = lerp(animation, opened ? 1 : 0, dTime / Constants.animationSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,6 @@ public class Quarry extends Construction {
|
||||||
if (digJob != null) return;
|
if (digJob != null) return;
|
||||||
if (terrain.getTile(getWorldPosition().xy().south().east()).has(Boulder.class)) return;
|
if (terrain.getTile(getWorldPosition().xy().south().east()).has(Boulder.class)) return;
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Dig job?");
|
|
||||||
|
|
||||||
digJob = get(JobBoard.class)
|
digJob = get(JobBoard.class)
|
||||||
.postSimpleWorkJob("Mine at Quarry", new IWorkable() {
|
.postSimpleWorkJob("Mine at Quarry", new IWorkable() {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class SleepActivity extends Activity {
|
||||||
// as it will induce oversleep
|
// as it will induce oversleep
|
||||||
WeightedAverage average = new WeightedAverage();
|
WeightedAverage average = new WeightedAverage();
|
||||||
average.add(needs.getSleepNeed(), 1);
|
average.add(needs.getSleepNeed(), 1);
|
||||||
// System.out.println(1 - 2 * clock.getSunlight());
|
|
||||||
average.add(1 - 2 * clock.getSunlight(), circadianStrength);
|
average.add(1 - 2 * clock.getSunlight(), circadianStrength);
|
||||||
return average.calculate();
|
return average.calculate();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import xyz.valnet.hadean.gameobjects.ui.ExclusivityManager;
|
||||||
import xyz.valnet.hadean.gameobjects.ui.HoverQuery;
|
import xyz.valnet.hadean.gameobjects.ui.HoverQuery;
|
||||||
import xyz.valnet.hadean.gameobjects.ui.tabs.BuildTab;
|
import xyz.valnet.hadean.gameobjects.ui.tabs.BuildTab;
|
||||||
import xyz.valnet.hadean.gameobjects.ui.tabs.DebugTab;
|
import xyz.valnet.hadean.gameobjects.ui.tabs.DebugTab;
|
||||||
|
import xyz.valnet.hadean.gameobjects.ui.tabs.MenuTab;
|
||||||
import xyz.valnet.hadean.gameobjects.worldobjects.pawn.Pawn;
|
import xyz.valnet.hadean.gameobjects.worldobjects.pawn.Pawn;
|
||||||
|
|
||||||
// TODO BIG IDEAS
|
// TODO BIG IDEAS
|
||||||
|
|
@ -54,8 +55,7 @@ public class GameScene extends SceneGraph {
|
||||||
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 MenuTab());
|
||||||
// objects.add(new LoadTab());
|
|
||||||
|
|
||||||
// objects.add(new Popup());
|
// objects.add(new Popup());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,13 @@ import xyz.valnet.engine.graphics.Tile9;
|
||||||
import xyz.valnet.engine.math.Vector4i;
|
import xyz.valnet.engine.math.Vector4i;
|
||||||
import xyz.valnet.engine.shaders.SimpleShader;
|
import xyz.valnet.engine.shaders.SimpleShader;
|
||||||
import xyz.valnet.engine.sound.Sound;
|
import xyz.valnet.engine.sound.Sound;
|
||||||
|
import xyz.valnet.hadean.gameobjects.ui.tabs.DebugTab;
|
||||||
|
|
||||||
public class Assets {
|
public class Assets {
|
||||||
|
|
||||||
public static final Sound sndBubble;
|
public static final Sound sndBubble;
|
||||||
public static final Sound sndCancel;
|
public static final Sound sndCancel;
|
||||||
public static final Sound sndGlassTap;
|
public static final Sound sndGlassTap;
|
||||||
public static final Sound sndSelectionChanged;
|
|
||||||
|
|
||||||
public static final Texture atlas;
|
public static final Texture atlas;
|
||||||
public static final Font font;
|
public static final Font font;
|
||||||
|
|
@ -59,7 +59,7 @@ public class Assets {
|
||||||
public static final SimpleShader flat;
|
public static final SimpleShader flat;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.out.println("=== [ LOADING ASSETS ] ===");
|
DebugTab.log("=== [ LOADING ASSETS ] ===");
|
||||||
flat = new SimpleShader("res/shaders/flat.vert", "res/shaders/flat.frag");
|
flat = new SimpleShader("res/shaders/flat.vert", "res/shaders/flat.frag");
|
||||||
|
|
||||||
atlas = new Texture("res/textures.png");
|
atlas = new Texture("res/textures.png");
|
||||||
|
|
@ -316,12 +316,11 @@ public class Assets {
|
||||||
|
|
||||||
wall = new Tile16(atlas, new Vector4i(0, 17 * 8, 32, 32));
|
wall = new Tile16(atlas, new Vector4i(0, 17 * 8, 32, 32));
|
||||||
|
|
||||||
sndSelectionChanged = new Sound("res/sounds/leohpaz/retro-rpg-menu-sounds/079_Buy_sell_01.ogg");
|
|
||||||
sndBubble = new Sound("res/sounds/p0ss/interface-sounds/appear-online.ogg");
|
sndBubble = new Sound("res/sounds/p0ss/interface-sounds/appear-online.ogg");
|
||||||
// sndCancel = new Sound("res/sounds/Listener/botton-sound-pack/cancel.ogg").setVolume(2f);
|
// sndCancel = new Sound("res/sounds/Listener/botton-sound-pack/cancel.ogg").setVolume(2f);
|
||||||
sndCancel = new Sound("res/sounds/leohpaz/retro-rpg-menu-sounds/098_Unpause_04.ogg").setVolume(0.8f);
|
sndCancel = new Sound("res/sounds/leohpaz/retro-rpg-menu-sounds/098_Unpause_04.ogg").setVolume(0.8f);
|
||||||
sndGlassTap = new Sound("res/sounds/p0ss/interface-sounds/click5.ogg").setVolume(0.2f);
|
sndGlassTap = new Sound("res/sounds/p0ss/interface-sounds/click5.ogg").setVolume(0.2f);
|
||||||
|
|
||||||
System.out.println("=== [ ASSETS LOADED ] ===");
|
DebugTab.log("=== [ ASSETS LOADED ] ===");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue