Apply BASE Widgets' attributes engine improvement
This commit is contained in:
@@ -2,11 +2,14 @@ package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.Color;
|
||||
import com.bartlomiejpluta.base.api.gui.Component;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.lib.gui.BaseComponent;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Bar extends BaseComponent {
|
||||
|
||||
private final Color stroke;
|
||||
@@ -16,8 +19,8 @@ public class Bar extends BaseComponent {
|
||||
private float actualValue = 1.0f;
|
||||
private final float speed = 0.05f;
|
||||
|
||||
public Bar(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
public Bar(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
|
||||
this.stroke = gui.createColor();
|
||||
this.fill = gui.createColor();
|
||||
|
||||
@@ -2,28 +2,32 @@ package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.Color;
|
||||
import com.bartlomiejpluta.base.api.gui.Component;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.input.Key;
|
||||
import com.bartlomiejpluta.base.api.input.KeyAction;
|
||||
import com.bartlomiejpluta.base.api.input.KeyEvent;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.lib.gui.Label;
|
||||
import com.bartlomiejpluta.base.lib.gui.TextAlignment;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Button extends Label {
|
||||
private final Color color;
|
||||
|
||||
@Setter
|
||||
private Runnable action;
|
||||
|
||||
public Button(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
public Button(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
this.color = gui.createColor();
|
||||
this.color.setRGBA(1, 1, 1, 0);
|
||||
|
||||
setText("");
|
||||
setFontSize(17f);
|
||||
setAlignment(GUI.ALIGN_TOP | GUI.ALIGN_CENTER);
|
||||
setAlignment(TextAlignment.TOP, TextAlignment.CENTER);
|
||||
setColor(0.4f, 0.7f, 0.0f, 1f);
|
||||
setPadding(10f);
|
||||
addEventListener(KeyEvent.TYPE, this::handleKeyEvent);
|
||||
|
||||
@@ -2,18 +2,21 @@ package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.Color;
|
||||
import com.bartlomiejpluta.base.api.gui.Component;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.gui.Paint;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.lib.gui.BaseWindow;
|
||||
|
||||
public abstract class DecoratedWindow extends BaseWindow {
|
||||
import java.util.Map;
|
||||
|
||||
public class DecoratedWindow extends BaseWindow {
|
||||
private final Paint paint;
|
||||
private final Color inner;
|
||||
private final Color outer;
|
||||
|
||||
public DecoratedWindow(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
public DecoratedWindow(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
|
||||
this.inner = gui.createColor();
|
||||
this.outer = gui.createColor();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.Component;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.gui.Ref;
|
||||
import com.bartlomiejpluta.base.api.gui.WindowManager;
|
||||
@@ -9,6 +10,8 @@ import com.bartlomiejpluta.base.lib.gui.VGridOptionChoice;
|
||||
import com.bartlomiejpluta.demo.entity.Player;
|
||||
import com.bartlomiejpluta.demo.runner.DemoRunner;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class EquipmentWindow extends DecoratedWindow {
|
||||
private final DemoRunner runner;
|
||||
@@ -17,8 +20,8 @@ public class EquipmentWindow extends DecoratedWindow {
|
||||
@Ref("eq")
|
||||
private VGridOptionChoice eqGrid;
|
||||
|
||||
public EquipmentWindow(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
public EquipmentWindow(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
this.runner = (DemoRunner) context.getGameRunner();
|
||||
this.player = runner.getPlayer();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.Component;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.gui.Inflatable;
|
||||
import com.bartlomiejpluta.base.api.gui.Ref;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class GameMenuWindow extends DecoratedWindow implements Inflatable {
|
||||
|
||||
@@ -21,8 +24,8 @@ public class GameMenuWindow extends DecoratedWindow implements Inflatable {
|
||||
@Getter
|
||||
private Button exitBtn;
|
||||
|
||||
public GameMenuWindow(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
public GameMenuWindow(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.Component;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.gui.Ref;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
@@ -15,6 +16,7 @@ import com.bartlomiejpluta.demo.util.LimitedQueue;
|
||||
import com.bartlomiejpluta.demo.world.weapon.Weapon;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@@ -43,8 +45,8 @@ public class HUD extends BorderLayout {
|
||||
@Ref("weapon")
|
||||
private IconView weapon;
|
||||
|
||||
public HUD(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
public HUD(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
this.runner = (DemoRunner) context.getGameRunner();
|
||||
this.player = runner.getPlayer();
|
||||
this.runtime = Runtime.getRuntime();
|
||||
|
||||
@@ -2,16 +2,19 @@ package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.Color;
|
||||
import com.bartlomiejpluta.base.api.gui.Component;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.lib.gui.IconView;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemIconView extends IconView {
|
||||
private final Color normal;
|
||||
private final Color hover;
|
||||
|
||||
public ItemIconView(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
public ItemIconView(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
this.normal = gui.createColor();
|
||||
this.hover = gui.createColor();
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.bartlomiejpluta.demo.gui;
|
||||
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.Component;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.gui.Inflatable;
|
||||
import com.bartlomiejpluta.base.api.gui.Ref;
|
||||
import com.bartlomiejpluta.base.lib.gui.VOptionChoice;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class StartMenuWindow extends DecoratedWindow implements Inflatable {
|
||||
|
||||
@Ref("new_game")
|
||||
@@ -16,8 +20,8 @@ public class StartMenuWindow extends DecoratedWindow implements Inflatable {
|
||||
@Getter
|
||||
private Button exitBtn;
|
||||
|
||||
public StartMenuWindow(Context context, GUI gui) {
|
||||
super(context, gui);
|
||||
public StartMenuWindow(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,18 +3,14 @@
|
||||
<demo:HUD
|
||||
xmlns:base="com.bartlomiejpluta.base.lib.gui"
|
||||
xmlns:demo="com.bartlomiejpluta.demo.gui"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
heightMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
height="1f">
|
||||
height="relative"
|
||||
width="relative">
|
||||
|
||||
<base:BorderLayout-TopLeft>
|
||||
<demo:Bar
|
||||
ref="hp"
|
||||
strokeColor="0x111111"
|
||||
fillColor="0xFF0000"
|
||||
widthMode="SizeMode.ABSOLUTE"
|
||||
heightMode="SizeMode.ABSOLUTE"
|
||||
width="250f"
|
||||
height="20f"/>
|
||||
</base:BorderLayout-TopLeft>
|
||||
@@ -27,10 +23,9 @@
|
||||
<base:Label
|
||||
ref="log"
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.ABSOLUTE"
|
||||
width="400f"
|
||||
height="25f"
|
||||
alignment="GUI.ALIGN_BOTTOM | GUI.ALIGN_LEFT"
|
||||
alignment="bottom|left"
|
||||
color="0xFFFFFF"
|
||||
fontSize="15f"/>
|
||||
</base:BorderLayout-BottomLeft>
|
||||
@@ -39,10 +34,9 @@
|
||||
<base:Label
|
||||
ref="debug"
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.ABSOLUTE"
|
||||
width="200f"
|
||||
height="25f"
|
||||
alignment="GUI.ALIGN_BOTTOM | GUI.ALIGN_RIGHT"
|
||||
alignment="bottom|right"
|
||||
color="0xFFFFFF"
|
||||
fontSize="15f"/>
|
||||
</base:BorderLayout-BottomRight>
|
||||
|
||||
@@ -3,19 +3,16 @@
|
||||
<demo:GameMenuWindow
|
||||
xmlns:base="com.bartlomiejpluta.base.lib.gui"
|
||||
xmlns:demo="com.bartlomiejpluta.demo.gui"
|
||||
windowPosition="WindowPosition.CENTER"
|
||||
windowPosition="center"
|
||||
margin="10f"
|
||||
padding="20f">
|
||||
|
||||
<base:VLayout
|
||||
width="200f"
|
||||
widthMode="SizeMode.ABSOLUTE">
|
||||
<base:VLayout width="200f">
|
||||
|
||||
<base:Label
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
alignment="GUI.ALIGN_TOP | GUI.ALIGN_CENTER"
|
||||
width="relative"
|
||||
alignment="top|center"
|
||||
red="1f"
|
||||
green="1f"
|
||||
blue="1f"
|
||||
@@ -23,15 +20,11 @@
|
||||
fontSize="30f">Game Menu
|
||||
</base:Label>
|
||||
|
||||
<base:VOptionChoice
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f">
|
||||
|
||||
<base:VOptionChoice width="relative">
|
||||
<demo:Button
|
||||
ref="resume_game"
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
width="relative"
|
||||
red="1f"
|
||||
green="1f"
|
||||
blue="1f"
|
||||
@@ -41,8 +34,7 @@
|
||||
<demo:Button
|
||||
ref="start_menu"
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
width="relative"
|
||||
red="1f"
|
||||
green="1f"
|
||||
blue="1f"
|
||||
@@ -52,14 +44,12 @@
|
||||
<demo:Button
|
||||
ref="exit"
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
width="relative"
|
||||
red="1f"
|
||||
green="1f"
|
||||
blue="1f"
|
||||
fontSize="17f">Exit
|
||||
</demo:Button>
|
||||
|
||||
</base:VOptionChoice>
|
||||
|
||||
</base:VLayout>
|
||||
|
||||
@@ -3,19 +3,15 @@
|
||||
<demo:StartMenuWindow
|
||||
xmlns:base="com.bartlomiejpluta.base.lib.gui"
|
||||
xmlns:demo="com.bartlomiejpluta.demo.gui"
|
||||
windowPosition="WindowPosition.BOTTOM"
|
||||
windowPosition="bottom"
|
||||
margin="10f"
|
||||
padding="20f">
|
||||
|
||||
<base:VLayout
|
||||
width="200f"
|
||||
widthMode="SizeMode.ABSOLUTE">
|
||||
|
||||
<base:VLayout width="200f">
|
||||
<base:Label
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
alignment="GUI.ALIGN_TOP | GUI.ALIGN_CENTER"
|
||||
width="relative"
|
||||
alignment="top|center"
|
||||
red="1f"
|
||||
green="1f"
|
||||
blue="1f"
|
||||
@@ -23,15 +19,11 @@
|
||||
fontSize="30f">Menu
|
||||
</base:Label>
|
||||
|
||||
<base:VOptionChoice
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f">
|
||||
|
||||
<base:VOptionChoice ref="menu" width="relative">
|
||||
<demo:Button
|
||||
ref="new_game"
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
width="relative"
|
||||
red="1f"
|
||||
green="1f"
|
||||
blue="1f"
|
||||
@@ -41,16 +33,13 @@
|
||||
<demo:Button
|
||||
ref="exit"
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
width="relative"
|
||||
red="1f"
|
||||
green="1f"
|
||||
blue="1f"
|
||||
fontSize="17f">Exit
|
||||
</demo:Button>
|
||||
|
||||
</base:VOptionChoice>
|
||||
|
||||
</base:VLayout>
|
||||
|
||||
</demo:StartMenuWindow>
|
||||
@@ -3,17 +3,16 @@
|
||||
<demo:EquipmentWindow
|
||||
xmlns:base="com.bartlomiejpluta.base.lib.gui"
|
||||
xmlns:demo="com.bartlomiejpluta.demo.gui"
|
||||
windowPosition="WindowPosition.CENTER"
|
||||
windowPosition="center"
|
||||
padding="20f"
|
||||
widthMode="SizeMode.AUTO"
|
||||
heightMode="SizeMode.AUTO">
|
||||
width="auto"
|
||||
height="auto">
|
||||
|
||||
<base:VLayout widthMode="SizeMode.AUTO" heightMode="SizeMode.AUTO">
|
||||
<base:VLayout width="auto" height="auto">
|
||||
<base:Label
|
||||
font="A.fonts.roboto_regular.uid"
|
||||
widthMode="SizeMode.RELATIVE"
|
||||
width="1f"
|
||||
alignment="GUI.ALIGN_TOP | GUI.ALIGN_CENTER"
|
||||
width="relative"
|
||||
alignment="top|center"
|
||||
red="1f"
|
||||
green="1f"
|
||||
blue="1f"
|
||||
@@ -21,7 +20,7 @@
|
||||
fontSize="30f">Equipment
|
||||
</base:Label>
|
||||
|
||||
<base:VGridOptionChoice ref="eq" columns="4" widthMode="SizeMode.AUTO" heightMode="SizeMode.AUTO">
|
||||
<base:VGridOptionChoice ref="eq" columns="4" width="auto" height="auto">
|
||||
<demo:ItemIconView margin="5f" />
|
||||
<demo:ItemIconView margin="5f" />
|
||||
<demo:ItemIconView margin="5f" />
|
||||
|
||||
Reference in New Issue
Block a user