Jump curve coloring
See #general-programming in the Mindustry Discord server: https://discord.com/channels/391020510269669376/663854113418641429/1256146387834372106 Co-authored-by: Ilya246 <ilyukarno@gmail.com>
This commit is contained in:
@@ -26,6 +26,7 @@ public class LCanvas extends Table{
|
||||
//ew static variables
|
||||
static LCanvas canvas;
|
||||
private static boolean dynamicJumpHeights = false;
|
||||
private static boolean coloredJumps = false;
|
||||
|
||||
public DragLayout statements;
|
||||
public ScrollPane pane;
|
||||
@@ -112,6 +113,7 @@ public class LCanvas extends Table{
|
||||
jumps = statements.jumps;
|
||||
|
||||
dynamicJumpHeights = Core.settings.getBool("dynamicjumpheights", false);
|
||||
coloredJumps = Core.settings.getBool("coloredjumps", false);
|
||||
|
||||
pane = pane(t -> {
|
||||
t.center();
|
||||
@@ -204,6 +206,7 @@ public class LCanvas extends Table{
|
||||
public Group jumps = new WidgetGroup();
|
||||
private Seq<JumpCurve> processedJumps = new Seq<JumpCurve>();
|
||||
public boolean updateJumpHeights = true;
|
||||
private Rand rand = new Rand();
|
||||
|
||||
{
|
||||
setTransform(true);
|
||||
@@ -264,6 +267,16 @@ public class LCanvas extends Table{
|
||||
updateJumpHeights = false;
|
||||
}
|
||||
|
||||
if(coloredJumps){
|
||||
jumps.getChildren().each(e -> {
|
||||
if(!(e instanceof JumpCurve e2) || e2.button.to.get() == null) return;
|
||||
int idx = e2.button.to.get().index;
|
||||
if(dragging != null && idx >= dragging.index) idx += 1;
|
||||
rand.setSeed((long) idx);
|
||||
Color.HSVtoRGB(rand.random(0.0f, 360.0f), rand.random(80.0f, 90.0f), 100.0f, e2.button.defaultColor);
|
||||
});
|
||||
}
|
||||
|
||||
if(parent != null) parent.invalidateHierarchy();//don't invalid self
|
||||
|
||||
if(parent != null && parent instanceof Table){
|
||||
@@ -533,7 +546,7 @@ public class LCanvas extends Table{
|
||||
|
||||
public static class JumpButton extends ImageButton{
|
||||
Color hoverColor = Pal.place;
|
||||
Color defaultColor = Color.white;
|
||||
Color defaultColor = new Color(Color.white);
|
||||
Prov<StatementElem> to;
|
||||
boolean selecting;
|
||||
float mx, my;
|
||||
@@ -673,6 +686,7 @@ public class LCanvas extends Table{
|
||||
public void drawCurve(float x, float y, float x2, float y2){
|
||||
Lines.stroke(4f, button.color);
|
||||
Draw.alpha(parentAlpha);
|
||||
Draw.color(button.color);
|
||||
|
||||
// exponential smoothing
|
||||
uiHeight = Mathf.lerp(100f + 100f * (float) predHeight, uiHeight, dynamicJumpHeights ? Mathf.pow(0.9f, Time.delta) : 0);
|
||||
@@ -698,6 +712,7 @@ public class LCanvas extends Table{
|
||||
x2 + uiHeight, y2,
|
||||
x2, y2,
|
||||
Math.max(18, (int)(Mathf.dst(x, y, x2, y2) / 6)));
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public void prepareHeight(){
|
||||
|
||||
@@ -504,6 +504,7 @@ public class SettingsMenuDialog extends BaseDialog{
|
||||
}
|
||||
|
||||
graphics.checkPref("dynamicjumpheights", true);
|
||||
graphics.checkPref("coloredjumps", true);
|
||||
}
|
||||
|
||||
public void exportData(Fi file) throws IOException{
|
||||
|
||||
Reference in New Issue
Block a user