Settings tooltips
This commit is contained in:
@@ -3,6 +3,7 @@ package mindustry.maps.filters;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.scene.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
@@ -60,16 +61,19 @@ public abstract class FilterOption{
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
Label label;
|
||||
Element base;
|
||||
if(!display){
|
||||
label = new Label("@filter.option." + name);
|
||||
Label l = new Label("@filter.option." + name);
|
||||
l.setWrap(true);
|
||||
l.setStyle(Styles.outlineLabel);
|
||||
base = l;
|
||||
}else{
|
||||
label = new Label(() -> Core.bundle.get("filter.option." + name) + ": " + Strings.autoFixed(getter.get(), 2));
|
||||
Table t = new Table().marginLeft(11f).marginRight(11f);
|
||||
base = t;
|
||||
t.add("@filter.option." + name).growX().wrap().style(Styles.outlineLabel);
|
||||
t.label(() -> Strings.autoFixed(getter.get(), 2)).style(Styles.outlineLabel).right().labelAlign(Align.right).padLeft(6);
|
||||
}
|
||||
label.setWrap(true);
|
||||
label.setAlignment(Align.center);
|
||||
label.touchable = Touchable.disabled;
|
||||
label.setStyle(Styles.outlineLabel);
|
||||
base.touchable = Touchable.disabled;
|
||||
|
||||
Slider slider = new Slider(min, max, step, false);
|
||||
slider.moved(setter);
|
||||
@@ -80,7 +84,7 @@ public abstract class FilterOption{
|
||||
slider.released(changed);
|
||||
}
|
||||
|
||||
table.stack(slider, label).colspan(2).pad(3).growX().row();
|
||||
table.stack(slider, base).colspan(2).pad(3).growX().row();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.Texture.*;
|
||||
import arc.input.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.TextButton.*;
|
||||
@@ -28,7 +30,6 @@ import java.io.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.net;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class SettingsMenuDialog extends Dialog{
|
||||
@@ -283,9 +284,9 @@ public class SettingsMenuDialog extends Dialog{
|
||||
}
|
||||
|
||||
void addSettings(){
|
||||
sound.sliderPref("musicvol", bundle.get("setting.musicvol.name", "Music Volume"), 100, 0, 100, 1, i -> i + "%");
|
||||
sound.sliderPref("sfxvol", bundle.get("setting.sfxvol.name", "SFX Volume"), 100, 0, 100, 1, i -> i + "%");
|
||||
sound.sliderPref("ambientvol", bundle.get("setting.ambientvol.name", "Ambient Volume"), 100, 0, 100, 1, i -> i + "%");
|
||||
sound.sliderPref("musicvol", 100, 0, 100, 1, i -> i + "%");
|
||||
sound.sliderPref("sfxvol", 100, 0, 100, 1, i -> i + "%");
|
||||
sound.sliderPref("ambientvol", 100, 0, 100, 1, i -> i + "%");
|
||||
|
||||
game.sliderPref("saveinterval", 60, 10, 5 * 120, 10, i -> Core.bundle.format("setting.seconds", i));
|
||||
|
||||
@@ -562,52 +563,26 @@ public class SettingsMenuDialog extends Dialog{
|
||||
rebuild();
|
||||
}
|
||||
|
||||
public SliderSetting sliderPref(String name, String title, int def, int min, int max, StringProcessor s){
|
||||
return sliderPref(name, title, def, min, max, 1, s);
|
||||
}
|
||||
|
||||
public SliderSetting sliderPref(String name, String title, int def, int min, int max, int step, StringProcessor s){
|
||||
SliderSetting res;
|
||||
list.add(res = new SliderSetting(name, title, def, min, max, step, s));
|
||||
settings.defaults(name, def);
|
||||
rebuild();
|
||||
return res;
|
||||
}
|
||||
|
||||
public SliderSetting sliderPref(String name, int def, int min, int max, StringProcessor s){
|
||||
return sliderPref(name, def, min, max, 1, s);
|
||||
}
|
||||
|
||||
public SliderSetting sliderPref(String name, int def, int min, int max, int step, StringProcessor s){
|
||||
SliderSetting res;
|
||||
list.add(res = new SliderSetting(name, bundle.get("setting." + name + ".name"), def, min, max, step, s));
|
||||
list.add(res = new SliderSetting(name, def, min, max, step, s));
|
||||
settings.defaults(name, def);
|
||||
rebuild();
|
||||
return res;
|
||||
}
|
||||
|
||||
public void checkPref(String name, String title, boolean def){
|
||||
list.add(new CheckSetting(name, title, def, null));
|
||||
settings.defaults(name, def);
|
||||
rebuild();
|
||||
}
|
||||
|
||||
public void checkPref(String name, String title, boolean def, Boolc changed){
|
||||
list.add(new CheckSetting(name, title, def, changed));
|
||||
settings.defaults(name, def);
|
||||
rebuild();
|
||||
}
|
||||
|
||||
/** Localized title. */
|
||||
public void checkPref(String name, boolean def){
|
||||
list.add(new CheckSetting(name, bundle.get("setting." + name + ".name"), def, null));
|
||||
list.add(new CheckSetting(name, def, null));
|
||||
settings.defaults(name, def);
|
||||
rebuild();
|
||||
}
|
||||
|
||||
/** Localized title. */
|
||||
public void checkPref(String name, boolean def, Boolc changed){
|
||||
list.add(new CheckSetting(name, bundle.get("setting." + name + ".name"), def, changed));
|
||||
list.add(new CheckSetting(name, def, changed));
|
||||
settings.defaults(name, def);
|
||||
rebuild();
|
||||
}
|
||||
@@ -631,17 +606,41 @@ public class SettingsMenuDialog extends Dialog{
|
||||
public abstract static class Setting{
|
||||
public String name;
|
||||
public String title;
|
||||
public @Nullable String description;
|
||||
|
||||
Setting(String name){
|
||||
this.name = name;
|
||||
title = bundle.get("setting." + name + ".name");
|
||||
description = bundle.getOrNull("setting." + name + ".description");
|
||||
}
|
||||
|
||||
public abstract void add(SettingsTable table);
|
||||
|
||||
public void addDesc(Element elem){
|
||||
if(description == null) return;
|
||||
|
||||
elem.addListener(new Tooltip(t -> t.background(Styles.black8).margin(4f).add(description).color(Color.lightGray)){
|
||||
{
|
||||
allowMobile = true;
|
||||
}
|
||||
@Override
|
||||
protected void setContainerPosition(Element element, float x, float y){
|
||||
this.targetActor = element;
|
||||
Vec2 pos = element.localToStageCoordinates(Tmp.v1.set(0, 0));
|
||||
container.pack();
|
||||
container.setPosition(pos.x, pos.y, Align.topLeft);
|
||||
container.setOrigin(0, element.getHeight());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static class CheckSetting extends Setting{
|
||||
boolean def;
|
||||
Boolc changed;
|
||||
|
||||
CheckSetting(String name, String title, boolean def, Boolc changed){
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
CheckSetting(String name, boolean def, Boolc changed){
|
||||
super(name);
|
||||
this.def = def;
|
||||
this.changed = changed;
|
||||
}
|
||||
@@ -660,7 +659,7 @@ public class SettingsMenuDialog extends Dialog{
|
||||
});
|
||||
|
||||
box.left();
|
||||
table.add(box).left().padTop(3f);
|
||||
addDesc(table.add(box).left().padTop(3f).get());
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
@@ -669,9 +668,8 @@ public class SettingsMenuDialog extends Dialog{
|
||||
int def, min, max, step;
|
||||
StringProcessor sp;
|
||||
|
||||
SliderSetting(String name, String title, int def, int min, int max, int step, StringProcessor s){
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
SliderSetting(String name, int def, int min, int max, int step, StringProcessor s){
|
||||
super(name);
|
||||
this.def = def;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
@@ -689,7 +687,7 @@ public class SettingsMenuDialog extends Dialog{
|
||||
Table content = new Table();
|
||||
content.add(title, Styles.outlineLabel).left().growX().wrap();
|
||||
content.add(value).padLeft(10f).right();
|
||||
content.margin(3f, 33.5f, 3f, 33.5f);
|
||||
content.margin(3f, 33f, 3f, 33f);
|
||||
content.touchable = Touchable.disabled;
|
||||
|
||||
slider.changed(() -> {
|
||||
@@ -699,7 +697,7 @@ public class SettingsMenuDialog extends Dialog{
|
||||
|
||||
slider.change();
|
||||
|
||||
table.stack(slider, content).width(Math.min(Core.graphics.getWidth() / 1.2f, 460f)).left().padTop(4f);
|
||||
addDesc(table.stack(slider, content).width(Math.min(Core.graphics.getWidth() / 1.2f, 460f)).left().padTop(4f).get());
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user