This commit is contained in:
sharlottes
2021-05-07 23:54:04 +09:00
parent b24c5742ee
commit d8a9d4cc90
2 changed files with 128 additions and 70 deletions

View File

@@ -18,7 +18,7 @@ public class SBar extends Element{
private String name = "";
private float value, lastValue, blink;
private Color blinkColor = new Color();
private boolean valid = true;
public SBar(String name, Color color, Floatp fraction){
this.fraction = fraction;
@@ -46,6 +46,26 @@ 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 SBar(){
}
@@ -83,7 +103,7 @@ public class SBar extends Element{
@Override
public void draw(){
if(fraction == null) return;
if(fraction == null || !valid) return;
float computed;
try{