1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-14 14:18:50 +03:00

Fixed ore/editor icon generation

This commit is contained in:
Anuken 2019-10-02 20:25:33 -04:00
parent e0ec9a047c
commit 76dbc1cca3
14 changed files with 157 additions and 82 deletions

View File

@ -67,7 +67,7 @@ committingchanges = Comitting Changes
done = Done
mods.alphainfo = Keep in mind that mods are in alpha, and[scarlet] may be very buggy[].\nReport any issues you find to the Mindustry Github or Discord.
mods.alpha = [scarlet](Alpha)
mods.alpha = [accent](Alpha)
mods = Mods
mods.none = [LIGHT_GRAY]No mods found!
mod.enabled = [lightgray]Enabled
@ -459,8 +459,6 @@ settings.graphics = Graphics
settings.cleardata = Clear Game Data...
settings.clear.confirm = Are you sure you want to clear this data?\nWhat is done cannot be undone!
settings.clearall.confirm = [scarlet]WARNING![]\nThis will clear all data, including saves, maps, unlocks and keybinds.\nOnce you press 'ok' the game will wipe all data and automatically exit.
settings.clearunlocks = Clear Unlocks
settings.clearall = Clear All
paused = [accent]< Paused >
yes = Yes
no = No

View File

@ -2741,11 +2741,11 @@ omega-mech-pad
orig: 96, 96
offset: 0, 0
index: -1
block-ore-coal-large
block-ore-coal-full
rotate: false
xy: 609, 1296
size: 40, 40
orig: 40, 40
xy: 661, 46
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1
block-ore-coal-medium
@ -2755,11 +2755,11 @@ block-ore-coal-medium
orig: 32, 32
offset: 0, 0
index: -1
ore-coal-icon-full
block-ore-coal-large
rotate: false
xy: 661, 46
size: 32, 32
orig: 32, 32
xy: 609, 1296
size: 40, 40
orig: 40, 40
offset: 0, 0
index: -1
block-ore-coal-small
@ -2783,11 +2783,11 @@ block-ore-coal-xlarge
orig: 48, 48
offset: 0, 0
index: -1
block-ore-copper-large
block-ore-copper-full
rotate: false
xy: 1557, 1253
size: 40, 40
orig: 40, 40
xy: 695, 80
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1
block-ore-copper-medium
@ -2797,11 +2797,11 @@ block-ore-copper-medium
orig: 32, 32
offset: 0, 0
index: -1
ore-copper-icon-full
block-ore-copper-large
rotate: false
xy: 695, 80
size: 32, 32
orig: 32, 32
xy: 1557, 1253
size: 40, 40
orig: 40, 40
offset: 0, 0
index: -1
block-ore-copper-small
@ -2825,11 +2825,11 @@ block-ore-copper-xlarge
orig: 48, 48
offset: 0, 0
index: -1
block-ore-lead-large
block-ore-lead-full
rotate: false
xy: 1557, 1211
size: 40, 40
orig: 40, 40
xy: 729, 114
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1
block-ore-lead-medium
@ -2839,11 +2839,11 @@ block-ore-lead-medium
orig: 32, 32
offset: 0, 0
index: -1
ore-lead-icon-full
block-ore-lead-large
rotate: false
xy: 729, 114
size: 32, 32
orig: 32, 32
xy: 1557, 1211
size: 40, 40
orig: 40, 40
offset: 0, 0
index: -1
block-ore-lead-small
@ -2867,11 +2867,11 @@ block-ore-lead-xlarge
orig: 48, 48
offset: 0, 0
index: -1
block-ore-scrap-large
block-ore-scrap-full
rotate: false
xy: 1557, 1169
size: 40, 40
orig: 40, 40
xy: 661, 12
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1
block-ore-scrap-medium
@ -2881,11 +2881,11 @@ block-ore-scrap-medium
orig: 32, 32
offset: 0, 0
index: -1
ore-scrap-icon-full
block-ore-scrap-large
rotate: false
xy: 661, 12
size: 32, 32
orig: 32, 32
xy: 1557, 1169
size: 40, 40
orig: 40, 40
offset: 0, 0
index: -1
block-ore-scrap-small
@ -2909,11 +2909,11 @@ block-ore-scrap-xlarge
orig: 48, 48
offset: 0, 0
index: -1
block-ore-thorium-large
block-ore-thorium-full
rotate: false
xy: 1557, 1127
size: 40, 40
orig: 40, 40
xy: 695, 46
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1
block-ore-thorium-medium
@ -2923,11 +2923,11 @@ block-ore-thorium-medium
orig: 32, 32
offset: 0, 0
index: -1
ore-thorium-icon-full
block-ore-thorium-large
rotate: false
xy: 695, 46
size: 32, 32
orig: 32, 32
xy: 1557, 1127
size: 40, 40
orig: 40, 40
offset: 0, 0
index: -1
block-ore-thorium-small
@ -2951,11 +2951,11 @@ block-ore-thorium-xlarge
orig: 48, 48
offset: 0, 0
index: -1
block-ore-titanium-large
block-ore-titanium-full
rotate: false
xy: 1557, 1085
size: 40, 40
orig: 40, 40
xy: 729, 80
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1
block-ore-titanium-medium
@ -2965,11 +2965,11 @@ block-ore-titanium-medium
orig: 32, 32
offset: 0, 0
index: -1
ore-titanium-icon-full
block-ore-titanium-large
rotate: false
xy: 729, 80
size: 32, 32
orig: 32, 32
xy: 1557, 1085
size: 40, 40
orig: 40, 40
offset: 0, 0
index: -1
block-ore-titanium-small

View File

@ -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);
}
}

View File

@ -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.*/

View File

@ -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);
}

View File

@ -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;

View File

@ -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() + ")");

View File

@ -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);

View File

@ -317,6 +317,10 @@ public class SettingsMenuDialog extends SettingsDialog{
tex.setFilter(filter, filter);
}
}
if(!mobile){
Core.settings.put("swapdiagonal", false);
}
}
private void back(){

View File

@ -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");

View File

@ -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;

View File

@ -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();

View File

@ -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);
}
}

View File

@ -265,7 +265,7 @@ public class Generators{
image.save("../editor/editor-ore-" + item.name + (i + 1));
//save icons
image.save(ore.name + "-icon-full");
image.save("block-" + ore.name + "-full");
for(Cicon icon : Cicon.scaled){
Image scaled = new Image(icon.size, icon.size);
scaled.drawScaled(image);