refactor(renderer): Remove controlId from ControlRenderingBo and related classes
This commit is contained in:
@@ -58,7 +58,6 @@ public class ScrollBar {
|
|||||||
this.lastNumElements = numElements;
|
this.lastNumElements = numElements;
|
||||||
|
|
||||||
final var bo = renderingBoPool.acquire(this.name + "_Slider", ControlRenderingBo.class)
|
final var bo = renderingBoPool.acquire(this.name + "_Slider", ControlRenderingBo.class)
|
||||||
.setControlId(this.name)
|
|
||||||
.setType(SliderControl.class)
|
.setType(SliderControl.class)
|
||||||
.setCustomData(Boolean.FALSE)
|
.setCustomData(Boolean.FALSE)
|
||||||
.setCustomData2(Double.valueOf(1.0D - this.scrollPosition))
|
.setCustomData2(Double.valueOf(1.0D - this.scrollPosition))
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ public class Window implements HasPositionAndDimension2, AutoCloseable {
|
|||||||
if (this.drawCloseButton) {
|
if (this.drawCloseButton) {
|
||||||
bo = this.renderingBoPool.acquire(this.name + "_Close", ControlRenderingBo.class)
|
bo = this.renderingBoPool.acquire(this.name + "_Close", ControlRenderingBo.class)
|
||||||
.setType(WindowCloseButtonControl.class)
|
.setType(WindowCloseButtonControl.class)
|
||||||
.setControlId(this.name + "_Close")
|
|
||||||
.setCustomData(this.draggable)
|
.setCustomData(this.draggable)
|
||||||
.setEnabled(true)
|
.setEnabled(true)
|
||||||
.setVisible(true)
|
.setVisible(true)
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
|
|
||||||
public static Map<String, List<BaseControl>> CONTROL_GROUPS = new HashMap<>();
|
public static Map<String, List<BaseControl>> CONTROL_GROUPS = new HashMap<>();
|
||||||
|
|
||||||
private String controlId;
|
|
||||||
|
|
||||||
private Class<? extends BaseControl> clazz;
|
private Class<? extends BaseControl> clazz;
|
||||||
|
|
||||||
private String caption;
|
private String caption;
|
||||||
@@ -69,17 +67,6 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
super(RenderingBoLayer.UI0_0);
|
super(RenderingBoLayer.UI0_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ControlRenderingBo setControlId(final String id) {
|
|
||||||
this.controlId = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getControlId() {
|
|
||||||
return this.controlId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ControlRenderingBo setType(final Class<? extends BaseControl> clazz) {
|
public ControlRenderingBo setType(final Class<? extends BaseControl> clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
@@ -148,7 +135,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(final Graphics2D graphics, final double scaleFactor, final boolean force) {
|
public void render(final Graphics2D graphics, final double scaleFactor, final boolean force) {
|
||||||
var control = (G2DBaseControlImpl) CACHED_CONTROLS.get(this.controlId);
|
var control = (G2DBaseControlImpl) CACHED_CONTROLS.get(this.id);
|
||||||
if (control == null) {
|
if (control == null) {
|
||||||
if (this.clazz == ButtonControl.class) {
|
if (this.clazz == ButtonControl.class) {
|
||||||
control = new G2DButtonControlImpl();
|
control = new G2DButtonControlImpl();
|
||||||
@@ -191,7 +178,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
control.setScaleFactor(scaleFactor)
|
control.setScaleFactor(scaleFactor)
|
||||||
.setControlGroup(this.controlGroup)
|
.setControlGroup(this.controlGroup)
|
||||||
.setRendererData(this.rendererData)
|
.setRendererData(this.rendererData)
|
||||||
.setControlId(this.controlId);
|
.setControlId(this.id);
|
||||||
if (this.clazz == TextfieldControl.class && this.customData instanceof Boolean) {
|
if (this.clazz == TextfieldControl.class && this.customData instanceof Boolean) {
|
||||||
((TextfieldControl) control).setMultiLine(((Boolean) this.customData).booleanValue());
|
((TextfieldControl) control).setMultiLine(((Boolean) this.customData).booleanValue());
|
||||||
}
|
}
|
||||||
@@ -199,7 +186,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
|
|
||||||
control.build();
|
control.build();
|
||||||
|
|
||||||
CACHED_CONTROLS.put(this.controlId, control);
|
CACHED_CONTROLS.put(this.id, control);
|
||||||
if (this.controlGroup != null && !this.controlGroup.isEmpty()) {
|
if (this.controlGroup != null && !this.controlGroup.isEmpty()) {
|
||||||
var controls = CONTROL_GROUPS.get(this.controlGroup);
|
var controls = CONTROL_GROUPS.get(this.controlGroup);
|
||||||
if (controls == null) {
|
if (controls == null) {
|
||||||
@@ -318,7 +305,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
super.apply(other);
|
super.apply(other);
|
||||||
|
|
||||||
if (other instanceof final G2DDrawControl o) {
|
if (other instanceof final G2DDrawControl o) {
|
||||||
this.controlId = o.controlId;
|
this.id = o.id;
|
||||||
this.clazz = o.clazz;
|
this.clazz = o.clazz;
|
||||||
this.caption = o.caption;
|
this.caption = o.caption;
|
||||||
this.controlGroup = o.controlGroup;
|
this.controlGroup = o.controlGroup;
|
||||||
@@ -337,7 +324,7 @@ public class G2DDrawControl extends G2DAbstractRenderingBo implements ControlRen
|
|||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
super.close();
|
super.close();
|
||||||
|
|
||||||
this.controlId = null;
|
this.id = null;
|
||||||
this.clazz = null;
|
this.clazz = null;
|
||||||
this.caption = null;
|
this.caption = null;
|
||||||
this.controlGroup = null;
|
this.controlGroup = null;
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ import de.extio.game_engine.resource.StaticResource;
|
|||||||
*/
|
*/
|
||||||
public interface ControlRenderingBo extends RenderingBoHasDimension {
|
public interface ControlRenderingBo extends RenderingBoHasDimension {
|
||||||
|
|
||||||
ControlRenderingBo setControlId(String id);
|
|
||||||
|
|
||||||
String getControlId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the type of the control. See class tree of BaseControl
|
* Sets the type of the control. See class tree of BaseControl
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user