From ce9e95e5ce47e9d7e11fe0b01ae0cf889f9ad7d1 Mon Sep 17 00:00:00 2001 From: opfromthestart Date: Sat, 11 Sep 2021 21:11:59 -0400 Subject: [PATCH 1/6] Well, its [i]a[/i] cube. -Added CubeComponent to render a cube to the screen -Added it to the title screen --- .../progressia/test/CubeComponent.java | 92 +++++++++++++++++++ .../windcorp/progressia/test/LayerTitle.java | 2 + 2 files changed, 94 insertions(+) create mode 100644 src/main/java/ru/windcorp/progressia/test/CubeComponent.java diff --git a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java new file mode 100644 index 0000000..8cc9331 --- /dev/null +++ b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java @@ -0,0 +1,92 @@ +package ru.windcorp.progressia.test; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import glm.mat._4.Mat4; +import glm.vec._3.Vec3; +import glm.vec._4.Vec4; +import ru.windcorp.progressia.client.graphics.flat.RenderTarget; +import ru.windcorp.progressia.client.graphics.gui.Component; + +public class CubeComponent extends Component { + + private Mat4 transforms[]; + + private final double pi2 = Math.PI/2; + private final double r3 = Math.sqrt(3); + + private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); + + private int size = 100; + + public CubeComponent(String name) { + super(name); + transforms = new Mat4[6]; + setPreferredSize((int) Math.ceil(r3*size),(int) Math.ceil(r3*size)); + executor.scheduleAtFixedRate(() -> requestReassembly(), 1, 60, TimeUnit.MILLISECONDS); + } + + // Notes to me + // z axis is through the screen + // y is horizontal spin + // x is vertical spin + + + private void computeTransforms() + { + transforms[0] = new Mat4(1); + transforms[1] = new Mat4(1); + transforms[2] = new Mat4(1); + transforms[3] = new Mat4(1); + transforms[4] = new Mat4(1); + transforms[5] = new Mat4(1); + + long time = System.currentTimeMillis(); + + for (int i=0;i<6;i++) + { + transforms[i].rotate((float) (time%(1000*6.28) )/ 1000, new Vec3(0,1,0)).rotate((float) (time%(6777*6.28) )/ 6777, new Vec3(1,0,0)); + } + + transforms[0] = transforms[0].translate(new Vec3(-50,-50,60)); + transforms[1] = transforms[1].translate(new Vec3(-50,-60,-50)).rotate((float) pi2, new Vec3(1,0,0)); + transforms[2] = transforms[2].translate(new Vec3(-40,-50,50)).rotate((float) pi2, new Vec3(0,1,0)); + transforms[3] = transforms[3].translate(new Vec3(-50,-50,-40)); + transforms[4] = transforms[4].translate(new Vec3(-50,40,-50)).rotate((float) pi2, new Vec3(1,0,0)); + transforms[5] = transforms[5].translate(new Vec3(60,-50,50)).rotate((float) pi2, new Vec3(0,1,0)); + } + + @Override + protected void assembleSelf(RenderTarget target) + { + computeTransforms(); + + int b=0; + + target.pushTransform(new Mat4(1).translate(new Vec3(size,size,0))); + + for (Mat4 tr : transforms) + { + target.pushTransform(tr); + switch (b%3) + { + case 0: + target.fill(0, 0, size, size, new Vec4(255,0,0,255)); + break; + case 1: + target.fill(0, 0, size, size, new Vec4(0,255,0,255)); + break; + case 2: + target.fill(0, 0, size, size, new Vec4(0,0,255,255)); + break; + } + + b++; + target.popTransform(); + } + + target.popTransform(); + } +} diff --git a/src/main/java/ru/windcorp/progressia/test/LayerTitle.java b/src/main/java/ru/windcorp/progressia/test/LayerTitle.java index 365e437..fd40e3a 100644 --- a/src/main/java/ru/windcorp/progressia/test/LayerTitle.java +++ b/src/main/java/ru/windcorp/progressia/test/LayerTitle.java @@ -51,6 +51,8 @@ public class LayerTitle extends GUILayer { System.exit(0); })); + content.addChild(new CubeComponent(name+".Cube")); + getRoot().addChild(content); } From 51bcca14992f0915dc0f0ae1b3e1286c130b84e4 Mon Sep 17 00:00:00 2001 From: opfromthestart Date: Mon, 13 Sep 2021 13:05:59 -0400 Subject: [PATCH 2/6] Betterish title screen -Black background used -New Background class for displaying a single texture to the back of the screen(probably not the best way) -Title now uses an image -Made TextureComponent, I think this probably exists elsewhere but I couldnt find it -Cube faces now change color based on where they are facing, looks a lot like the source material except for rearranging --- .../client/graphics/gui/Background.java | 28 ++++++++++ .../client/graphics/gui/TextureComponent.java | 23 ++++++++ .../progressia/test/CubeComponent.java | 51 +++++++++--------- .../windcorp/progressia/test/LayerTitle.java | 13 ++--- .../assets/textures/title/background.png | Bin 0 -> 133 bytes .../assets/textures/title/progressia.png | Bin 0 -> 2248 bytes 6 files changed, 83 insertions(+), 32 deletions(-) create mode 100644 src/main/java/ru/windcorp/progressia/client/graphics/gui/Background.java create mode 100644 src/main/java/ru/windcorp/progressia/client/graphics/gui/TextureComponent.java create mode 100644 src/main/resources/assets/textures/title/background.png create mode 100644 src/main/resources/assets/textures/title/progressia.png diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/gui/Background.java b/src/main/java/ru/windcorp/progressia/client/graphics/gui/Background.java new file mode 100644 index 0000000..a3312dd --- /dev/null +++ b/src/main/java/ru/windcorp/progressia/client/graphics/gui/Background.java @@ -0,0 +1,28 @@ +package ru.windcorp.progressia.client.graphics.gui; + +import glm.mat._4.Mat4; +import glm.vec._3.Vec3; +import ru.windcorp.progressia.client.graphics.flat.RenderTarget; +import ru.windcorp.progressia.client.graphics.texture.Texture; + +public class Background extends GUILayer { + + protected Texture backgroundTexture; + + public Background(String name, Layout layout, Texture inTexture) { + super(name, layout); + + backgroundTexture = inTexture; + } + + @Override + protected void assemble(RenderTarget target) { + getRoot().setBounds(0, 0, getWidth(), getHeight()); + getRoot().invalidate(); + target.pushTransform(new Mat4(1).translate(new Vec3(0,0,500))); + target.drawTexture(0, 0, getWidth(), getHeight(), backgroundTexture); + target.popTransform(); + getRoot().assemble(target); + } + +} diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/gui/TextureComponent.java b/src/main/java/ru/windcorp/progressia/client/graphics/gui/TextureComponent.java new file mode 100644 index 0000000..98c238b --- /dev/null +++ b/src/main/java/ru/windcorp/progressia/client/graphics/gui/TextureComponent.java @@ -0,0 +1,23 @@ +package ru.windcorp.progressia.client.graphics.gui; + +import ru.windcorp.progressia.client.graphics.flat.RenderTarget; +import ru.windcorp.progressia.client.graphics.texture.Texture; + +public class TextureComponent extends Component { + + private Texture texture; + + public TextureComponent(String name, Texture texture2) { + super(name); + + texture = texture2; + setPreferredSize(texture.getSprite().getWidth(),texture.getSprite().getHeight()); + } + + @Override + protected void assembleSelf(RenderTarget target) + { + target.drawTexture(getX(), getY(), getWidth(), getHeight(), texture); + } + +} diff --git a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java index 8cc9331..cce31a2 100644 --- a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java +++ b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java @@ -13,17 +13,19 @@ import ru.windcorp.progressia.client.graphics.gui.Component; public class CubeComponent extends Component { private Mat4 transforms[]; + private Vec4[] normals; private final double pi2 = Math.PI/2; private final double r3 = Math.sqrt(3); private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); - private int size = 100; + private int size = 250; public CubeComponent(String name) { super(name); transforms = new Mat4[6]; + normals = new Vec4[6]; setPreferredSize((int) Math.ceil(r3*size),(int) Math.ceil(r3*size)); executor.scheduleAtFixedRate(() -> requestReassembly(), 1, 60, TimeUnit.MILLISECONDS); } @@ -45,17 +47,24 @@ public class CubeComponent extends Component { long time = System.currentTimeMillis(); + normals[0] = new Vec4(0,0,-1,0); + normals[1] = new Vec4(0,1,0,0); + normals[2] = new Vec4(1,0,0,0); + normals[3] = new Vec4(0,0,1,0); + normals[4] = new Vec4(0,-1,0,0); + normals[5] = new Vec4(-1,0,0,0); + for (int i=0;i<6;i++) { - transforms[i].rotate((float) (time%(1000*6.28) )/ 1000, new Vec3(0,1,0)).rotate((float) (time%(6777*6.28) )/ 6777, new Vec3(1,0,0)); + normals[i] = transforms[i].rotate((float) (time%(6000*6.28) )/ 6000, new Vec3(0,1,0)).rotate((float) 24, new Vec3(1,.5,0)).mul_(normals[i]); } - transforms[0] = transforms[0].translate(new Vec3(-50,-50,60)); - transforms[1] = transforms[1].translate(new Vec3(-50,-60,-50)).rotate((float) pi2, new Vec3(1,0,0)); - transforms[2] = transforms[2].translate(new Vec3(-40,-50,50)).rotate((float) pi2, new Vec3(0,1,0)); - transforms[3] = transforms[3].translate(new Vec3(-50,-50,-40)); - transforms[4] = transforms[4].translate(new Vec3(-50,40,-50)).rotate((float) pi2, new Vec3(1,0,0)); - transforms[5] = transforms[5].translate(new Vec3(60,-50,50)).rotate((float) pi2, new Vec3(0,1,0)); + transforms[0].translate(new Vec3(-size/2,-size/2,size/2+13)); + transforms[1].translate(new Vec3(-size/2,-size/2-13,-size/2)).rotate((float) pi2, new Vec3(1,0,0)); + transforms[2].translate(new Vec3(-size/2+13,-size/2,size/2)).rotate((float) pi2, new Vec3(0,1,0)); + transforms[3].translate(new Vec3(-size/2,-size/2,-size/2+13)); + transforms[4].translate(new Vec3(-size/2,size/2-13,-size/2)).rotate((float) pi2, new Vec3(1,0,0)); + transforms[5].translate(new Vec3(size/2+13,-size/2,size/2)).rotate((float) pi2, new Vec3(0,1,0)); } @Override @@ -63,27 +72,17 @@ public class CubeComponent extends Component { { computeTransforms(); - int b=0; + target.pushTransform(new Mat4(1).translate(new Vec3(getX()+size*r3/2,getY()+size*r3/2,0))); - target.pushTransform(new Mat4(1).translate(new Vec3(size,size,0))); - - for (Mat4 tr : transforms) + for (int b=0; b<6;b++) { - target.pushTransform(tr); - switch (b%3) - { - case 0: - target.fill(0, 0, size, size, new Vec4(255,0,0,255)); - break; - case 1: - target.fill(0, 0, size, size, new Vec4(0,255,0,255)); - break; - case 2: - target.fill(0, 0, size, size, new Vec4(0,0,255,255)); - break; - } + target.pushTransform(transforms[b]); + + float dot = normals[b].dot(new Vec4(-1,0,0,0)); + Vec4 color = new Vec4(.4+.3*dot, .4+.3*dot, .6+.4*dot,1.0); + + target.fill(0,0, size, size, color); - b++; target.popTransform(); } diff --git a/src/main/java/ru/windcorp/progressia/test/LayerTitle.java b/src/main/java/ru/windcorp/progressia/test/LayerTitle.java index fd40e3a..850fb61 100644 --- a/src/main/java/ru/windcorp/progressia/test/LayerTitle.java +++ b/src/main/java/ru/windcorp/progressia/test/LayerTitle.java @@ -4,13 +4,15 @@ import ru.windcorp.progressia.client.ClientState; import ru.windcorp.progressia.client.graphics.Colors; import ru.windcorp.progressia.client.graphics.GUI; import ru.windcorp.progressia.client.graphics.font.Font; +import ru.windcorp.progressia.client.graphics.gui.Background; import ru.windcorp.progressia.client.graphics.gui.BasicButton; import ru.windcorp.progressia.client.graphics.gui.Button; -import ru.windcorp.progressia.client.graphics.gui.GUILayer; import ru.windcorp.progressia.client.graphics.gui.Group; import ru.windcorp.progressia.client.graphics.gui.Label; +import ru.windcorp.progressia.client.graphics.gui.TextureComponent; import ru.windcorp.progressia.client.graphics.gui.layout.LayoutAlign; import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical; +import ru.windcorp.progressia.client.graphics.texture.SimpleTextures; import ru.windcorp.progressia.client.localization.MutableString; import ru.windcorp.progressia.client.localization.MutableStringLocalized; import ru.windcorp.progressia.common.util.crash.CrashReports; @@ -24,17 +26,16 @@ import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; -public class LayerTitle extends GUILayer { +public class LayerTitle extends Background { private final BasicButton resetButton; public LayerTitle(String name) { - super(name, new LayoutAlign(0.5f, 0.7f, 15)); + super(name, new LayoutAlign(0.5f, 0.7f, 15), SimpleTextures.get("title/background")); Group content = new Group("Layer" + name + ".Group", new LayoutVertical(15)); - MutableString title = new MutableStringLocalized("Layer" + name + ".Title"); - Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f); - content.addChild(new Label(name + ".Title", titleFont, title)); + Font titleFont = new Font().deriveBold().withColor(Colors.BLUE).withAlign(0.5f); + content.addChild(new TextureComponent(name + ".Title", SimpleTextures.get("title/progressia"))); Font buttonFont = titleFont.deriveNotBold(); MutableString playText = new MutableStringLocalized("Layer" + name + ".Play"); diff --git a/src/main/resources/assets/textures/title/background.png b/src/main/resources/assets/textures/title/background.png new file mode 100644 index 0000000000000000000000000000000000000000..21b7d763b03983a8ee441df6eb2344a29f4a3c74 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={W7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!GcfQS24TkI`72U@f>NF?jv*f2Zx1r^0(plPeD{Bw#;3r*(6E}3 XM}dLSOo?kPP@KWj)z4*}Q$iB}sS+Rq literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/textures/title/progressia.png b/src/main/resources/assets/textures/title/progressia.png new file mode 100644 index 0000000000000000000000000000000000000000..7d8ff7c986e924b94554e1efe928561b40a41c20 GIT binary patch literal 2248 zcmW-ic~}$Y7RCc%lf}?5?37p&Gy01bkq z3Zg*}H%iLVLQzpOh*yONu1Z8KZKxKlwhvy{Td4ON|M(@DyyyGQH|M-_Mv;^lYh&qR zNg|PK;`lKl5{Zm~-#iO4_`ISzp$1<@rJ~qqQs=1Kb8um@m6O0Bk+esw7PgoIO^_6y z%yko$!8_0Ul$-$pUh*1R_Az5~OP``szNH$Mggg@)DioPw>EUM|xq-rpvUF$IM@c-T z`;Cmru1JYX{5H=`U)u(7DE^Vl(hr&1I{Fl~tZIF>;^gCi!`J-2(vmH#Lt1|IE;wms z=ii2Zda#l7!F(R9Kr0sP}-tNHJXl!EU#6yGClTf%Q=-8N7))5<@5O&=dv|79z zRg#R1X<0{I5(^j=mz{;V^qhvqNV^$O#3e<1Nhyi6^d^DPt-=mDiDYgb7sE;3x%t)f z?>mw+ZEwwIF!kJ+6$o_Q!3yCZF-+SE#|jSK`RS9C5tXsybv@&KE$zRRGr!?4gDd_z zwMh5fI`*ic!QHOxUT*(3_V49S-i8kUaj4m@jCNdAa6|v_o}M>g`u@(#6t~%O*He!l zz5>_eMtSaJvz|9q(|`V_uIfJXRlEUL*~I4Rxc3=%|M+?3M!WAC8hYO@8K8_M{^VJj z^|!}RSPI2Ze||BQ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njy~3?(8q=asD{cJUpB8H z)^ElVlqrC2agSh-KTee`bJULoK*o2?iXH@xjv`dO;}W9_FOBHwI^ Date: Sat, 25 Sep 2021 20:45:17 -0400 Subject: [PATCH 3/6] Cleaning -Cleaned up offsets to make it look like a cube and not 6 squares. -Fixed error where regions would incorrectly reset files -Some additions to try to match the intended look. I really dont understand layouts. --- .../server/world/io/region/Region.java | 1 + .../server/world/io/region/RegionFile.java | 12 +++++++----- .../progressia/test/CubeComponent.java | 16 +++++++++------- .../windcorp/progressia/test/LayerTitle.java | 17 +++++++++++------ .../assets/textures/title/progressia.png | Bin 2248 -> 11920 bytes 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/main/java/ru/windcorp/progressia/server/world/io/region/Region.java b/src/main/java/ru/windcorp/progressia/server/world/io/region/Region.java index b25535c..1839034 100644 --- a/src/main/java/ru/windcorp/progressia/server/world/io/region/Region.java +++ b/src/main/java/ru/windcorp/progressia/server/world/io/region/Region.java @@ -60,6 +60,7 @@ public class Region { } catch (IOException e) { RegionWorldContainer.LOG.debug("Uh the file broke"); + RegionWorldContainer.LOG.debug(e.getLocalizedMessage()); if (RESET_CORRUPTED) { this.file.makeHeader(regionCoords); } diff --git a/src/main/java/ru/windcorp/progressia/server/world/io/region/RegionFile.java b/src/main/java/ru/windcorp/progressia/server/world/io/region/RegionFile.java index 520d24e..c68f252 100644 --- a/src/main/java/ru/windcorp/progressia/server/world/io/region/RegionFile.java +++ b/src/main/java/ru/windcorp/progressia/server/world/io/region/RegionFile.java @@ -63,9 +63,10 @@ public class RegionFile { } - char prog; + byte prog; + file.seek(0); for (int i=0;i<4;i++) { - prog = file.readChar(); + prog = file.readByte(); if (prog != HEADER_ID[i]) { throw new IOException("File is not a .progressia_chunk file"); @@ -131,14 +132,15 @@ public class RegionFile { } public void makeHeader(Vec3i regionCoords) throws IOException { + file.seek(0); + for (int i = 0; i < HEADER_SIZE; i++) { + file.write(0); + } file.seek(0); file.write(HEADER_ID); file.writeInt(regionCoords.x); file.writeInt(regionCoords.y); file.writeInt(regionCoords.z); - for (int i = 0; i < HEADER_SIZE; i++) { - file.write(0); - } } public void writeBuffer(byte[] buffer, int dataOffset, Vec3i pos) throws IOException { diff --git a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java index cce31a2..90eaf30 100644 --- a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java +++ b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java @@ -20,7 +20,7 @@ public class CubeComponent extends Component { private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); - private int size = 250; + private int size = 400; public CubeComponent(String name) { super(name); @@ -59,12 +59,12 @@ public class CubeComponent extends Component { normals[i] = transforms[i].rotate((float) (time%(6000*6.28) )/ 6000, new Vec3(0,1,0)).rotate((float) 24, new Vec3(1,.5,0)).mul_(normals[i]); } - transforms[0].translate(new Vec3(-size/2,-size/2,size/2+13)); - transforms[1].translate(new Vec3(-size/2,-size/2-13,-size/2)).rotate((float) pi2, new Vec3(1,0,0)); + transforms[0].translate(new Vec3(-size/2,-size/2,size/2+11)); + transforms[1].translate(new Vec3(-size/2,-size/2-12,-size/2)).rotate((float) pi2, new Vec3(1,0,0)); transforms[2].translate(new Vec3(-size/2+13,-size/2,size/2)).rotate((float) pi2, new Vec3(0,1,0)); - transforms[3].translate(new Vec3(-size/2,-size/2,-size/2+13)); - transforms[4].translate(new Vec3(-size/2,size/2-13,-size/2)).rotate((float) pi2, new Vec3(1,0,0)); - transforms[5].translate(new Vec3(size/2+13,-size/2,size/2)).rotate((float) pi2, new Vec3(0,1,0)); + transforms[3].translate(new Vec3(-size/2,-size/2,-size/2+14)); + transforms[4].translate(new Vec3(-size/2,size/2-15.5,-size/2)).rotate((float) pi2, new Vec3(1,0,0)); + transforms[5].translate(new Vec3(size/2+15.5,-size/2,size/2)).rotate((float) pi2, new Vec3(0,1,0)); } @Override @@ -72,7 +72,9 @@ public class CubeComponent extends Component { { computeTransforms(); - target.pushTransform(new Mat4(1).translate(new Vec3(getX()+size*r3/2,getY()+size*r3/2,0))); + setPosition(750,780); + + target.pushTransform(new Mat4(1).translate(new Vec3(getX()+size*r3/2,getY()-size*r3/2,0))); //-size*r3/2 for (int b=0; b<6;b++) { diff --git a/src/main/java/ru/windcorp/progressia/test/LayerTitle.java b/src/main/java/ru/windcorp/progressia/test/LayerTitle.java index 850fb61..baa5e06 100644 --- a/src/main/java/ru/windcorp/progressia/test/LayerTitle.java +++ b/src/main/java/ru/windcorp/progressia/test/LayerTitle.java @@ -31,30 +31,35 @@ public class LayerTitle extends Background { private final BasicButton resetButton; public LayerTitle(String name) { - super(name, new LayoutAlign(0.5f, 0.7f, 15), SimpleTextures.get("title/background")); + super(name, new LayoutAlign(0, 1f, 15), SimpleTextures.get("title/background")); Group content = new Group("Layer" + name + ".Group", new LayoutVertical(15)); + Group buttonContent = new Group("Layer" + name + ".ButtonGroup", new LayoutVertical(15)); Font titleFont = new Font().deriveBold().withColor(Colors.BLUE).withAlign(0.5f); content.addChild(new TextureComponent(name + ".Title", SimpleTextures.get("title/progressia"))); Font buttonFont = titleFont.deriveNotBold(); MutableString playText = new MutableStringLocalized("Layer" + name + ".Play"); - content.addChild(new Button(name + ".Play", new Label(name + ".Play", buttonFont, playText)).addAction(this::startGame)); + buttonContent.addChild(new Button(name + ".Play", new Label(name + ".Play", buttonFont, playText)).addAction(this::startGame)); MutableString resetText = new MutableStringLocalized("Layer" + name + ".Reset"); this.resetButton = new Button(name + ".Reset", new Label(name + ".Reset", buttonFont, resetText)).addAction(this::resetWorld); - content.addChild(resetButton); + buttonContent.addChild(resetButton); updateResetButton(); MutableString quitText = new MutableStringLocalized("Layer" + name + ".Quit"); - content.addChild(new Button(name + "Quit", new Label(name + ".Quit", buttonFont, quitText)).addAction(b -> { + buttonContent.addChild(new Button(name + "Quit", new Label(name + ".Quit", buttonFont, quitText)).addAction(b -> { System.exit(0); })); - content.addChild(new CubeComponent(name+".Cube")); - + content.addChild(buttonContent); getRoot().addChild(content); + buttonContent.setPreferredSize(500, 1000); + + CubeComponent cube = new CubeComponent(name+".Cube"); + + getRoot().addChild(cube); } private void updateResetButton() { diff --git a/src/main/resources/assets/textures/title/progressia.png b/src/main/resources/assets/textures/title/progressia.png index 7d8ff7c986e924b94554e1efe928561b40a41c20..1506b138f3ba6e2ae81338a74f283934af53432c 100644 GIT binary patch literal 11920 zcmaKSbzBo%`}fq_LJ1{Q6cCXvX=#g)8cNCtB?alhKoF)V2t!GU5d%dSBc)3~g-Mry zG)haek%O_l2XDQ-pXd2~-akaxIp;c8owM)vx=x6$jv6fuD-8q!p}nbo<2D3xmdpRb8za|Cirh3{I=RPNM8H7S@6eSc2~8pLLdd<$H?~%g1?Wts^5V_AatMh{_SJt z(|8Plh;ZM$aaG^jd~xLAi=<7zZ-j?ovR+=XEhAHYp;4Jr+)Z*qk+IgYZl)Y1Y`nN+ z7U#$3`6E7G{h~~hcAp_tCE(4K$A2A6xFC$$AI5bj!;r5Q=s%wR*IhQ-azjo@q1t~CcnlqJmm5ljDNbZoZ${~%H<=jy7m{OI%9ItTZ zn+!}nS|_O`fh278pG6w5*D}4&)bS=IU}kCuOYN~IUY^ZhBbwA?#|IhZ`o!FJUg@9w zxNKw_^tA5;jf#&<9(gUlL1yitK?8?z>QOH1gkH;1amA#no|HLd<2J2>YWiZi^+Ah@ zzBMcsJMUop&xajW;{J+u7SK3a%I+>RjbC?Wr2*H;#^5}WlI|7@q03HRG?&t;qt+h^QsnIY-MEx*#Wpr-6~ zJL^{IP#`#pI#R@ZP>rG;Dr1U zvIO;)t+CC9ov2QqYPlEmJ}r6J(cb#J7r}da!FOu*MA<9)u+mEsgDe)ixSes8-oyy$=$Uh*ws(YnObQ-P?za~;Yfy^QkMxUJ9|Ae0=W zQ0FS%jUR(o9OFpWsZRIDpQH(l%QfDpw^MNm*~lv!XIn@v(VZ8@7-7yd(XzMDvomWB zJBS#_XX?K7HS56Shm1t9E$bR7lpG%t(WXs@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same row on opposite sides of the screen -LayoutColumn for a non-max width column -More accessible version string --- logs/game.log | 1 + .../client/graphics/gui/Button.java | 4 ++ .../graphics/gui/layout/LayoutAlign.java | 4 +- .../graphics/gui/layout/LayoutEdges.java | 60 +++++++++++++++++++ .../progressia/test/CubeComponent.java | 9 ++- .../windcorp/progressia/test/LayerAbout.java | 4 +- .../windcorp/progressia/test/LayerTitle.java | 22 ++++++- .../progressia/test/LayoutColumn.java | 36 +++++++++++ 8 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 logs/game.log create mode 100644 src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutEdges.java create mode 100644 src/main/java/ru/windcorp/progressia/test/LayoutColumn.java diff --git a/logs/game.log b/logs/game.log new file mode 100644 index 0000000..7244071 --- /dev/null +++ b/logs/game.log @@ -0,0 +1 @@ +22:26:25.948 [Music Thread ] WARN ru.windcorp.progressia.test.TestMusicPlayer > No music found diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/gui/Button.java b/src/main/java/ru/windcorp/progressia/client/graphics/gui/Button.java index 5d42241..e5bc3ef 100644 --- a/src/main/java/ru/windcorp/progressia/client/graphics/gui/Button.java +++ b/src/main/java/ru/windcorp/progressia/client/graphics/gui/Button.java @@ -23,6 +23,10 @@ import ru.windcorp.progressia.client.graphics.flat.RenderTarget; import ru.windcorp.progressia.client.graphics.font.Font; import ru.windcorp.progressia.client.graphics.Colors; +/** Class for a traditional button that gets clicked to activate + * + * @author opfromthestart + */ public class Button extends BasicButton { public Button(String name, String label, Font labelFont) { diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutAlign.java b/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutAlign.java index d521914..3c75711 100644 --- a/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutAlign.java +++ b/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutAlign.java @@ -27,8 +27,8 @@ import ru.windcorp.progressia.client.graphics.gui.Layout; public class LayoutAlign implements Layout { - private final int margin; - private double alignX, alignY; + protected final int margin; + protected double alignX, alignY; public LayoutAlign(double alignX, double alignY, int margin) { this.alignX = alignX; diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutEdges.java b/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutEdges.java new file mode 100644 index 0000000..2265411 --- /dev/null +++ b/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutEdges.java @@ -0,0 +1,60 @@ +package ru.windcorp.progressia.client.graphics.gui.layout; + +import glm.vec._2.i.Vec2i; +import ru.windcorp.progressia.client.graphics.gui.Component; +import ru.windcorp.progressia.client.graphics.gui.Layout; +import ru.windcorp.progressia.client.localization.MutableStringLocalized; + +import static java.lang.Math.max; +import static java.lang.Math.min; + +public class LayoutEdges implements Layout { + + private int margin; + + public LayoutEdges(int margin) { + this.margin = margin; + } + + @Override + public void layout(Component c) { + for (int i=0;i<2;i++) + { + Component child = c.getChild(i); + + Vec2i size = child.getPreferredSize(); + + int cWidth = c.getWidth() - 2 * margin; + int cHeight = c.getHeight() - 2 * margin; + + size.x = min(size.x, cWidth); + size.y = min(size.y, cHeight); + + if (i==0) { + child.setBounds( + c.getX() + margin, + c.getY(), + size + ); + } else { + child.setBounds( + 1920 - size.x - margin, + c.getY(), + size + ); + } + + } + } + + @Override + public Vec2i calculatePreferredSize(Component c) { + Vec2i result = new Vec2i(1920,0); + c.getChildren().stream() + .map(child -> child.getPreferredSize()) + .forEach(size -> { + result.y = max(Math.abs(size.y), result.y); + }); + return result; + } +} diff --git a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java index 90eaf30..e3c029c 100644 --- a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java +++ b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java @@ -21,9 +21,14 @@ public class CubeComponent extends Component { private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); private int size = 400; - - public CubeComponent(String name) { + + public CubeComponent(String name) + { + this(name, 400); + } + public CubeComponent(String name, int size) { super(name); + this.size = size; transforms = new Mat4[6]; normals = new Vec4[6]; setPreferredSize((int) Math.ceil(r3*size),(int) Math.ceil(r3*size)); diff --git a/src/main/java/ru/windcorp/progressia/test/LayerAbout.java b/src/main/java/ru/windcorp/progressia/test/LayerAbout.java index fae2357..36d1b65 100644 --- a/src/main/java/ru/windcorp/progressia/test/LayerAbout.java +++ b/src/main/java/ru/windcorp/progressia/test/LayerAbout.java @@ -30,6 +30,8 @@ import ru.windcorp.progressia.client.localization.MutableStringLocalized; public class LayerAbout extends GUILayer { + public static String version = "pre-alpha 3"; + public LayerAbout() { super("LayerAbout", new LayoutAlign(1, 1, 5)); @@ -50,7 +52,7 @@ public class LayerAbout extends GUILayer { new Label( "Version", font, - new MutableStringLocalized("LayerAbout.Version").format("pre-alpha 3") + new MutableStringLocalized("LayerAbout.Version").format(version) ) ); diff --git a/src/main/java/ru/windcorp/progressia/test/LayerTitle.java b/src/main/java/ru/windcorp/progressia/test/LayerTitle.java index baa5e06..101712d 100644 --- a/src/main/java/ru/windcorp/progressia/test/LayerTitle.java +++ b/src/main/java/ru/windcorp/progressia/test/LayerTitle.java @@ -11,6 +11,7 @@ import ru.windcorp.progressia.client.graphics.gui.Group; import ru.windcorp.progressia.client.graphics.gui.Label; import ru.windcorp.progressia.client.graphics.gui.TextureComponent; import ru.windcorp.progressia.client.graphics.gui.layout.LayoutAlign; +import ru.windcorp.progressia.client.graphics.gui.layout.LayoutEdges; import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical; import ru.windcorp.progressia.client.graphics.texture.SimpleTextures; import ru.windcorp.progressia.client.localization.MutableString; @@ -33,11 +34,28 @@ public class LayerTitle extends Background { public LayerTitle(String name) { super(name, new LayoutAlign(0, 1f, 15), SimpleTextures.get("title/background")); Group content = new Group("Layer" + name + ".Group", new LayoutVertical(15)); - Group buttonContent = new Group("Layer" + name + ".ButtonGroup", new LayoutVertical(15)); + Group info = new Group("Layer"+name+".InfoGroup", new LayoutEdges(30)); + Group buttonContent = new Group("Layer" + name + ".ButtonGroup", new LayoutColumn(15, 320)); Font titleFont = new Font().deriveBold().withColor(Colors.BLUE).withAlign(0.5f); content.addChild(new TextureComponent(name + ".Title", SimpleTextures.get("title/progressia"))); + info.addChild(new Label( + "About", + titleFont, + new MutableStringLocalized("LayerAbout.Title") + ) + ); + + info.addChild( + new Label( + "Version", + titleFont, + new MutableStringLocalized("LayerAbout.Version").format(LayerAbout.version) + ) + ); + content.addChild(info); + Font buttonFont = titleFont.deriveNotBold(); MutableString playText = new MutableStringLocalized("Layer" + name + ".Play"); buttonContent.addChild(new Button(name + ".Play", new Label(name + ".Play", buttonFont, playText)).addAction(this::startGame)); @@ -57,7 +75,7 @@ public class LayerTitle extends Background { getRoot().addChild(content); buttonContent.setPreferredSize(500, 1000); - CubeComponent cube = new CubeComponent(name+".Cube"); + CubeComponent cube = new CubeComponent(name+".Cube",300); getRoot().addChild(cube); } diff --git a/src/main/java/ru/windcorp/progressia/test/LayoutColumn.java b/src/main/java/ru/windcorp/progressia/test/LayoutColumn.java new file mode 100644 index 0000000..7a87cac --- /dev/null +++ b/src/main/java/ru/windcorp/progressia/test/LayoutColumn.java @@ -0,0 +1,36 @@ +package ru.windcorp.progressia.test; + +import glm.vec._2.i.Vec2i; +import ru.windcorp.progressia.client.graphics.gui.Component; +import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical; + +import static java.lang.Math.min; + +public class LayoutColumn extends LayoutVertical { + + protected int maxWidth; + private int margin; + + public LayoutColumn(int gap, int maxWidth) + { + super(gap); + this.maxWidth = maxWidth; + margin = gap; + } + + @Override + public void layout(Component c) { + int x = c.getX() + margin, + y = c.getY() + c.getHeight(); + + synchronized (c.getChildren()) { + for (Component child : c.getChildren()) { + + int height = child.getPreferredSize().y; + y -= margin + height; + child.setBounds(x, y, maxWidth, height); + + } + } + } +} From 576cfed99f78485987690e403fefcd65e8e51d4a Mon Sep 17 00:00:00 2001 From: OLEGSHA Date: Sun, 17 Oct 2021 14:05:40 +0300 Subject: [PATCH 5/6] Fixed import warnings --- .../progressia/client/graphics/gui/layout/LayoutEdges.java | 2 -- src/main/java/ru/windcorp/progressia/test/LayoutColumn.java | 3 --- 2 files changed, 5 deletions(-) diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutEdges.java b/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutEdges.java index 2265411..5266f53 100644 --- a/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutEdges.java +++ b/src/main/java/ru/windcorp/progressia/client/graphics/gui/layout/LayoutEdges.java @@ -3,8 +3,6 @@ package ru.windcorp.progressia.client.graphics.gui.layout; import glm.vec._2.i.Vec2i; import ru.windcorp.progressia.client.graphics.gui.Component; import ru.windcorp.progressia.client.graphics.gui.Layout; -import ru.windcorp.progressia.client.localization.MutableStringLocalized; - import static java.lang.Math.max; import static java.lang.Math.min; diff --git a/src/main/java/ru/windcorp/progressia/test/LayoutColumn.java b/src/main/java/ru/windcorp/progressia/test/LayoutColumn.java index 7a87cac..5574f7c 100644 --- a/src/main/java/ru/windcorp/progressia/test/LayoutColumn.java +++ b/src/main/java/ru/windcorp/progressia/test/LayoutColumn.java @@ -1,11 +1,8 @@ package ru.windcorp.progressia.test; -import glm.vec._2.i.Vec2i; import ru.windcorp.progressia.client.graphics.gui.Component; import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical; -import static java.lang.Math.min; - public class LayoutColumn extends LayoutVertical { protected int maxWidth; From c1a57f7d7a09f68692aeecdef0b165a99ba04c77 Mon Sep 17 00:00:00 2001 From: opfromthestart Date: Sat, 8 Jan 2022 12:45:28 -0500 Subject: [PATCH 6/6] Slightly better alignment The mode for alignment is more concise --- .../progressia/test/CubeComponent.java | 64 +++++++++++-------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java index e3c029c..bf535d0 100644 --- a/src/main/java/ru/windcorp/progressia/test/CubeComponent.java +++ b/src/main/java/ru/windcorp/progressia/test/CubeComponent.java @@ -12,27 +12,23 @@ import ru.windcorp.progressia.client.graphics.gui.Component; public class CubeComponent extends Component { - private Mat4 transforms[]; - private Vec4[] normals; - - private final double pi2 = Math.PI/2; - private final double r3 = Math.sqrt(3); - - private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); - - private int size = 400; + private final Mat4[] transforms; + private final Vec4[] normals; + private final long startTime; + + private final double r3 = Math.sqrt(3+.01); + + private final int size; - public CubeComponent(String name) - { - this(name, 400); - } public CubeComponent(String name, int size) { super(name); this.size = size; transforms = new Mat4[6]; normals = new Vec4[6]; setPreferredSize((int) Math.ceil(r3*size),(int) Math.ceil(r3*size)); - executor.scheduleAtFixedRate(() -> requestReassembly(), 1, 60, TimeUnit.MILLISECONDS); + ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); + executor.scheduleAtFixedRate(this::requestReassembly, 1, 60, TimeUnit.MILLISECONDS); + startTime = System.currentTimeMillis(); } // Notes to me @@ -43,15 +39,18 @@ public class CubeComponent extends Component { private void computeTransforms() { + //Creates all of the sides transforms[0] = new Mat4(1); transforms[1] = new Mat4(1); transforms[2] = new Mat4(1); transforms[3] = new Mat4(1); transforms[4] = new Mat4(1); transforms[5] = new Mat4(1); - - long time = System.currentTimeMillis(); - + + //Gets time since creation(for rotation amount) + long time = System.currentTimeMillis()-startTime; + + //Initializes the way each face is facing normals[0] = new Vec4(0,0,-1,0); normals[1] = new Vec4(0,1,0,0); normals[2] = new Vec4(1,0,0,0); @@ -61,15 +60,25 @@ public class CubeComponent extends Component { for (int i=0;i<6;i++) { + //Rotates given side with the time one first, then ot get it on its off axis, then gets the image of each axis under the given rotation + //The rotate functions do change the transforms, but the multiplication does not normals[i] = transforms[i].rotate((float) (time%(6000*6.28) )/ 6000, new Vec3(0,1,0)).rotate((float) 24, new Vec3(1,.5,0)).mul_(normals[i]); } - - transforms[0].translate(new Vec3(-size/2,-size/2,size/2+11)); - transforms[1].translate(new Vec3(-size/2,-size/2-12,-size/2)).rotate((float) pi2, new Vec3(1,0,0)); - transforms[2].translate(new Vec3(-size/2+13,-size/2,size/2)).rotate((float) pi2, new Vec3(0,1,0)); - transforms[3].translate(new Vec3(-size/2,-size/2,-size/2+14)); - transforms[4].translate(new Vec3(-size/2,size/2-15.5,-size/2)).rotate((float) pi2, new Vec3(1,0,0)); - transforms[5].translate(new Vec3(size/2+15.5,-size/2,size/2)).rotate((float) pi2, new Vec3(0,1,0)); + double pi2 = Math.PI / 2; + + //Move and rotate the sides from the middle of the cube to the appropriate edges + transforms[0].translate(new Vec3(-size/2f,-size/2f,size/2f)); + transforms[1].translate(new Vec3(-size/2f,-size/2f,-size/2f)).rotate((float) pi2, new Vec3(1,0,0)); + transforms[2].translate(new Vec3(-size/2f,-size/2f,size/2f)).rotate((float) pi2, new Vec3(0,1,0)); + transforms[3].translate(new Vec3(-size/2f,-size/2f,-size/2f)); + transforms[4].translate(new Vec3(-size/2f,size/2f,-size/2f)).rotate((float) pi2, new Vec3(1,0,0)); + transforms[5].translate(new Vec3(size/2f,-size/2f,size/2f)).rotate((float) pi2, new Vec3(0,1,0)); + + for (int i=0;i<6;i++) // I have no clue why this is necessary, without it the sides of the cube mess up; may need to be changed if the title screen changes position. + { + transforms[i] = transforms[i].translate(new Vec3(0,0,17.5-3*(i<2 ? 1 : 0))); + } + } @Override @@ -85,9 +94,10 @@ public class CubeComponent extends Component { { target.pushTransform(transforms[b]); - float dot = normals[b].dot(new Vec4(-1,0,0,0)); - Vec4 color = new Vec4(.4+.3*dot, .4+.3*dot, .6+.4*dot,1.0); - + float dot = normals[b].dot(new Vec4(-1,0,0,0)); //Gets the "amount" the given side is pointing in the -x direction + + Vec4 color = new Vec4(.4+.3*dot, .4+.3*dot, .6+.4*dot,1.0); //More aligned means brighter color + target.fill(0,0, size, size, color); target.popTransform();