Merge branch 'stable' into world-object-unification-project
commit
e31a164871
|
|
@ -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
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
target
|
target
|
||||||
out
|
out
|
||||||
bin
|
output
|
||||||
SAVE_DATA.TXT
|
SAVE_DATA.TXT
|
||||||
|
.DS_Store
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,154 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>xyz.valnet.hadean</groupId>
|
||||||
|
<artifactId>hadean</artifactId>
|
||||||
|
<name>hadean</name>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<url>http://www.example.com</url>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>output/${platform.name}/raw</outputDirectory>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<classpathPrefix>lib/</classpathPrefix>
|
||||||
|
<mainClass>xyz.valnet.hadean.HadeanGame</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-dependencies</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>output/${platform.name}/raw/lib</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<configuration>
|
||||||
|
<filesets>
|
||||||
|
<fileset>
|
||||||
|
<directory>output</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*</include>
|
||||||
|
</includes>
|
||||||
|
</fileset>
|
||||||
|
</filesets>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-resources02</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>output/${platform.name}/raw/res</outputDirectory>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${basedir}/res</directory>
|
||||||
|
<include>**/*.*</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>2.5.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.akathist.maven.plugins.launch4j</groupId>
|
||||||
|
<artifactId>launch4j-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<transformers>
|
||||||
|
<transformer>
|
||||||
|
<mainClass>foo.bar.Generate</mainClass>
|
||||||
|
<manifestEntries>
|
||||||
|
<Multi-Release>true</Multi-Release>
|
||||||
|
</manifestEntries>
|
||||||
|
</transformer>
|
||||||
|
<transformer />
|
||||||
|
</transformers>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>linux</id>
|
||||||
|
<properties>
|
||||||
|
<lwjgl.natives>natives-linux</lwjgl.natives>
|
||||||
|
<platform.name>linux</platform.name>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>macos</id>
|
||||||
|
<properties>
|
||||||
|
<lwjgl.natives>natives-macos</lwjgl.natives>
|
||||||
|
<platform.name>macos</platform.name>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>windows</id>
|
||||||
|
<properties>
|
||||||
|
<lwjgl.natives>natives-windows</lwjgl.natives>
|
||||||
|
<platform.name>windows</platform.name>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lwjgl</groupId>
|
||||||
|
<artifactId>lwjgl-bom</artifactId>
|
||||||
|
<version>${lwjgl.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<jar.finalName>${project.name}</jar.finalName>
|
||||||
|
<lwjgl.version>3.3.1</lwjgl.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
||||||
148
pom.xml
148
pom.xml
|
|
@ -6,22 +6,23 @@
|
||||||
|
|
||||||
<groupId>xyz.valnet.hadean</groupId>
|
<groupId>xyz.valnet.hadean</groupId>
|
||||||
<artifactId>hadean</artifactId>
|
<artifactId>hadean</artifactId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>hadean</name>
|
<name>hadean</name>
|
||||||
<!-- FIXME change it to the project's website -->
|
|
||||||
<url>http://www.example.com</url>
|
<url>http://www.example.com</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>16</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>16</maven.compiler.target>
|
||||||
<lwjgl.version>3.3.1</lwjgl.version>
|
<lwjgl.version>3.3.1</lwjgl.version>
|
||||||
|
<jar.finalName>${project.name}</jar.finalName>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>lwjgl-natives-linux-amd64</id>
|
<id>linux</id>
|
||||||
<activation>
|
<activation>
|
||||||
<os>
|
<os>
|
||||||
<family>unix</family>
|
<family>unix</family>
|
||||||
|
|
@ -30,10 +31,11 @@
|
||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<lwjgl.natives>natives-linux</lwjgl.natives>
|
<lwjgl.natives>natives-linux</lwjgl.natives>
|
||||||
|
<platform.name>linux</platform.name>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>lwjgl-natives-macos-x86_64</id>
|
<id>macos</id>
|
||||||
<activation>
|
<activation>
|
||||||
<os>
|
<os>
|
||||||
<family>mac</family>
|
<family>mac</family>
|
||||||
|
|
@ -42,10 +44,11 @@
|
||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<lwjgl.natives>natives-macos</lwjgl.natives>
|
<lwjgl.natives>natives-macos</lwjgl.natives>
|
||||||
|
<platform.name>macos</platform.name>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>lwjgl-natives-windows-amd64</id>
|
<id>windows</id>
|
||||||
<activation>
|
<activation>
|
||||||
<os>
|
<os>
|
||||||
<family>windows</family>
|
<family>windows</family>
|
||||||
|
|
@ -54,6 +57,7 @@
|
||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<lwjgl.natives>natives-windows</lwjgl.natives>
|
<lwjgl.natives>natives-windows</lwjgl.natives>
|
||||||
|
<platform.name>windows</platform.name>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
@ -71,7 +75,11 @@
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||||
|
<version>2.13.4</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.lwjgl</groupId>
|
<groupId>org.lwjgl</groupId>
|
||||||
<artifactId>lwjgl</artifactId>
|
<artifactId>lwjgl</artifactId>
|
||||||
|
|
@ -129,48 +137,86 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
<plugins>
|
||||||
<plugins>
|
<plugin>
|
||||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<plugin>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<configuration>
|
||||||
<version>3.1.0</version>
|
<outputDirectory>output/${platform.name}/raw</outputDirectory>
|
||||||
</plugin>
|
<archive>
|
||||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
<manifest>
|
||||||
<plugin>
|
<addClasspath>true</addClasspath>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<classpathPrefix>lib/</classpathPrefix>
|
||||||
<version>3.0.2</version>
|
<mainClass>xyz.valnet.hadean.HadeanGame</mainClass>
|
||||||
</plugin>
|
</manifest>
|
||||||
<plugin>
|
</archive>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
</configuration>
|
||||||
<version>3.8.0</version>
|
</plugin>
|
||||||
</plugin>
|
<plugin>
|
||||||
<plugin>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
<version>2.22.1</version>
|
<executions>
|
||||||
</plugin>
|
<execution>
|
||||||
<plugin>
|
<id>copy-dependencies</id>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<phase>prepare-package</phase>
|
||||||
<version>3.0.2</version>
|
<goals>
|
||||||
</plugin>
|
<goal>copy-dependencies</goal>
|
||||||
<plugin>
|
</goals>
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
<configuration>
|
||||||
<version>2.5.2</version>
|
<outputDirectory>output/${platform.name}/raw/lib</outputDirectory>
|
||||||
</plugin>
|
</configuration>
|
||||||
<plugin>
|
</execution>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
</executions>
|
||||||
<version>2.8.2</version>
|
</plugin>
|
||||||
</plugin>
|
<plugin>
|
||||||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
<plugin>
|
<version>3.1.0</version>
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
<configuration>
|
||||||
<version>3.7.1</version>
|
<filesets>
|
||||||
</plugin>
|
<fileset>
|
||||||
<plugin>
|
<directory>output</directory>
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
<includes>
|
||||||
<version>3.0.0</version>
|
<include>**/*</include>
|
||||||
</plugin>
|
</includes>
|
||||||
</plugins>
|
</fileset>
|
||||||
</pluginManagement>
|
</filesets>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-resources02</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>output/${platform.name}/raw/res</outputDirectory>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${basedir}/res</directory>
|
||||||
|
<include>**/*.*</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>2.5.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.akathist.maven.plugins.launch4j</groupId>
|
||||||
|
<artifactId>launch4j-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public class App {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
loop();
|
loop();
|
||||||
|
|
||||||
|
|
@ -65,7 +66,7 @@ public class App {
|
||||||
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
|
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
|
||||||
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
|
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
glfwSetCursorPosCallback(window, new GLFWCursorPosCallback() {
|
glfwSetCursorPosCallback(window, new GLFWCursorPosCallback() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -115,6 +116,7 @@ public class App {
|
||||||
);
|
);
|
||||||
} // the stack frame is popped automatically
|
} // the stack frame is popped automatically
|
||||||
|
|
||||||
|
|
||||||
// Make the OpenGL context current
|
// Make the OpenGL context current
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
// Enable v-sync
|
// Enable v-sync
|
||||||
|
|
@ -130,6 +132,7 @@ public class App {
|
||||||
// bindings available for use.
|
// bindings available for use.
|
||||||
GL.createCapabilities();
|
GL.createCapabilities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float clearBrightness = 0.09f;
|
float clearBrightness = 0.09f;
|
||||||
glClearColor(clearBrightness, clearBrightness, clearBrightness, 1.0f);
|
glClearColor(clearBrightness, clearBrightness, clearBrightness, 1.0f);
|
||||||
|
|
@ -140,6 +143,7 @@ public class App {
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
|
|
||||||
game.start();
|
game.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ public class SimpleShader extends Shader {
|
||||||
|
|
||||||
public void pushColor(Vector4f color) {
|
public void pushColor(Vector4f color) {
|
||||||
colorStack.push(color);
|
colorStack.push(color);
|
||||||
|
|
||||||
setUniform4f("uColor", color);
|
setUniform4f("uColor", color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
package xyz.valnet.hadean.designation;
|
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.gameobjects.worldobjects.items.Item;
|
||||||
import xyz.valnet.hadean.interfaces.BuildableMetadata;
|
import xyz.valnet.hadean.interfaces.BuildableMetadata;
|
||||||
|
|
||||||
@BuildableMetadata(category = "Jobs", name = "Haul Items")
|
@BuildableMetadata(category = "Jobs", name = "Haul Items")
|
||||||
public class HaulItemDesignation extends Designation<Item> {
|
public class HaulItemDesignation extends Designation<Item> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<Item> getType() {
|
protected Class<Item> getType() {
|
||||||
return Item.class;
|
return Item.class;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
package xyz.valnet.hadean.gameobjects.ui.tabs;
|
package xyz.valnet.hadean.gameobjects.ui.tabs;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -16,10 +11,15 @@ import xyz.valnet.engine.math.Vector2i;
|
||||||
import xyz.valnet.engine.math.Vector4f;
|
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.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.BottomBar;
|
||||||
import xyz.valnet.hadean.gameobjects.Camera;
|
import xyz.valnet.hadean.gameobjects.Camera;
|
||||||
import xyz.valnet.hadean.gameobjects.inputlayer.BuildLayer;
|
import xyz.valnet.hadean.gameobjects.inputlayer.BuildLayer;
|
||||||
import xyz.valnet.hadean.gameobjects.inputlayer.SelectionLayer;
|
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.Button;
|
||||||
import xyz.valnet.hadean.input.IButtonListener;
|
import xyz.valnet.hadean.input.IButtonListener;
|
||||||
import xyz.valnet.hadean.input.SimpleButton;
|
import xyz.valnet.hadean.input.SimpleButton;
|
||||||
|
|
@ -48,57 +48,57 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
|
||||||
|
|
||||||
private String selectedCategory = "";
|
private String selectedCategory = "";
|
||||||
|
|
||||||
private transient BuildableRecord selectedBuildable = null;
|
private static transient Map<String, List<BuildableRecord>> buildables = new HashMap<String, List<BuildableRecord>>();
|
||||||
private transient Map<String, List<BuildableRecord>> buildables = null;
|
|
||||||
private transient Map<Button, BuildableRecord> buildableButtons = null;
|
private transient Map<Button, BuildableRecord> 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,
|
String name,
|
||||||
Constructor<? extends IBuildable> constructor,
|
Constructor<? extends IBuildable> constructor,
|
||||||
BuildableMetadata.Type type
|
BuildableMetadata.Type type
|
||||||
) {
|
) {}
|
||||||
|
|
||||||
}
|
public static void registerBuildable(Class<? extends IBuildable> clazz) {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void calculateBuildables() {
|
|
||||||
try {
|
try {
|
||||||
Class<?>[] maybeBuildables = getClasses("xyz.valnet.hadean");
|
System.out.println("Its fine");
|
||||||
|
|
||||||
for(Class<?> clazz : maybeBuildables) {
|
BuildableMetadata annotation = clazz.getAnnotation(BuildableMetadata.class);
|
||||||
if(clazz.isAnonymousClass()) continue;
|
if(annotation == null) {
|
||||||
if(!IBuildable.class.isAssignableFrom(clazz)) continue;
|
System.out.println(clazz + " has no buildable data annotation");
|
||||||
if(clazz.isInterface()) continue;
|
return;
|
||||||
if(Modifier.isAbstract(clazz.getModifiers())) continue;
|
|
||||||
|
|
||||||
Constructor<? extends IBuildable> constructor = (Constructor<? extends IBuildable>) 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<BuildableRecord>());
|
|
||||||
buildables.get(category).add(new BuildableRecord(name, constructor, type));
|
|
||||||
|
|
||||||
System.out.println("Added " + category + " / " + name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
Constructor<? extends IBuildable> constructor = (Constructor<? extends IBuildable>) clazz.getConstructor();
|
||||||
System.out.println(e);
|
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<BuildableRecord>());
|
||||||
|
buildables.get(category).add(new BuildableRecord(name, constructor, type));
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -146,10 +146,7 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
|
||||||
selection.subscribe(this);
|
selection.subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildables = new HashMap<String, List<BuildableRecord>>();
|
|
||||||
buildableButtons = new HashMap<Button, BuildableRecord>();
|
buildableButtons = new HashMap<Button, BuildableRecord>();
|
||||||
|
|
||||||
calculateBuildables();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Button> categoryButtons = new ArrayList<Button>();
|
private List<Button> categoryButtons = new ArrayList<Button>();
|
||||||
|
|
@ -336,40 +333,4 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
|
||||||
selectBuildable(newBuildableRecord);
|
selectBuildable(newBuildableRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private static Class<?>[] getClasses(String packageName) throws ClassNotFoundException, IOException {
|
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
|
||||||
assert classLoader != null;
|
|
||||||
String path = packageName.replace('.', '/');
|
|
||||||
Enumeration<URL> resources = classLoader.getResources(path);
|
|
||||||
List<File> dirs = new ArrayList<File>();
|
|
||||||
while (resources.hasMoreElements()) {
|
|
||||||
URL resource = resources.nextElement();
|
|
||||||
dirs.add(new File(resource.getFile()));
|
|
||||||
}
|
|
||||||
ArrayList<Class> classes = new ArrayList<Class>();
|
|
||||||
for (File directory : dirs) {
|
|
||||||
classes.addAll(findClasses(directory, packageName));
|
|
||||||
}
|
|
||||||
return (Class<?>[]) classes.toArray(new Class[classes.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private static List<Class> findClasses(File directory, String packageName) throws ClassNotFoundException {
|
|
||||||
List<Class> classes = new ArrayList<Class>();
|
|
||||||
if (!directory.exists()) {
|
|
||||||
return classes;
|
|
||||||
}
|
|
||||||
File[] files = directory.listFiles();
|
|
||||||
for (File file : files) {
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
assert !file.getName().contains(".");
|
|
||||||
classes.addAll(findClasses(file, packageName + "." + file.getName()));
|
|
||||||
} else if (file.getName().endsWith(".class")) {
|
|
||||||
classes.add(Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return classes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,14 @@ public class Assets {
|
||||||
public static final SimpleShader flat;
|
public static final SimpleShader flat;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
flat = new SimpleShader("shaders/flat.vert", "shaders/flat.frag");
|
System.out.println("START ASSETS");
|
||||||
|
flat = new SimpleShader("res/shaders/flat.vert", "res/shaders/flat.frag");
|
||||||
|
System.out.println("SHADERS LOADED");
|
||||||
|
|
||||||
atlas = new Texture("res/textures.png");
|
atlas = new Texture("res/textures.png");
|
||||||
|
System.out.println("ATLAS LOADED");
|
||||||
|
|
||||||
|
System.out.println("CREATE SPRITES");
|
||||||
whiteBox = new Sprite(atlas, 0, 88, 8, 8);
|
whiteBox = new Sprite(atlas, 0, 88, 8, 8);
|
||||||
|
|
||||||
defaultTerrain = new Sprite[] {
|
defaultTerrain = new Sprite[] {
|
||||||
|
|
@ -300,5 +304,6 @@ public class Assets {
|
||||||
new Sprite(atlas, 7, 103, 1, 1)
|
new Sprite(atlas, 7, 103, 1, 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
System.out.println("END ASSETS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue