update UIActor

- to set Label styles for font inside Table
This commit is contained in:
Anthony Calosa
2022-02-22 12:30:18 +08:00
parent 68ecc56a4e
commit b6a6b4517c
3 changed files with 102 additions and 80 deletions

View File

@@ -9,6 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField; import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.ui.Window;
@@ -50,6 +51,10 @@ public class UIActor extends Group {
newActor = new Label("", Controls.GetSkin()); newActor = new Label("", Controls.GetSkin());
readLabelProperties((Label) newActor, new OrderedMap.OrderedMapEntries<>(element)); readLabelProperties((Label) newActor, new OrderedMap.OrderedMapEntries<>(element));
break; break;
case "Table":
newActor = new Table(Controls.GetSkin());
readTableProperties((Table) newActor, new OrderedMap.OrderedMapEntries<>(element));
break;
case "Image": case "Image":
newActor = new Image(); newActor = new Image();
readImageProperties((Image) newActor, new OrderedMap.OrderedMapEntries<>(element)); readImageProperties((Image) newActor, new OrderedMap.OrderedMapEntries<>(element));
@@ -161,6 +166,16 @@ public class UIActor extends Group {
} }
} }
private void readTableProperties(Table newActor, ObjectMap.Entries<String, String> entries) {
for (ObjectMap.Entry property : entries) {
switch (property.key.toString()) {
case "font":
newActor.getSkin().get(Label.LabelStyle.class).font = Controls.GetSkin().getFont(property.value.toString());
break;
}
}
}
private void readSelectorProperties(Selector newActor, ObjectMap.Entries<String, String> entries) { private void readSelectorProperties(Selector newActor, ObjectMap.Entries<String, String> entries) {
} }

View File

@@ -9,7 +9,6 @@
"width": 480, "width": 480,
"height": 270 "height": 270
}, },
{ {
"type": "Image", "type": "Image",
"name": "preview", "name": "preview",
@@ -18,7 +17,6 @@
"width": 96, "width": 96,
"height": 54 "height": 54
}, },
{ {
"type": "Scroll", "type": "Scroll",
"name": "saveSlots", "name": "saveSlots",
@@ -44,8 +42,10 @@
"height": 16, "height": 16,
"x": 115, "x": 115,
"y": 250 "y": 250
},
{
"type": "Table",
"font": "default"
} }
] ]
} }

View File

@@ -9,7 +9,6 @@
"width": 480, "width": 480,
"height": 270 "height": 270
}, },
{ {
"type": "Scroll", "type": "Scroll",
"name": "enemies", "name": "enemies",
@@ -32,7 +31,8 @@
"x": 90, "x": 90,
"y": 84, "y": 84,
"width": 80, "width": 80,
"height": 24 "height": 24,
"font": "default"
}, },
{ {
"type": "Label", "type": "Label",
@@ -40,7 +40,8 @@
"x": 10, "x": 10,
"y": 84, "y": 84,
"width": 80, "width": 80,
"height": 24 "height": 24,
"font": "default"
}, },
{ {
"type": "Label", "type": "Label",
@@ -48,7 +49,8 @@
"x": 90, "x": 90,
"y": 104, "y": 104,
"width": 80, "width": 80,
"height": 24 "height": 24,
"font": "default"
}, },
{ {
"type": "Label", "type": "Label",
@@ -56,7 +58,8 @@
"x": 10, "x": 10,
"y": 104, "y": 104,
"width": 80, "width": 80,
"height": 24 "height": 24,
"font": "default"
}, },
{ {
"type": "Label", "type": "Label",
@@ -64,7 +67,8 @@
"x": 90, "x": 90,
"y": 124, "y": 124,
"width": 80, "width": 80,
"height": 24 "height": 24,
"font": "default"
}, },
{ {
"type": "Label", "type": "Label",
@@ -72,7 +76,8 @@
"x": 10, "x": 10,
"y": 124, "y": 124,
"width": 80, "width": 80,
"height": 24 "height": 24,
"font": "default"
}, },
{ {
"type": "Image", "type": "Image",
@@ -90,8 +95,10 @@
"height": 16, "height": 16,
"x": 15, "x": 15,
"y": 250 "y": 250
},
{
"type": "Table",
"font": "default"
} }
] ]
} }