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?
|
//TODO duplicated code?
|
||||||
table.table(t -> {
|
table.table(t -> {
|
||||||
t.left();
|
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);
|
t.labelWrap(block.getDisplayName(tile)).left().width(190f).padLeft(5);
|
||||||
}).growX().left();
|
}).growX().left();
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import arc.graphics.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.serialization.*;
|
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(Color.class, (type, data) -> Color.valueOf(data.asString()));
|
||||||
put(StatusEffect.class, (type, data) -> {
|
put(StatusEffect.class, (type, data) -> {
|
||||||
if(data.isString()){
|
if(data.isString()){
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ public class PlacementFragment{
|
|||||||
}
|
}
|
||||||
String keyComboFinal = keyCombo;
|
String keyComboFinal = keyCombo;
|
||||||
header.left();
|
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)
|
header.labelWrap(() -> !unlocked(displayBlock) ? Core.bundle.get("block.unknown") : displayBlock.localizedName + keyComboFinal)
|
||||||
.left().width(190f).padLeft(5);
|
.left().width(190f).padLeft(5);
|
||||||
header.add().growX();
|
header.add().growX();
|
||||||
|
|||||||
@@ -250,6 +250,15 @@ public class PatcherTests{
|
|||||||
assertEquals(1, Vars.state.patcher.patches.first().warnings.size);
|
assertEquals(1, Vars.state.patcher.patches.first().warnings.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testNoIdAssign() throws Exception{
|
||||||
|
Vars.state.patcher.apply(Seq.with("""
|
||||||
|
block.router.id: 9231
|
||||||
|
"""));
|
||||||
|
|
||||||
|
assertEquals(1, Vars.state.patcher.patches.first().warnings.size);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUnknownFieldWarn() throws Exception{
|
void testUnknownFieldWarn() throws Exception{
|
||||||
Vars.state.patcher.apply(Seq.with("""
|
Vars.state.patcher.apply(Seq.with("""
|
||||||
|
|||||||
Reference in New Issue
Block a user