refactor(renderer): change RenderingBoLayer enum to short type for layer representation
This commit is contained in:
@@ -30,7 +30,7 @@ public class ScrollBar {
|
||||
|
||||
private int lastNumElements;
|
||||
|
||||
private RenderingBoLayer layer = RenderingBoLayer.UI1;
|
||||
private short layer = RenderingBoLayer.UI1;
|
||||
|
||||
public ScrollBar(final String nameSuffix) {
|
||||
this.name = "Scrollbar_" + nameSuffix;
|
||||
@@ -83,11 +83,11 @@ public class ScrollBar {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public RenderingBoLayer getLayer() {
|
||||
public short getLayer() {
|
||||
return this.layer;
|
||||
}
|
||||
|
||||
public void setLayer(final RenderingBoLayer layer) {
|
||||
public void setLayer(final short layer) {
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
||||
|
||||
private boolean drawCloseButton;
|
||||
|
||||
private RenderingBoLayer renderingBoLayer;
|
||||
private short renderingBoLayer;
|
||||
|
||||
private CoordI2 lastEffectiveViewportDimension;
|
||||
|
||||
@@ -178,7 +178,7 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
||||
.withDimensionAbsolute(this.area.getDimension())
|
||||
.withPositionAbsoluteAnchorTopLeft(this.area.getPosition())
|
||||
.setColor(this.color != null ? this.color : null);
|
||||
if (this.renderingBoLayer != null) {
|
||||
if (this.renderingBoLayer > 0) {
|
||||
bo.setLayer(this.renderingBoLayer);
|
||||
}
|
||||
consumer.accept(renderingBo, bo);
|
||||
@@ -192,8 +192,8 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
||||
.withDimensionAbsolute(this.area.getDimension())
|
||||
.withPositionAbsoluteAnchorTopLeft(this.area.getPosition())
|
||||
.setColor(this.color != null ? this.color : null);
|
||||
if (this.renderingBoLayer != null) {
|
||||
bo.setLayer(RenderingBoLayer.values()[Math.min(this.renderingBoLayer.ordinal() + 2, RenderingBoLayer.values().length - 1)]);
|
||||
if (this.renderingBoLayer > 0) {
|
||||
bo.setLayer((short) Math.min(this.renderingBoLayer + 20, RenderingBoLayer.TOP));
|
||||
}
|
||||
else {
|
||||
bo.setLayer(RenderingBoLayer.UI1);
|
||||
@@ -332,11 +332,11 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
||||
this.draggable = draggable;
|
||||
}
|
||||
|
||||
public RenderingBoLayer getRenderingBoLayer() {
|
||||
public short getRenderingBoLayer() {
|
||||
return this.renderingBoLayer;
|
||||
}
|
||||
|
||||
public void setRenderingBoLayer(final RenderingBoLayer renderingBoLayer) {
|
||||
public void setRenderingBoLayer(final short renderingBoLayer) {
|
||||
this.renderingBoLayer = renderingBoLayer;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ public class G2DRenderer implements Renderer {
|
||||
this.drawStatistics();
|
||||
this.rendererData.getRendererWorkingSet().commit(this.rendererModuleId, true);
|
||||
this.rendererData.getRendererWorkingSet().getLiveSet(this.renderingBOs, this.rendererData.getModuleService()::isDisplayed);
|
||||
this.renderingBOs.sort((bo0, bo1) -> bo0.getLayer().compareTo(bo1.getLayer()));
|
||||
this.renderingBOs.sort((bo0, bo1) -> Short.compare(bo0.getLayer(), bo1.getLayer()));
|
||||
|
||||
Graphics2D screenGraphics = null;
|
||||
try {
|
||||
|
||||
@@ -3,11 +3,10 @@ package de.extio.game_engine.renderer.g2d.bo.rendering;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import de.extio.game_engine.renderer.model.AbstractRenderingBo;
|
||||
import de.extio.game_engine.renderer.model.RenderingBoLayer;
|
||||
|
||||
public abstract class G2DAbstractRenderingBo extends AbstractRenderingBo {
|
||||
|
||||
public G2DAbstractRenderingBo(final RenderingBoLayer layer) {
|
||||
public G2DAbstractRenderingBo(final short layer) {
|
||||
super(layer);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ public abstract class AbstractRenderingBo implements RenderingBo {
|
||||
|
||||
protected int height;
|
||||
|
||||
protected RenderingBoLayer layer;
|
||||
protected short layer;
|
||||
|
||||
private final RenderingBoLayer defaultLayer;
|
||||
private final short defaultLayer;
|
||||
|
||||
public AbstractRenderingBo(final RenderingBoLayer layer) {
|
||||
public AbstractRenderingBo(final short layer) {
|
||||
this.layer = layer;
|
||||
this.defaultLayer = layer;
|
||||
}
|
||||
@@ -288,15 +288,13 @@ public abstract class AbstractRenderingBo implements RenderingBo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderingBoLayer getLayer() {
|
||||
public short getLayer() {
|
||||
return this.layer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderingBo setLayer(final RenderingBoLayer layer) {
|
||||
if (layer != null) {
|
||||
this.layer = layer;
|
||||
}
|
||||
public RenderingBo setLayer(final short layer) {
|
||||
this.layer = layer;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ public interface RenderingBo extends AutoCloseable {
|
||||
/**
|
||||
* Sets the layer to render this bo on. Business objects are rendered layered on top of each other in the natural order of RenderingBoLayer enum fields. Objects on the same layer are rendered in the order of being added to <i>List<RenderingBo> renderingBo</i>.
|
||||
*/
|
||||
RenderingBo setLayer(RenderingBoLayer layer);
|
||||
RenderingBo setLayer(short layer);
|
||||
|
||||
RenderingBoLayer getLayer();
|
||||
short getLayer();
|
||||
|
||||
/**
|
||||
* Positions this bo with an absolute position on the viewport. x0 y0 coordinates are at the top left. Call RendererControl#getEffectiveViewportDimension to get the absolute dimension of the viewport.
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
package de.extio.game_engine.renderer.model;
|
||||
|
||||
public enum RenderingBoLayer {
|
||||
public class RenderingBoLayer {
|
||||
|
||||
BACKGROUND0,
|
||||
BACKGROUND1,
|
||||
BACKGROUND2,
|
||||
FOREGROUND0,
|
||||
FOREGROUND1,
|
||||
FOREGROUND2,
|
||||
UI_BGR,
|
||||
UI0,
|
||||
UI1,
|
||||
UI2,
|
||||
TOP;
|
||||
public static final short BACKGROUND0 = 100;
|
||||
public static final short BACKGROUND1 = 110;
|
||||
public static final short BACKGROUND2 = 120;
|
||||
|
||||
public static final short FOREGROUND0 = 1000;
|
||||
public static final short FOREGROUND1 = 1100;
|
||||
public static final short FOREGROUND2 = 1200;
|
||||
public static final short FOREGROUND3 = 1300;
|
||||
public static final short FOREGROUND4 = 1400;
|
||||
public static final short FOREGROUND5 = 1500;
|
||||
public static final short FOREGROUND6 = 1600;
|
||||
|
||||
public static final short UI_BGR = 2000;
|
||||
public static final short UI0 = 2100;
|
||||
public static final short UI1 = 2200;
|
||||
public static final short UI2 = 2300;
|
||||
public static final short UI_TOP = 2999;
|
||||
// Note: UI repeats layers per z-index up to TOP
|
||||
|
||||
public static final short TOP = 30000;
|
||||
|
||||
private RenderingBoLayer() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user