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.Label;
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.TextField;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
@@ -50,6 +51,10 @@ public class UIActor extends Group {
newActor = new Label("", Controls.GetSkin());
readLabelProperties((Label) newActor, new OrderedMap.OrderedMapEntries<>(element));
break;
case "Table":
newActor = new Table(Controls.GetSkin());
readTableProperties((Table) newActor, new OrderedMap.OrderedMapEntries<>(element));
break;
case "Image":
newActor = new Image();
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) {
}

View File

@@ -1,51 +1,51 @@
{
"width": 480,
"height": 270,
"yDown": true,
"elements":[
"width": 480,
"height": 270,
"yDown": true,
"elements": [
{
"type" : "Image",
"image":"ui/title_bg.png",
"type": "Image",
"image": "ui/title_bg.png",
"width": 480,
"height": 270
} ,
},
{
"type" : "Image",
"type": "Image",
"name": "preview",
"x": 364,
"y": 10 ,
"x": 364,
"y": 10,
"width": 96,
"height": 54
} ,
},
{
"type" : "Scroll",
"type": "Scroll",
"name": "saveSlots",
"x": 10,
"y": 10 ,
"x": 10,
"y": 10,
"width": 344,
"height": 235
} ,
},
{
"type" : "TextButton",
"name" : "return" ,
"text" : "Back" ,
"width": 48,
"height": 16,
"x": 15,
"y": 250
} ,
"type": "TextButton",
"name": "return",
"text": "Back",
"width": 48,
"height": 16,
"x": 15,
"y": 250
},
{
"type" : "TextButton",
"name" : "save" ,
"text" : "saveLoad" ,
"width": 48,
"height": 16,
"x": 115,
"y": 250
}
]
"type": "TextButton",
"name": "save",
"text": "saveLoad",
"width": 48,
"height": 16,
"x": 115,
"y": 250
},
{
"type": "Table",
"font": "default"
}
]
}

View File

@@ -2,96 +2,103 @@
"width": 480,
"height": 270,
"yDown": true,
"elements":[
"elements": [
{
"type" : "Image",
"image":"ui/title_bg.png",
"type": "Image",
"image": "ui/title_bg.png",
"width": 480,
"height": 270
} ,
},
{
"type" : "Scroll",
"type": "Scroll",
"name": "enemies",
"x": 206,
"y": 10 ,
"y": 10,
"width": 256,
"height": 235
} ,
},
{
"type" : "Image",
"type": "Image",
"name": "avatar",
"x": 10,
"y": 10 ,
"y": 10,
"width": 64,
"height": 64
} ,
},
{
"type" : "Label",
"type": "Label",
"name": "totalWins",
"x": 90,
"y": 84 ,
"y": 84,
"width": 80,
"height": 24
} ,
"height": 24,
"font": "default"
},
{
"type" : "Label",
"type": "Label",
"text": "Win:",
"x": 10,
"y": 84 ,
"y": 84,
"width": 80,
"height": 24
} ,
"height": 24,
"font": "default"
},
{
"type" : "Label",
"type": "Label",
"name": "totalLoss",
"x": 90,
"y": 104 ,
"y": 104,
"width": 80,
"height": 24
} ,
"height": 24,
"font": "default"
},
{
"type" : "Label",
"type": "Label",
"text": "Loss:",
"x": 10,
"y": 104 ,
"y": 104,
"width": 80,
"height": 24
} ,
"height": 24,
"font": "default"
},
{
"type" : "Label",
"type": "Label",
"name": "lossWinRatio",
"x": 90,
"y": 124 ,
"y": 124,
"width": 80,
"height": 24
} ,
"height": 24,
"font": "default"
},
{
"type" : "Label",
"type": "Label",
"text": "Win Loss Ratio:",
"x": 10,
"y": 124 ,
"y": 124,
"width": 80,
"height": 24
} ,
"height": 24,
"font": "default"
},
{
"type" : "Image",
"image" : "ui/avatarhud.png" ,
"type": "Image",
"image": "ui/avatarhud.png",
"x": 10,
"y": 10 ,
"y": 10,
"width": 64,
"height": 64
} ,
},
{
"type" : "TextButton",
"name" : "return" ,
"text" : "Back" ,
"type": "TextButton",
"name": "return",
"text": "Back",
"width": 48,
"height": 16,
"x": 15,
"y": 250
},
{
"type": "Table",
"font": "default"
}
]
}