-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
msx80
committed
Apr 28, 2024
1 parent
eb9044a
commit 9c017fb
Showing
5 changed files
with
169 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>feature-demo</artifactId> | ||
<groupId>com.github.msx80.omicron</groupId> | ||
<version>0.0.3</version> | ||
<artifactId>feature-demo</artifactId> | ||
<groupId>com.github.msx80.omicron</groupId> | ||
<version>0.0.3</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
</properties> | ||
<repositories> | ||
|
||
<repositories> | ||
<repository> | ||
<id>jitpack.io</id> | ||
<url>https://jitpack.io</url> | ||
<id>jitpack.io</id> | ||
<url>https://jitpack.io</url> | ||
</repository> | ||
</repositories> | ||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>com.github.msx80.omicron</groupId> | ||
<version>0.0.3</version> | ||
<artifactId>omicron-desktop</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
<build> | ||
<plugins> | ||
|
||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>omicron.demo.featuresdemo.FeaturesDemo</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.coderplus.maven.plugins</groupId> | ||
<artifactId>copy-rename-maven-plugin</artifactId> | ||
<version>1.0</version> | ||
<executions> | ||
<execution> | ||
<id>rename-file</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
<configuration> | ||
<sourceFile>${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</sourceFile> | ||
<destinationFile>${project.artifactId}-standalone.jar</destinationFile> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.1.0</version> | ||
|
||
<configuration> | ||
<mainClass>omicron.demo.featuresdemo.FeaturesDemo</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.msx80.omicron</groupId> | ||
<version>0.0.3</version> | ||
<artifactId>omicron-desktop</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<!-- generate fat jar with the engine and all --> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>omicron.demo.featuresdemo.FeaturesDemo</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<!-- copy the jar with a different name, not sure about this --> | ||
<groupId>com.coderplus.maven.plugins</groupId> | ||
<artifactId>copy-rename-maven-plugin</artifactId> | ||
<version>1.0</version> | ||
<executions> | ||
<execution> | ||
<id>rename-file</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
<configuration> | ||
<sourceFile> | ||
${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</sourceFile> | ||
<destinationFile> | ||
${project.artifactId}-standalone.jar</destinationFile> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<!-- make this executable with exec:exec --> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<mainClass>omicron.demo.featuresdemo.FeaturesDemo</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...ader/src/main/java/com/github/msx80/omicron/fantasyconsole/cartridges/ClassCartridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.github.msx80.omicron.fantasyconsole.cartridges; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
import com.github.msx80.omicron.api.Game; | ||
import com.github.msx80.omicron.api.adv.Cartridge; | ||
|
||
import com.github.msx80.omicron.fantasyconsole.utils.FileUtil; | ||
|
||
public class ClassCartridge implements Cartridge { | ||
|
||
|
||
private Game game; | ||
private Class<? extends Game> gameClass; | ||
|
||
public ClassCartridge(String name, Class<? extends Game> gameClass) | ||
{ | ||
this.gameClass = gameClass; | ||
} | ||
|
||
@Override | ||
public Game getGameObject(){ | ||
try { | ||
game = gameClass.getDeclaredConstructor().newInstance(); | ||
return game; | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public byte[] loadFile(String name) { | ||
try { | ||
//String path = '/'+props.getProperty(PROP_PKG).replace('.', '/')+'/'; | ||
String path = '/'+gameClass.getPackage().getName().replace('.', '/')+'/'; | ||
InputStream is = game.getClass().getResourceAsStream(path+name); | ||
if(is == null) return null; | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
try | ||
{ | ||
FileUtil.copy(is, baos); | ||
} | ||
finally | ||
{ | ||
is.close(); | ||
} | ||
return baos.toByteArray(); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Unable to load file from cartridge",e); | ||
} | ||
} | ||
|
||
@Override | ||
public Properties getOmicronProperties() { | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
|
||
|
||
} | ||
|
||
|
||
} |
5 changes: 0 additions & 5 deletions
5
...der/src/main/java/com/github/msx80/omicron/fantasyconsole/cartridges/SourceCartridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters