Added color picker / Customizable lighting rules

This commit is contained in:
Anuken 2019-11-16 23:27:42 -05:00
parent d73b99945f
commit 84968c9f73
14 changed files with 1555 additions and 1464 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

View File

@ -78,6 +78,7 @@ maps.browse = Browse Maps
continue = Continue
maps.none = [lightgray]No maps found!
invalid = Invalid
pickcolor = Pick Color
preparingconfig = Preparing Config
preparingcontent = Preparing Content
uploadingcontent = Uploading Content
@ -731,6 +732,9 @@ rules.title.resourcesbuilding = Resources & Building
rules.title.player = Players
rules.title.enemy = Enemies
rules.title.unit = Units
rules.title.experimental = Experimental
rules.lighting = Lighting
rules.ambientlight = Ambient Light
content.item.name = Items
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

View File

@ -300,7 +300,7 @@ public class Renderer implements ApplicationListener{
playerGroup.draw(p -> !p.isDead(), Player::drawName);
if(state.rules.darkness){
if(state.rules.lighting){
lights.draw();
}

View File

@ -70,6 +70,7 @@ public class UI implements ApplicationListener, Loadable{
public MinimapDialog minimap;
public SchematicsDialog schematics;
public ModsDialog mods;
public ColorPicker picker;
public Cursor drillCursor, unloadCursor;
@ -211,6 +212,7 @@ public class UI implements ApplicationListener, Loadable{
listfrag = new PlayerListFragment();
loadfrag = new LoadingFragment();
picker = new ColorPicker();
editor = new MapEditorDialog();
controls = new ControlsDialog();
restart = new GameOverDialog();

View File

@ -74,9 +74,9 @@ public class Rules{
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
/** Blocks that cannot be placed. */
public ObjectSet<Block> bannedBlocks = new ObjectSet<>();
/** Whether everything is dark. Enables lights. Exeperimental. */
public boolean darkness = true;
/** Ambient light color, used when darkness is enabled. */
/** Whether everything is dark. Enables lights. Experimental. */
public boolean lighting = false;
/** Ambient light color, used when lighting is enabled. */
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. */

View File

@ -218,7 +218,7 @@ public class BlockRenderer implements Disposable{
addRequest(tile, Layer.block);
}
if(state.rules.darkness){
if(state.rules.lighting){
addRequest(tile, Layer.lights);
}

View File

@ -170,7 +170,7 @@ public class LightRenderer{
}
public boolean enabled(){
return state.rules.darkness;
return state.rules.lighting;
}
public void draw(){

View 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();
});
}
}

View File

@ -116,7 +116,7 @@ public class CustomRulesDialog extends FloatingDialog{
void setup(){
cont.clear();
cont.pane(m -> main = m);
cont.pane(m -> main = m).get().setScrollingDisabled(true, false);
main.margin(10f);
main.addButton("$settings.reset", () -> {
rules = resetter.get();
@ -169,6 +169,20 @@ public class CustomRulesDialog extends FloatingDialog{
check("$rules.attack", b -> rules.attackMode = b, () -> rules.attackMode);
check("$rules.enemyCheat", b -> rules.enemyCheat = b, () -> rules.enemyCheat);
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){
@ -198,7 +212,9 @@ public class CustomRulesDialog extends FloatingDialog{
}
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();
}
}

View File

@ -31,7 +31,7 @@ public class HostDialog extends FloatingDialog{
}).grow().pad(8).get().setMaxLength(40);
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
new ColorPickDialog().show(color -> {
new PaletteDialog().show(color -> {
player.color.set(color);
Core.settings.put("color-0", Color.rgba8888(color));
Core.settings.save();

View File

@ -247,7 +247,7 @@ public class JoinDialog extends FloatingDialog{
}
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
new ColorPickDialog().show(color -> {
new PaletteDialog().show(color -> {
player.color.set(color);
Core.settings.put("color-0", Color.rgba8888(color));
Core.settings.save();

View File

@ -10,10 +10,10 @@ import io.anuke.mindustry.ui.*;
import static io.anuke.mindustry.Vars.*;
public class ColorPickDialog extends Dialog{
public class PaletteDialog extends Dialog{
private Cons<Color> cons;
public ColorPickDialog(){
public PaletteDialog(){
super("");
build();
}