Skip to content

Commit

Permalink
Yet more code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceWalkerRS committed May 10, 2021
1 parent 28e0a53 commit 2abfd60
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ private void renderTicksTable(MatrixStack matrices, int x, int y, int width, int
long firstTick = getSelectedTick() - SELECTED_COLUMN;
long currentTick = client.getLastServerTick() + 1;

int markerColumn = (currentTick < firstTick || currentTick > (firstTick + COLUMN_COUNT)) ? -1 : (int)(currentTick - firstTick);
int markedColumn = (currentTick < firstTick || currentTick > (firstTick + COLUMN_COUNT)) ? -1 : (int)(currentTick - firstTick);

drawBackground(matrices, x, y, width, height);
drawGridLines(matrices, x, y, height, COLUMN_COUNT, markerColumn);
drawGridLines(matrices, x, y, height, COLUMN_COUNT, markedColumn);

int rowX = x;
int rowY = y;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/rsmm/fabric/client/gui/MultimeterScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class MultimeterScreen extends RSMMScreen {

private static double lastScrollAmount;

private boolean isPauseScreen;
private final boolean isPauseScreen;

private double scrollAmount = -1;
private int scrollSpeed = 7;
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/rsmm/fabric/client/gui/element/IParentElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public interface IParentElement extends IElement {

@Override
default void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
for (IElement child : getChildren()) {
child.render(matrices, mouseX, mouseY, delta);
List<IElement> children = getChildren();

for (int index = 0; index < children.size(); index++) {
children.get(index).render(matrices, mouseX, mouseY, delta);
}
}

Expand Down Expand Up @@ -49,13 +51,14 @@ default boolean mouseClick(double mouseX, double mouseY, int button) {

@Override
default boolean mouseRelease(double mouseX, double mouseY, int button) {
boolean released = false;

if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
setDraggingMouse(false);
}

boolean released = false;

List<IElement> children = getChildren();

for (int index = 0; index < children.size(); index++) {
IElement child = children.get(index);

Expand Down Expand Up @@ -147,7 +150,11 @@ default void clearChildren() {

default IElement getHoveredElement(double mouseX, double mouseY) {
if (isHovered(mouseX, mouseY)) {
for (IElement child : getChildren()) {
List<IElement> children = getChildren();

for (int index = 0; index < children.size(); index++) {
IElement child = children.get(index);

if (child.isHovered(mouseX, mouseY)) {
return child;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,6 @@ private void updateCoordinates() {

y += ROW_HEIGHT;
}


}

this.height = y - this.y;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/rsmm/fabric/client/gui/widget/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;

import rsmm.fabric.client.MultimeterClient;
import rsmm.fabric.client.gui.element.IElement;

Expand Down

0 comments on commit 2abfd60

Please sign in to comment.