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 int lastNumElements;
|
||||||
|
|
||||||
private RenderingBoLayer layer = RenderingBoLayer.UI1;
|
private short layer = RenderingBoLayer.UI1;
|
||||||
|
|
||||||
public ScrollBar(final String nameSuffix) {
|
public ScrollBar(final String nameSuffix) {
|
||||||
this.name = "Scrollbar_" + nameSuffix;
|
this.name = "Scrollbar_" + nameSuffix;
|
||||||
@@ -83,11 +83,11 @@ public class ScrollBar {
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderingBoLayer getLayer() {
|
public short getLayer() {
|
||||||
return this.layer;
|
return this.layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLayer(final RenderingBoLayer layer) {
|
public void setLayer(final short layer) {
|
||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
|||||||
|
|
||||||
private boolean drawCloseButton;
|
private boolean drawCloseButton;
|
||||||
|
|
||||||
private RenderingBoLayer renderingBoLayer;
|
private short renderingBoLayer;
|
||||||
|
|
||||||
private CoordI2 lastEffectiveViewportDimension;
|
private CoordI2 lastEffectiveViewportDimension;
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
|||||||
.withDimensionAbsolute(this.area.getDimension())
|
.withDimensionAbsolute(this.area.getDimension())
|
||||||
.withPositionAbsoluteAnchorTopLeft(this.area.getPosition())
|
.withPositionAbsoluteAnchorTopLeft(this.area.getPosition())
|
||||||
.setColor(this.color != null ? this.color : null);
|
.setColor(this.color != null ? this.color : null);
|
||||||
if (this.renderingBoLayer != null) {
|
if (this.renderingBoLayer > 0) {
|
||||||
bo.setLayer(this.renderingBoLayer);
|
bo.setLayer(this.renderingBoLayer);
|
||||||
}
|
}
|
||||||
consumer.accept(renderingBo, bo);
|
consumer.accept(renderingBo, bo);
|
||||||
@@ -192,8 +192,8 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
|||||||
.withDimensionAbsolute(this.area.getDimension())
|
.withDimensionAbsolute(this.area.getDimension())
|
||||||
.withPositionAbsoluteAnchorTopLeft(this.area.getPosition())
|
.withPositionAbsoluteAnchorTopLeft(this.area.getPosition())
|
||||||
.setColor(this.color != null ? this.color : null);
|
.setColor(this.color != null ? this.color : null);
|
||||||
if (this.renderingBoLayer != null) {
|
if (this.renderingBoLayer > 0) {
|
||||||
bo.setLayer(RenderingBoLayer.values()[Math.min(this.renderingBoLayer.ordinal() + 2, RenderingBoLayer.values().length - 1)]);
|
bo.setLayer((short) Math.min(this.renderingBoLayer + 20, RenderingBoLayer.TOP));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bo.setLayer(RenderingBoLayer.UI1);
|
bo.setLayer(RenderingBoLayer.UI1);
|
||||||
@@ -332,11 +332,11 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
|||||||
this.draggable = draggable;
|
this.draggable = draggable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderingBoLayer getRenderingBoLayer() {
|
public short getRenderingBoLayer() {
|
||||||
return this.renderingBoLayer;
|
return this.renderingBoLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderingBoLayer(final RenderingBoLayer renderingBoLayer) {
|
public void setRenderingBoLayer(final short renderingBoLayer) {
|
||||||
this.renderingBoLayer = renderingBoLayer;
|
this.renderingBoLayer = renderingBoLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class G2DRenderer implements Renderer {
|
|||||||
this.drawStatistics();
|
this.drawStatistics();
|
||||||
this.rendererData.getRendererWorkingSet().commit(this.rendererModuleId, true);
|
this.rendererData.getRendererWorkingSet().commit(this.rendererModuleId, true);
|
||||||
this.rendererData.getRendererWorkingSet().getLiveSet(this.renderingBOs, this.rendererData.getModuleService()::isDisplayed);
|
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;
|
Graphics2D screenGraphics = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ package de.extio.game_engine.renderer.g2d.bo.rendering;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
import de.extio.game_engine.renderer.model.AbstractRenderingBo;
|
import de.extio.game_engine.renderer.model.AbstractRenderingBo;
|
||||||
import de.extio.game_engine.renderer.model.RenderingBoLayer;
|
|
||||||
|
|
||||||
public abstract class G2DAbstractRenderingBo extends AbstractRenderingBo {
|
public abstract class G2DAbstractRenderingBo extends AbstractRenderingBo {
|
||||||
|
|
||||||
public G2DAbstractRenderingBo(final RenderingBoLayer layer) {
|
public G2DAbstractRenderingBo(final short layer) {
|
||||||
super(layer);
|
super(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ public abstract class AbstractRenderingBo implements RenderingBo {
|
|||||||
|
|
||||||
protected int height;
|
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.layer = layer;
|
||||||
this.defaultLayer = layer;
|
this.defaultLayer = layer;
|
||||||
}
|
}
|
||||||
@@ -288,15 +288,13 @@ public abstract class AbstractRenderingBo implements RenderingBo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingBoLayer getLayer() {
|
public short getLayer() {
|
||||||
return this.layer;
|
return this.layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingBo setLayer(final RenderingBoLayer layer) {
|
public RenderingBo setLayer(final short layer) {
|
||||||
if (layer != null) {
|
|
||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
}
|
|
||||||
return this;
|
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>.
|
* 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.
|
* 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;
|
package de.extio.game_engine.renderer.model;
|
||||||
|
|
||||||
public enum RenderingBoLayer {
|
public class RenderingBoLayer {
|
||||||
|
|
||||||
BACKGROUND0,
|
public static final short BACKGROUND0 = 100;
|
||||||
BACKGROUND1,
|
public static final short BACKGROUND1 = 110;
|
||||||
BACKGROUND2,
|
public static final short BACKGROUND2 = 120;
|
||||||
FOREGROUND0,
|
|
||||||
FOREGROUND1,
|
public static final short FOREGROUND0 = 1000;
|
||||||
FOREGROUND2,
|
public static final short FOREGROUND1 = 1100;
|
||||||
UI_BGR,
|
public static final short FOREGROUND2 = 1200;
|
||||||
UI0,
|
public static final short FOREGROUND3 = 1300;
|
||||||
UI1,
|
public static final short FOREGROUND4 = 1400;
|
||||||
UI2,
|
public static final short FOREGROUND5 = 1500;
|
||||||
TOP;
|
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() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -418,12 +418,12 @@ public class RendererWorkingSetImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingBo setLayer(final RenderingBoLayer layer) {
|
public RenderingBo setLayer(final short layer) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingBoLayer getLayer() {
|
public short getLayer() {
|
||||||
return RenderingBoLayer.UI0;
|
return RenderingBoLayer.UI0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -334,13 +334,13 @@ public class RenderingBoPoolImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingBo setLayer(final RenderingBoLayer layer) {
|
public RenderingBo setLayer(final short layer) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingBoLayer getLayer() {
|
public short getLayer() {
|
||||||
return null;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -483,13 +483,13 @@ public class RenderingBoPoolImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingBo setLayer(final RenderingBoLayer layer) {
|
public RenderingBo setLayer(final short layer) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingBoLayer getLayer() {
|
public short getLayer() {
|
||||||
return null;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user