Added color picker / Customizable lighting rules
This commit is contained in:
BIN
core/assets-raw/sprites/ui/alpha-bg.png
Normal file
BIN
core/assets-raw/sprites/ui/alpha-bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 754 B |
@@ -78,6 +78,7 @@ maps.browse = Browse Maps
|
|||||||
continue = Continue
|
continue = Continue
|
||||||
maps.none = [lightgray]No maps found!
|
maps.none = [lightgray]No maps found!
|
||||||
invalid = Invalid
|
invalid = Invalid
|
||||||
|
pickcolor = Pick Color
|
||||||
preparingconfig = Preparing Config
|
preparingconfig = Preparing Config
|
||||||
preparingcontent = Preparing Content
|
preparingcontent = Preparing Content
|
||||||
uploadingcontent = Uploading Content
|
uploadingcontent = Uploading Content
|
||||||
@@ -731,6 +732,9 @@ rules.title.resourcesbuilding = Resources & Building
|
|||||||
rules.title.player = Players
|
rules.title.player = Players
|
||||||
rules.title.enemy = Enemies
|
rules.title.enemy = Enemies
|
||||||
rules.title.unit = Units
|
rules.title.unit = Units
|
||||||
|
rules.title.experimental = Experimental
|
||||||
|
rules.lighting = Lighting
|
||||||
|
rules.ambientlight = Ambient Light
|
||||||
|
|
||||||
content.item.name = Items
|
content.item.name = Items
|
||||||
content.liquid.name = Liquids
|
content.liquid.name = Liquids
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 891 KiB After Width: | Height: | Size: 897 KiB |
@@ -300,7 +300,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
playerGroup.draw(p -> !p.isDead(), Player::drawName);
|
playerGroup.draw(p -> !p.isDead(), Player::drawName);
|
||||||
|
|
||||||
if(state.rules.darkness){
|
if(state.rules.lighting){
|
||||||
lights.draw();
|
lights.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
public MinimapDialog minimap;
|
public MinimapDialog minimap;
|
||||||
public SchematicsDialog schematics;
|
public SchematicsDialog schematics;
|
||||||
public ModsDialog mods;
|
public ModsDialog mods;
|
||||||
|
public ColorPicker picker;
|
||||||
|
|
||||||
public Cursor drillCursor, unloadCursor;
|
public Cursor drillCursor, unloadCursor;
|
||||||
|
|
||||||
@@ -211,6 +212,7 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
listfrag = new PlayerListFragment();
|
listfrag = new PlayerListFragment();
|
||||||
loadfrag = new LoadingFragment();
|
loadfrag = new LoadingFragment();
|
||||||
|
|
||||||
|
picker = new ColorPicker();
|
||||||
editor = new MapEditorDialog();
|
editor = new MapEditorDialog();
|
||||||
controls = new ControlsDialog();
|
controls = new ControlsDialog();
|
||||||
restart = new GameOverDialog();
|
restart = new GameOverDialog();
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ public class Rules{
|
|||||||
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
|
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
|
||||||
/** Blocks that cannot be placed. */
|
/** Blocks that cannot be placed. */
|
||||||
public ObjectSet<Block> bannedBlocks = new ObjectSet<>();
|
public ObjectSet<Block> bannedBlocks = new ObjectSet<>();
|
||||||
/** Whether everything is dark. Enables lights. Exeperimental. */
|
/** Whether everything is dark. Enables lights. Experimental. */
|
||||||
public boolean darkness = true;
|
public boolean lighting = false;
|
||||||
/** Ambient light color, used when darkness is enabled. */
|
/** Ambient light color, used when lighting is enabled. */
|
||||||
public Color ambientLight = new Color(0.01f, 0.01f, 0.04f, 0.99f);
|
public Color ambientLight = new Color(0.01f, 0.01f, 0.04f, 0.99f);
|
||||||
|
|
||||||
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ public class BlockRenderer implements Disposable{
|
|||||||
addRequest(tile, Layer.block);
|
addRequest(tile, Layer.block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.rules.darkness){
|
if(state.rules.lighting){
|
||||||
addRequest(tile, Layer.lights);
|
addRequest(tile, Layer.lights);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class LightRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean enabled(){
|
public boolean enabled(){
|
||||||
return state.rules.darkness;
|
return state.rules.lighting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(){
|
public void draw(){
|
||||||
|
|||||||
62
core/src/io/anuke/mindustry/ui/dialogs/ColorPicker.java
Normal file
62
core/src/io/anuke/mindustry/ui/dialogs/ColorPicker.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
|
import io.anuke.arc.func.*;
|
||||||
|
import io.anuke.arc.graphics.*;
|
||||||
|
import io.anuke.arc.scene.ui.*;
|
||||||
|
import io.anuke.mindustry.gen.*;
|
||||||
|
import io.anuke.mindustry.graphics.*;
|
||||||
|
|
||||||
|
public class ColorPicker extends FloatingDialog{
|
||||||
|
private Cons<Color> cons = c -> {};
|
||||||
|
private Color current = new Color();
|
||||||
|
|
||||||
|
public ColorPicker(){
|
||||||
|
super("$pickcolor");
|
||||||
|
shown(this::setup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(Color color, Cons<Color> consumer){
|
||||||
|
this.current.set(color);
|
||||||
|
this.cons = consumer;
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
cont.clear();
|
||||||
|
cont.pane(t -> {
|
||||||
|
t.table(Tex.pane, i -> {
|
||||||
|
i.stack(new Image(Tex.alphaBg), new Image(){{
|
||||||
|
setColor(current);
|
||||||
|
update(() -> setColor(current));
|
||||||
|
}}).size(200f);
|
||||||
|
}).colspan(2).padBottom(5);
|
||||||
|
|
||||||
|
float w = 150f;
|
||||||
|
|
||||||
|
t.row();
|
||||||
|
|
||||||
|
t.defaults().padBottom(4);
|
||||||
|
t.add("R").color(Pal.remove);
|
||||||
|
t.addSlider(0f, 1f, 0.01f, current.r, current::r).width(w);
|
||||||
|
t.row();
|
||||||
|
t.add("G").color(Color.lime);
|
||||||
|
t.addSlider(0f, 1f, 0.01f, current.g, current::g).width(w);
|
||||||
|
t.row();
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
buttons.clear();
|
||||||
|
addCloseButton();
|
||||||
|
buttons.addImageTextButton("$ok", Icon.checkSmall, () -> {
|
||||||
|
cons.get(current);
|
||||||
|
hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -116,7 +116,7 @@ public class CustomRulesDialog extends FloatingDialog{
|
|||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
cont.clear();
|
cont.clear();
|
||||||
cont.pane(m -> main = m);
|
cont.pane(m -> main = m).get().setScrollingDisabled(true, false);
|
||||||
main.margin(10f);
|
main.margin(10f);
|
||||||
main.addButton("$settings.reset", () -> {
|
main.addButton("$settings.reset", () -> {
|
||||||
rules = resetter.get();
|
rules = resetter.get();
|
||||||
@@ -169,6 +169,20 @@ public class CustomRulesDialog extends FloatingDialog{
|
|||||||
check("$rules.attack", b -> rules.attackMode = b, () -> rules.attackMode);
|
check("$rules.attack", b -> rules.attackMode = b, () -> rules.attackMode);
|
||||||
check("$rules.enemyCheat", b -> rules.enemyCheat = b, () -> rules.enemyCheat);
|
check("$rules.enemyCheat", b -> rules.enemyCheat = b, () -> rules.enemyCheat);
|
||||||
number("$rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200));
|
number("$rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200));
|
||||||
|
|
||||||
|
title("$rules.title.experimental");
|
||||||
|
check("$rules.lighting", b -> rules.lighting = b, () -> rules.lighting);
|
||||||
|
|
||||||
|
main.addButton(b -> {
|
||||||
|
b.left();
|
||||||
|
b.table(Tex.pane, in -> {
|
||||||
|
in.stack(new Image(Tex.alphaBg), new Image(Tex.whiteui){{
|
||||||
|
update(() -> setColor(rules.ambientLight));
|
||||||
|
}}).grow();
|
||||||
|
}).margin(4).size(50f).padRight(10);
|
||||||
|
b.add("$rules.ambientlight");
|
||||||
|
}, () -> ui.picker.show(rules.ambientLight, rules.ambientLight::set)).left().width(250f);
|
||||||
|
main.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
void number(String text, Floatc cons, Floatp prov){
|
void number(String text, Floatc cons, Floatp prov){
|
||||||
@@ -198,7 +212,9 @@ public class CustomRulesDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void title(String text){
|
void title(String text){
|
||||||
main.add(text).color(Pal.accent).padTop(20).padBottom(20).padRight(100f);
|
main.add(text).color(Pal.accent).padTop(20).padRight(100f).padBottom(-3);
|
||||||
|
main.row();
|
||||||
|
main.addImage().color(Pal.accent).height(3f).padRight(100f).padBottom(20);
|
||||||
main.row();
|
main.row();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class HostDialog extends FloatingDialog{
|
|||||||
}).grow().pad(8).get().setMaxLength(40);
|
}).grow().pad(8).get().setMaxLength(40);
|
||||||
|
|
||||||
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
|
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
|
||||||
new ColorPickDialog().show(color -> {
|
new PaletteDialog().show(color -> {
|
||||||
player.color.set(color);
|
player.color.set(color);
|
||||||
Core.settings.put("color-0", Color.rgba8888(color));
|
Core.settings.put("color-0", Color.rgba8888(color));
|
||||||
Core.settings.save();
|
Core.settings.save();
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ public class JoinDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
|
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
|
||||||
new ColorPickDialog().show(color -> {
|
new PaletteDialog().show(color -> {
|
||||||
player.color.set(color);
|
player.color.set(color);
|
||||||
Core.settings.put("color-0", Color.rgba8888(color));
|
Core.settings.put("color-0", Color.rgba8888(color));
|
||||||
Core.settings.save();
|
Core.settings.save();
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import io.anuke.mindustry.ui.*;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class ColorPickDialog extends Dialog{
|
public class PaletteDialog extends Dialog{
|
||||||
private Cons<Color> cons;
|
private Cons<Color> cons;
|
||||||
|
|
||||||
public ColorPickDialog(){
|
public PaletteDialog(){
|
||||||
super("");
|
super("");
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user