Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -38,8 +38,14 @@ public class WaveGraph extends Table{
|
|||||||
|
|
||||||
lay.setText(font, "1");
|
lay.setText(font, "1");
|
||||||
|
|
||||||
|
int maxY = switch(mode){
|
||||||
|
case counts -> nextStep(max);
|
||||||
|
case health -> nextStep((int)maxHealth);
|
||||||
|
case totals -> nextStep(maxTotal);
|
||||||
|
};
|
||||||
|
|
||||||
float fh = lay.height;
|
float fh = lay.height;
|
||||||
float offsetX = Scl.scl(30f), offsetY = Scl.scl(22f) + fh + Scl.scl(5f);
|
float offsetX = Scl.scl(lay.width * (maxY + "").length() * 2), offsetY = Scl.scl(22f) + fh + Scl.scl(5f);
|
||||||
|
|
||||||
float graphX = x + offsetX, graphY = y + offsetY, graphW = width - offsetX, graphH = height - offsetY;
|
float graphX = x + offsetX, graphY = y + offsetY, graphW = width - offsetX, graphH = height - offsetY;
|
||||||
float spacing = graphW / (values.length - 1);
|
float spacing = graphW / (values.length - 1);
|
||||||
@@ -53,7 +59,7 @@ public class WaveGraph extends Table{
|
|||||||
|
|
||||||
for(int i = 0; i < values.length; i++){
|
for(int i = 0; i < values.length; i++){
|
||||||
int val = values[i][type.id];
|
int val = values[i][type.id];
|
||||||
float cx = graphX + i*spacing, cy = graphY + val * graphH / max;
|
float cx = graphX + i * spacing, cy = graphY + val * graphH / maxY;
|
||||||
Lines.linePoint(cx, cy);
|
Lines.linePoint(cx, cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +75,7 @@ public class WaveGraph extends Table{
|
|||||||
sum += values[i][type.id];
|
sum += values[i][type.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
float cx = graphX + i*spacing, cy = graphY + sum * graphH / maxTotal;
|
float cx = graphX + i * spacing, cy = graphY + sum * graphH / maxY;
|
||||||
Lines.linePoint(cx, cy);
|
Lines.linePoint(cx, cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +90,7 @@ public class WaveGraph extends Table{
|
|||||||
sum += (type.health) * values[i][type.id];
|
sum += (type.health) * values[i][type.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
float cx = graphX + i*spacing, cy = graphY + sum * graphH / maxHealth;
|
float cx = graphX + i * spacing, cy = graphY + sum * graphH / maxY;
|
||||||
Lines.linePoint(cx, cy);
|
Lines.linePoint(cx, cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,19 +98,23 @@ public class WaveGraph extends Table{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//how many numbers can fit here
|
//how many numbers can fit here
|
||||||
float totalMarks = (graphH - getMarginBottom() *2f) / (lay.height * 2);
|
float totalMarks = Mathf.clamp(maxY, 1, 10);
|
||||||
|
|
||||||
int markSpace = Math.max(1, Mathf.ceil(max / totalMarks));
|
int markSpace = Math.max(1, Mathf.ceil(maxY / totalMarks));
|
||||||
|
|
||||||
Draw.color(Color.lightGray);
|
Draw.color(Color.lightGray);
|
||||||
for(int i = 0; i < max; i += markSpace){
|
Draw.alpha(0.1f);
|
||||||
float cy = graphY + i * graphH / max, cx = graphX;
|
|
||||||
//Lines.line(cx, cy, cx + len, cy);
|
for(int i = 0; i < maxY; i += markSpace){
|
||||||
|
float cy = graphY + i * graphH / maxY, cx = graphX;
|
||||||
|
|
||||||
|
Lines.line(cx, cy, cx + graphW, cy);
|
||||||
|
|
||||||
lay.setText(font, "" + i);
|
lay.setText(font, "" + i);
|
||||||
|
|
||||||
font.draw("" + i, cx, cy + lay.height / 2f, Align.right);
|
font.draw("" + i, cx, cy + lay.height / 2f, Align.right);
|
||||||
}
|
}
|
||||||
|
Draw.alpha(1f);
|
||||||
|
|
||||||
float len = Scl.scl(4f);
|
float len = Scl.scl(4f);
|
||||||
font.setColor(Color.lightGray);
|
font.setColor(Color.lightGray);
|
||||||
@@ -200,6 +210,23 @@ public class WaveGraph extends Table{
|
|||||||
return Tmp.c1.fromHsv(type.id / (float)Vars.content.units().size * 360f, 0.7f, 1f);
|
return Tmp.c1.fromHsv(type.id / (float)Vars.content.units().size * 360f, 0.7f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nextStep(float value){
|
||||||
|
int order = 1;
|
||||||
|
while(order < value){
|
||||||
|
if(order * 2 > value){
|
||||||
|
return order * 2;
|
||||||
|
}
|
||||||
|
if(order * 5 > value){
|
||||||
|
return order * 5;
|
||||||
|
}
|
||||||
|
if(order * 10 > value){
|
||||||
|
return order * 10;
|
||||||
|
}
|
||||||
|
order *= 10;
|
||||||
|
}
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
enum Mode{
|
enum Mode{
|
||||||
counts, totals, health;
|
counts, totals, health;
|
||||||
|
|
||||||
|
|||||||
@@ -110,5 +110,9 @@
|
|||||||
{
|
{
|
||||||
"name": "CreateDustry",
|
"name": "CreateDustry",
|
||||||
"address": ["144.76.120.74:18645"]
|
"address": ["144.76.120.74:18645"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "HexedPvP",
|
||||||
|
"address": ["001.finland.eu.hosts.dynamichost.xyz:23664"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user