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:
@@ -1226,6 +1226,7 @@ setting.playerchat.name = Display Player Bubble Chat
|
|||||||
setting.showweather.name = Show Weather Graphics
|
setting.showweather.name = Show Weather Graphics
|
||||||
setting.hidedisplays.name = Hide Logic Displays
|
setting.hidedisplays.name = Hide Logic Displays
|
||||||
setting.dynamicjumpheights.name = Dynamic Jump Heights
|
setting.dynamicjumpheights.name = Dynamic Jump Heights
|
||||||
|
setting.coloredjumps.name = Colored Jumps
|
||||||
setting.macnotch.name = Adapt interface to display notch
|
setting.macnotch.name = Adapt interface to display notch
|
||||||
setting.macnotch.description = Restart required to apply changes
|
setting.macnotch.description = Restart required to apply changes
|
||||||
steam.friendsonly = Friends Only
|
steam.friendsonly = Friends Only
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public class LCanvas extends Table{
|
|||||||
//ew static variables
|
//ew static variables
|
||||||
static LCanvas canvas;
|
static LCanvas canvas;
|
||||||
private static boolean dynamicJumpHeights = false;
|
private static boolean dynamicJumpHeights = false;
|
||||||
|
private static boolean coloredJumps = false;
|
||||||
|
|
||||||
public DragLayout statements;
|
public DragLayout statements;
|
||||||
public ScrollPane pane;
|
public ScrollPane pane;
|
||||||
@@ -112,6 +113,7 @@ public class LCanvas extends Table{
|
|||||||
jumps = statements.jumps;
|
jumps = statements.jumps;
|
||||||
|
|
||||||
dynamicJumpHeights = Core.settings.getBool("dynamicjumpheights", false);
|
dynamicJumpHeights = Core.settings.getBool("dynamicjumpheights", false);
|
||||||
|
coloredJumps = Core.settings.getBool("coloredjumps", false);
|
||||||
|
|
||||||
pane = pane(t -> {
|
pane = pane(t -> {
|
||||||
t.center();
|
t.center();
|
||||||
@@ -204,6 +206,7 @@ public class LCanvas extends Table{
|
|||||||
public Group jumps = new WidgetGroup();
|
public Group jumps = new WidgetGroup();
|
||||||
private Seq<JumpCurve> processedJumps = new Seq<JumpCurve>();
|
private Seq<JumpCurve> processedJumps = new Seq<JumpCurve>();
|
||||||
public boolean updateJumpHeights = true;
|
public boolean updateJumpHeights = true;
|
||||||
|
private Rand rand = new Rand();
|
||||||
|
|
||||||
{
|
{
|
||||||
setTransform(true);
|
setTransform(true);
|
||||||
@@ -264,6 +267,16 @@ public class LCanvas extends Table{
|
|||||||
updateJumpHeights = false;
|
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.invalidateHierarchy();//don't invalid self
|
||||||
|
|
||||||
if(parent != null && parent instanceof Table){
|
if(parent != null && parent instanceof Table){
|
||||||
@@ -533,7 +546,7 @@ public class LCanvas extends Table{
|
|||||||
|
|
||||||
public static class JumpButton extends ImageButton{
|
public static class JumpButton extends ImageButton{
|
||||||
Color hoverColor = Pal.place;
|
Color hoverColor = Pal.place;
|
||||||
Color defaultColor = Color.white;
|
Color defaultColor = new Color(Color.white);
|
||||||
Prov<StatementElem> to;
|
Prov<StatementElem> to;
|
||||||
boolean selecting;
|
boolean selecting;
|
||||||
float mx, my;
|
float mx, my;
|
||||||
@@ -673,6 +686,7 @@ public class LCanvas extends Table{
|
|||||||
public void drawCurve(float x, float y, float x2, float y2){
|
public void drawCurve(float x, float y, float x2, float y2){
|
||||||
Lines.stroke(4f, button.color);
|
Lines.stroke(4f, button.color);
|
||||||
Draw.alpha(parentAlpha);
|
Draw.alpha(parentAlpha);
|
||||||
|
Draw.color(button.color);
|
||||||
|
|
||||||
// exponential smoothing
|
// exponential smoothing
|
||||||
uiHeight = Mathf.lerp(100f + 100f * (float) predHeight, uiHeight, dynamicJumpHeights ? Mathf.pow(0.9f, Time.delta) : 0);
|
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 + uiHeight, y2,
|
||||||
x2, y2,
|
x2, y2,
|
||||||
Math.max(18, (int)(Mathf.dst(x, y, x2, y2) / 6)));
|
Math.max(18, (int)(Mathf.dst(x, y, x2, y2) / 6)));
|
||||||
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepareHeight(){
|
public void prepareHeight(){
|
||||||
|
|||||||
@@ -504,6 +504,7 @@ public class SettingsMenuDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
graphics.checkPref("dynamicjumpheights", true);
|
graphics.checkPref("dynamicjumpheights", true);
|
||||||
|
graphics.checkPref("coloredjumps", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exportData(Fi file) throws IOException{
|
public void exportData(Fi file) throws IOException{
|
||||||
|
|||||||
Reference in New Issue
Block a user