Skip to content

Commit 3c431b7

Browse files
Fixing what I broke
1 parent 1dbee6d commit 3c431b7

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

src/main/java/com/tanishisherewith/dynamichud/widgets/GraphWidget.java

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public GraphWidget(String registryID, String registryKey, String modId, Anchor a
6565
this.showGrid = showGrid;
6666
this.gridLines = gridLines;
6767
this.label = label;
68+
this.setMinValue(minValue);
69+
this.setMaxValue(maxValue);
6870

6971
internal_init();
7072

@@ -74,8 +76,6 @@ public GraphWidget(String registryID, String registryKey, String modId, Anchor a
7476
private void internal_init(){
7577
Validate.isTrue(maxDataPoints > 2, "MaxDataPoints should be more than 2.");
7678
this.dataPoints = new float[maxDataPoints];
77-
this.setMinValue(minValue);
78-
this.setMaxValue(maxValue);
7979
this.label = label.trim();
8080
this.widgetBox = new WidgetBox(x, y, (int) width, (int) height);
8181

@@ -259,6 +259,7 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY) {
259259
DrawHelper.drawVerticalLine(matrix, xPos, y, height, 0.5f, 0x4DFFFFFF);
260260
}
261261
}
262+
262263
// Draw interpolated graph curve
263264
List<float[]> points = getInterpolatedPoints();
264265
drawInterpolatedCurve(matrix, points, graphColor.getRGB(), lineThickness);
@@ -276,8 +277,9 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY) {
276277
1.0f, 0.8f, 1.0f, 0.05f, true
277278
);
278279

280+
279281
// Draw axes
280-
DrawHelper.drawHorizontalLine(matrix, x, width, y + height, 1.0f, 0xFFFFFFFF); // X-axis
282+
DrawHelper.drawHorizontalLine(matrix, x, width, y + height - 1, 1.0f, 0xFFFFFFFF); // X-axis
281283
DrawHelper.drawVerticalLine(matrix, x, y, height, 1.0f, 0xFFFFFFFF); // Y-axis
282284

283285
// Draw min and max value labels with formatted values
@@ -345,25 +347,6 @@ public void createMenu() {
345347
);
346348
}
347349

348-
@Override
349-
public void readFromTag(NbtCompound tag) {
350-
super.readFromTag(tag);
351-
this.width = tag.getFloat("width");
352-
this.height = tag.getFloat("height");
353-
this.maxDataPoints = tag.getInt("maxDataPoints");
354-
this.minValue = tag.getFloat("minValue");
355-
this.maxValue = tag.getFloat("maxValue");
356-
this.graphColor = new Color(tag.getInt("graphColor"));
357-
this.backgroundColor = new Color(tag.getInt("backgroundColor"));
358-
this.lineThickness = tag.getFloat("lineThickness");
359-
this.showGrid = tag.getBoolean("showGrid");
360-
this.gridLines = tag.getInt("gridLines");
361-
this.label = tag.getString("label");
362-
363-
internal_init();
364-
createMenu();
365-
}
366-
367350
public float getMinValue() {
368351
return minValue;
369352
}
@@ -484,6 +467,29 @@ public void writeToTag(NbtCompound tag) {
484467
tag.putBoolean("showGrid", showGrid);
485468
tag.putInt("gridLines", gridLines);
486469
tag.putString("label", label);
470+
tag.putBoolean("autoUpdateRange", autoUpdateRange);
471+
}
472+
473+
@Override
474+
public void readFromTag(NbtCompound tag) {
475+
super.readFromTag(tag);
476+
this.width = tag.getFloat("width");
477+
this.height = tag.getFloat("height");
478+
this.maxDataPoints = tag.getInt("maxDataPoints");
479+
this.minValue = tag.getFloat("minValue");
480+
this.maxValue = tag.getFloat("maxValue");
481+
this.graphColor = new Color(tag.getInt("graphColor"));
482+
this.backgroundColor = new Color(tag.getInt("backgroundColor"));
483+
this.lineThickness = tag.getFloat("lineThickness");
484+
this.showGrid = tag.getBoolean("showGrid");
485+
this.gridLines = tag.getInt("gridLines");
486+
this.label = tag.getString("label");
487+
this.autoUpdateRange = tag.getBoolean("autoUpdateRange");
488+
this.setMinValue(minValue);
489+
this.setMaxValue(maxValue);
490+
491+
internal_init();
492+
createMenu();
487493
}
488494

489495
@Override

src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public TextWidget(String registryID, String registryKey, boolean shadow, boolean
5151
}
5252

5353
public void createMenu() {
54-
boolean dark_mode = false;
5554
ContextMenuProperties properties = ContextMenuProperties.builder().build();
5655
menu = new ContextMenu<>(getX(), getY(), properties);
5756

0 commit comments

Comments
 (0)