From 1e53ea50b09552595e6b488e77a1b75f954aa505 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 26 Feb 2020 19:37:22 -0500 Subject: [PATCH] Added support for export/import of all basic terrain as image --- core/assets/bundles/bundle.properties | 6 +- core/src/mindustry/core/ContentLoader.java | 11 ++- core/src/mindustry/core/Platform.java | 35 +++++++- core/src/mindustry/editor/MapEditor.java | 2 +- .../src/mindustry/editor/MapEditorDialog.java | 88 +++++++------------ .../mindustry/entities/def/FlyingComp.java | 4 +- core/src/mindustry/io/MapIO.java | 55 +++++++----- .../maps/planet/TestPlanetGenerator.java | 2 +- core/src/mindustry/type/UnitType.java | 6 +- core/src/mindustry/ui/dialogs/LoadDialog.java | 26 +----- .../mindustry/ui/dialogs/PlanetDialog.java | 5 -- .../ui/dialogs/SchematicsDialog.java | 22 +---- core/src/mindustry/world/Block.java | 6 +- core/src/mindustry/world/ColorMapper.java | 24 +++++ .../mindustry/world/LegacyColorMapper.java | 73 --------------- core/src/mindustry/world/blocks/Cliff.java | 4 +- core/src/mindustry/world/blocks/Floor.java | 4 +- core/src/mindustry/world/blocks/OreBlock.java | 4 +- gradle.properties | 2 +- 19 files changed, 154 insertions(+), 225 deletions(-) create mode 100644 core/src/mindustry/world/ColorMapper.java delete mode 100644 core/src/mindustry/world/LegacyColorMapper.java diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 12985f8ec1..085b94c51f 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -261,8 +261,6 @@ data.openfolder = Open Data Folder data.exported = Data exported. data.invalid = This isn't valid game data. data.import.confirm = Importing external data will overwrite[scarlet] all[] your current game data.\n[accent]This cannot be undone![]\n\nOnce the data is imported, your game will exit immediately. -classic.export = Export Classic Data -classic.export.text = [accent]Mindustry[] has just had a major update.\nClassic (v3.5 build 40) save or map data has been detected. Would you like to export these saves to your phone's home folder, for use in the Mindustry Classic app? quit.confirm = Are you sure you want to quit? quit.confirm.tutorial = Are you sure you know what you're doing?\nThe tutorial can be re-taken in[accent] Settings->Game->Re-Take Tutorial.[] loading = [accent]Loading... @@ -363,13 +361,13 @@ editor.importmap = Import Map editor.importmap.description = Import an already existing map editor.importfile = Import File editor.importfile.description = Import an external map file -editor.importimage = Import Legacy Map +editor.importimage = Import Image File editor.importimage.description = Import an external map image file editor.export = Export... editor.exportfile = Export File editor.exportfile.description = Export a map file editor.exportimage = Export Terrain Image -editor.exportimage.description = Export a map image file +editor.exportimage.description = Export an image file containing only basic terrain editor.loadimage = Import Terrain editor.saveimage = Export Terrain editor.unsaved = [scarlet]You have unsaved changes![]\nAre you sure you want to exit? diff --git a/core/src/mindustry/core/ContentLoader.java b/core/src/mindustry/core/ContentLoader.java index 2f662ef13b..6ed5fea4bb 100644 --- a/core/src/mindustry/core/ContentLoader.java +++ b/core/src/mindustry/core/ContentLoader.java @@ -39,10 +39,7 @@ public class ContentLoader{ new TechTree(), new Weathers(), new Planets(), - new Zones(), - - //these are not really content classes, but this makes initialization easier - new LegacyColorMapper(), + new Zones() }; public ContentLoader(){ @@ -134,13 +131,15 @@ public class ContentLoader{ if(blocks().size > i){ int color = pixmap.getPixel(i, 0); - if(color == 0) continue; + if(color == 0 || color == 255) continue; Block block = block(i); - Color.rgba8888ToColor(block.color, color); + Color.rgba8888ToColor(block.minimapColor, color); + block.hasColor = true; } } pixmap.dispose(); + ColorMapper.load(); } public void dispose(){ diff --git a/core/src/mindustry/core/Platform.java b/core/src/mindustry/core/Platform.java index ba23ff61a5..f1aef6e88f 100644 --- a/core/src/mindustry/core/Platform.java +++ b/core/src/mindustry/core/Platform.java @@ -2,11 +2,12 @@ package mindustry.core; import arc.*; import arc.Input.*; -import arc.struct.*; import arc.files.*; import arc.func.*; import arc.math.*; import arc.scene.ui.*; +import arc.struct.*; +import arc.util.*; import arc.util.serialization.*; import mindustry.mod.*; import mindustry.net.*; @@ -15,7 +16,7 @@ import mindustry.type.*; import mindustry.ui.dialogs.*; import org.mozilla.javascript.*; -import static mindustry.Vars.mobile; +import static mindustry.Vars.*; public interface Platform{ @@ -103,6 +104,32 @@ public interface Platform{ default void shareFile(Fi file){ } + default void export(String name, String extension, FileWriter writer){ + if(!ios){ + platform.showFileChooser(false, extension, file -> { + ui.loadAnd(() -> { + try{ + writer.write(file); + }catch(Throwable e){ + ui.showException(e); + Log.err(e); + } + }); + }); + }else{ + ui.loadAnd(() -> { + try{ + Fi result = Core.files.local(name+ "." + extension); + writer.write(result); + platform.shareFile(result); + }catch(Throwable e){ + ui.showException(e); + Log.err(e); + } + }); + } + } + /** * Show a file chooser. * @param cons Selection listener @@ -130,4 +157,8 @@ public interface Platform{ /** Stops forcing the app into landscape orientation.*/ default void endForceLandscape(){ } + + interface FileWriter{ + void write(Fi file) throws Throwable; + } } diff --git a/core/src/mindustry/editor/MapEditor.java b/core/src/mindustry/editor/MapEditor.java index eefe8f174a..64a60cbd58 100644 --- a/core/src/mindustry/editor/MapEditor.java +++ b/core/src/mindustry/editor/MapEditor.java @@ -64,7 +64,7 @@ public class MapEditor{ reset(); createTiles(pixmap.getWidth(), pixmap.getHeight()); - load(() -> MapIO.readPixmap(pixmap, tiles())); + load(() -> MapIO.readImage(pixmap, tiles())); renderer.resize(width(), height()); } diff --git a/core/src/mindustry/editor/MapEditorDialog.java b/core/src/mindustry/editor/MapEditorDialog.java index a6f9f3b506..0cc46715fd 100644 --- a/core/src/mindustry/editor/MapEditorDialog.java +++ b/core/src/mindustry/editor/MapEditorDialog.java @@ -87,62 +87,42 @@ public class MapEditorDialog extends Dialog implements Disposable{ t.row(); - t.addImageTextButton("$editor.import", Icon.download, () -> - createDialog("$editor.import", - "$editor.importmap", "$editor.importmap.description", Icon.download, (Runnable)loadDialog::show, - "$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() -> - platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> { - maps.tryCatchMapError(() -> { - if(MapIO.isImage(file)){ - ui.showInfo("$editor.errorimage"); - }else{ - editor.beginEdit(MapIO.createMap(file, true)); - } - }); - })), - - "$editor.importimage", "$editor.importimage.description", Icon.fileImage, (Runnable)() -> - platform.showFileChooser(true, "png", file -> - ui.loadAnd(() -> { - try{ - Pixmap pixmap = new Pixmap(file); - editor.beginEdit(pixmap); - pixmap.dispose(); - }catch(Exception e){ - ui.showException("$editor.errorload", e); - Log.err(e); - } - }))) - ); - - t.addImageTextButton("$editor.export", Icon.upload, () -> { - if(!ios){ - platform.showFileChooser(false, mapExtension, file -> { - ui.loadAnd(() -> { - try{ - if(!editor.getTags().containsKey("name")){ - editor.getTags().put("name", file.nameWithoutExtension()); - } - MapIO.writeMap(file, editor.createMap(file)); - }catch(Exception e){ - ui.showException("$editor.errorsave", e); - Log.err(e); - } - }); - }); - }else{ - ui.loadAnd(() -> { - try{ - Fi result = Core.files.local(editor.getTags().get("name", "unknown") + "." + mapExtension); - MapIO.writeMap(result, editor.createMap(result)); - platform.shareFile(result); - }catch(Exception e){ - ui.showException("$editor.errorsave", e); - Log.err(e); + t.addImageTextButton("$editor.import", Icon.download, () -> createDialog("$editor.import", + "$editor.importmap", "$editor.importmap.description", Icon.download, (Runnable)loadDialog::show, + "$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() -> + platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> { + maps.tryCatchMapError(() -> { + if(MapIO.isImage(file)){ + ui.showInfo("$editor.errorimage"); + }else{ + editor.beginEdit(MapIO.createMap(file, true)); } }); - } - }); + })), + + "$editor.importimage", "$editor.importimage.description", Icon.fileImage, (Runnable)() -> + platform.showFileChooser(true, "png", file -> + ui.loadAnd(() -> { + try{ + Pixmap pixmap = new Pixmap(file); + editor.beginEdit(pixmap); + pixmap.dispose(); + }catch(Exception e){ + ui.showException("$editor.errorload", e); + Log.err(e); + } + }))) + ); + + t.addImageTextButton("$editor.export", Icon.upload, () -> createDialog("$editor.export", + "$editor.exportfile", "$editor.exportfile.description", Icon.file, + (Runnable)() -> platform.export(editor.getTags().get("name", "unknown"), mapExtension, file -> MapIO.writeMap(file, editor.createMap(file))), + "$editor.exportimage", "$editor.exportimage.description", Icon.fileImage, + (Runnable)() -> platform.export(editor.getTags().get("name", "unknown"), "png", file -> { + Pixmap out = MapIO.writeImage(editor.tiles()); + file.writePNG(out); + out.dispose(); + }))); }); menu.cont.row(); diff --git a/core/src/mindustry/entities/def/FlyingComp.java b/core/src/mindustry/entities/def/FlyingComp.java index b4cdfc87ed..d5a20724b4 100644 --- a/core/src/mindustry/entities/def/FlyingComp.java +++ b/core/src/mindustry/entities/def/FlyingComp.java @@ -66,7 +66,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{ if(isGrounded() && floor.isLiquid){ if((splashTimer += Mathf.dst(deltaX(), deltaY())) >= 7f){ - floor.walkEffect.at(x, y, 0, floor.color); + floor.walkEffect.at(x, y, 0, floor.minimapColor); splashTimer = 0f; } } @@ -75,7 +75,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{ drownTime += Time.delta() * 1f / floor.drownTime; drownTime = Mathf.clamp(drownTime); if(Mathf.chance(Time.delta() * 0.05f)){ - floor.drownUpdateEffect.at(x, y, 0f, floor.color); + floor.drownUpdateEffect.at(x, y, 0f, floor.minimapColor); } //TODO is the netClient check necessary? diff --git a/core/src/mindustry/io/MapIO.java b/core/src/mindustry/io/MapIO.java index e1a9b3eefa..5657962e6d 100644 --- a/core/src/mindustry/io/MapIO.java +++ b/core/src/mindustry/io/MapIO.java @@ -1,16 +1,16 @@ package mindustry.io; -import arc.struct.*; import arc.files.*; import arc.graphics.*; import arc.graphics.Pixmap.*; +import arc.math.geom.*; +import arc.struct.*; import arc.util.io.*; import mindustry.content.*; import mindustry.core.*; import mindustry.game.*; import mindustry.maps.*; import mindustry.world.*; -import mindustry.world.LegacyColorMapper.*; import mindustry.world.blocks.storage.*; import java.io.*; @@ -147,32 +147,43 @@ public class MapIO{ if(wall.synthetic()){ return team.color.rgba(); } - return Color.rgba8888(wall.solid ? wall.color : ore == Blocks.air ? floor.color : ore.color); + return Color.rgba8888(wall.solid ? wall.minimapColor : ore == Blocks.air ? floor.minimapColor : ore.minimapColor); } - /** Reads a pixmap in the 3.5 pixmap format. */ - public static void readPixmap(Pixmap pixmap, Tiles tiles){ - for(int x = 0; x < pixmap.getWidth(); x++){ - for(int y = 0; y < pixmap.getHeight(); y++){ - int color = pixmap.getPixel(x, pixmap.getHeight() - 1 - y); - LegacyBlock block = LegacyColorMapper.get(color); - Tile tile = tiles.getn(x, y); + public static Pixmap writeImage(Tiles tiles){ + Pixmap pix = new Pixmap(tiles.width, tiles.height); + for(Tile tile : tiles){ + int color = tile.block().hasColor && !tile.block().synthetic() ? tile.block().minimapColor.rgba() : tile.floor().minimapColor.rgba(); + pix.draw(tile.x, tiles.height - 1 - tile.y, color); + } + return pix; + } - tile.setFloor(block.floor); - tile.setBlock(block.wall); - if(block.ore != null) tile.setOverlay(block.ore); + public static void readImage(Pixmap pixmap, Tiles tiles){ + for(Tile tile : tiles){ + int color = pixmap.getPixel(tile.x, pixmap.getHeight() - 1 - tile.y); + Block block = ColorMapper.get(color); - //place core - if(color == Color.rgba8888(Color.green)){ - //actual core parts - tile.setBlock(Blocks.coreShard); - tile.setTeam(Team.sharded); + if(block.isFloor()){ + tile.setFloor(block.asFloor()); + }else if(block.isMultiblock()){ + tile.set(block, Team.derelict); + }else{ + tile.setBlock(block); + } + } + + //guess at floors by grabbing a random adjacent floor + for(Tile tile : tiles){ + if(tile.floor() == Blocks.air && tile.block() != Blocks.air){ + for(Point2 p : Geometry.d4){ + Tile other = tiles.get(tile.x + p.x, tile.y + p.y); + if(other != null && other.floor() != Blocks.air){ + tile.setFloor(other.floor()); + break; + } } } } } - - interface TileProvider{ - Tile get(int x, int y); - } } diff --git a/core/src/mindustry/maps/planet/TestPlanetGenerator.java b/core/src/mindustry/maps/planet/TestPlanetGenerator.java index d1b93a57c6..7bf4f59ec9 100644 --- a/core/src/mindustry/maps/planet/TestPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/TestPlanetGenerator.java @@ -60,7 +60,7 @@ public class TestPlanetGenerator extends PlanetGenerator{ public Color getColor(Vec3 position){ Block block = getBlock(position); //replace salt with sand color - return block == Blocks.salt ? Blocks.sand.color : block.color; + return block == Blocks.salt ? Blocks.sand.minimapColor : block.minimapColor; } @Override diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 9694fbef01..adba81184f 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -231,7 +231,7 @@ public class UnitType extends UnlockableContent{ Floor floor = unit.floorOn(); if(floor.isLiquid){ - Draw.color(Color.white, floor.color, 0.5f); + Draw.color(Color.white, floor.minimapColor, 0.5f); } for(int i : Mathf.signs){ @@ -242,7 +242,7 @@ public class UnitType extends UnlockableContent{ } if(floor.isLiquid){ - Draw.color(Color.white, floor.color, unit.drownTime() * 0.4f); + Draw.color(Color.white, floor.minimapColor, unit.drownTime() * 0.4f); }else{ Draw.color(Color.white); } @@ -255,7 +255,7 @@ public class UnitType extends UnlockableContent{ public void applyColor(Unitc unit){ Draw.mixcol(Color.white, unit.hitTime()); if(unit.drownTime() > 0 && unit.floorOn().isDeep()){ - Draw.mixcol(unit.floorOn().color, unit.drownTime() * 0.8f); + Draw.mixcol(unit.floorOn().minimapColor, unit.drownTime() * 0.8f); } } diff --git a/core/src/mindustry/ui/dialogs/LoadDialog.java b/core/src/mindustry/ui/dialogs/LoadDialog.java index 2d5c6a7e76..e2895f1a92 100644 --- a/core/src/mindustry/ui/dialogs/LoadDialog.java +++ b/core/src/mindustry/ui/dialogs/LoadDialog.java @@ -1,13 +1,12 @@ package mindustry.ui.dialogs; import arc.*; -import arc.struct.*; -import arc.files.*; import arc.graphics.*; import arc.graphics.g2d.*; import arc.scene.style.*; import arc.scene.ui.*; import arc.scene.ui.layout.*; +import arc.struct.*; import arc.util.*; import mindustry.core.GameState.*; import mindustry.game.Saves.*; @@ -15,7 +14,6 @@ import mindustry.gen.*; import mindustry.io.*; import mindustry.io.SaveIO.*; import mindustry.ui.*; -import mindustry.ui.Styles; import java.io.*; @@ -70,6 +68,7 @@ public class LoadDialog extends FloatingDialog{ title.table(t -> { t.right(); + t.defaults().size(40f); t.addImageButton(Icon.save, Styles.emptytogglei, () -> { slot.setAutosave(!slot.isAutosave()); @@ -89,26 +88,7 @@ public class LoadDialog extends FloatingDialog{ }); }).right(); - t.addImageButton(Icon.save, Styles.emptyi, () -> { - if(!ios){ - platform.showFileChooser(false, saveExtension, file -> { - try{ - slot.exportFile(file); - setup(); - }catch(IOException e){ - ui.showException("save.export.fail", e); - } - }); - }else{ - try{ - Fi file = Core.files.local("save-" + slot.getName() + "." + saveExtension); - slot.exportFile(file); - platform.shareFile(file); - }catch(Exception e){ - ui.showException("save.export.fail", e); - } - } - }).right(); + t.addImageButton(Icon.export, Styles.emptyi, () -> platform.export("save-" + slot.getName(), saveExtension, slot::exportFile)).right(); }).padRight(-10).growX(); }).growX().colspan(2); diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 299955f6a1..3c7a63f956 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -162,11 +162,6 @@ public class PlanetDialog extends FloatingDialog{ if(true) Draw.batch(projector, () -> { - if(hovered != null){ - setPlane(hovered); - Fonts.outline.draw("" + hovered.id, 0, 0, Align.center); - } - if(selected != null){ setPlane(selected); stable.draw(); diff --git a/core/src/mindustry/ui/dialogs/SchematicsDialog.java b/core/src/mindustry/ui/dialogs/SchematicsDialog.java index fb29f9fa8e..67cb1aa0e9 100644 --- a/core/src/mindustry/ui/dialogs/SchematicsDialog.java +++ b/core/src/mindustry/ui/dialogs/SchematicsDialog.java @@ -1,7 +1,6 @@ package mindustry.ui.dialogs; import arc.*; -import arc.files.*; import arc.graphics.*; import arc.graphics.Texture.*; import arc.graphics.g2d.*; @@ -216,25 +215,8 @@ public class SchematicsDialog extends FloatingDialog{ }).marginLeft(12f); t.row(); t.addImageTextButton("$schematic.exportfile", Icon.export, style, () -> { - if(!ios){ - platform.showFileChooser(false, schematicExtension, file -> { - dialog.hide(); - try{ - Schematics.write(s, file); - }catch(Throwable e){ - ui.showException(e); - } - }); - }else{ - dialog.hide(); - try{ - Fi file = Core.files.local(s.name() + "." + schematicExtension); - Schematics.write(s, file); - platform.shareFile(file); - }catch(Throwable e){ - ui.showException(e); - } - } + dialog.hide(); + platform.export(s.name(), schematicExtension, file -> Schematics.write(s, file)); }).marginLeft(12f); }); }); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 31ed096ad6..91c81d17c9 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -102,7 +102,9 @@ public class Block extends BlockStorage{ * The color of this block when displayed on the minimap or map preview. * Do not set manually! This is overriden when loading for most blocks. */ - public Color color = new Color(0, 0, 0, 1); + public Color minimapColor = new Color(0, 0, 0, 1); + /** Whether this block has a minimap color. */ + public boolean hasColor = false; /** Whether units target this block. */ public boolean targetable = true; /** Whether the overdrive core has any effect on this block. */ @@ -763,7 +765,7 @@ public class Block extends BlockStorage{ if(!synthetic()){ PixmapRegion image = Core.atlas.getPixmap((AtlasRegion)icon(Cicon.full)); - color.set(image.getPixel(image.width/2, image.height/2)); + minimapColor.set(image.getPixel(image.width/2, image.height/2)); } getGeneratedIcons(); diff --git a/core/src/mindustry/world/ColorMapper.java b/core/src/mindustry/world/ColorMapper.java new file mode 100644 index 0000000000..8eea201ec9 --- /dev/null +++ b/core/src/mindustry/world/ColorMapper.java @@ -0,0 +1,24 @@ +package mindustry.world; + +import arc.graphics.*; +import arc.struct.*; +import mindustry.*; +import mindustry.content.*; + +public class ColorMapper{ + private static final IntMap color2block = new IntMap<>(); + + public static Block get(int color){ + return color2block.get(color, Blocks.air); + } + + public static void load(){ + color2block.clear(); + + for(Block block : Vars.content.blocks()){ + color2block.put(block.minimapColor.rgba(), block); + } + + color2block.put(Color.rgba8888(0, 0, 0, 1), Blocks.air); + } +} diff --git a/core/src/mindustry/world/LegacyColorMapper.java b/core/src/mindustry/world/LegacyColorMapper.java deleted file mode 100644 index 8f3f80e953..0000000000 --- a/core/src/mindustry/world/LegacyColorMapper.java +++ /dev/null @@ -1,73 +0,0 @@ -package mindustry.world; - -import arc.struct.IntMap; -import arc.graphics.Color; -import mindustry.content.Blocks; -import mindustry.ctype.ContentList; -import mindustry.world.blocks.Floor; - -public class LegacyColorMapper implements ContentList{ - private static IntMap blockMap = new IntMap<>(); - private static LegacyBlock defaultValue; - - public static LegacyBlock get(int color){ - return blockMap.get(color, defaultValue); - } - - @Override - public void load(){ - defaultValue = new LegacyBlock(Blocks.stone, Blocks.air); - - map("ff0000", Blocks.stone, Blocks.air, Blocks.spawn); - map("00ff00", Blocks.stone); - map("323232", Blocks.stone); - map("646464", Blocks.stone, Blocks.rocks); - map("50965a", Blocks.grass); - map("5ab464", Blocks.grass, Blocks.pine); - map("506eb4", Blocks.water); - map("465a96", Blocks.deepwater); - map("252525", Blocks.ignarock); - map("575757", Blocks.ignarock, Blocks.duneRocks); - map("988a67", Blocks.sand); - map("e5d8bb", Blocks.sand, Blocks.duneRocks); - map("c2d1d2", Blocks.snow); - map("c4e3e7", Blocks.ice); - map("f7feff", Blocks.snow, Blocks.snowrocks); - map("6e501e", Blocks.holostone); - map("ed5334", Blocks.magmarock); - map("292929", Blocks.tar); - map("c3a490", Blocks.stone, Blocks.air, Blocks.oreCopper); - map("161616", Blocks.stone, Blocks.air, Blocks.oreCoal); - map("6277bc", Blocks.stone, Blocks.air, Blocks.oreTitanium); - map("83bc58", Blocks.stone, Blocks.air, Blocks.oreThorium); - } - - private void map(String color, Block block, Block wall, Block ore){ - blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall, ore)); - } - - private void map(String color, Block block, Block wall){ - blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall)); - } - - private void map(String color, Block block){ - blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, Blocks.air)); - } - - public static class LegacyBlock{ - public final Floor floor; - public final Block wall; - public final Block ore; - - public LegacyBlock(Block floor, Block wall){ - this(floor, wall, Blocks.air); - } - - public LegacyBlock(Block floor, Block wall, Block ore){ - this.floor = (Floor)floor; - this.wall = wall; - this.ore = ore; - } - } - -} diff --git a/core/src/mindustry/world/blocks/Cliff.java b/core/src/mindustry/world/blocks/Cliff.java index 4c71c46bda..6b53b6785d 100644 --- a/core/src/mindustry/world/blocks/Cliff.java +++ b/core/src/mindustry/world/blocks/Cliff.java @@ -21,7 +21,7 @@ public class Cliff extends Block{ int r = tile.rotation(); for(int i = 0; i < 8; i++){ if((r & (1 << i)) != 0){ - Draw.color(Tmp.c1.set(tile.floor().color).mul(1.3f + (i >= 4 ? -0.4f : 0.3f))); + Draw.color(Tmp.c1.set(tile.floor().minimapColor).mul(1.3f + (i >= 4 ? -0.4f : 0.3f))); Draw.rect(region, tile.worldx(), tile.worldy(), 11f, 11f, i * 45f); } } @@ -31,6 +31,6 @@ public class Cliff extends Block{ @Override public int minimapColor(Tile tile){ - return Tmp.c1.set(tile.floor().color).mul(1.2f).rgba(); + return Tmp.c1.set(tile.floor().minimapColor).mul(1.2f).rgba(); } } diff --git a/core/src/mindustry/world/blocks/Floor.java b/core/src/mindustry/world/blocks/Floor.java index db6bf7dac8..4c9afd2a2e 100644 --- a/core/src/mindustry/world/blocks/Floor.java +++ b/core/src/mindustry/world/blocks/Floor.java @@ -110,7 +110,7 @@ public class Floor extends Block{ if(wall == null) wall = Blocks.air; if(decoration == Blocks.air){ - decoration = content.blocks().min(b -> b instanceof Rock && b.breakable ? color.diff(b.color) : Float.POSITIVE_INFINITY); + decoration = content.blocks().min(b -> b instanceof Rock && b.breakable ? minimapColor.diff(b.minimapColor) : Float.POSITIVE_INFINITY); } } @@ -219,7 +219,7 @@ public class Floor extends Block{ for(int i = 0; i < 4; i++){ Tile other = tile.getNearby(i); if(other != null && doEdge(other.floor(), sameLayer)){ - Color color = other.floor().color; + Color color = other.floor().minimapColor; Draw.color(color.r, color.g, color.b, 1f); Draw.rect(edgeRegion, tile.worldx(), tile.worldy(), i*90); } diff --git a/core/src/mindustry/world/blocks/OreBlock.java b/core/src/mindustry/world/blocks/OreBlock.java index f6c25ef06c..6938ffa37d 100644 --- a/core/src/mindustry/world/blocks/OreBlock.java +++ b/core/src/mindustry/world/blocks/OreBlock.java @@ -19,7 +19,7 @@ public class OreBlock extends OverlayFloor{ this.localizedName = ore.localizedName; this.itemDrop = ore; this.variants = 3; - this.color.set(ore.color); + this.minimapColor.set(ore.color); } /** For mod use only!*/ @@ -31,7 +31,7 @@ public class OreBlock extends OverlayFloor{ public void setup(Item ore){ this.localizedName = ore.localizedName; this.itemDrop = ore; - this.color.set(ore.color); + this.minimapColor.set(ore.color); } @Override diff --git a/gradle.properties b/gradle.properties index 675667516d..7f841592d5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=4db0d154520aa33bbd35c0a71a6e1d9794f3f403 +archash=307ea4c34bfa0d16098865a354103a85973398b0