From f2f39573bbd48af278839e13a9fec1fc122a0b5e Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 19 Mar 2020 20:02:43 -0400 Subject: [PATCH] Color cleanup --- core/src/mindustry/core/ContentLoader.java | 2 +- core/src/mindustry/core/Control.java | 2 +- core/src/mindustry/core/NetClient.java | 2 +- core/src/mindustry/entities/type/Player.java | 2 +- core/src/mindustry/io/MapIO.java | 6 +++--- core/src/mindustry/io/TypeIO.java | 2 +- core/src/mindustry/ui/dialogs/HostDialog.java | 3 +-- core/src/mindustry/ui/dialogs/JoinDialog.java | 7 +++---- core/src/mindustry/world/LegacyColorMapper.java | 6 +++--- gradle.properties | 2 +- 10 files changed, 16 insertions(+), 18 deletions(-) diff --git a/core/src/mindustry/core/ContentLoader.java b/core/src/mindustry/core/ContentLoader.java index 70b9f85f56..9018f5883e 100644 --- a/core/src/mindustry/core/ContentLoader.java +++ b/core/src/mindustry/core/ContentLoader.java @@ -140,7 +140,7 @@ public class ContentLoader{ if(color == 0) continue; Block block = block(i); - Color.rgba8888ToColor(block.color, color); + block.color.set(color); } } pixmap.dispose(); diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 657c9c74e2..77ea0e2150 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -193,7 +193,7 @@ public class Control implements ApplicationListener, Loadable{ Core.settings.defaults( "ip", "localhost", - "color-0", Color.rgba8888(playerColors[8]), + "color-0", playerColors[8].rgba(), "name", "", "lastBuild", 0 ); diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index c483e8cb26..fa2336f26c 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -81,7 +81,7 @@ public class NetClient implements ApplicationListener{ c.mods = mods.getModStrings(); c.mobile = mobile; c.versionType = Version.type; - c.color = Color.rgba8888(player.color); + c.color = player.color.rgba(); c.usid = getUsid(packet.addressTCP); c.uuid = platform.getUUID(); diff --git a/core/src/mindustry/entities/type/Player.java b/core/src/mindustry/entities/type/Player.java index 34ce3fcbe3..0cbaaaf909 100644 --- a/core/src/mindustry/entities/type/Player.java +++ b/core/src/mindustry/entities/type/Player.java @@ -900,7 +900,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{ super.writeSave(buffer, !isLocal); TypeIO.writeStringData(buffer, name); buffer.writeByte(Pack.byteValue(isAdmin) | (Pack.byteValue(dead) << 1) | (Pack.byteValue(isBoosting) << 2) | (Pack.byteValue(isTyping) << 3)| (Pack.byteValue(isBuilding) << 4)); - buffer.writeInt(Color.rgba8888(color)); + buffer.writeInt(color.rgba()); buffer.writeByte(mech.id); buffer.writeInt(mining == null ? noSpawner : mining.pos()); buffer.writeInt(spawner == null || !spawner.hasUnit(this) ? noSpawner : spawner.getTile().pos()); diff --git a/core/src/mindustry/io/MapIO.java b/core/src/mindustry/io/MapIO.java index 10bcd5cda9..1cae0913ba 100644 --- a/core/src/mindustry/io/MapIO.java +++ b/core/src/mindustry/io/MapIO.java @@ -75,7 +75,7 @@ public class MapIO{ Pixmap floors = new Pixmap(map.width, map.height, Format.RGBA8888); Pixmap walls = new Pixmap(map.width, map.height, Format.RGBA8888); - int black = Color.rgba8888(Color.black); + int black = 255; int shade = Color.rgba8888(0f, 0f, 0f, 0.5f); CachedTile tile = new CachedTile(){ @Override @@ -148,7 +148,7 @@ 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 (wall.solid ? wall.color : ore == Blocks.air ? floor.color : ore.color).rgba(); } /** Reads a pixmap in the 3.5 pixmap format. */ @@ -164,7 +164,7 @@ public class MapIO{ if(block.ore != null) tile.setOverlay(block.ore); //place core - if(color == Color.rgba8888(Color.green)){ + if(color == Color.green.rgba()){ //actual core parts tile.setBlock(Blocks.coreShard); tile.setTeam(Team.sharded); diff --git a/core/src/mindustry/io/TypeIO.java b/core/src/mindustry/io/TypeIO.java index 5095ce396a..8c2e4669d3 100644 --- a/core/src/mindustry/io/TypeIO.java +++ b/core/src/mindustry/io/TypeIO.java @@ -244,7 +244,7 @@ public class TypeIO{ @WriteClass(Color.class) public static void writeColor(ByteBuffer buffer, Color color){ - buffer.putInt(Color.rgba8888(color)); + buffer.putInt(color.rgba()); } @ReadClass(Color.class) diff --git a/core/src/mindustry/ui/dialogs/HostDialog.java b/core/src/mindustry/ui/dialogs/HostDialog.java index 196f93d63f..61e01c2668 100644 --- a/core/src/mindustry/ui/dialogs/HostDialog.java +++ b/core/src/mindustry/ui/dialogs/HostDialog.java @@ -1,7 +1,6 @@ package mindustry.ui.dialogs; import arc.*; -import arc.graphics.*; import arc.scene.ui.*; import arc.util.*; import mindustry.*; @@ -33,7 +32,7 @@ public class HostDialog extends FloatingDialog{ ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> { new PaletteDialog().show(color -> { player.color.set(color); - Core.settings.put("color-0", Color.rgba8888(color)); + Core.settings.put("color-0", color.rgba()); Core.settings.save(); }); }).size(54f).get(); diff --git a/core/src/mindustry/ui/dialogs/JoinDialog.java b/core/src/mindustry/ui/dialogs/JoinDialog.java index 2e62161957..7e6ad2be86 100644 --- a/core/src/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/mindustry/ui/dialogs/JoinDialog.java @@ -1,16 +1,15 @@ package mindustry.ui.dialogs; import arc.*; -import mindustry.annotations.Annotations.*; -import arc.struct.*; -import arc.graphics.*; import arc.input.*; import arc.math.*; import arc.scene.ui.*; import arc.scene.ui.layout.*; +import arc.struct.*; import arc.util.*; import arc.util.serialization.*; import mindustry.*; +import mindustry.annotations.Annotations.*; import mindustry.core.*; import mindustry.gen.*; import mindustry.graphics.*; @@ -275,7 +274,7 @@ public class JoinDialog extends FloatingDialog{ ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> { new PaletteDialog().show(color -> { player.color.set(color); - Core.settings.put("color-0", Color.rgba8888(color)); + Core.settings.put("color-0", color.rgba()); Core.settings.save(); }); }).size(54f).get(); diff --git a/core/src/mindustry/world/LegacyColorMapper.java b/core/src/mindustry/world/LegacyColorMapper.java index 8f3f80e953..44a0eb2beb 100644 --- a/core/src/mindustry/world/LegacyColorMapper.java +++ b/core/src/mindustry/world/LegacyColorMapper.java @@ -43,15 +43,15 @@ public class LegacyColorMapper implements ContentList{ } private void map(String color, Block block, Block wall, Block ore){ - blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall, ore)); + blockMap.put(Color.valueOf(color).rgba(), 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)); + blockMap.put(Color.valueOf(color).rgba(), new LegacyBlock(block, wall)); } private void map(String color, Block block){ - blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, Blocks.air)); + blockMap.put(Color.valueOf(color).rgba(), new LegacyBlock(block, Blocks.air)); } public static class LegacyBlock{ diff --git a/gradle.properties b/gradle.properties index 3b4da6f663..1d264aa135 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=31a5158c6395b7e905ba546348c98fd99ea736bb +archash=f0eda1168b1230b6ce6c7ecee6b51eaf2048d856