Unfinished rendering system for GUI

This commit is contained in:
Allexit 2015-05-11 15:09:11 +03:00
parent 3261557dc9
commit 7a04b439ac
5 changed files with 27 additions and 18 deletions

View File

@ -2,10 +2,8 @@ buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
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") {
apply plugin: "java"

View File

@ -188,6 +188,7 @@ public class GladiatorBrawler extends ApplicationAdapter {
super.resize(width, height);
RenderingSystem rs = engine.getSystem(RenderingSystem.class);
float aspectratio = ((float) width) / ((float) height);
rs.aspectratio = aspectratio;
rs.setViewport((int) (AppUtil.VPHEIGHT_CONST * aspectratio), AppUtil.VPHEIGHT_CONST);
}
}

View File

@ -54,6 +54,10 @@ public class GUINode {
return this;
}
public ArrayList<GUINode> getChildren() {
return this.children;
}
public Vector2 getPosition() {
return this.position;
}

View File

@ -15,9 +15,13 @@ import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
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.CRenderedObject;
import com.saltosion.gladiator.gui.GUINode;
import com.saltosion.gladiator.gui.ImageNode;
import com.saltosion.gladiator.util.AppUtil;
import com.saltosion.gladiator.util.Log;
import com.saltosion.gladiator.util.SpriteSequence;
public class RenderingSystem extends EntitySystem {
@ -30,6 +34,7 @@ public class RenderingSystem extends EntitySystem {
private BitmapFont font;
private ShapeRenderer debugRenderer;
private OrthographicCamera camera;
public float aspectratio;
private boolean debug = true;
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();
renderedObject.setCurrentFrame(nextFrame % currSequence.frameCount());
}
renderGUINode(AppUtil.guiManager.getRootNode(), Vector2.Zero);
batch.end();
if (debug) {
@ -101,6 +108,20 @@ public class RenderingSystem extends EntitySystem {
}
}
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) {
entities = engine.getEntitiesFor(Family.getFor(CRenderedObject.class, CPhysics.class));
}

View File

@ -1 +1 @@
include 'desktop', 'html', 'core'
include 'desktop', 'core'