From 4de40e327cceb3079b421e66f400b5085d002b08 Mon Sep 17 00:00:00 2001 From: BlazingTwist Date: Sat, 20 Mar 2021 16:27:24 +0100 Subject: [PATCH] 1.0.4 added notes to testCannonCharges testCannonData of fields gets saved when closing while focused changed FrameConfig from int to float, more accurate, but using a lot of rounding calls --- build.gradle | 2 +- .../cannontracer/gui/ConfigGUI.java | 8 +- .../cannontracer/gui/TestCannonGUI.java | 43 +++--- .../gui/guielements/BasicTextFrame.java | 48 ++++--- .../guielements/CompactToggleValueFrame.java | 42 ++++++ .../gui/guielements/DoubleSegmentFrame.java | 106 +++++++++------ .../gui/guielements/ScrollableTable.java | 126 +++++++++--------- .../gui/guielements/ScrollbarFrame.java | 43 +++--- .../gui/guielements/ToggleKeybindFrame.java | 12 +- .../interfaces/IClickableFrame.java | 10 +- .../interfaces/IFocusableFrame.java | 10 +- .../interfaces/IRenderableFrame.java | 39 +++--- .../cannontracer/gui/utils/FormatData.java | 6 +- .../cannontracer/gui/utils/FrameColors.java | 13 ++ .../cannontracer/gui/utils/FrameConfig.java | 12 +- .../cannontracer/modules/ModuleManager.java | 4 +- 16 files changed, 322 insertions(+), 202 deletions(-) create mode 100644 src/main/java/the_dark_jumper/cannontracer/gui/guielements/CompactToggleValueFrame.java diff --git a/build.gradle b/build.gradle index 6acd1a5..16cc942 100644 --- a/build.gradle +++ b/build.gradle @@ -108,7 +108,7 @@ dependencies { // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft 'net.minecraftforge:forge:1.15.2-31.2.47' - provided name: 'JumperCommons', version: '1.1' + provided name: 'JumperCommons', version: '1.0.4' // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/ConfigGUI.java b/src/main/java/the_dark_jumper/cannontracer/gui/ConfigGUI.java index e15035a..9bcce2f 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/ConfigGUI.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/ConfigGUI.java @@ -130,7 +130,7 @@ public void generateSingleplayerScreenComponents() { guiComponents.add(new BasicTextFrame(this, "Keybinds", config.duplicate(), headerColors)); config.init(80, 35, 94, 39, 8); guiComponents.add(new ButtonFrame(this, "open Hotkey Menu", config.duplicate(), colors, this::openHotkeyScreen)); - config.init(6, 40, 94, 59, 8); + config.init(6, 40, 94, 59, 4); generateModuleKeybindTable(config, colors, Main.getInstance().moduleManager.singlePlayerModules); //tracing entries @@ -138,7 +138,7 @@ public void generateSingleplayerScreenComponents() { guiComponents.add(new BasicTextFrame(this, "Tracked Entities", config.duplicate(), headerColors)); config.init(80, 65, 94, 69, 8); guiComponents.add(new ButtonFrame(this, "add entity", config.duplicate(), colors, this::addTrackingEntity)); - config.init(6, 70, 94, 94, 8); + config.init(6, 70, 94, 94, 4); generateTrackingTable(Main.getInstance().dataManager.getTrackingDataSP(), config, colors); //generateTrackingScreenComponents(guiManager.main.entityTracker.observedEntityIDSP, config, colors, 6, 70, 94, 5, 8); } @@ -171,7 +171,7 @@ public void generateMultiplayerScreenComponents() { guiComponents.add(new BasicTextFrame(this, "Keybinds", config.duplicate(), headerColors)); config.init(80, 35, 94, 39, 8); guiComponents.add(new ButtonFrame(this, "open Hotkey Menu", config.duplicate(), colors, this::openHotkeyScreen)); - config.init(6, 40, 94, 59, 8); + config.init(6, 40, 94, 59, 4); generateModuleKeybindTable(config, colors, Main.getInstance().moduleManager.multiPlayerModules); //tracing entries @@ -179,7 +179,7 @@ public void generateMultiplayerScreenComponents() { guiComponents.add(new BasicTextFrame(this, "Tracked Entities", config.duplicate(), headerColors)); config.init(80, 65, 94, 69, 8); guiComponents.add(new ButtonFrame(this, "add entity", config.duplicate(), colors, this::addTrackingEntity)); - config.init(6, 70, 94, 94, 8); + config.init(6, 70, 94, 94, 4); generateTrackingTable(Main.getInstance().dataManager.getTrackingDataMP(), config, colors); //generateTrackingScreenComponents(guiManager.main.entityTracker.observedEntityIDMP, config, colors, 6, 70, 94, 5, 8); } diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/TestCannonGUI.java b/src/main/java/the_dark_jumper/cannontracer/gui/TestCannonGUI.java index d12d66c..7399fbf 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/TestCannonGUI.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/TestCannonGUI.java @@ -17,6 +17,7 @@ import the_dark_jumper.cannontracer.Main; import the_dark_jumper.cannontracer.gui.guielements.BasicTextFrame; import the_dark_jumper.cannontracer.gui.guielements.ButtonFrame; +import the_dark_jumper.cannontracer.gui.guielements.CompactToggleValueFrame; import the_dark_jumper.cannontracer.gui.guielements.ScrollableTable; import the_dark_jumper.cannontracer.gui.guielements.ValueFrame; import the_dark_jumper.cannontracer.gui.guielements.interfaces.IClickableFrame; @@ -82,6 +83,13 @@ public void closeButtonPressed(boolean isPressed) { } } + private void cancelButtonPressed(boolean isPressed){ + if(isPressed){ + cancelCannonData = true; + shouldClose = true; + } + } + public void addChargeButtonPressed(boolean isPressed) { if (isPressed) { testCannon.getCharges().add(new TestCannonCharge()); @@ -118,7 +126,7 @@ public void generateScreenComponents() { config.init(6, 10, 60, 14, 8); guiComponents.add(new BasicTextFrame(this, "Cannon Tester", config.duplicate(), colors)); config.init(80, 10, 89, 14, 8); - guiComponents.add(new ButtonFrame(this, "cancel", config.duplicate(), colors, this::closeWithoutSend)); + guiComponents.add(new ButtonFrame(this, "cancel", config.duplicate(), colors, this::cancelButtonPressed)); config.init(90, 10, 94, 14, 8); guiComponents.add(new ButtonFrame(this, "X", config.duplicate(), colors, this::closeButtonPressed)); @@ -153,17 +161,19 @@ public void generateScreenComponents() { guiComponents.add(new BasicTextFrame(this, "Charges", config.duplicate(), headerColors)); config.init(23, 40, 25, 44, 8); guiComponents.add(new ButtonFrame(this, "+", config.duplicate(), colors, this::addChargeButtonPressed)); - config.init(10, 45, 63, 94, 8); + config.init(10, 45, 63, 94, 4); chargesTable = new ScrollableTable(this, config.duplicate(), colors); chargesTable.setUniformColFormat(false, 9, 1); // fallback value, shouldn't be needed - chargesTable.setColFormat(false, - new FormatData(2, 1), // delete button - new FormatData(9, 0), // amount text field - new FormatData(2, 0), // increment button - new FormatData(2, 1), // decrement button - new FormatData(9, 0), // delay text field - new FormatData(2, 0), // increment button - new FormatData(2, 1));// decrement button + chargesTable.setColFormat(true, + new FormatData(4, 1), // delete button + new FormatData(10, 1), // enabled/disabled + new FormatData(15, 0), // amount text field + new FormatData(4, 0), // increment button + new FormatData(4, 1), // decrement button + new FormatData(15, 0), // delay text field + new FormatData(4, 0), // increment button + new FormatData(4, 1), // decrement button + new FormatData(35, 1));// notes text field chargesTable.setUniformRowFormat(false, 4, 1); chargesTable.generateScrollbars(false, 0, true, chargesTable.matchHeightToWidth(1)); generateChargesTable(); @@ -184,12 +194,14 @@ private void generateChargesTable() { chargesTable.addRow( new ButtonFrame(this, "X", null, colors, new DeleteChargeCallback(i, this::removeCharge)::onPressed), + new CompactToggleValueFrame(this, null, colors, "enabled", "disabled", charge.getEnabledGNS()), amountValueFrame, new ButtonFrame(this, "+", null, colors, amountIncrementer::onIncrement), new ButtonFrame(this, "-", null, colors, amountIncrementer::onDecrement), delayValueFrame, new ButtonFrame(this, "+", null, colors, delayIncrementer::onIncrement), - new ButtonFrame(this, "-", null, colors, delayIncrementer::onDecrement) + new ButtonFrame(this, "-", null, colors, delayIncrementer::onDecrement), + new ValueFrame<>(this, null, colors, "note", charge.getNoteGNS(), String.class, true) ); } @@ -266,6 +278,7 @@ public void render(int mouseX, int mouseY, float partialTicks) { if (shouldClose) { onClose(); shouldClose = false; + cancelCannonData = false; } } @@ -315,14 +328,6 @@ public void drawCenteredString(FontRenderer fontRenderer, String text, int xPos, GL11.glPopMatrix(); } - private void closeWithoutSend(boolean isPressed){ - if(isPressed){ - cancelCannonData = true; - onClose(); - cancelCannonData = false; - } - } - @Override public void onClose() { guiManager.main.moduleManager.focusReleaseAllFrames(); diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/BasicTextFrame.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/BasicTextFrame.java index b952534..93e7659 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/BasicTextFrame.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/BasicTextFrame.java @@ -6,18 +6,30 @@ import the_dark_jumper.cannontracer.gui.utils.FrameColors; import the_dark_jumper.cannontracer.gui.utils.FrameConfig; -public class BasicTextFrame implements IRenderableFrame{ +public class BasicTextFrame implements IRenderableFrame { public final IJumperGUI parent; public final Minecraft minecraft; public String text; - + public FrameConfig config; - @Override public FrameConfig getConfig() {return config;} - @Override public void setConfig(FrameConfig config) {this.config = config;} - + + @Override + public FrameConfig getConfig() { + return config; + } + + @Override + public void setConfig(FrameConfig config) { + this.config = config; + } + public FrameColors colors; - @Override public FrameColors getColors() {return colors;} - + + @Override + public FrameColors getColors() { + return colors; + } + //all values are percentages of the full screen public BasicTextFrame(IJumperGUI parent, String text, FrameConfig config, FrameColors colors) { this.parent = parent; @@ -26,22 +38,24 @@ public BasicTextFrame(IJumperGUI parent, String text, FrameConfig config, FrameC this.config = config; this.colors = colors; } - + @Override public void render(int scaledScreenWidth, int scaledScreenHeight, int guiScale) { //outer corners - int x1 = getPercentValue(scaledScreenWidth, this.config.x); - int x2 = getPercentValue(scaledScreenWidth, this.config.xEnd); - int y1 = getPercentValue(scaledScreenHeight, this.config.y); - int y2 = getPercentValue(scaledScreenHeight, this.config.yEnd); + float x1 = getPercentValue(scaledScreenWidth, this.config.x); + float x2 = getPercentValue(scaledScreenWidth, this.config.xEnd); + float y1 = getPercentValue(scaledScreenHeight, this.config.y); + float y2 = getPercentValue(scaledScreenHeight, this.config.yEnd); doFills(x1, y1, x2, y2, config.borderThickness / guiScale); - if(!text.equals("")) { + if (!text.equals("")) { drawTexts(x1, y1, x2, y2); } } - - public void drawTexts(int x1, int y1, int x2, int y2) { - int height = (y2 + y1) / 2; - parent.drawCenteredString(minecraft.fontRenderer, text, (x2 + x1) / 2, height, 0xfff1f1f1); + + @Override + public void drawTexts(float x1, float y1, float x2, float y2) { + int height = Math.round((y2 + y1) / 2); + int width = Math.round((x2 + x1) / 2); + parent.drawCenteredString(minecraft.fontRenderer, text, width, height, 0xfff1f1f1); } } diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/CompactToggleValueFrame.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/CompactToggleValueFrame.java new file mode 100644 index 0000000..1afb3f8 --- /dev/null +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/CompactToggleValueFrame.java @@ -0,0 +1,42 @@ +package the_dark_jumper.cannontracer.gui.guielements; + +import jumpercommons.GetterAndSetter; +import the_dark_jumper.cannontracer.gui.IJumperGUI; +import the_dark_jumper.cannontracer.gui.guielements.interfaces.IClickableFrame; +import the_dark_jumper.cannontracer.gui.utils.FrameColors; +import the_dark_jumper.cannontracer.gui.utils.FrameConfig; + +public class CompactToggleValueFrame extends BasicTextFrame implements IClickableFrame { + public final GetterAndSetter source; + public final String enabledText; + public final String disabledText; + + public boolean isClicked = false; + @Override public boolean getIsClicked() {return isClicked;} + @Override + public void setIsClicked(boolean isClicked) { + if(isClicked) { + boolean result = !source.get(); + source.set(result); + super.text = result ? enabledText : disabledText; + } + } + + public boolean hovered = false; + @Override public boolean getHovered() {return hovered;} + @Override public void setHovered(boolean hovered) {this.hovered = hovered;} + + public CompactToggleValueFrame(IJumperGUI parent, FrameConfig config, FrameColors colors, String enabledText, String disabledText, GetterAndSetter source) { + super(parent, source.get() ? enabledText : disabledText, config, colors); + this.source = source; + this.enabledText = enabledText; + this.disabledText = disabledText; + } + + @Override + public void drawTexts(float x1, float y1, float x2, float y2) { + int height = Math.round((y2 + y1) / 2); + int width = Math.round((x2 + x1) / 2); + parent.drawCenteredString(minecraft.fontRenderer, text, width, height, source.get() ? colors.colorOn : colors.colorOff); + } +} diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/DoubleSegmentFrame.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/DoubleSegmentFrame.java index d88fd4e..c53e0e2 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/DoubleSegmentFrame.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/DoubleSegmentFrame.java @@ -6,68 +6,98 @@ import the_dark_jumper.cannontracer.gui.utils.FrameColors; import the_dark_jumper.cannontracer.gui.utils.FrameConfig; -public class DoubleSegmentFrame extends BasicTextFrame implements IClickableFrame{ +public class DoubleSegmentFrame extends BasicTextFrame implements IClickableFrame { public int valueColor; - + public String value; - public String getValue() {return value;} - public void setValue(String value) {this.value = value;} - + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + public boolean isClicked = false; - @Override public boolean getIsClicked() {return isClicked;} - @Override public void setIsClicked(boolean isClicked) {this.isClicked = isClicked;} - + + @Override + public boolean getIsClicked() { + return isClicked; + } + + @Override + public void setIsClicked(boolean isClicked) { + this.isClicked = isClicked; + } + public boolean hovered = false; - @Override public boolean getHovered() {return hovered;} - @Override public void setHovered(boolean hovered) {this.hovered = hovered;} - + + @Override + public boolean getHovered() { + return hovered; + } + + @Override + public void setHovered(boolean hovered) { + this.hovered = hovered; + } + public DoubleSegmentFrame(IJumperGUI parent, String text, String value, int valueColor, FrameConfig config, FrameColors colors) { super(parent, text, config, colors); init(value, valueColor); } - + public DoubleSegmentFrame(IJumperGUI parent, String text, String value, FrameConfig config, FrameColors colors) { super(parent, text, config, colors); init(value, colors.defaultValueColor); } - + public void init(String value, int valueColor) { this.value = value; this.valueColor = valueColor; } - + @Override - public void doFills(int x1, int y1, int x2, int y2, int borderPx) { - Screen.fill(x1, y1, x1 + borderPx, y2, colors.borderColor); //left edge - Screen.fill(x1 + borderPx, y1, x2 - borderPx, y1 + borderPx, colors.borderColor); //top edge - Screen.fill(x2 - borderPx, y1, x2, y2, colors.borderColor); //right edge - Screen.fill(x1 + borderPx, y2 - borderPx, x2 - borderPx, y2, colors.borderColor); //bottom edge - int valueEdge = getEstimateValueBorder(x1, x2); - Screen.fill(valueEdge, y1, valueEdge + borderPx, y2, colorToFullAlpha(colors.borderColor)); + public void doFills(float x1, float y1, float x2, float y2, float borderPx) { + int x1i = Math.round(x1); + int x2i = Math.round(x2); + int y1i = Math.round(y1); + int y2i = Math.round(y2); + int borderPxi = Math.round(borderPx); + + Screen.fill(x1i, y1i, x1i + borderPxi, y2i, colors.borderColor); //left edge + Screen.fill(x1i + borderPxi, y1i, x2i - borderPxi, y1i + borderPxi, colors.borderColor); //top edge + Screen.fill(x2i - borderPxi, y1i, x2i, y2i, colors.borderColor); //right edge + Screen.fill(x1i + borderPxi, y2i - borderPxi, x2i - borderPxi, y2i, colors.borderColor); //bottom edge + int valueEdge = Math.round(getEstimateValueBorder(x1i, x2i)); + Screen.fill(valueEdge, y1i, valueEdge + borderPxi, y2i, colorToFullAlpha(colors.borderColor)); //fill value sections - Screen.fill(x1 + borderPx, y1 + borderPx, valueEdge, y2 - borderPx, getInnerColor()); - Screen.fill(valueEdge + borderPx, y1 + borderPx, x2 - borderPx, y2 - borderPx, getInnerColor2()); + Screen.fill(x1i + borderPxi, y1i + borderPxi, valueEdge, y2i - borderPxi, getInnerColor()); + Screen.fill(valueEdge + borderPxi, y1i + borderPxi, x2i - borderPxi, y2i - borderPxi, getInnerColor2()); } - + @Override - public void drawTexts(int x1, int y1, int x2, int y2) { - int valueEdge = getEstimateValueBorder(x1, x2); - int height = (y2 + y1) / 2; - parent.drawCenteredString(minecraft.fontRenderer, text, (x1 + valueEdge) / 2, height, 0xfff1f1f1); - parent.drawCenteredString(minecraft.fontRenderer, value, (x2 + valueEdge) / 2, height, valueColor); + public void drawTexts(float x1, float y1, float x2, float y2) { + float valueEdge = getEstimateValueBorder(x1, x2); + int height = Math.round((y2 + y1) / 2); + int width1 = Math.round((x1 + valueEdge) / 2); + int width2 = Math.round((x2 + valueEdge) / 2); + parent.drawCenteredString(minecraft.fontRenderer, text, width1, height, 0xfff1f1f1); + parent.drawCenteredString(minecraft.fontRenderer, value, width2, height, valueColor); } - - public int getEstimateValueBorder(int x1, int x2) { - double bias = ((double)text.length()) / (text.length() + value.length()); - if(bias > 0.8) { - bias = 0.8; + + public float getEstimateValueBorder(float x1, float x2) { + float bias = ((float) text.length()) / (text.length() + value.length()); + if (bias > 0.8f) { + bias = 0.8f; } - if(bias < 0.2){ - bias = 0.2; + if (bias < 0.2f) { + bias = 0.2f; } - return (int)(bias * (x2 - x1) + x1); + return (bias * (x2 - x1) + x1); } - + public int colorToFullAlpha(int color) { return (0xff000000 | color); } diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ScrollableTable.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ScrollableTable.java index 14a8412..d1bde89 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ScrollableTable.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ScrollableTable.java @@ -50,31 +50,31 @@ public ScrollableTable(IJumperGUI parent, FrameConfig config, FrameColors colors this.colors = colors; } - public int matchWidthToHeight(int height) { - int tableHeight = getPercentValue(Minecraft.getInstance().getMainWindow().getScaledHeight() ,config.yEnd - config.y); + public float matchWidthToHeight(int height) { + float tableHeight = getPercentValue(Minecraft.getInstance().getMainWindow().getScaledHeight() ,config.yEnd - config.y); //int tableHeight = getPercentValue(Minecraft.getInstance().func_228018_at_().getScaledHeight() ,config.yEnd - config.y); //int tableHeight = getPercentValue(Minecraft.getInstance().mainWindow.getScaledHeight() ,config.yEnd - config.y); - int tableWidth = getPercentValue(Minecraft.getInstance().getMainWindow().getScaledWidth(), config.xEnd - config.x); + float tableWidth = getPercentValue(Minecraft.getInstance().getMainWindow().getScaledWidth(), config.xEnd - config.x); //int tableWidth = getPercentValue(Minecraft.getInstance().func_228018_at_().getScaledWidth(), config.xEnd - config.x); //int tableWidth = getPercentValue(Minecraft.getInstance().mainWindow.getScaledWidth(), config.xEnd - config.x); return height * tableHeight / tableWidth; } - public int matchHeightToWidth(int width) { - int tableHeight = getPercentValue(Minecraft.getInstance().getMainWindow().getScaledHeight() ,config.yEnd - config.y); + public float matchHeightToWidth(int width) { + float tableHeight = getPercentValue(Minecraft.getInstance().getMainWindow().getScaledHeight() ,config.yEnd - config.y); //int tableHeight = getPercentValue(Minecraft.getInstance().func_228018_at_().getScaledHeight() ,config.yEnd - config.y); //int tableHeight = getPercentValue(Minecraft.getInstance().mainWindow.getScaledHeight() ,config.yEnd - config.y); - int tableWidth = getPercentValue(Minecraft.getInstance().getMainWindow().getScaledWidth(), config.xEnd - config.x); + float tableWidth = getPercentValue(Minecraft.getInstance().getMainWindow().getScaledWidth(), config.xEnd - config.x); //int tableWidth = getPercentValue(Minecraft.getInstance().func_228018_at_().getScaledWidth(), config.xEnd - config.x); //int tableWidth = getPercentValue(Minecraft.getInstance().mainWindow.getScaledWidth(), config.xEnd - config.x); return width * tableWidth / tableHeight; } - public void generateScrollbars(boolean useHorizontal, int height, boolean useVertical, int width) { + public void generateScrollbars(boolean useHorizontal, float height, boolean useVertical, float width) { if(useHorizontal) { horizontalScrollbar = new ScrollbarFrame(parent, new FrameConfig().init(0, 100, 100, 100 + height, config.borderThickness), colors, null); horizontalScrollbar.isVertical = false; @@ -149,14 +149,14 @@ public FrameConfig getCellConfig(int col, int row) { FormatData format = getColFormat(c); startX += (format.width + format.offset); } - int endX = startX + getColFormat(col).width; + float endX = startX + getColFormat(col).width; int startY = 0; for(int r = 0; r < row; r++) { FormatData format = getRowFormat(r); startY += (format.width + format.offset); } - int endY = startY + getRowFormat(row).width; + float endY = startY + getRowFormat(row).width; return new FrameConfig().init(startX, startY, endX, endY, this.config.borderThickness); } @@ -165,11 +165,11 @@ public void clearUniformRowFormat() { uniformRowFormat = null; } - public void setUniformRowFormat(boolean isScaled, int height, int offset) { - if(!isScaled) { - int tableHeight = config.yEnd - config.y; - height = (int)(height * 100d / tableHeight); - offset = (int)(offset * 100d / tableHeight); + public void setUniformRowFormat(boolean isRelativeToTable, float height, float offset) { + if(!isRelativeToTable) { + float tableHeight = config.yEnd - config.y; + height = height * 100f / tableHeight; + offset = offset * 100f / tableHeight; } uniformRowFormat = new FormatData(height, offset); } @@ -181,26 +181,26 @@ public void clearNonUniformRowFormat() { rowFormat = null; } - public void setRowFormat(boolean isScaled, FormatData... formats) { + public void setRowFormat(boolean isRelativeToTable, FormatData... formats) { if(rowFormat == null) { rowFormat = new ArrayList<>(); }else { rowFormat.clear(); } - int tableHeight = config.yEnd - config.y; + float tableHeight = config.yEnd - config.y; for(int i = 0; i < formats.length; i++) { FormatData formatData = formats[i]; if(formatData != null) { - if(!isScaled) { - formatData.width = (int)(formatData.width * 100d / tableHeight); - formatData.offset = (int)(formatData.offset * 100d / tableHeight); + if(!isRelativeToTable) { + formatData.width = formatData.width * 100f / tableHeight; + formatData.offset = formatData.offset * 100f / tableHeight; } } rowFormat.add(formatData); } } - public void setRowFormat(int index, boolean isScaled, FormatData format) { + public void setRowFormat(int index, boolean isRelativeToTable, FormatData format) { if(rowFormat == null) { rowFormat = new ArrayList<>(); } @@ -209,10 +209,10 @@ public void setRowFormat(int index, boolean isScaled, FormatData format) { rowFormat.add(null); } } - if(!isScaled) { - int tableHeight = config.yEnd - config.y; - format.width = (int)(format.width * 100d / tableHeight); - format.offset = (int)(format.offset * 100d / tableHeight); + if(!isRelativeToTable) { + float tableHeight = config.yEnd - config.y; + format.width = format.width * 100f / tableHeight; + format.offset = format.offset * 100f / tableHeight; } rowFormat.set(index, format); } @@ -221,11 +221,11 @@ public void clearUniformColFormat() { uniformColFormat = null; } - public void setUniformColFormat(boolean isScaled, int width, int offset) { - if(!isScaled) { - int tableWidth = config.xEnd - config.x; - width = (int)(width * 100d / tableWidth); - offset = (int)(offset * 100d / tableWidth); + public void setUniformColFormat(boolean isRelativeToTable, float width, float offset) { + if(!isRelativeToTable) { + float tableWidth = config.xEnd - config.x; + width = width * 100f / tableWidth; + offset = offset * 100f / tableWidth; } uniformColFormat = new FormatData(width, offset); } @@ -237,26 +237,26 @@ public void clearNonUniformColFormat() { colFormat = null; } - public void setColFormat(boolean isScaled, FormatData... formats) { + public void setColFormat(boolean isRelativeToTable, FormatData... formats) { if(colFormat == null) { colFormat = new ArrayList<>(); }else { colFormat.clear(); } - int tableWidth = config.xEnd - config.x; + float tableWidth = config.xEnd - config.x; for(int i = 0; i < formats.length; i++) { FormatData formatData = formats[i]; if(formatData != null) { - if(!isScaled) { - formatData.width = (int)(formatData.width * 100d / tableWidth); - formatData.offset = (int)(formatData.offset * 100d / tableWidth); + if(!isRelativeToTable) { + formatData.width = formatData.width * 100f / tableWidth; + formatData.offset = formatData.offset * 100f / tableWidth; } } colFormat.add(formatData); } } - public void setColFormat(int index, boolean isScaled, FormatData format) { + public void setColFormat(int index, boolean isRelativeToTable, FormatData format) { if(colFormat == null) { colFormat = new ArrayList<>(); } @@ -265,10 +265,10 @@ public void setColFormat(int index, boolean isScaled, FormatData format) { colFormat.add(null); } } - if(!isScaled) { - int tableWidth = config.xEnd - config.x; - format.width = (int)(format.width * 100d / tableWidth); - format.offset = (int)(format.offset * 100d / tableWidth); + if(!isRelativeToTable) { + float tableWidth = config.xEnd - config.x; + format.width = format.width * 100f / tableWidth; + format.offset = format.offset * 100f / tableWidth; } colFormat.set(index, format); } @@ -317,13 +317,13 @@ public void deleteRow(int rowIndex) { } @Override - public void mouseOver(int x, int y, int scaledScreenWidth, int scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { - int relX1 = getPercentValue(scaledScreenWidth, config.x); - int relX2 = getPercentValue(scaledScreenWidth, config.xEnd); - int relY1 = getPercentValue(scaledScreenHeight, config.y); - int relY2 = getPercentValue(scaledScreenHeight, config.yEnd); - int perceivedScreenWidth = relX2 - relX1; - int perceivedScreenHeight = relY2 - relY1; + public void mouseOver(float x, float y, float scaledScreenWidth, float scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { + float relX1 = getPercentValue(scaledScreenWidth, config.x); + float relX2 = getPercentValue(scaledScreenWidth, config.xEnd); + float relY1 = getPercentValue(scaledScreenHeight, config.y); + float relY2 = getPercentValue(scaledScreenHeight, config.yEnd); + float perceivedScreenWidth = relX2 - relX1; + float perceivedScreenHeight = relY2 - relY1; double scrollOffsetX = 0; if(horizontalScrollbar != null) { @@ -359,19 +359,25 @@ public void mouseOver(int x, int y, int scaledScreenWidth, int scaledScreenHeigh } @Override - public void doFills(int x1, int y1, int x2, int y2, int borderPx) { - Screen.fill(x1, y1, x1 + borderPx, y2, getColors().borderColor); //left edge - Screen.fill(x1 + borderPx, y1, x2 - borderPx, y1 + borderPx, getColors().borderColor); //top edge - Screen.fill(x2 - borderPx, y1, x2, y2, getColors().borderColor); //right edge - Screen.fill(x1 + borderPx, y2 - borderPx, x2 - borderPx, y2, getColors().borderColor); //bottom edge + public void doFills(float x1, float y1, float x2, float y2, float borderPx) { + int x1i = Math.round(x1); + int x2i = Math.round(x2); + int y1i = Math.round(y1); + int y2i = Math.round(y2); + int borderPxi = Math.round(borderPx); + + Screen.fill(x1i, y1i, x1i + borderPxi, y2i, getColors().borderColor); //left edge + Screen.fill(x1i + borderPxi, y1i, x2i - borderPxi, y1i + borderPxi, getColors().borderColor); //top edge + Screen.fill(x2i - borderPxi, y1i, x2i, y2i, getColors().borderColor); //right edge + Screen.fill(x1i + borderPxi, y2i - borderPxi, x2i - borderPxi, y2i, getColors().borderColor); //bottom edge //System.out.println("doFills called with: "+x1+" | "+y1+" | "+x2+" | "+y2+" | "+borderPx); //System.out.println("Config is: "+getConfig().x+" | "+getConfig().y+" | "+getConfig().xEnd+" | "+getConfig().yEnd); int guiScale = Minecraft.getInstance().gameSettings.guiScale; if(horizontalScrollbar != null) { - renderTableFrame(horizontalScrollbar, x1, y1, x2, y2, guiScale, horizontalScrollbar.config, true); + renderTableFrame(horizontalScrollbar, x1i, y1i, x2i, y2i, guiScale, horizontalScrollbar.config, true); } if(verticalScrollbar != null) { - renderTableFrame(verticalScrollbar, x1, y1, x2, y2, guiScale, verticalScrollbar.config, true); + renderTableFrame(verticalScrollbar, x1i, y1i, x2i, y2i, guiScale, verticalScrollbar.config, true); } for(int i = 0; i < rows.size(); i++) { ArrayList row = rows.get(i); @@ -384,13 +390,13 @@ public void doFills(int x1, int y1, int x2, int y2, int borderPx) { } } - public void renderTableFrame(IRenderableFrame frame, int perceivedX1, int perceivedY1, int perceivedX2, int perceivedY2, int guiScale, FrameConfig frameConfig, boolean allowOutOfBounds) { - int width = perceivedX2 - perceivedX1; - int height = perceivedY2 - perceivedY1; - int x1 = getPercentValue(width, frameConfig.x) + perceivedX1; - int x2 = getPercentValue(width, frameConfig.xEnd) + perceivedX1; - int y1 = getPercentValue(height, frameConfig.y) + perceivedY1; - int y2 = getPercentValue(height, frameConfig.yEnd) + perceivedY1; + public void renderTableFrame(IRenderableFrame frame, float perceivedX1, float perceivedY1, float perceivedX2, float perceivedY2, int guiScale, FrameConfig frameConfig, boolean allowOutOfBounds) { + float width = perceivedX2 - perceivedX1; + float height = perceivedY2 - perceivedY1; + float x1 = getPercentValue(width, frameConfig.x) + perceivedX1; + float x2 = getPercentValue(width, frameConfig.xEnd) + perceivedX1; + float y1 = getPercentValue(height, frameConfig.y) + perceivedY1; + float y2 = getPercentValue(height, frameConfig.yEnd) + perceivedY1; if(allowOutOfBounds) { //render without scrollbar shifting frame.doFills(x1, y1, x2, y2, frameConfig.borderThickness / guiScale); diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ScrollbarFrame.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ScrollbarFrame.java index e061cbb..7d4fbc5 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ScrollbarFrame.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ScrollbarFrame.java @@ -89,7 +89,7 @@ public ScrollbarFrame(IJumperGUI parent, FrameConfig config, FrameColors colors, } @Override - public void mouseOver(int x, int y, int scaledScreenWidth, int scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { + public void mouseOver(float x, float y, float scaledScreenWidth, float scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { IClickableFrame.super.mouseOver(x, y, scaledScreenWidth, scaledScreenHeight, mouseLeftDown, queueLeftUpdate); if (isClicked) { double current; @@ -129,37 +129,42 @@ public void doDrag(double pos) { } @Override - public void doFills(int x1, int y1, int x2, int y2, int borderPx) { - int width = Math.abs(x2 - x1); - int height = Math.abs(y2 - y1); - - Screen.fill(x1, y1, x1 + borderPx, y2, colors.borderColor); //left edge - Screen.fill(x1 + borderPx, y1, x2 - borderPx, y1 + borderPx, colors.borderColor); //top edge - Screen.fill(x2 - borderPx, y1, x2, y2, colors.borderColor); //right edge - Screen.fill(x1 + borderPx, y2 - borderPx, x2 - borderPx, y2, colors.borderColor); //bottom edge + public void doFills(float x1, float y1, float x2, float y2, float borderPx) { + int x1i = Math.round(x1); + int x2i = Math.round(x2); + int y1i = Math.round(y1); + int y2i = Math.round(y2); + int borderPxi = Math.round(borderPx); + float width = Math.abs(x2i - x1i); + float height = Math.abs(y2i - y1i); + + Screen.fill(x1i, y1i, x1i + borderPxi, y2i, colors.borderColor); //left edge + Screen.fill(x1i + borderPxi, y1i, x2i - borderPxi, y1i + borderPxi, colors.borderColor); //top edge + Screen.fill(x2i - borderPxi, y1i, x2i, y2i, colors.borderColor); //right edge + Screen.fill(x1i + borderPxi, y2i - borderPxi, x2i - borderPxi, y2i, colors.borderColor); //bottom edge int relative1; int relative2; if (isVertical) { - relative1 = y1; - relative2 = y2; + relative1 = y1i; + relative2 = y2i; } else { - relative1 = x1; - relative2 = x2; + relative1 = x1i; + relative2 = x2i; } int halfBarSize = (int) ((relative2 - relative1) * scrollbarSize / 2); int relativeBarPos = (int) (relative1 + halfBarSize + ((relative2 - relative1 - (2 * halfBarSize)) * scrollbarPos)); if (isVertical) { - int xOffset = width <= (2 * borderPx) - ? (int) Math.ceil((width - (2 * borderPx)) / 2d) + int xOffset = width <= (2 * borderPxi) + ? (int) Math.ceil((width - (2 * borderPxi)) / 2d) : 0; - Screen.fill(x1 + borderPx - xOffset, relativeBarPos - halfBarSize + borderPx, x2 - borderPx + xOffset, relativeBarPos + halfBarSize - borderPx, getInnerColor()); + Screen.fill(x1i + borderPxi - xOffset, relativeBarPos - halfBarSize + borderPxi, x2i - borderPxi + xOffset, relativeBarPos + halfBarSize - borderPxi, getInnerColor()); } else { - int yOffset = height <= (2 * borderPx) - ? (int) Math.ceil((height - (2 * borderPx)) / 2d) + int yOffset = height <= (2 * borderPxi) + ? (int) Math.ceil((height - (2 * borderPxi)) / 2d) : 0; - Screen.fill(relativeBarPos - halfBarSize + borderPx, y1 + borderPx - yOffset, relativeBarPos + halfBarSize - borderPx, y2 - borderPx + yOffset, getInnerColor()); + Screen.fill(relativeBarPos - halfBarSize + borderPxi, y1i + borderPxi - yOffset, relativeBarPos + halfBarSize - borderPxi, y2i - borderPxi + yOffset, getInnerColor()); } } } diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ToggleKeybindFrame.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ToggleKeybindFrame.java index 81d333c..d73aee8 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ToggleKeybindFrame.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/ToggleKeybindFrame.java @@ -19,15 +19,15 @@ public ToggleKeybindFrame(IJumperGUI parent, FrameConfig config, FrameColors col } @Override - public void mouseOver(int x, int y, int scaledScreenWidth, int scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { + public void mouseOver(float x, float y, float scaledScreenWidth, float scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { if (getIsClicked() && !mouseLeftDown) { setIsClicked(false); } - int x1 = getPercentValue(scaledScreenWidth, this.getConfig().x); - int x2 = getPercentValue(scaledScreenWidth, this.getEstimateValueBorder(this.getConfig().x, this.getConfig().xEnd)); - int x3 = getPercentValue(scaledScreenWidth, this.getConfig().xEnd); - int y1 = getPercentValue(scaledScreenHeight, this.getConfig().y); - int y2 = getPercentValue(scaledScreenHeight, this.getConfig().yEnd); + float x1 = getPercentValue(scaledScreenWidth, this.getConfig().x); + float x2 = getPercentValue(scaledScreenWidth, this.getEstimateValueBorder(this.getConfig().x, this.getConfig().xEnd)); + float x3 = getPercentValue(scaledScreenWidth, this.getConfig().xEnd); + float y1 = getPercentValue(scaledScreenHeight, this.getConfig().y); + float y2 = getPercentValue(scaledScreenHeight, this.getConfig().yEnd); if (x > x1 && x < x3 && y > y1 && y < y2) { setHovered(true); if (x < x2) { diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IClickableFrame.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IClickableFrame.java index 30e50d8..40d2800 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IClickableFrame.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IClickableFrame.java @@ -7,14 +7,14 @@ public interface IClickableFrame extends IRenderableFrame{ boolean getHovered(); void setHovered(boolean hovered); - default void mouseOver(int x, int y, int scaledScreenWidth, int scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { + default void mouseOver(float x, float y, float scaledScreenWidth, float scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { if(getIsClicked() && !mouseLeftDown) { setIsClicked(false); } - int x1 = getPercentValue(scaledScreenWidth, this.getConfig().x); - int x2 = getPercentValue(scaledScreenWidth, this.getConfig().xEnd); - int y1 = getPercentValue(scaledScreenHeight, this.getConfig().y); - int y2 = getPercentValue(scaledScreenHeight, this.getConfig().yEnd); + float x1 = getPercentValue(scaledScreenWidth, this.getConfig().x); + float x2 = getPercentValue(scaledScreenWidth, this.getConfig().xEnd); + float y1 = getPercentValue(scaledScreenHeight, this.getConfig().y); + float y2 = getPercentValue(scaledScreenHeight, this.getConfig().yEnd); if(x >= x1 && x <= x2 && y >= y1 && y <= y2) { setHovered(true); if(queueLeftUpdate && mouseLeftDown) { diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IFocusableFrame.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IFocusableFrame.java index 338b3e6..2912b73 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IFocusableFrame.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IFocusableFrame.java @@ -5,14 +5,14 @@ public interface IFocusableFrame extends IClickableFrame{ @Override - default void mouseOver(int x, int y, int scaledScreenWidth, int scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { + default void mouseOver(float x, float y, float scaledScreenWidth, float scaledScreenHeight, boolean mouseLeftDown, boolean queueLeftUpdate) { if(getIsClicked() && !mouseLeftDown) { setIsClicked(false); } - int x1 = getPercentValue(scaledScreenWidth, this.getConfig().x); - int x2 = getPercentValue(scaledScreenWidth, this.getConfig().xEnd); - int y1 = getPercentValue(scaledScreenHeight, this.getConfig().y); - int y2 = getPercentValue(scaledScreenHeight, this.getConfig().yEnd); + float x1 = getPercentValue(scaledScreenWidth, this.getConfig().x); + float x2 = getPercentValue(scaledScreenWidth, this.getConfig().xEnd); + float y1 = getPercentValue(scaledScreenHeight, this.getConfig().y); + float y2 = getPercentValue(scaledScreenHeight, this.getConfig().yEnd); if(x > x1 && x < x2 && y > y1 && y < y2) { setHovered(true); if(queueLeftUpdate && mouseLeftDown) { diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IRenderableFrame.java b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IRenderableFrame.java index b7e3a35..bb7cb15 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IRenderableFrame.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/guielements/interfaces/IRenderableFrame.java @@ -5,35 +5,40 @@ import the_dark_jumper.cannontracer.gui.utils.FrameConfig; public interface IRenderableFrame { - public FrameConfig getConfig(); - public void setConfig(FrameConfig config); + FrameConfig getConfig(); + void setConfig(FrameConfig config); - public FrameColors getColors(); + FrameColors getColors(); - public default void render(int scaledScreenWidth, int scaledScreenHeight, int guiScale) { + default void render(int scaledScreenWidth, int scaledScreenHeight, int guiScale) { //outer corners - int x1 = getPercentValue(scaledScreenWidth, getConfig().x); - int x2 = getPercentValue(scaledScreenWidth, getConfig().xEnd); - int y1 = getPercentValue(scaledScreenHeight, getConfig().y); - int y2 = getPercentValue(scaledScreenHeight, getConfig().yEnd); + float x1 = getPercentValue(scaledScreenWidth, getConfig().x); + float x2 = getPercentValue(scaledScreenWidth, getConfig().xEnd); + float y1 = getPercentValue(scaledScreenHeight, getConfig().y); + float y2 = getPercentValue(scaledScreenHeight, getConfig().yEnd); doFills(x1, y1, x2, y2, getConfig().borderThickness / guiScale); } - public default void doFills(int x1, int y1, int x2, int y2, int borderPx) { - Screen.fill(x1, y1, x1 + borderPx, y2, getColors().borderColor); //left edge - Screen.fill(x1 + borderPx, y1, x2 - borderPx, y1 + borderPx, getColors().borderColor); //top edge - Screen.fill(x2 - borderPx, y1, x2, y2, getColors().borderColor); //right edge - Screen.fill(x1 + borderPx, y2 - borderPx, x2 - borderPx, y2, getColors().borderColor); //bottom edge - Screen.fill(x1 + borderPx, y1 + borderPx, x2 - borderPx, y2 - borderPx, getInnerColor()); + default void doFills(float x1, float y1, float x2, float y2, float borderPx) { + int x1i = Math.round(x1); + int x2i = Math.round(x2); + int y1i = Math.round(y1); + int y2i = Math.round(y2); + int borderPxi = Math.round(borderPx); + Screen.fill(x1i, y1i, x1i + borderPxi, y2i, getColors().borderColor); //left edge + Screen.fill(x1i + borderPxi, y1i, x2i - borderPxi, y1i + borderPxi, getColors().borderColor); //top edge + Screen.fill(x2i - borderPxi, y1i, x2i, y2i, getColors().borderColor); //right edge + Screen.fill(x1i + borderPxi, y2i - borderPxi, x2i - borderPxi, y2i, getColors().borderColor); //bottom edge + Screen.fill(x1i + borderPxi, y1i + borderPxi, x2i - borderPxi, y2i - borderPxi, getInnerColor()); } - public default int getInnerColor() { + default int getInnerColor() { return getColors().innerColor; } - public default int getPercentValue(int full, int percent) { + default float getPercentValue(float full, float percent) { return (full * percent) / 100; } - public default void drawTexts(int x1, int y1, int x2, int y2) {} + default void drawTexts(float x1, float y1, float x2, float y2) {} } diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/utils/FormatData.java b/src/main/java/the_dark_jumper/cannontracer/gui/utils/FormatData.java index e14fcd0..cd29e7e 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/utils/FormatData.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/utils/FormatData.java @@ -3,11 +3,11 @@ public class FormatData { public FormatData(){} - public FormatData(int width, int offset){ + public FormatData(float width, float offset){ this.width = width; this.offset = offset; } - public int width; - public int offset; + public float width; + public float offset; } diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/utils/FrameColors.java b/src/main/java/the_dark_jumper/cannontracer/gui/utils/FrameColors.java index 636262d..83cc72a 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/utils/FrameColors.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/utils/FrameColors.java @@ -9,4 +9,17 @@ public class FrameColors { public int colorHover = 0xff4a88ce; public int colorHover2 = 0xff3e72ad; public int defaultValueColor = 0xfff1f1f1; + + public FrameColors duplicate() { + FrameColors duplicate = new FrameColors(); + duplicate.borderColor = borderColor; + duplicate.innerColor = innerColor; + duplicate.innerColor2 = innerColor2; + duplicate.colorOn = colorOn; + duplicate.colorOff = colorOff; + duplicate.colorHover = colorHover; + duplicate.colorHover2 = colorHover2; + duplicate.defaultValueColor = defaultValueColor; + return duplicate; + } } diff --git a/src/main/java/the_dark_jumper/cannontracer/gui/utils/FrameConfig.java b/src/main/java/the_dark_jumper/cannontracer/gui/utils/FrameConfig.java index bcfc767..893154c 100644 --- a/src/main/java/the_dark_jumper/cannontracer/gui/utils/FrameConfig.java +++ b/src/main/java/the_dark_jumper/cannontracer/gui/utils/FrameConfig.java @@ -1,13 +1,13 @@ package the_dark_jumper.cannontracer.gui.utils; public class FrameConfig { - public int x; - public int y; - public int xEnd; - public int yEnd; - public int borderThickness; + public float x; + public float y; + public float xEnd; + public float yEnd; + public float borderThickness; - public FrameConfig init(int x, int y, int xEnd, int yEnd, int borderThickness) { + public FrameConfig init(float x, float y, float xEnd, float yEnd, float borderThickness) { this.x = x; this.y = y; this.xEnd = xEnd; diff --git a/src/main/java/the_dark_jumper/cannontracer/modules/ModuleManager.java b/src/main/java/the_dark_jumper/cannontracer/modules/ModuleManager.java index 4c9f083..6a8c417 100644 --- a/src/main/java/the_dark_jumper/cannontracer/modules/ModuleManager.java +++ b/src/main/java/the_dark_jumper/cannontracer/modules/ModuleManager.java @@ -70,7 +70,7 @@ public void onFrameFocusChanged(IFocusableFrame frame, boolean focus) { public void focusReleaseAllFrames(){ List focusedFramesCopy = new ArrayList<>(focusedFrames); for (IFocusableFrame focusedFrame : focusedFramesCopy) { - focusedFrame.setFocused(false); + focusedFrame.onFocusChange(false); } } @@ -218,7 +218,7 @@ public void keyPressed(int key, boolean screenActive) { if (!screenActive) { // TODO this really doesn't belong here, but eh for (IFocusableFrame focusedFrame : focusedFrames) { - focusedFrame.setFocused(false); + focusedFrame.onFocusChange(false); } } else { return;