mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
clean up
This commit is contained in:
@@ -96,39 +96,12 @@ public class Main extends Mod {
|
|||||||
if(!mobile && !Vars.state.isPaused() && settings.getBool("gaycursor"))
|
if(!mobile && !Vars.state.isPaused() && settings.getBool("gaycursor"))
|
||||||
Fx.mine.at(Core.input.mouseWorldX(), Core.input.mouseWorldY(), Tmp.c2.set(Color.red).shiftHue(Time.time * 1.5f));
|
Fx.mine.at(Core.input.mouseWorldX(), Core.input.mouseWorldY(), Tmp.c2.set(Color.red).shiftHue(Time.time * 1.5f));
|
||||||
|
|
||||||
Groups.unit.each(unit -> {
|
if(!renderer.pixelator.enabled()) Groups.unit.each(unit -> unit.item() != null && unit.itemTime > 0.01f, unit -> {
|
||||||
Draw.color();
|
|
||||||
Tmp.c1.set(Color.white).lerp(Pal.heal, Mathf.clamp(unit.healTime - unit.hitTime));
|
|
||||||
Draw.mixcol(Tmp.c1, Math.max(unit.hitTime, Mathf.clamp(unit.healTime)));
|
|
||||||
if(unit.drownTime > 0 && unit.floorOn().isDeep())
|
|
||||||
Draw.mixcol(unit.floorOn().mapColor, unit.drownTime * 0.8f);
|
|
||||||
|
|
||||||
//draw back items
|
|
||||||
if(unit.item() != null && unit.itemTime > 0.01f){
|
|
||||||
float size = (itemSize + Mathf.absin(Time.time, 5f, 1f)) * unit.itemTime;
|
|
||||||
|
|
||||||
Draw.mixcol(Pal.accent, Mathf.absin(Time.time, 5f, 0.1f));
|
|
||||||
Draw.rect(unit.item().fullIcon,
|
|
||||||
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
|
|
||||||
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY),
|
|
||||||
size, size, unit.rotation);
|
|
||||||
Draw.mixcol();
|
|
||||||
|
|
||||||
Lines.stroke(1f, Pal.accent);
|
|
||||||
Lines.circle(
|
|
||||||
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
|
|
||||||
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY),
|
|
||||||
(3f + Mathf.absin(Time.time, 5f, 1f)) * unit.itemTime);
|
|
||||||
|
|
||||||
if(!renderer.pixelator.enabled()){
|
|
||||||
Fonts.outline.draw(unit.stack.amount + "",
|
Fonts.outline.draw(unit.stack.amount + "",
|
||||||
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
|
unit.x + Angles.trnsx(unit.rotation + 180f, unit.type.itemOffsetY),
|
||||||
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY) - 3,
|
unit.y + Angles.trnsy(unit.rotation + 180f, unit.type.itemOffsetY) - 3,
|
||||||
Pal.accent, 0.25f * unit.itemTime / Scl.scl(1f), false, Align.center);
|
Pal.accent, 0.25f * unit.itemTime / Scl.scl(1f), false, Align.center);
|
||||||
}
|
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ public class SBar extends Element{
|
|||||||
private String name = "";
|
private String name = "";
|
||||||
private float value, lastValue, blink;
|
private float value, lastValue, blink;
|
||||||
private final Color blinkColor = new Color();
|
private final Color blinkColor = new Color();
|
||||||
|
NinePatchDrawable bar;
|
||||||
|
NinePatchDrawable top;
|
||||||
|
float spriteWidth;
|
||||||
|
|
||||||
public SBar(Prov<String> name, Prov<Color> color, Floatp fraction){
|
public SBar(Prov<String> name, Prov<Color> color, Floatp fraction){
|
||||||
this.fraction = fraction;
|
this.fraction = fraction;
|
||||||
@@ -37,55 +40,15 @@ public class SBar extends Element{
|
|||||||
this.name = "";
|
this.name = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
public Drawable drawable(String name, int left, int right, int top, int bottom){
|
|
||||||
Drawable out;
|
|
||||||
|
|
||||||
TextureAtlas.AtlasRegion region = Core.atlas.find(name);
|
|
||||||
|
|
||||||
int[] splits = {left, right, top, bottom};
|
|
||||||
NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
|
|
||||||
int[] pads = region.pads;
|
|
||||||
if(pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
|
|
||||||
out = new ScaledNinePatchDrawable(patch, 1f);
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(){
|
|
||||||
if(fraction == null) return;
|
|
||||||
boolean ssim = Core.settings.getBool("ssim");
|
boolean ssim = Core.settings.getBool("ssim");
|
||||||
boolean shar = Core.settings.getBool("shar");
|
boolean shar = Core.settings.getBool("shar");
|
||||||
boolean shar1 = Core.settings.getBool("shar1");
|
boolean shar1 = Core.settings.getBool("shar1");
|
||||||
boolean shar2 = Core.settings.getBool("shar2");
|
boolean shar2 = Core.settings.getBool("shar2");
|
||||||
boolean shar3 = Core.settings.getBool("shar3");
|
boolean shar3 = Core.settings.getBool("shar3");
|
||||||
float computed;
|
|
||||||
try{
|
|
||||||
computed = Mathf.clamp(fraction.get());
|
|
||||||
}catch(Exception e){ //getting the fraction may involve referring to invalid data
|
|
||||||
computed = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lastValue > computed){
|
bar = (NinePatchDrawable) drawable("unitinfo-barS", 10, 10, 9, 9);
|
||||||
blink = 1f;
|
top = (NinePatchDrawable) drawable("unitinfo-barS-top", 10, 10, 9, 9);
|
||||||
lastValue = computed;
|
spriteWidth = Core.atlas.find("unitinfo-barS").width;
|
||||||
}
|
|
||||||
|
|
||||||
if(Float.isNaN(lastValue)) lastValue = 0;
|
|
||||||
if(Float.isInfinite(lastValue)) lastValue = 1f;
|
|
||||||
if(Float.isNaN(value)) value = 0;
|
|
||||||
if(Float.isInfinite(value)) value = 1f;
|
|
||||||
if(Float.isNaN(computed)) computed = 0;
|
|
||||||
if(Float.isInfinite(computed)) computed = 1f;
|
|
||||||
|
|
||||||
blink = Mathf.lerpDelta(blink, 0f, 0.2f);
|
|
||||||
value = Mathf.lerpDelta(value, computed, 0.05f);
|
|
||||||
|
|
||||||
NinePatchDrawable bar = (NinePatchDrawable) drawable("unitinfo-barS", 10, 10, 9, 9);
|
|
||||||
NinePatchDrawable top = (NinePatchDrawable) drawable("unitinfo-barS-top", 10, 10, 9, 9);
|
|
||||||
float spriteWidth = Core.atlas.find("unitinfo-barS").width;
|
|
||||||
if(ssim){
|
if(ssim){
|
||||||
bar = (NinePatchDrawable) drawable("unitinfo-barSS", 14, 14, 19, 19);
|
bar = (NinePatchDrawable) drawable("unitinfo-barSS", 14, 14, 19, 19);
|
||||||
top = (NinePatchDrawable) drawable("unitinfo-barSS-top", 14, 14, 19, 19);
|
top = (NinePatchDrawable) drawable("unitinfo-barSS-top", 14, 14, 19, 19);
|
||||||
@@ -112,13 +75,53 @@ public class SBar extends Element{
|
|||||||
spriteWidth = Core.atlas.find("unitinfo-barSSSSSS").width;
|
spriteWidth = Core.atlas.find("unitinfo-barSSSSSS").width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable drawable(String name, int left, int right, int top, int bottom){
|
||||||
|
Drawable out;
|
||||||
|
|
||||||
|
TextureAtlas.AtlasRegion region = Core.atlas.find(name);
|
||||||
|
|
||||||
|
int[] splits = {left, right, top, bottom};
|
||||||
|
NinePatch patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
|
||||||
|
int[] pads = region.pads;
|
||||||
|
if(pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
|
||||||
|
out = new ScaledNinePatchDrawable(patch, 1f);
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
if(fraction == null) return;
|
||||||
|
float computed;
|
||||||
|
try{
|
||||||
|
computed = Mathf.clamp(fraction.get());
|
||||||
|
}catch(Exception e){ //getting the fraction may involve referring to invalid data
|
||||||
|
computed = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lastValue > computed){
|
||||||
|
blink = 1f;
|
||||||
|
lastValue = computed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Float.isNaN(lastValue)) lastValue = 0;
|
||||||
|
if(Float.isInfinite(lastValue)) lastValue = 1f;
|
||||||
|
if(Float.isNaN(value)) value = 0;
|
||||||
|
if(Float.isInfinite(value)) value = 1f;
|
||||||
|
if(Float.isNaN(computed)) computed = 0;
|
||||||
|
if(Float.isInfinite(computed)) computed = 1f;
|
||||||
|
|
||||||
|
blink = Mathf.lerpDelta(blink, 0f, 0.2f);
|
||||||
|
value = Mathf.lerpDelta(value, computed, 0.05f);
|
||||||
|
|
||||||
Draw.colorl(0.1f);
|
Draw.colorl(0.1f);
|
||||||
bar.draw(x, y, width, height);
|
bar.draw(x, y, width, height);
|
||||||
|
|
||||||
|
|
||||||
Draw.color(color.cpy().mul(Pal.lightishGray), blinkColor, blink);
|
Draw.color(color.cpy().mul(Pal.lightishGray), blinkColor, blink);
|
||||||
|
|
||||||
float topWidth = width * value;
|
float topWidth = width * value;
|
||||||
|
|
||||||
if(topWidth > spriteWidth){
|
if(topWidth > spriteWidth){
|
||||||
top.draw(x, y, topWidth, height);
|
top.draw(x, y, topWidth, height);
|
||||||
}else{
|
}else{
|
||||||
@@ -130,7 +133,6 @@ public class SBar extends Element{
|
|||||||
|
|
||||||
Draw.color(color, blinkColor, blink);
|
Draw.color(color, blinkColor, blink);
|
||||||
float topWidthReal = width * (Math.min(value, computed));
|
float topWidthReal = width * (Math.min(value, computed));
|
||||||
|
|
||||||
if(topWidthReal > spriteWidth){
|
if(topWidthReal > spriteWidth){
|
||||||
top.draw(x, y, topWidthReal, height);
|
top.draw(x, y, topWidthReal, height);
|
||||||
}else{
|
}else{
|
||||||
@@ -141,7 +143,6 @@ public class SBar extends Element{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
|
||||||
Font font = Fonts.outline;
|
Font font = Fonts.outline;
|
||||||
GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||||
font.getData().setScale(Scl.scl());
|
font.getData().setScale(Scl.scl());
|
||||||
|
|||||||
Reference in New Issue
Block a user