Unfinished rendering system for GUI
This commit is contained in:
parent
3261557dc9
commit
7a04b439ac
17
build.gradle
17
build.gradle
@ -2,10 +2,8 @@ buildscript {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
jcenter()
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,21 +40,6 @@ project(":desktop") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project(":html") {
|
|
||||||
apply plugin: "gwt"
|
|
||||||
apply plugin: "war"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile project(":core")
|
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
|
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
|
|
||||||
compile "com.badlogicgames.ashley:ashley:$ashleyVersion:sources"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
project(":core") {
|
project(":core") {
|
||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
@ -188,6 +188,7 @@ public class GladiatorBrawler extends ApplicationAdapter {
|
|||||||
super.resize(width, height);
|
super.resize(width, height);
|
||||||
RenderingSystem rs = engine.getSystem(RenderingSystem.class);
|
RenderingSystem rs = engine.getSystem(RenderingSystem.class);
|
||||||
float aspectratio = ((float) width) / ((float) height);
|
float aspectratio = ((float) width) / ((float) height);
|
||||||
|
rs.aspectratio = aspectratio;
|
||||||
rs.setViewport((int) (AppUtil.VPHEIGHT_CONST * aspectratio), AppUtil.VPHEIGHT_CONST);
|
rs.setViewport((int) (AppUtil.VPHEIGHT_CONST * aspectratio), AppUtil.VPHEIGHT_CONST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,10 @@ public class GUINode {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<GUINode> getChildren() {
|
||||||
|
return this.children;
|
||||||
|
}
|
||||||
|
|
||||||
public Vector2 getPosition() {
|
public Vector2 getPosition() {
|
||||||
return this.position;
|
return this.position;
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,13 @@ import com.badlogic.gdx.graphics.g2d.Sprite;
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.saltosion.gladiator.components.CPhysics;
|
import com.saltosion.gladiator.components.CPhysics;
|
||||||
import com.saltosion.gladiator.components.CRenderedObject;
|
import com.saltosion.gladiator.components.CRenderedObject;
|
||||||
|
import com.saltosion.gladiator.gui.GUINode;
|
||||||
|
import com.saltosion.gladiator.gui.ImageNode;
|
||||||
import com.saltosion.gladiator.util.AppUtil;
|
import com.saltosion.gladiator.util.AppUtil;
|
||||||
|
import com.saltosion.gladiator.util.Log;
|
||||||
import com.saltosion.gladiator.util.SpriteSequence;
|
import com.saltosion.gladiator.util.SpriteSequence;
|
||||||
|
|
||||||
public class RenderingSystem extends EntitySystem {
|
public class RenderingSystem extends EntitySystem {
|
||||||
@ -30,6 +34,7 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
private ShapeRenderer debugRenderer;
|
private ShapeRenderer debugRenderer;
|
||||||
private OrthographicCamera camera;
|
private OrthographicCamera camera;
|
||||||
|
public float aspectratio;
|
||||||
|
|
||||||
private boolean debug = true;
|
private boolean debug = true;
|
||||||
private final Color debugColor = new Color(0, 1, 0, 1);
|
private final Color debugColor = new Color(0, 1, 0, 1);
|
||||||
@ -79,6 +84,8 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
float nextFrame = renderedObject.getCurrentFrame() + deltaTime * currSequence.getPlayspeed();
|
float nextFrame = renderedObject.getCurrentFrame() + deltaTime * currSequence.getPlayspeed();
|
||||||
renderedObject.setCurrentFrame(nextFrame % currSequence.frameCount());
|
renderedObject.setCurrentFrame(nextFrame % currSequence.frameCount());
|
||||||
}
|
}
|
||||||
|
renderGUINode(AppUtil.guiManager.getRootNode(), Vector2.Zero);
|
||||||
|
|
||||||
batch.end();
|
batch.end();
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@ -100,6 +107,20 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
debugRenderer.end();
|
debugRenderer.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void renderGUINode(GUINode node, Vector2 position) {
|
||||||
|
position.add(node.getPosition());
|
||||||
|
if (node instanceof ImageNode) {
|
||||||
|
Log.info("Node found with ImageNode");
|
||||||
|
Sprite s = ((ImageNode) node).getImage();
|
||||||
|
s.setPosition(position.x*AppUtil.VPHEIGHT_CONST*aspectratio+camera.position.x,
|
||||||
|
position.y*AppUtil.VPHEIGHT_CONST+camera.position.y);
|
||||||
|
s.draw(batch);
|
||||||
|
}
|
||||||
|
for (GUINode child : node.getChildren()) {
|
||||||
|
renderGUINode(child, position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateEntities(Engine engine) {
|
public void updateEntities(Engine engine) {
|
||||||
entities = engine.getEntitiesFor(Family.getFor(CRenderedObject.class, CPhysics.class));
|
entities = engine.getEntitiesFor(Family.getFor(CRenderedObject.class, CPhysics.class));
|
||||||
|
@ -1 +1 @@
|
|||||||
include 'desktop', 'html', 'core'
|
include 'desktop', 'core'
|
Loading…
Reference in New Issue
Block a user