totally didn't forget commits <_<

This commit is contained in:
DaniTheSkunk 2022-11-25 19:08:33 +00:00
parent 55dd993fb9
commit 128b85b5d6
16 changed files with 253 additions and 0 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="skunkworks">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../skunkworks/out/artifacts/skunkworks_jar/skunkworks.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/skunkstream.iml" filepath="$PROJECT_DIR$/skunkstream.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

BIN
9slice-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
fonts/ega-8x14.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
fonts/thin-6x12.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

12
skunkstream.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="skunkworks" level="project" />
</component>
</module>

View File

@ -0,0 +1,7 @@
package com.danitheskunk.skunkstream;
import com.danitheskunk.skunkworks.gfx.IRenderContext;
public interface IElement {
void render(IRenderContext rc);
}

View File

@ -0,0 +1,34 @@
package com.danitheskunk.skunkstream;
import com.danitheskunk.skunkworks.Recti;
import com.danitheskunk.skunkworks.Vec2i;
import com.danitheskunk.skunkworks.gfx.Color;
import com.danitheskunk.skunkworks.gfx.IRenderContext;
import com.danitheskunk.skunkworks.gfx.ITexture;
public class Image implements IElement {
private final Vec2i pos;
private final ITexture texture;
private final Vec2i size;
private final Color color;
public Image(Vec2i pos, ITexture texture, Vec2i size, Color color) {
this.pos = pos;
this.texture = texture;
this.size = size;
this.color = color;
}
@Override
public void render(IRenderContext rc) {
if(size == Vec2i.ZERO) {
rc.drawTexture(pos, texture, color);
} else {
rc.drawTextureRectangle(new Recti(pos, size),
texture,
color,
false
);
}
}
}

View File

@ -0,0 +1,30 @@
package com.danitheskunk.skunkstream;
import com.danitheskunk.skunkworks.Vec2i;
import com.danitheskunk.skunkworks.gfx.Color;
import com.danitheskunk.skunkworks.gfx.IRenderContext;
import com.danitheskunk.skunkworks.gfx.font.IFont;
public class Label implements IElement {
private final Vec2i pos;
private final String text;
private final IFont font;
private final Color color;
public Label(Vec2i pos, String text, IFont font, Color color) {
this.pos = pos;
this.text = text;
this.font = font;
this.color = color;
}
@Override
public void render(IRenderContext rc) {
rc.drawString(
pos,
text,
font,
color
);
}
}

View File

@ -0,0 +1,23 @@
package com.danitheskunk.skunkstream;
import com.danitheskunk.skunkworks.Recti;
import com.danitheskunk.skunkworks.Vec2i;
import com.danitheskunk.skunkworks.gfx.IRenderContext;
public class NineSlice implements IElement {
private final Vec2i pos;
private final com.danitheskunk.skunkworks.gfx.NineSlice nineSlice;
private final Vec2i size;
public NineSlice(Vec2i pos,
com.danitheskunk.skunkworks.gfx.NineSlice nineSlice, Vec2i size) {
this.pos = pos;
this.nineSlice = nineSlice;
this.size = size;
}
@Override
public void render(IRenderContext rc) {
rc.drawNineSlice(nineSlice, new Recti(pos, size));
}
}

View File

@ -0,0 +1,87 @@
package com.danitheskunk.skunkstream;
import com.danitheskunk.skunkworks.BaseGame;
import com.danitheskunk.skunkworks.Data;
import com.danitheskunk.skunkworks.Vec2i;
import com.danitheskunk.skunkworks.gfx.IRenderContext;
import com.danitheskunk.skunkworks.gfx.ITexture;
import com.danitheskunk.skunkworks.gfx.font.IFont;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Skunkstream extends BaseGame {
Data data;
List<IElement> elements;
HashMap<String, IFont> fonts;
HashMap<String, ITexture> textures;
HashMap<String, com.danitheskunk.skunkworks.gfx.NineSlice> nineSlices;
public Skunkstream() {
super(new Vec2i(1920, 1080), "Skunkstream v0.0");
data = engine.loadDataWatched("c:\\dev\\skunkstream\\test.ini");
elements = new ArrayList<>();
fonts = new HashMap<>();
textures = new HashMap<>();
nineSlices = new HashMap<>();
fonts.put("", debugFont);
prepare();
data.onReload(this::prepare);
}
public static void main(String params[]) {
new Skunkstream().run();
}
void prepare() {
elements.clear();
var cats = data.getCategories();
for(var cat : cats) {
if(!cat.equals("")) {
var type = data.get(cat, "type");
if(type.equals("label")) {
elements.add(new Label(
data.getVec2i(cat, "pos"),
data.get(cat, "text"),
fonts.get(data.get(cat, "font")),
data.getColor(cat, "color")
));
} else if(type.equals("image")) {
var path = data.get(cat, "path");
if(!textures.containsKey(path)) {
textures.put(path, window.loadTexture(path));
}
elements.add(new Image(
data.getVec2i(cat, "pos"),
textures.get(path),
data.getVec2i(cat, "size"),
data.getColor(cat, "color")
));
} else if(type.equals("9slice")) {
var path = data.get(cat, "path");
if(!nineSlices.containsKey(path)) {
nineSlices.put(path, window.loadNineSlice(path));
}
elements.add(new NineSlice(
data.getVec2i(cat, "pos"),
nineSlices.get(path),
data.getVec2i(cat, "size")
));
} else if(type.equals("font")) {
if(!fonts.containsKey(cat)) {
var path = data.get(cat, "path");
fonts.put(cat, window.loadFontTileset(path));
}
}
}
}
}
@Override
protected void render(IRenderContext rc) {
for(var element : elements) {
element.render(rc);
}
}
}

28
test.ini Normal file
View File

@ -0,0 +1,28 @@
[thin_font]
type = font
path = fonts/thin-6x12.png
[test_img]
type = image
path = test.png
pos = 50, 450
size = 500, 100
color = #ff0000
[test_label]
type = label
text = Test1234
pos = 100x500
[test_label2]
type = label
text = nya! thin font test
pos = 100, 516
color = #ff00ffff
font = thin_font
[test_9slice]
type = 9slice
path = 9slice-2.png
pos = 200, 200
size = 100, 50

BIN
test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB