I FEEL FANSTSTICCCCCCCCCCCCCCCCCCCAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

This commit is contained in:
Sharlotte
2021-07-18 19:14:21 +09:00
parent 072f8a5681
commit 34a0e8fd7a
2 changed files with 74 additions and 54 deletions

View File

@@ -16,19 +16,10 @@ import mindustry.ui.*;
public class SBar extends Element{
private static final Rect scissor = new Rect();
private Floatp fraction;
private final Floatp fraction;
private String name = "";
private float value, lastValue, blink;
private final Color blinkColor = new Color();
private boolean valid = true;
public SBar(String name, Color color, Floatp fraction){
this.fraction = fraction;
this.name = Core.bundle.get(name, name);
this.blinkColor.set(color);
lastValue = value = fraction.get();
setColor(color);
}
public SBar(Prov<String> name, Prov<Color> color, Floatp fraction){
this.fraction = fraction;
@@ -48,25 +39,6 @@ public class SBar extends Element{
});
}
public SBar(Prov<String> name, Prov<Color> color, Floatp fraction, Boolp valid){
this.fraction = fraction;
try{
lastValue = value = Mathf.clamp(fraction.get());
}catch(Exception e){ //getting the fraction may involve referring to invalid data
lastValue = value = 0f;
}
update(() -> {
try{
this.valid = valid.get();
this.name = name.get();
this.blinkColor.set(color.get());
setColor(color.get());
}catch(Exception e){ //getting the fraction may involve referring to invalid data
this.name = "";
}
});
}
public Drawable drawable(String name, int left, int right, int top, int bottom){
Drawable out;
@@ -83,6 +55,7 @@ public class SBar extends Element{
@Override
public void draw(){
boolean valid = true;
if(fraction == null || !valid) return;
boolean ssim = Core.settings.getBool("ssim");