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
This commit is contained in:
parent
ce9e95e5ce
commit
51bcca1499
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
BIN
src/main/resources/assets/textures/title/background.png
Normal file
BIN
src/main/resources/assets/textures/title/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 133 B |
BIN
src/main/resources/assets/textures/title/progressia.png
Normal file
BIN
src/main/resources/assets/textures/title/progressia.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user