Better sliders
This commit is contained in:
@@ -2047,7 +2047,6 @@ public class UnitTypes implements ContentList{
|
||||
buildSpeed = 3f;
|
||||
|
||||
abilities.add(new EnergyFieldAbility(35f, 65f, 180f){{
|
||||
repair = 35f;
|
||||
statusDuration = 60f * 6f;
|
||||
maxTargets = 25;
|
||||
}});
|
||||
|
||||
@@ -16,14 +16,14 @@ import mindustry.type.*;
|
||||
public class EnergyFieldAbility extends Ability{
|
||||
private static final Seq<Healthc> all = new Seq<>();
|
||||
|
||||
public float damage = 1, repair = 20f, reload = 100, range = 60;
|
||||
public float damage = 1, reload = 100, range = 60;
|
||||
public Effect healEffect = Fx.heal, hitEffect = Fx.hitLaserBlast, damageEffect = Fx.chainLightning;
|
||||
public StatusEffect status = StatusEffects.electrified;
|
||||
public float statusDuration = 60f * 6f;
|
||||
public float x, y;
|
||||
public boolean hitBuildings = true;
|
||||
public int maxTargets = 25;
|
||||
public float healPercent = 3f;
|
||||
public float healPercent = 2.5f;
|
||||
|
||||
public float layer = Layer.bullet - 0.001f, blinkScl = 20f;
|
||||
public float effectRadius = 5f, sectorRad = 0.14f, rotateSpeed = 0.5f;
|
||||
|
||||
@@ -3,12 +3,15 @@ package mindustry.maps.filters;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
@@ -35,7 +38,7 @@ public abstract class FilterOption{
|
||||
final Floatc setter;
|
||||
final float min, max, step;
|
||||
|
||||
boolean display;
|
||||
boolean display = true;
|
||||
|
||||
SliderOption(String name, Floatp getter, Floatc setter, float min, float max){
|
||||
this(name, getter, setter, min, max, (max - min) / 200);
|
||||
@@ -57,19 +60,27 @@ public abstract class FilterOption{
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
Label label;
|
||||
if(!display){
|
||||
table.add("@filter.option." + name);
|
||||
label = new Label("@filter.option." + name);
|
||||
}else{
|
||||
table.label(() -> Core.bundle.get("filter.option." + name) + ": " + (int)getter.get());
|
||||
label = new Label(() -> Core.bundle.get("filter.option." + name) + ": " + Strings.autoFixed(getter.get(), 2));
|
||||
}
|
||||
table.row();
|
||||
Slider slider = table.slider(min, max, step, setter).growX().get();
|
||||
label.setWrap(true);
|
||||
label.setAlignment(Align.center);
|
||||
label.touchable = Touchable.disabled;
|
||||
label.setStyle(Styles.outlineLabel);
|
||||
|
||||
Slider slider = new Slider(min, max, step, false);
|
||||
slider.moved(setter);
|
||||
slider.setValue(getter.get());
|
||||
if(updateEditorOnChange){
|
||||
slider.changed(changed);
|
||||
}else{
|
||||
slider.released(changed);
|
||||
}
|
||||
|
||||
table.stack(slider, label).colspan(2).pad(3).growX().row();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Styles{
|
||||
public static ImageButtonStyle defaulti, nodei, righti, emptyi, emptytogglei, selecti, logici, geni, colori, accenti, cleari, clearFulli, clearPartiali, clearPartial2i, clearTogglei, clearTransi, clearToggleTransi, clearTogglePartiali;
|
||||
public static ScrollPaneStyle defaultPane, horizontalPane, smallPane, nonePane;
|
||||
public static KeybindDialog.KeybindDialogStyle defaultKeybindDialog;
|
||||
public static SliderStyle defaultSlider, vSlider;
|
||||
public static SliderStyle defaultSlider;
|
||||
public static LabelStyle defaultLabel, outlineLabel, techLabel;
|
||||
public static TextFieldStyle defaultField, nodeField, areaField, nodeArea;
|
||||
public static CheckBoxStyle defaultCheck;
|
||||
@@ -320,13 +320,7 @@ public class Styles{
|
||||
}};
|
||||
|
||||
defaultSlider = new SliderStyle(){{
|
||||
background = slider;
|
||||
knob = sliderKnob;
|
||||
knobOver = sliderKnobOver;
|
||||
knobDown = sliderKnobDown;
|
||||
}};
|
||||
vSlider = new SliderStyle(){{
|
||||
background = sliderVertical;
|
||||
background = sliderBack;
|
||||
knob = sliderKnob;
|
||||
knobOver = sliderKnobOver;
|
||||
knobDown = sliderKnobDown;
|
||||
|
||||
@@ -6,6 +6,7 @@ import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.Texture.*;
|
||||
import arc.input.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.TextButton.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
@@ -686,23 +687,21 @@ public class SettingsMenuDialog extends Dialog{
|
||||
|
||||
slider.setValue(settings.getInt(name));
|
||||
|
||||
Label label = new Label(title);
|
||||
Label value = new Label("");
|
||||
value.setStyle(Styles.outlineLabel);
|
||||
value.touchable = Touchable.disabled;
|
||||
|
||||
slider.changed(() -> {
|
||||
settings.put(name, (int)slider.getValue());
|
||||
label.setText(title + ": " + sp.get((int)slider.getValue()));
|
||||
value.setText(title + ": " + sp.get((int)slider.getValue()));
|
||||
});
|
||||
|
||||
value.setAlignment(Align.center);
|
||||
value.setWrap(true);
|
||||
|
||||
slider.change();
|
||||
|
||||
table.table(t -> {
|
||||
t.left().defaults().left();
|
||||
t.add(label).minWidth(label.getPrefWidth() / Scl.scl(1f) + 50);
|
||||
if(Core.graphics.isPortrait()){
|
||||
t.row();
|
||||
}
|
||||
t.add(slider).width(180);
|
||||
}).left().padTop(3);
|
||||
|
||||
table.stack(slider, value).width(420f).left().padTop(4);
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user