Misc preparations for unified packing
This commit is contained in:
@@ -32,6 +32,8 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
public boolean inlineDescription = true;
|
public boolean inlineDescription = true;
|
||||||
/** Whether details of blocks are hidden in custom games if they haven't been unlocked in campaign mode. */
|
/** Whether details of blocks are hidden in custom games if they haven't been unlocked in campaign mode. */
|
||||||
public boolean hideDetails = true;
|
public boolean hideDetails = true;
|
||||||
|
/** If false, all icon generation is disabled for this content; createIcons is not called. */
|
||||||
|
public boolean generateIcons = true;
|
||||||
/** Special logic icon ID. */
|
/** Special logic icon ID. */
|
||||||
public int iconId = 0;
|
public int iconId = 0;
|
||||||
/** Icon of the content to use in UI. */
|
/** Icon of the content to use in UI. */
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class MultiPacker implements Disposable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(PageType type, String name, PixmapRegion region){
|
public void add(PageType type, String name, PixmapRegion region){
|
||||||
packers[type.ordinal()].pack(name, region);
|
add(type, name, region, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(PageType type, String name, PixmapRegion region, int[] splits, int[] pads){
|
public void add(PageType type, String name, PixmapRegion region, int[] splits, int[] pads){
|
||||||
@@ -74,7 +74,7 @@ public class MultiPacker implements Disposable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(PageType type, String name, Pixmap pix){
|
public void add(PageType type, String name, Pixmap pix){
|
||||||
packers[type.ordinal()].pack(name, pix);
|
add(type, name, new PixmapRegion(pix));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextureAtlas flush(TextureFilter filter, TextureAtlas atlas){
|
public TextureAtlas flush(TextureFilter filter, TextureAtlas atlas){
|
||||||
@@ -95,13 +95,13 @@ public class MultiPacker implements Disposable{
|
|||||||
//main page (sprites.png) - all sprites for units, weapons, placeable blocks, effects, bullets, etc
|
//main page (sprites.png) - all sprites for units, weapons, placeable blocks, effects, bullets, etc
|
||||||
//environment page (sprites2.png) - all sprites for things in the environmental cache layer
|
//environment page (sprites2.png) - all sprites for things in the environmental cache layer
|
||||||
//editor page (sprites3.png) - all sprites needed for rendering in the editor, including block icons and a few minor sprites
|
//editor page (sprites3.png) - all sprites needed for rendering in the editor, including block icons and a few minor sprites
|
||||||
//zone page (sprites4.png) - zone preview
|
|
||||||
//rubble page - scorch textures for unit deaths & wrecks
|
//rubble page - scorch textures for unit deaths & wrecks
|
||||||
//ui page (sprites5.png) - content icons, white icons, fonts and UI elements
|
//ui page (sprites5.png) - content icons, white icons, fonts and UI elements
|
||||||
public enum PageType{
|
public enum PageType{
|
||||||
//main page can be massive, but 8192 throws GL_OUT_OF_MEMORY on some GPUs and I can't deal with it yet.
|
//main page can be massive, but 8192 throws GL_OUT_OF_MEMORY on some GPUs and I can't deal with it yet.
|
||||||
main(4096),
|
main(4096),
|
||||||
|
|
||||||
|
//TODO stuff like this throws OOM on some devices
|
||||||
environment(4096, 2048),
|
environment(4096, 2048),
|
||||||
editor(4096, 2048),
|
editor(4096, 2048),
|
||||||
rubble(4096, 2048),
|
rubble(4096, 2048),
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ public class Mods implements Loadable{
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
//(horrible code below)
|
//(horrible code below)
|
||||||
}else if(prefix && name.endsWith("-outline") && file.path().contains("units") && !file.path().contains("blocks")){
|
}else if(prefix && !mod.meta.keepOutlines && name.endsWith("-outline") && file.path().contains("units") && !file.path().contains("blocks")){
|
||||||
Log.warn("Sprite '@' in mod '@' is likely to be an unnecessary unit outline. These should not be separate sprites. Ignoring.", name, mod.name);
|
Log.warn("Sprite '@' in mod '@' is likely to be an unnecessary unit outline. These should not be separate sprites. Ignoring.", name, mod.name);
|
||||||
//TODO !!! document this on the wiki !!!
|
//TODO !!! document this on the wiki !!!
|
||||||
//do not allow packing standard outline sprites for now, they are no longer necessary and waste space!
|
//do not allow packing standard outline sprites for now, they are no longer necessary and waste space!
|
||||||
@@ -336,7 +336,9 @@ public class Mods implements Loadable{
|
|||||||
if(c instanceof UnlockableContent u && c.minfo.mod != null){
|
if(c instanceof UnlockableContent u && c.minfo.mod != null){
|
||||||
u.load();
|
u.load();
|
||||||
u.loadIcon();
|
u.loadIcon();
|
||||||
u.createIcons(packer);
|
if(u.generateIcons){
|
||||||
|
u.createIcons(packer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1137,6 +1139,8 @@ public class Mods implements Loadable{
|
|||||||
public boolean hidden;
|
public boolean hidden;
|
||||||
/** If true, this mod should be loaded as a Java class mod. This is technically optional, but highly recommended. */
|
/** If true, this mod should be loaded as a Java class mod. This is technically optional, but highly recommended. */
|
||||||
public boolean java;
|
public boolean java;
|
||||||
|
/** If true, -outline regions for units are kept when packing. Only use if you know exactly what you are doing. */
|
||||||
|
public boolean keepOutlines;
|
||||||
|
|
||||||
public String displayName(){
|
public String displayName(){
|
||||||
return displayName == null ? name : displayName;
|
return displayName == null ? name : displayName;
|
||||||
|
|||||||
@@ -278,8 +278,10 @@ public class Planet extends UnlockableContent{
|
|||||||
public void load(){
|
public void load(){
|
||||||
super.load();
|
super.load();
|
||||||
|
|
||||||
mesh = meshLoader.get();
|
if(!headless){
|
||||||
cloudMesh = cloudMeshLoader.get();
|
mesh = meshLoader.get();
|
||||||
|
cloudMesh = cloudMeshLoader.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -857,6 +857,8 @@ public class UnitType extends UnlockableContent{
|
|||||||
var toOutline = new Seq<TextureRegion>();
|
var toOutline = new Seq<TextureRegion>();
|
||||||
getRegionsToOutline(toOutline);
|
getRegionsToOutline(toOutline);
|
||||||
|
|
||||||
|
boolean separateOutline = weapons.contains(w -> !w.top);
|
||||||
|
|
||||||
for(var region : toOutline){
|
for(var region : toOutline){
|
||||||
if(region instanceof AtlasRegion atlas){
|
if(region instanceof AtlasRegion atlas){
|
||||||
String regionName = atlas.name;
|
String regionName = atlas.name;
|
||||||
@@ -869,9 +871,13 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(outlines){
|
if(outlines){
|
||||||
|
Seq<TextureRegion> outlineSeq = Seq.with(region, jointRegion, footRegion, baseJointRegion, legRegion, treadRegion);
|
||||||
|
if(Core.atlas.has(name + "-leg-base")){
|
||||||
|
outlineSeq.add(legBaseRegion);
|
||||||
|
}
|
||||||
|
|
||||||
//note that mods with these regions already outlined will have *two* outlines made, which is... undesirable
|
//note that mods with these regions already outlined will have *two* outlines made, which is... undesirable
|
||||||
for(var outlineTarget : new TextureRegion[]{region, jointRegion, footRegion, legBaseRegion, baseJointRegion, legRegion, treadRegion}){
|
for(var outlineTarget : outlineSeq){
|
||||||
if(!outlineTarget.found()) continue;
|
if(!outlineTarget.found()) continue;
|
||||||
|
|
||||||
makeOutline(PageType.main, packer, outlineTarget, alwaysCreateOutline && region == outlineTarget, outlineColor, outlineRadius);
|
makeOutline(PageType.main, packer, outlineTarget, alwaysCreateOutline && region == outlineTarget, outlineColor, outlineRadius);
|
||||||
@@ -880,7 +886,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
for(Weapon weapon : weapons){
|
for(Weapon weapon : weapons){
|
||||||
if(!weapon.name.isEmpty()){
|
if(!weapon.name.isEmpty()){
|
||||||
//TODO makeNew isn't really necessary here is it
|
//TODO makeNew isn't really necessary here is it
|
||||||
makeOutline(PageType.main, packer, weapon.region, true, outlineColor, outlineRadius);
|
makeOutline(PageType.main, packer, weapon.region, separateOutline, outlineColor, outlineRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1290,7 +1290,7 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var editorBase = Core.atlas.getPixmap(fullIcon);
|
PixmapRegion editorBase;
|
||||||
|
|
||||||
if(gen.length > 1){
|
if(gen.length > 1){
|
||||||
Pixmap base = Core.atlas.getPixmap(gen[0]).crop();
|
Pixmap base = Core.atlas.getPixmap(gen[0]).crop();
|
||||||
@@ -1304,6 +1304,8 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
packer.add(PageType.main, "block-" + name + "-full", base);
|
packer.add(PageType.main, "block-" + name + "-full", base);
|
||||||
|
|
||||||
editorBase = new PixmapRegion(base);
|
editorBase = new PixmapRegion(base);
|
||||||
|
}else{
|
||||||
|
editorBase = Core.atlas.getPixmap(gen[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
packer.add(PageType.editor, name + "-icon-editor", editorBase);
|
packer.add(PageType.editor, name + "-icon-editor", editorBase);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class ConstructBlock extends Block{
|
|||||||
health = 10;
|
health = 10;
|
||||||
consumesTap = true;
|
consumesTap = true;
|
||||||
solidifes = true;
|
solidifes = true;
|
||||||
|
generateIcons = false;
|
||||||
inEditor = false;
|
inEditor = false;
|
||||||
consBlocks[size - 1] = this;
|
consBlocks[size - 1] = this;
|
||||||
sync = true;
|
sync = true;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class AirBlock extends Floor{
|
|||||||
hasShadow = false;
|
hasShadow = false;
|
||||||
useColor = false;
|
useColor = false;
|
||||||
wall = this;
|
wall = this;
|
||||||
|
generateIcons = false;
|
||||||
needsSurface = false;
|
needsSurface = false;
|
||||||
canShadow = false;
|
canShadow = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,8 +161,8 @@ public class Floor extends Block{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PixmapRegion image = Core.atlas.getPixmap(icons()[0]);
|
var image = Core.atlas.getPixmap(icons()[0]);
|
||||||
PixmapRegion edge = Core.atlas.getPixmap(Core.atlas.find(name + "-edge-stencil", "edge-stencil"));
|
var edge = Core.atlas.getPixmap(Core.atlas.find(name + "-edge-stencil", "edge-stencil"));
|
||||||
Pixmap result = new Pixmap(edge.width, edge.height);
|
Pixmap result = new Pixmap(edge.width, edge.height);
|
||||||
|
|
||||||
for(int x = 0; x < edge.width; x++){
|
for(int x = 0; x < edge.width; x++){
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public class LegacyBlock extends Block{
|
|||||||
public LegacyBlock(String name){
|
public LegacyBlock(String name){
|
||||||
super(name);
|
super(name);
|
||||||
inEditor = false;
|
inEditor = false;
|
||||||
|
generateIcons = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Removes this block from the world, or replaces it with something else. */
|
/** Removes this block from the world, or replaces it with something else. */
|
||||||
|
|||||||
Reference in New Issue
Block a user