Added support for export/import of all basic terrain as image
This commit is contained in:
@@ -261,8 +261,6 @@ data.openfolder = Open Data Folder
|
|||||||
data.exported = Data exported.
|
data.exported = Data exported.
|
||||||
data.invalid = This isn't valid game data.
|
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.
|
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 = 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.[]
|
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...
|
loading = [accent]Loading...
|
||||||
@@ -363,13 +361,13 @@ editor.importmap = Import Map
|
|||||||
editor.importmap.description = Import an already existing map
|
editor.importmap.description = Import an already existing map
|
||||||
editor.importfile = Import File
|
editor.importfile = Import File
|
||||||
editor.importfile.description = Import an external map 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.importimage.description = Import an external map image file
|
||||||
editor.export = Export...
|
editor.export = Export...
|
||||||
editor.exportfile = Export File
|
editor.exportfile = Export File
|
||||||
editor.exportfile.description = Export a map file
|
editor.exportfile.description = Export a map file
|
||||||
editor.exportimage = Export Terrain Image
|
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.loadimage = Import Terrain
|
||||||
editor.saveimage = Export Terrain
|
editor.saveimage = Export Terrain
|
||||||
editor.unsaved = [scarlet]You have unsaved changes![]\nAre you sure you want to exit?
|
editor.unsaved = [scarlet]You have unsaved changes![]\nAre you sure you want to exit?
|
||||||
|
|||||||
@@ -39,10 +39,7 @@ public class ContentLoader{
|
|||||||
new TechTree(),
|
new TechTree(),
|
||||||
new Weathers(),
|
new Weathers(),
|
||||||
new Planets(),
|
new Planets(),
|
||||||
new Zones(),
|
new Zones()
|
||||||
|
|
||||||
//these are not really content classes, but this makes initialization easier
|
|
||||||
new LegacyColorMapper(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public ContentLoader(){
|
public ContentLoader(){
|
||||||
@@ -134,13 +131,15 @@ public class ContentLoader{
|
|||||||
if(blocks().size > i){
|
if(blocks().size > i){
|
||||||
int color = pixmap.getPixel(i, 0);
|
int color = pixmap.getPixel(i, 0);
|
||||||
|
|
||||||
if(color == 0) continue;
|
if(color == 0 || color == 255) continue;
|
||||||
|
|
||||||
Block block = block(i);
|
Block block = block(i);
|
||||||
Color.rgba8888ToColor(block.color, color);
|
Color.rgba8888ToColor(block.minimapColor, color);
|
||||||
|
block.hasColor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pixmap.dispose();
|
pixmap.dispose();
|
||||||
|
ColorMapper.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ package mindustry.core;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.Input.*;
|
import arc.Input.*;
|
||||||
import arc.struct.*;
|
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
import arc.util.serialization.*;
|
import arc.util.serialization.*;
|
||||||
import mindustry.mod.*;
|
import mindustry.mod.*;
|
||||||
import mindustry.net.*;
|
import mindustry.net.*;
|
||||||
@@ -15,7 +16,7 @@ import mindustry.type.*;
|
|||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
import org.mozilla.javascript.*;
|
import org.mozilla.javascript.*;
|
||||||
|
|
||||||
import static mindustry.Vars.mobile;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public interface Platform{
|
public interface Platform{
|
||||||
|
|
||||||
@@ -103,6 +104,32 @@ public interface Platform{
|
|||||||
default void shareFile(Fi file){
|
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.
|
* Show a file chooser.
|
||||||
* @param cons Selection listener
|
* @param cons Selection listener
|
||||||
@@ -130,4 +157,8 @@ public interface Platform{
|
|||||||
/** Stops forcing the app into landscape orientation.*/
|
/** Stops forcing the app into landscape orientation.*/
|
||||||
default void endForceLandscape(){
|
default void endForceLandscape(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FileWriter{
|
||||||
|
void write(Fi file) throws Throwable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class MapEditor{
|
|||||||
reset();
|
reset();
|
||||||
|
|
||||||
createTiles(pixmap.getWidth(), pixmap.getHeight());
|
createTiles(pixmap.getWidth(), pixmap.getHeight());
|
||||||
load(() -> MapIO.readPixmap(pixmap, tiles()));
|
load(() -> MapIO.readImage(pixmap, tiles()));
|
||||||
renderer.resize(width(), height());
|
renderer.resize(width(), height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,62 +87,42 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
t.row();
|
t.row();
|
||||||
|
|
||||||
t.addImageTextButton("$editor.import", Icon.download, () ->
|
t.addImageTextButton("$editor.import", Icon.download, () -> createDialog("$editor.import",
|
||||||
createDialog("$editor.import",
|
"$editor.importmap", "$editor.importmap.description", Icon.download, (Runnable)loadDialog::show,
|
||||||
"$editor.importmap", "$editor.importmap.description", Icon.download, (Runnable)loadDialog::show,
|
"$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() ->
|
||||||
"$editor.importfile", "$editor.importfile.description", Icon.file, (Runnable)() ->
|
platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> {
|
||||||
platform.showFileChooser(true, mapExtension, file -> ui.loadAnd(() -> {
|
maps.tryCatchMapError(() -> {
|
||||||
maps.tryCatchMapError(() -> {
|
if(MapIO.isImage(file)){
|
||||||
if(MapIO.isImage(file)){
|
ui.showInfo("$editor.errorimage");
|
||||||
ui.showInfo("$editor.errorimage");
|
}else{
|
||||||
}else{
|
editor.beginEdit(MapIO.createMap(file, true));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
})),
|
||||||
});
|
|
||||||
|
"$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();
|
menu.cont.row();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
|||||||
|
|
||||||
if(isGrounded() && floor.isLiquid){
|
if(isGrounded() && floor.isLiquid){
|
||||||
if((splashTimer += Mathf.dst(deltaX(), deltaY())) >= 7f){
|
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;
|
splashTimer = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{
|
|||||||
drownTime += Time.delta() * 1f / floor.drownTime;
|
drownTime += Time.delta() * 1f / floor.drownTime;
|
||||||
drownTime = Mathf.clamp(drownTime);
|
drownTime = Mathf.clamp(drownTime);
|
||||||
if(Mathf.chance(Time.delta() * 0.05f)){
|
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?
|
//TODO is the netClient check necessary?
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package mindustry.io;
|
package mindustry.io;
|
||||||
|
|
||||||
import arc.struct.*;
|
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.Pixmap.*;
|
import arc.graphics.Pixmap.*;
|
||||||
|
import arc.math.geom.*;
|
||||||
|
import arc.struct.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.maps.*;
|
import mindustry.maps.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.LegacyColorMapper.*;
|
|
||||||
import mindustry.world.blocks.storage.*;
|
import mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -147,32 +147,43 @@ public class MapIO{
|
|||||||
if(wall.synthetic()){
|
if(wall.synthetic()){
|
||||||
return team.color.rgba();
|
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 Pixmap writeImage(Tiles tiles){
|
||||||
public static void readPixmap(Pixmap pixmap, Tiles tiles){
|
Pixmap pix = new Pixmap(tiles.width, tiles.height);
|
||||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
for(Tile tile : tiles){
|
||||||
for(int y = 0; y < pixmap.getHeight(); y++){
|
int color = tile.block().hasColor && !tile.block().synthetic() ? tile.block().minimapColor.rgba() : tile.floor().minimapColor.rgba();
|
||||||
int color = pixmap.getPixel(x, pixmap.getHeight() - 1 - y);
|
pix.draw(tile.x, tiles.height - 1 - tile.y, color);
|
||||||
LegacyBlock block = LegacyColorMapper.get(color);
|
}
|
||||||
Tile tile = tiles.getn(x, y);
|
return pix;
|
||||||
|
}
|
||||||
|
|
||||||
tile.setFloor(block.floor);
|
public static void readImage(Pixmap pixmap, Tiles tiles){
|
||||||
tile.setBlock(block.wall);
|
for(Tile tile : tiles){
|
||||||
if(block.ore != null) tile.setOverlay(block.ore);
|
int color = pixmap.getPixel(tile.x, pixmap.getHeight() - 1 - tile.y);
|
||||||
|
Block block = ColorMapper.get(color);
|
||||||
|
|
||||||
//place core
|
if(block.isFloor()){
|
||||||
if(color == Color.rgba8888(Color.green)){
|
tile.setFloor(block.asFloor());
|
||||||
//actual core parts
|
}else if(block.isMultiblock()){
|
||||||
tile.setBlock(Blocks.coreShard);
|
tile.set(block, Team.derelict);
|
||||||
tile.setTeam(Team.sharded);
|
}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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class TestPlanetGenerator extends PlanetGenerator{
|
|||||||
public Color getColor(Vec3 position){
|
public Color getColor(Vec3 position){
|
||||||
Block block = getBlock(position);
|
Block block = getBlock(position);
|
||||||
//replace salt with sand color
|
//replace salt with sand color
|
||||||
return block == Blocks.salt ? Blocks.sand.color : block.color;
|
return block == Blocks.salt ? Blocks.sand.minimapColor : block.minimapColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
Floor floor = unit.floorOn();
|
Floor floor = unit.floorOn();
|
||||||
|
|
||||||
if(floor.isLiquid){
|
if(floor.isLiquid){
|
||||||
Draw.color(Color.white, floor.color, 0.5f);
|
Draw.color(Color.white, floor.minimapColor, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i : Mathf.signs){
|
for(int i : Mathf.signs){
|
||||||
@@ -242,7 +242,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(floor.isLiquid){
|
if(floor.isLiquid){
|
||||||
Draw.color(Color.white, floor.color, unit.drownTime() * 0.4f);
|
Draw.color(Color.white, floor.minimapColor, unit.drownTime() * 0.4f);
|
||||||
}else{
|
}else{
|
||||||
Draw.color(Color.white);
|
Draw.color(Color.white);
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
public void applyColor(Unitc unit){
|
public void applyColor(Unitc unit){
|
||||||
Draw.mixcol(Color.white, unit.hitTime());
|
Draw.mixcol(Color.white, unit.hitTime());
|
||||||
if(unit.drownTime() > 0 && unit.floorOn().isDeep()){
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package mindustry.ui.dialogs;
|
package mindustry.ui.dialogs;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.struct.*;
|
|
||||||
import arc.files.*;
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.game.Saves.*;
|
import mindustry.game.Saves.*;
|
||||||
@@ -15,7 +14,6 @@ import mindustry.gen.*;
|
|||||||
import mindustry.io.*;
|
import mindustry.io.*;
|
||||||
import mindustry.io.SaveIO.*;
|
import mindustry.io.SaveIO.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.Styles;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@@ -70,6 +68,7 @@ public class LoadDialog extends FloatingDialog{
|
|||||||
|
|
||||||
title.table(t -> {
|
title.table(t -> {
|
||||||
t.right();
|
t.right();
|
||||||
|
t.defaults().size(40f);
|
||||||
|
|
||||||
t.addImageButton(Icon.save, Styles.emptytogglei, () -> {
|
t.addImageButton(Icon.save, Styles.emptytogglei, () -> {
|
||||||
slot.setAutosave(!slot.isAutosave());
|
slot.setAutosave(!slot.isAutosave());
|
||||||
@@ -89,26 +88,7 @@ public class LoadDialog extends FloatingDialog{
|
|||||||
});
|
});
|
||||||
}).right();
|
}).right();
|
||||||
|
|
||||||
t.addImageButton(Icon.save, Styles.emptyi, () -> {
|
t.addImageButton(Icon.export, Styles.emptyi, () -> platform.export("save-" + slot.getName(), saveExtension, slot::exportFile)).right();
|
||||||
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();
|
|
||||||
|
|
||||||
}).padRight(-10).growX();
|
}).padRight(-10).growX();
|
||||||
}).growX().colspan(2);
|
}).growX().colspan(2);
|
||||||
|
|||||||
@@ -162,11 +162,6 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
|
|
||||||
if(true)
|
if(true)
|
||||||
Draw.batch(projector, () -> {
|
Draw.batch(projector, () -> {
|
||||||
if(hovered != null){
|
|
||||||
setPlane(hovered);
|
|
||||||
Fonts.outline.draw("" + hovered.id, 0, 0, Align.center);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selected != null){
|
if(selected != null){
|
||||||
setPlane(selected);
|
setPlane(selected);
|
||||||
stable.draw();
|
stable.draw();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package mindustry.ui.dialogs;
|
package mindustry.ui.dialogs;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.files.*;
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.Texture.*;
|
import arc.graphics.Texture.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
@@ -216,25 +215,8 @@ public class SchematicsDialog extends FloatingDialog{
|
|||||||
}).marginLeft(12f);
|
}).marginLeft(12f);
|
||||||
t.row();
|
t.row();
|
||||||
t.addImageTextButton("$schematic.exportfile", Icon.export, style, () -> {
|
t.addImageTextButton("$schematic.exportfile", Icon.export, style, () -> {
|
||||||
if(!ios){
|
dialog.hide();
|
||||||
platform.showFileChooser(false, schematicExtension, file -> {
|
platform.export(s.name(), schematicExtension, file -> Schematics.write(s, 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).marginLeft(12f);
|
}).marginLeft(12f);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ public class Block extends BlockStorage{
|
|||||||
* The color of this block when displayed on the minimap or map preview.
|
* 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.
|
* 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. */
|
/** Whether units target this block. */
|
||||||
public boolean targetable = true;
|
public boolean targetable = true;
|
||||||
/** Whether the overdrive core has any effect on this block. */
|
/** Whether the overdrive core has any effect on this block. */
|
||||||
@@ -763,7 +765,7 @@ public class Block extends BlockStorage{
|
|||||||
|
|
||||||
if(!synthetic()){
|
if(!synthetic()){
|
||||||
PixmapRegion image = Core.atlas.getPixmap((AtlasRegion)icon(Cicon.full));
|
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();
|
getGeneratedIcons();
|
||||||
|
|||||||
24
core/src/mindustry/world/ColorMapper.java
Normal file
24
core/src/mindustry/world/ColorMapper.java
Normal file
@@ -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<Block> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<LegacyBlock> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,7 @@ public class Cliff extends Block{
|
|||||||
int r = tile.rotation();
|
int r = tile.rotation();
|
||||||
for(int i = 0; i < 8; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
if((r & (1 << i)) != 0){
|
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);
|
Draw.rect(region, tile.worldx(), tile.worldy(), 11f, 11f, i * 45f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,6 @@ public class Cliff extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minimapColor(Tile tile){
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class Floor extends Block{
|
|||||||
if(wall == null) wall = Blocks.air;
|
if(wall == null) wall = Blocks.air;
|
||||||
|
|
||||||
if(decoration == 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++){
|
for(int i = 0; i < 4; i++){
|
||||||
Tile other = tile.getNearby(i);
|
Tile other = tile.getNearby(i);
|
||||||
if(other != null && doEdge(other.floor(), sameLayer)){
|
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.color(color.r, color.g, color.b, 1f);
|
||||||
Draw.rect(edgeRegion, tile.worldx(), tile.worldy(), i*90);
|
Draw.rect(edgeRegion, tile.worldx(), tile.worldy(), i*90);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class OreBlock extends OverlayFloor{
|
|||||||
this.localizedName = ore.localizedName;
|
this.localizedName = ore.localizedName;
|
||||||
this.itemDrop = ore;
|
this.itemDrop = ore;
|
||||||
this.variants = 3;
|
this.variants = 3;
|
||||||
this.color.set(ore.color);
|
this.minimapColor.set(ore.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For mod use only!*/
|
/** For mod use only!*/
|
||||||
@@ -31,7 +31,7 @@ public class OreBlock extends OverlayFloor{
|
|||||||
public void setup(Item ore){
|
public void setup(Item ore){
|
||||||
this.localizedName = ore.localizedName;
|
this.localizedName = ore.localizedName;
|
||||||
this.itemDrop = ore;
|
this.itemDrop = ore;
|
||||||
this.color.set(ore.color);
|
this.minimapColor.set(ore.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=4db0d154520aa33bbd35c0a71a6e1d9794f3f403
|
archash=307ea4c34bfa0d16098865a354103a85973398b0
|
||||||
|
|||||||
Reference in New Issue
Block a user