diff --git a/core/src/io/anuke/mindustry/content/Blocks.java b/core/src/io/anuke/mindustry/content/Blocks.java index 3fa044e97b..a82e73a7a5 100644 --- a/core/src/io/anuke/mindustry/content/Blocks.java +++ b/core/src/io/anuke/mindustry/content/Blocks.java @@ -742,8 +742,8 @@ public class Blocks implements ContentList{ //disabled until implemented properly requirements(Category.effect, BuildVisibility.lightingOnly, ItemStack.with(Items.graphite, 5)); color = Color.valueOf("7d93ff"); - brightness = 0.6f; - radius = 80f; + brightness = 0.67f; + radius = 120f; consumes.power(0.05f); }}; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ColorPicker.java b/core/src/io/anuke/mindustry/ui/dialogs/ColorPicker.java index 926a45a7c3..03454d76e5 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ColorPicker.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ColorPicker.java @@ -12,16 +12,17 @@ public class ColorPicker extends FloatingDialog{ public ColorPicker(){ super("$pickcolor"); - shown(this::setup); } public void show(Color color, Cons consumer){ + show(color, true, consumer); + } + + public void show(Color color, boolean alpha, Cons consumer){ this.current.set(color); this.cons = consumer; show(); - } - void setup(){ cont.clear(); cont.pane(t -> { t.table(Tex.pane, i -> { @@ -45,13 +46,13 @@ public class ColorPicker extends FloatingDialog{ t.add("B").color(Color.royal); t.addSlider(0f, 1f, 0.01f, current.b, current::b).width(w); t.row(); - t.add("A"); - t.addSlider(0f, 1f, 0.01f, current.a, current::a).width(w); - t.row(); + if(alpha){ + t.add("A"); + t.addSlider(0f, 1f, 0.01f, current.a, current::a).width(w); + t.row(); + } }); - - buttons.clear(); addCloseButton(); buttons.addImageTextButton("$ok", Icon.checkSmall, () -> { diff --git a/core/src/io/anuke/mindustry/world/blocks/logic/MessageBlock.java b/core/src/io/anuke/mindustry/world/blocks/logic/MessageBlock.java index da13ab499f..9b773c6356 100644 --- a/core/src/io/anuke/mindustry/world/blocks/logic/MessageBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/logic/MessageBlock.java @@ -98,7 +98,7 @@ public class MessageBlock extends Block{ public void buildTable(Tile tile, Table table){ MessageBlockEntity entity = tile.entity(); - table.addImageButton(io.anuke.mindustry.gen.Icon.pencilSmall, () -> { + table.addImageButton(Icon.pencilSmall, () -> { if(mobile){ Core.input.getTextInput(new TextInput(){{ text = entity.message; diff --git a/core/src/io/anuke/mindustry/world/blocks/power/LightBlock.java b/core/src/io/anuke/mindustry/world/blocks/power/LightBlock.java index 02fc2227b1..a85fdf937b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/LightBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/LightBlock.java @@ -2,14 +2,21 @@ package io.anuke.mindustry.world.blocks.power; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; +import io.anuke.arc.scene.ui.layout.*; +import io.anuke.arc.util.*; import io.anuke.mindustry.entities.type.*; +import io.anuke.mindustry.gen.*; +import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.world.*; -import static io.anuke.mindustry.Vars.renderer; +import java.io.*; + +import static io.anuke.mindustry.Vars.*; public class LightBlock extends Block{ - protected Color color = Color.royal; - protected float brightness = 0.5f; + private static int lastColor = 0; + + protected float brightness = 0.9f; protected float radius = 200f; protected int topRegion; @@ -22,16 +29,38 @@ public class LightBlock extends Block{ entityType = LightEntity::new; } + @Override + public void playerPlaced(Tile tile){ + if(lastColor != 0){ + tile.configure(lastColor); + } + } + @Override public void draw(Tile tile){ super.draw(tile); + LightEntity entity = tile.entity(); + Draw.blend(Blending.additive); - Draw.color(color, tile.entity.efficiency() * 0.3f); + Draw.color(Tmp.c1.set(entity.color), entity.efficiency() * 0.3f); Draw.rect(reg(topRegion), tile.drawx(), tile.drawy()); Draw.color(); Draw.blend(); } + @Override + public void buildTable(Tile tile, Table table){ + LightEntity entity = tile.entity(); + + table.addImageButton(Icon.pencilSmall, () -> { + ui.picker.show(Tmp.c1.set(entity.color).a(0.5f), false, res -> { + entity.color = res.rgba(); + lastColor = entity.color; + }); + control.input.frag.config.hideConfig(); + }).size(40f); + } + @Override public void configured(Tile tile, Player player, int value){ tile.entity().color = value; @@ -39,10 +68,23 @@ public class LightBlock extends Block{ @Override public void drawLight(Tile tile){ - renderer.lights.add(tile.drawx(), tile.drawy(), radius, color, brightness * tile.entity.efficiency()); + LightEntity entity = tile.entity(); + renderer.lights.add(tile.drawx(), tile.drawy(), radius, Tmp.c1.set(entity.color), brightness * tile.entity.efficiency()); } public class LightEntity extends TileEntity{ - public int color; + public int color = Pal.accent.rgba(); + + @Override + public void write(DataOutput stream) throws IOException{ + super.write(stream); + stream.writeInt(color); + } + + @Override + public void read(DataInput stream, byte revision) throws IOException{ + super.read(stream, revision); + color = stream.readInt(); + } } }