Fixed ore/editor icon generation
This commit is contained in:
@@ -388,7 +388,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
GenTile tile = buffer1[px][py];
|
||||
color = MapIO.colorFor(content.block(tile.floor), content.block(tile.block), content.block(tile.ore), Team.derelict);
|
||||
}
|
||||
pixmap.drawPixel(px, pixmap.getHeight() - 1 - py, color);
|
||||
pixmap.draw(px, pixmap.getHeight() - 1 - py, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
@@ -21,8 +22,10 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
this.description = Core.bundle.getOrNull(getContentType() + "." + name + ".description");
|
||||
}
|
||||
|
||||
public void createIcons(){
|
||||
//TODO implement; generate special icons, like mech icons or ores w/ pixmaps
|
||||
/** Generate any special icons for this content. Called asynchronously.*/
|
||||
@CallSuper
|
||||
public void createIcons(PixmapPacker out, PixmapPacker editor){
|
||||
|
||||
}
|
||||
|
||||
/** Returns a specific content icon, or the region {contentType}-{name} if not found.*/
|
||||
|
||||
@@ -106,7 +106,7 @@ public class MinimapRenderer implements Disposable{
|
||||
public void updateAll(){
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, colorFor(world.tile(x, y)));
|
||||
pixmap.draw(x, pixmap.getHeight() - 1 - y, colorFor(world.tile(x, y)));
|
||||
}
|
||||
}
|
||||
texture.draw(pixmap, 0, 0);
|
||||
@@ -114,7 +114,7 @@ public class MinimapRenderer implements Disposable{
|
||||
|
||||
public void update(Tile tile){
|
||||
int color = colorFor(world.tile(tile.x, tile.y));
|
||||
pixmap.drawPixel(tile.x, pixmap.getHeight() - 1 - tile.y, color);
|
||||
pixmap.draw(tile.x, pixmap.getHeight() - 1 - tile.y, color);
|
||||
|
||||
Pixmaps.drawPixel(texture, tile.x, pixmap.getHeight() - 1 - tile.y, color);
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ public class MapIO{
|
||||
super.setBlock(type);
|
||||
int c = colorFor(Blocks.air, block(), Blocks.air, getTeam());
|
||||
if(c != black){
|
||||
walls.drawPixel(x, floors.getHeight() - 1 - y, c);
|
||||
floors.drawPixel(x, floors.getHeight() - 1 - y + 1, shade);
|
||||
walls.draw(x, floors.getHeight() - 1 - y, c);
|
||||
floors.draw(x, floors.getHeight() - 1 - y + 1, shade);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ public class MapIO{
|
||||
@Override
|
||||
public Tile create(int x, int y, int floorID, int overlayID, int wallID){
|
||||
if(overlayID != 0){
|
||||
floors.drawPixel(x, floors.getHeight() - 1 - y, colorFor(Blocks.air, Blocks.air, content.block(overlayID), Team.derelict));
|
||||
floors.draw(x, floors.getHeight() - 1 - y, colorFor(Blocks.air, Blocks.air, content.block(overlayID), Team.derelict));
|
||||
}else{
|
||||
floors.drawPixel(x, floors.getHeight() - 1 - y, colorFor(content.block(floorID), Blocks.air, Blocks.air, Team.derelict));
|
||||
floors.draw(x, floors.getHeight() - 1 - y, colorFor(content.block(floorID), Blocks.air, Blocks.air, Team.derelict));
|
||||
}
|
||||
if(content.block(overlayID) == Blocks.spawn){
|
||||
map.spawns ++;
|
||||
@@ -136,7 +136,7 @@ public class MapIO{
|
||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
||||
for(int y = 0; y < pixmap.getHeight(); y++){
|
||||
Tile tile = tiles[x][y];
|
||||
pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, colorFor(tile.floor(), tile.block(), tile.overlay(), tile.getTeam()));
|
||||
pixmap.draw(x, pixmap.getHeight() - 1 - y, colorFor(tile.floor(), tile.block(), tile.overlay(), tile.getTeam()));
|
||||
}
|
||||
}
|
||||
return pixmap;
|
||||
|
||||
@@ -261,7 +261,9 @@ public class ContentParser{
|
||||
FieldMetadata metadata = fields.get(child.name().replace(" ", "_"));
|
||||
if(metadata == null){
|
||||
if(ignoreUnknownFields){
|
||||
Log.err("{0}: Ignoring unknown field: " + child.name + " (" + type.getName() + ")", object);
|
||||
if(!child.name.equals("research")){
|
||||
Log.err("{0}: Ignoring unknown field: " + child.name + " (" + type.getName() + ")", object);
|
||||
}
|
||||
continue;
|
||||
}else{
|
||||
SerializationException ex = new SerializationException("Field not found: " + child.name + " (" + type.getName() + ")");
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.Pixmap.*;
|
||||
import io.anuke.arc.graphics.Texture.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.graphics.g2d.TextureAtlas.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.io.*;
|
||||
@@ -44,7 +45,8 @@ public class Mods implements Loadable{
|
||||
}
|
||||
|
||||
/** @return the loaded mod found by class, or null if not found. */
|
||||
public @Nullable LoadedMod getMod(Class<? extends Mod> type){
|
||||
public @Nullable
|
||||
LoadedMod getMod(Class<? extends Mod> type){
|
||||
return loaded.find(l -> l.mod.getClass() == type);
|
||||
}
|
||||
|
||||
@@ -74,6 +76,7 @@ public class Mods implements Loadable{
|
||||
if(loaded.isEmpty()) return;
|
||||
|
||||
packer = new PixmapPacker(2048, 2048, Format.RGBA8888, 2, true);
|
||||
|
||||
for(LoadedMod mod : loaded){
|
||||
int[] packed = {0};
|
||||
boolean[] failed = {false};
|
||||
@@ -105,11 +108,32 @@ public class Mods implements Loadable{
|
||||
public void loadSync(){
|
||||
if(packer == null) return;
|
||||
|
||||
Texture editor = Core.atlas.find("clear-editor").getTexture();
|
||||
PixmapPacker editorPacker = new PixmapPacker(2048, 2048, Format.RGBA8888, 2, true);
|
||||
|
||||
for(AtlasRegion region : Core.atlas.getRegions()){
|
||||
if(region.getTexture() == editor){
|
||||
editorPacker.pack(region.name, Core.atlas.getPixmap(region).crop());
|
||||
}
|
||||
}
|
||||
|
||||
//get textures packed
|
||||
if(totalSprites > 0){
|
||||
TextureFilter filter = Core.settings.getBool("linear") ? TextureFilter.Linear : TextureFilter.Nearest;
|
||||
packer.getPages().each(page -> page.updateTexture(filter, filter, false));
|
||||
packer.getPages().each(page -> page.getRects().each((name, rect) -> Core.atlas.addRegion(name, page.getTexture(), (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height)));
|
||||
|
||||
packer.updateTextureAtlas(Core.atlas, filter, filter, false);
|
||||
//generate new icons
|
||||
for(Array<Content> arr : content.getContentMap()){
|
||||
arr.each(c -> {
|
||||
if(c instanceof UnlockableContent && c.mod != null){
|
||||
UnlockableContent u = (UnlockableContent)c;
|
||||
u.createIcons(packer, editorPacker);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editorPacker.updateTextureAtlas(Core.atlas, filter, filter, false);
|
||||
packer.updateTextureAtlas(Core.atlas, filter, filter, false);
|
||||
}
|
||||
|
||||
packer.dispose();
|
||||
@@ -199,6 +223,7 @@ public class Mods implements Loadable{
|
||||
for(FileHandle file : folder.list()){
|
||||
if(file.extension().equals("json")){
|
||||
try{
|
||||
//this binds the content but does not load it entirely
|
||||
Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString(), type);
|
||||
Log.info("[{0}] Loaded '{1}'.", mod.meta.name, loaded);
|
||||
}catch(Exception e){
|
||||
@@ -211,6 +236,7 @@ public class Mods implements Loadable{
|
||||
}
|
||||
}
|
||||
|
||||
//this finishes parsing content fields
|
||||
parser.finishParsing();
|
||||
|
||||
each(Mod::loadContent);
|
||||
|
||||
@@ -317,6 +317,10 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
tex.setFilter(filter, filter);
|
||||
}
|
||||
}
|
||||
|
||||
if(!mobile){
|
||||
Core.settings.put("swapdiagonal", false);
|
||||
}
|
||||
}
|
||||
|
||||
private void back(){
|
||||
|
||||
@@ -667,6 +667,13 @@ public class Block extends BlockStorage{
|
||||
draw.rotation = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createIcons(PixmapPacker out, PixmapPacker editor){
|
||||
super.createIcons(out, editor);
|
||||
|
||||
editor.pack(name + "-icon-editor", Core.atlas.getPixmap((AtlasRegion)icon(Cicon.full)).crop());
|
||||
}
|
||||
|
||||
/** Never use outside of the editor! */
|
||||
public TextureRegion editorIcon(){
|
||||
if(editorIcon == null) editorIcon = Core.atlas.find(name + "-icon-editor");
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.IntSet;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.Effects.Effect;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
/**An overlay ore for a specific item type.*/
|
||||
public class OreBlock extends OverlayFloor{
|
||||
|
||||
@@ -26,6 +32,39 @@ public class OreBlock extends OverlayFloor{
|
||||
this.color.set(ore.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OverrideCallSuper
|
||||
public void createIcons(PixmapPacker out, PixmapPacker editor){
|
||||
for(int i = 0; i < 3; i++){
|
||||
Pixmap image = new Pixmap(32, 32);
|
||||
PixmapRegion shadow = Core.atlas.getPixmap(itemDrop.name + (i + 1));
|
||||
|
||||
int offset = image.getWidth() / tilesize - 1;
|
||||
Color color = new Color();
|
||||
|
||||
for(int x = 0; x < image.getWidth(); x++){
|
||||
for(int y = offset; y < image.getHeight(); y++){
|
||||
shadow.getPixel(x, y - offset, color);
|
||||
|
||||
if(color.a > 0.001f){
|
||||
color.set(0, 0, 0, 0.3f);
|
||||
image.draw(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
image.draw(shadow);
|
||||
|
||||
out.pack(name + (i + 1), image);
|
||||
editor.pack("editor-" + name + (i + 1), image);
|
||||
|
||||
if(i == 0){
|
||||
editor.pack("editor-block-" + name + "-full", image);
|
||||
out.pack("block-" + name + "-full", image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
@@ -144,9 +144,9 @@ public class Drill extends Block{
|
||||
float width = drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / (drillTime + hardnessDrillMultiplier * returnItem.hardness) * returnCount, 2), x, y, valid);
|
||||
float dx = x * tilesize + offset() - width/2f - 4f, dy = y * tilesize + offset() + size * tilesize / 2f + 5;
|
||||
Draw.mixcol(Color.darkGray, 1f);
|
||||
Draw.rect(returnItem.icon(Cicon.medium), dx, dy - 1);
|
||||
Draw.rect(returnItem.icon(Cicon.small), dx, dy - 1);
|
||||
Draw.reset();
|
||||
Draw.rect(returnItem.icon(Cicon.medium), dx, dy);
|
||||
Draw.rect(returnItem.icon(Cicon.small), dx, dy);
|
||||
}else{
|
||||
Tile to = tile.getLinkedTilesAs(this, tempTiles).find(t -> t.drop() != null && t.drop().hardness > tier);
|
||||
Item item = to == null ? null : to.drop();
|
||||
@@ -163,9 +163,9 @@ public class Drill extends Block{
|
||||
if(entity.dominantItem != null){
|
||||
float dx = tile.drawx() - size * tilesize/2f, dy = tile.drawy() + size * tilesize/2f;
|
||||
Draw.mixcol(Color.darkGray, 1f);
|
||||
Draw.rect(entity.dominantItem.icon(Cicon.medium), dx, dy);
|
||||
Draw.rect(entity.dominantItem.icon(Cicon.small), dx, dy - 1);
|
||||
Draw.reset();
|
||||
Draw.rect(entity.dominantItem.icon(Cicon.medium), dx, dy);
|
||||
Draw.rect(entity.dominantItem.icon(Cicon.small), dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user