Create ComponentWrapper
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
package com.bartlomiejpluta.base.api.game.gui.component;
|
||||||
|
|
||||||
|
import com.bartlomiejpluta.base.api.game.context.Context;
|
||||||
|
import com.bartlomiejpluta.base.api.game.gui.base.GUI;
|
||||||
|
import com.bartlomiejpluta.base.api.game.screen.Screen;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
|
public abstract class ComponentWrapper extends BaseComponent {
|
||||||
|
protected Component component;
|
||||||
|
|
||||||
|
protected ComponentWrapper(Context context, GUI gui) {
|
||||||
|
super(context, gui);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(Component component) {
|
||||||
|
this.component = requireNonNull(component);
|
||||||
|
component.setParent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getContentWidth() {
|
||||||
|
return component.getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getContentHeight() {
|
||||||
|
return component.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Screen screen, GUI gui) {
|
||||||
|
component.setPosition(x, y);
|
||||||
|
component.draw(screen, gui);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,27 +27,27 @@ public final class WindowManager extends BaseWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getContentWidth() {
|
protected final float getContentWidth() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getContentHeight() {
|
protected final float getContentHeight() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSizeMode(SizeMode widthMode, SizeMode heightMode) {
|
public final void setSizeMode(SizeMode widthMode, SizeMode heightMode) {
|
||||||
throw new UnsupportedOperationException("Window Manager is hardcoded to be of MATCH_PARENT mode");
|
throw new UnsupportedOperationException("Window Manager is hardcoded to be of MATCH_PARENT mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWidthMode(SizeMode mode) {
|
public final void setWidthMode(SizeMode mode) {
|
||||||
throw new UnsupportedOperationException("Window Manager is hardcoded to be of MATCH_PARENT mode");
|
throw new UnsupportedOperationException("Window Manager is hardcoded to be of MATCH_PARENT mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeightMode(SizeMode mode) {
|
public final void setHeightMode(SizeMode mode) {
|
||||||
throw new UnsupportedOperationException("Window Manager is hardcoded to be of MATCH_PARENT mode");
|
throw new UnsupportedOperationException("Window Manager is hardcoded to be of MATCH_PARENT mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user