Patcher support for icon regions
This commit is contained in:
@@ -1509,7 +1509,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
//TODO duplicated code?
|
||||
table.table(t -> {
|
||||
t.left();
|
||||
t.add(new Image(block.getDisplayIcon(tile))).size(8 * 4);
|
||||
t.add(new Image(block.getDisplayIcon(tile))).scaling(Scaling.fit).size(8 * 4);
|
||||
t.labelWrap(block.getDisplayName(tile)).left().width(190f).padLeft(5);
|
||||
}).growX().left();
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.serialization.*;
|
||||
@@ -99,7 +100,22 @@ public class ContentParser{
|
||||
}
|
||||
}
|
||||
});
|
||||
put(TextureRegion.class, (type, data) -> Core.atlas == null ? null : Core.atlas.find(data.asString()));
|
||||
put(TextureRegion.class, (type, data) -> {
|
||||
if(Core.atlas == null) return null;
|
||||
String str = data.asString();
|
||||
if(str.startsWith("icon-")){
|
||||
var icon = Icon.icons.get(str.substring("icon-".length()));
|
||||
if(icon != null){
|
||||
icon.getRegion().scale = 1f / Scl.scl(1f);
|
||||
return icon.getRegion();
|
||||
}
|
||||
}
|
||||
TextureRegion result = Core.atlas.find(str);
|
||||
if(!result.found()){
|
||||
warn("Sprite not found: '" + str + "'");
|
||||
}
|
||||
return result;
|
||||
});
|
||||
put(Color.class, (type, data) -> Color.valueOf(data.asString()));
|
||||
put(StatusEffect.class, (type, data) -> {
|
||||
if(data.isString()){
|
||||
|
||||
@@ -379,7 +379,7 @@ public class PlacementFragment{
|
||||
}
|
||||
String keyComboFinal = keyCombo;
|
||||
header.left();
|
||||
header.add(new Image(displayBlock.uiIcon)).size(8 * 4);
|
||||
header.add(new Image(displayBlock.uiIcon)).scaling(Scaling.fit).size(8 * 4);
|
||||
header.labelWrap(() -> !unlocked(displayBlock) ? Core.bundle.get("block.unknown") : displayBlock.localizedName + keyComboFinal)
|
||||
.left().width(190f).padLeft(5);
|
||||
header.add().growX();
|
||||
|
||||
Reference in New Issue
Block a user