diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0c26683 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +bin/jdk16-linux.gz filter=lfs diff=lfs merge=lfs -text +bin/jdk16-windows.zip filter=lfs diff=lfs merge=lfs -text +bin/jdk16-macos.gz filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index 1d8620e..3bd11db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ target out -bin -SAVE_DATA.TXT \ No newline at end of file +output +SAVE_DATA.TXT +.DS_Store diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..594d279 --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,15 @@ +#!/usr/bin/bash +mvn clean +mvn package -Pwindows +mvn package -Pmacos +mvn package -Plinux + +echo " === Windows === " +java -jar ./bin/packr-all-4.0.0.jar ./bin/packr.windows.json + +echo " ==== Macos ==== " +java -jar ./bin/packr-all-4.0.0.jar ./bin/packr.macos.json +mv output/macos/built output/macos/Hadean.app + +echo " ==== Linux ==== " +java -jar ./bin/packr-all-4.0.0.jar ./bin/packr.linux.json diff --git a/bin/jdk16-linux.gz b/bin/jdk16-linux.gz new file mode 100644 index 0000000..ee14176 --- /dev/null +++ b/bin/jdk16-linux.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:323d6d7474a359a28eff7ddd0df8e65bd61554a8ed12ef42fd9365349e573c2c +size 205463525 diff --git a/bin/jdk16-macos.gz b/bin/jdk16-macos.gz new file mode 100644 index 0000000..1561b77 --- /dev/null +++ b/bin/jdk16-macos.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27975d9e695cfbb93861540926f9f7bcac973a254ceecbee549706a99cbbdf95 +size 206621395 diff --git a/bin/jdk16-windows.zip b/bin/jdk16-windows.zip new file mode 100644 index 0000000..5cb756d --- /dev/null +++ b/bin/jdk16-windows.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40191ffbafd8a6f9559352d8de31e8d22a56822fb41bbcf45f34e3fd3afa5f9e +size 203448494 diff --git a/bin/packr-all-4.0.0.jar b/bin/packr-all-4.0.0.jar new file mode 100644 index 0000000..4fcf201 Binary files /dev/null and b/bin/packr-all-4.0.0.jar differ diff --git a/bin/packr.linux.json b/bin/packr.linux.json new file mode 100644 index 0000000..49f99bc --- /dev/null +++ b/bin/packr.linux.json @@ -0,0 +1,18 @@ +{ + "platform": "linux64", + "executable": "Hadean", + "jdk": "bin/jdk16-linux.gz", + "classpath": [ + "output/linux/raw/hadean.jar" + ], + "removelibs": [], + "mainclass": "xyz.valnet.hadean.HadeanGame", + "vmargs": [ + + ], + "resources": [ + "output/linux/raw/lib", + "output/linux/raw/res" + ], + "output": "output/linux/built" +} \ No newline at end of file diff --git a/bin/packr.macos.json b/bin/packr.macos.json new file mode 100644 index 0000000..3c9b132 --- /dev/null +++ b/bin/packr.macos.json @@ -0,0 +1,18 @@ +{ + "platform": "mac", + "executable": "Hadean", + "jdk": "bin/jdk16-macos.gz", + "classpath": [ + "output/macos/raw/hadean.jar" + ], + "removelibs": [], + "mainclass": "xyz.valnet.hadean.HadeanGame", + "vmargs": [ + "-XstartOnFirstThread" + ], + "resources": [ + "output/macos/raw/lib", + "output/macos/raw/res" + ], + "output": "output/macos/built" +} diff --git a/bin/packr.windows.json b/bin/packr.windows.json new file mode 100644 index 0000000..8870750 --- /dev/null +++ b/bin/packr.windows.json @@ -0,0 +1,18 @@ +{ + "platform": "windows64", + "executable": "Hadean", + "jdk": "bin/jdk16-windows.zip", + "classpath": [ + "output/windows/raw/hadean.jar" + ], + "removelibs": [], + "mainclass": "xyz.valnet.hadean.HadeanGame", + "vmargs": [ + + ], + "resources": [ + "output/windows/raw/lib", + "output/windows/raw/res" + ], + "output": "output/windows/built" +} \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..85de4f1 --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,154 @@ + + + 4.0.0 + xyz.valnet.hadean + hadean + hadean + 1.0-SNAPSHOT + http://www.example.com + + + + maven-jar-plugin + + output/${platform.name}/raw + + + true + lib/ + xyz.valnet.hadean.HadeanGame + + + + + + maven-dependency-plugin + + + copy-dependencies + prepare-package + + copy-dependencies + + + output/${platform.name}/raw/lib + + + + + + maven-clean-plugin + 3.1.0 + + + + output + + **/* + + + + + + + maven-resources-plugin + 3.0.2 + + + copy-resources02 + prepare-package + + copy-resources + + + output/${platform.name}/raw/res + UTF-8 + + + ${basedir}/res + **/*.* + + + + + + + + maven-compiler-plugin + 3.8.0 + + + maven-install-plugin + 2.5.2 + + + com.akathist.maven.plugins.launch4j + launch4j-maven-plugin + + + maven-shade-plugin + 3.2.1 + + + package + + shade + + + + + foo.bar.Generate + + true + + + + + + + + + + + + + linux + + natives-linux + linux + + + + macos + + natives-macos + macos + + + + windows + + natives-windows + windows + + + + + + + org.lwjgl + lwjgl-bom + ${lwjgl.version} + pom + import + + + + + 17 + 17 + UTF-8 + ${project.name} + 3.3.1 + + diff --git a/pom.xml b/pom.xml index 42f3e32..dac787d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,22 +6,23 @@ xyz.valnet.hadean hadean - 0.1-SNAPSHOT + 1.0-SNAPSHOT + jar hadean - http://www.example.com UTF-8 - 17 - 17 + 16 + 16 3.3.1 + ${project.name} - lwjgl-natives-linux-amd64 + linux unix @@ -30,10 +31,11 @@ natives-linux + linux - lwjgl-natives-macos-x86_64 + macos mac @@ -42,10 +44,11 @@ natives-macos + macos - lwjgl-natives-windows-amd64 + windows windows @@ -54,6 +57,7 @@ natives-windows + windows @@ -71,7 +75,11 @@ - + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + 2.13.4 + org.lwjgl lwjgl @@ -129,48 +137,86 @@ - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - + + + org.apache.maven.plugins + maven-jar-plugin + + output/${platform.name}/raw + + + true + lib/ + xyz.valnet.hadean.HadeanGame + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + prepare-package + + copy-dependencies + + + output/${platform.name}/raw/lib + + + + + + maven-clean-plugin + 3.1.0 + + + + output + + **/* + + + + + + + maven-resources-plugin + 3.0.2 + + + copy-resources02 + prepare-package + + copy-resources + + + output/${platform.name}/raw/res + UTF-8 + + + ${basedir}/res + **/*.* + + + + + + + + maven-compiler-plugin + 3.8.0 + + + maven-install-plugin + 2.5.2 + + + com.akathist.maven.plugins.launch4j + launch4j-maven-plugin + + diff --git a/res/content/base/index.yml b/res/content/base/index.yml new file mode 100644 index 0000000..e69de29 diff --git a/shaders/flat.frag b/res/shaders/flat.frag similarity index 100% rename from shaders/flat.frag rename to res/shaders/flat.frag diff --git a/shaders/flat.vert b/res/shaders/flat.vert similarity index 100% rename from shaders/flat.vert rename to res/shaders/flat.vert diff --git a/src/main/java/xyz/valnet/engine/App.java b/src/main/java/xyz/valnet/engine/App.java index 360622a..bd358b3 100644 --- a/src/main/java/xyz/valnet/engine/App.java +++ b/src/main/java/xyz/valnet/engine/App.java @@ -29,6 +29,7 @@ public class App { public void run() { + init(); loop(); @@ -65,7 +66,7 @@ public class App { if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop }); - + glfwSetCursorPosCallback(window, new GLFWCursorPosCallback() { @Override @@ -115,6 +116,7 @@ public class App { ); } // the stack frame is popped automatically + // Make the OpenGL context current glfwMakeContextCurrent(window); // Enable v-sync @@ -130,6 +132,7 @@ public class App { // bindings available for use. GL.createCapabilities(); + float clearBrightness = 0.09f; glClearColor(clearBrightness, clearBrightness, clearBrightness, 1.0f); @@ -140,6 +143,7 @@ public class App { glDepthMask(true); glfwSwapInterval(1); + game.start(); } diff --git a/src/main/java/xyz/valnet/engine/shaders/SimpleShader.java b/src/main/java/xyz/valnet/engine/shaders/SimpleShader.java index 156d518..dc5f8c2 100644 --- a/src/main/java/xyz/valnet/engine/shaders/SimpleShader.java +++ b/src/main/java/xyz/valnet/engine/shaders/SimpleShader.java @@ -19,7 +19,6 @@ public class SimpleShader extends Shader { public void pushColor(Vector4f color) { colorStack.push(color); - setUniform4f("uColor", color); } diff --git a/src/main/java/xyz/valnet/hadean/designation/HaulItemDesignation.java b/src/main/java/xyz/valnet/hadean/designation/HaulItemDesignation.java index 077ffa4..002b89b 100644 --- a/src/main/java/xyz/valnet/hadean/designation/HaulItemDesignation.java +++ b/src/main/java/xyz/valnet/hadean/designation/HaulItemDesignation.java @@ -1,10 +1,13 @@ package xyz.valnet.hadean.designation; +import xyz.valnet.hadean.gameobjects.ui.tabs.BuildTab; import xyz.valnet.hadean.gameobjects.worldobjects.items.Item; import xyz.valnet.hadean.interfaces.BuildableMetadata; @BuildableMetadata(category = "Jobs", name = "Haul Items") public class HaulItemDesignation extends Designation { + + @Override protected Class getType() { return Item.class; diff --git a/src/main/java/xyz/valnet/hadean/gameobjects/ui/tabs/BuildTab.java b/src/main/java/xyz/valnet/hadean/gameobjects/ui/tabs/BuildTab.java index 055f803..55f51d8 100644 --- a/src/main/java/xyz/valnet/hadean/gameobjects/ui/tabs/BuildTab.java +++ b/src/main/java/xyz/valnet/hadean/gameobjects/ui/tabs/BuildTab.java @@ -1,12 +1,7 @@ package xyz.valnet.hadean.gameobjects.ui.tabs; -import java.io.File; -import java.io.IOException; import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; -import java.net.URL; import java.util.ArrayList; -import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -16,10 +11,15 @@ import xyz.valnet.engine.math.Vector2i; import xyz.valnet.engine.math.Vector4f; import xyz.valnet.engine.scenegraph.GameObject; import xyz.valnet.engine.scenegraph.IMouseCaptureArea; +import xyz.valnet.hadean.designation.CutTreesDesignation; +import xyz.valnet.hadean.designation.HaulItemDesignation; import xyz.valnet.hadean.gameobjects.BottomBar; import xyz.valnet.hadean.gameobjects.Camera; import xyz.valnet.hadean.gameobjects.inputlayer.BuildLayer; import xyz.valnet.hadean.gameobjects.inputlayer.SelectionLayer; +import xyz.valnet.hadean.gameobjects.worldobjects.Bed; +import xyz.valnet.hadean.gameobjects.worldobjects.FarmPlot; +import xyz.valnet.hadean.gameobjects.worldobjects.Stockpile; import xyz.valnet.hadean.input.Button; import xyz.valnet.hadean.input.IButtonListener; import xyz.valnet.hadean.input.SimpleButton; @@ -48,57 +48,57 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap private String selectedCategory = ""; - private transient BuildableRecord selectedBuildable = null; - private transient Map> buildables = null; + private static transient Map> buildables = new HashMap>(); private transient Map buildableButtons = null; + private transient BuildableRecord selectedBuildable = null; - private int height = 0; + private int height = Math.max((int)Math.ceil(buildables.size() / 2f) * 24, 24*3); - private record BuildableRecord( + static { + BuildTab.registerBuildable(HaulItemDesignation.class); + BuildTab.registerBuildable(CutTreesDesignation.class); + + BuildTab.registerBuildable(Bed.class); + + BuildTab.registerBuildable(FarmPlot.class); + BuildTab.registerBuildable(Stockpile.class); + } + + public record BuildableRecord( String name, Constructor constructor, BuildableMetadata.Type type - ) { + ) {} - } - - @SuppressWarnings("unchecked") - private void calculateBuildables() { + public static void registerBuildable(Class clazz) { try { - Class[] maybeBuildables = getClasses("xyz.valnet.hadean"); + System.out.println("Its fine"); - for(Class clazz : maybeBuildables) { - if(clazz.isAnonymousClass()) continue; - if(!IBuildable.class.isAssignableFrom(clazz)) continue; - if(clazz.isInterface()) continue; - if(Modifier.isAbstract(clazz.getModifiers())) continue; - - Constructor constructor = (Constructor) clazz.getConstructor(); - if(constructor.getParameterCount() != 0) { - System.out.println(clazz + " has no default constructor (no params)"); - continue; - } - BuildableMetadata annotation = clazz.getAnnotation(BuildableMetadata.class); - if(annotation == null) { - System.out.println(clazz + " has no buildable data annotation"); - continue; - } - String category = annotation.category(); - String name = annotation.name(); - BuildableMetadata.Type type = annotation.type(); - - if(!buildables.containsKey(category)) - buildables.put(category, new ArrayList()); - buildables.get(category).add(new BuildableRecord(name, constructor, type)); - - System.out.println("Added " + category + " / " + name); + BuildableMetadata annotation = clazz.getAnnotation(BuildableMetadata.class); + if(annotation == null) { + System.out.println(clazz + " has no buildable data annotation"); + return; } - } catch (Exception e) { - System.out.println(e); - } + Constructor constructor = (Constructor) clazz.getConstructor(); + if(constructor.getParameterCount() != 0) { + System.out.println(clazz + " has no default constructor (no params)"); + return; + } - height = Math.max((int)Math.ceil(buildables.size() / 2f) * 24, 24*3); + String category = annotation.category(); + String name = annotation.name(); + BuildableMetadata.Type type = annotation.type(); + + System.out.println("Added " + category + " / " + name); + + if(!buildables.containsKey(category)) + buildables.put(category, new ArrayList()); + buildables.get(category).add(new BuildableRecord(name, constructor, type)); + + } catch (Exception e) { + e.printStackTrace(); + } } @Override @@ -146,10 +146,7 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap selection.subscribe(this); } - buildables = new HashMap>(); buildableButtons = new HashMap(); - - calculateBuildables(); } private List