Skip to content

Commit

Permalink
refactor: access and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dxxxxy committed Jan 4, 2023
1 parent f322c14 commit 6980b41
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 143 deletions.
4 changes: 2 additions & 2 deletions src/main/java/studio/dreamys/icarus/component/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.lang.reflect.Field;

public abstract class Component {
public Window window;
public Group group;
@Getter protected Window window;
@Getter protected Group group;

@Getter protected double x, y;
@Getter protected double width, height;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/studio/dreamys/icarus/component/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import java.util.List;

public class Group extends Component {
public Page page;
@Getter protected Page page;

@Getter private List<Component> children = new ArrayList<>();
@Getter protected List<Component> children = new ArrayList<>();

public Group(String label, double x, double y) {
super(label, 150, 10);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/studio/dreamys/icarus/component/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class Page extends Component {
@Getter private List<Group> groups = new ArrayList<>();

private char icon;
protected char icon;

public Page(String label, char icon) {
super(label, 37.5, 35);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.awt.*;

public class Button extends Component {
private boolean held;
protected boolean held;

public Button(String label) {
super(label, 80, 12);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.List;

public class Choice extends Component {
private List<String> options;
protected List<String> options;

public Choice(String label, List<String> options) {
super(label, 80, 12);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/studio/dreamys/icarus/component/sub/Combo.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import studio.dreamys.icarus.util.RenderUtils;
import studio.dreamys.icarus.util.position.Bounds;

import java.awt.Color;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

public class Combo extends Component {
private List<String> options;
protected List<String> options;

public Combo(String label, List<String> options) {
super(label, 80, 12);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.regex.Pattern;

public class Field extends Component {
private boolean focused;
protected boolean focused;

public Field(String label) {
super(label, 80, 12);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/studio/dreamys/icarus/component/sub/Slider.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import java.math.RoundingMode;

public class Slider extends Component {
private double max;
private double min;
private boolean onlyInt;
private String units;
protected double max;
protected double min;
protected boolean onlyInt;
protected String units;

private double percent;
protected double percent;

private boolean dragging;
protected boolean dragging;

public Slider(String label, double min, double max, boolean onlyInt, String units) {
super(label, 80, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import studio.dreamys.icarus.component.Component;

public abstract class Attachment extends Component {
@Getter private Component child;
@Getter protected Component child;

protected double x, y;

public void attachTo(Component child) {
this.child = child; //set child
this.child.group.addChild(this); //add for render
this.child.getGroup().addChild(this); //add for render
Icarus.getWindow().attachments.add(this); //add for config
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import java.awt.*;

public class Keybind extends Attachment {
@Getter private int key;
@Getter protected int key;

private String keybind = "[NONE]";
private boolean capturing;
protected String keybind = "[NONE]";
protected boolean capturing;

public Keybind(int key) {
setKey(key);
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/studio/dreamys/icarus/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ public static void saveAttachments() {

for (Attachment attachment : Icarus.getWindow().attachments) {
if (attachment instanceof Keybind) {
if (json.has(attachment.getChild().group.page.getLabel())) { //page already exists
if (json.has(attachment.getChild().getGroup().getPage().getLabel())) { //page already exists
//lets get it
JsonObject pageObject = json.getAsJsonObject(attachment.getChild().group.page.getLabel());
JsonObject pageObject = json.getAsJsonObject(attachment.getChild().getGroup().getPage().getLabel());

if (pageObject.has(attachment.getChild().group.getLabel())) { //group already exists
if (pageObject.has(attachment.getChild().getGroup().getLabel())) { //group already exists
//lets get it
JsonObject groupObject = pageObject.getAsJsonObject(attachment.getChild().group.getLabel());
JsonObject groupObject = pageObject.getAsJsonObject(attachment.getChild().getGroup().getLabel());

//add keybind to group
groupObject.addProperty(attachment.getChild().configField.getName(), ((Keybind) attachment).getKey());
Expand All @@ -334,7 +334,7 @@ public static void saveAttachments() {
groupObject.addProperty(attachment.getChild().configField.getName(), ((Keybind) attachment).getKey());

//add group to page
pageObject.add(attachment.getChild().group.getLabel(), groupObject);
pageObject.add(attachment.getChild().getGroup().getLabel(), groupObject);
}
} else { //page doesn't exist
//lets create a page
Expand All @@ -347,10 +347,10 @@ public static void saveAttachments() {
groupObject.addProperty(attachment.getChild().configField.getName(), ((Keybind) attachment).getKey());

//add group to page
pageObject.add(attachment.getChild().group.getLabel(), groupObject);
pageObject.add(attachment.getChild().getGroup().getLabel(), groupObject);

//add page to json
json.add(attachment.getChild().group.page.getLabel(), pageObject);
json.add(attachment.getChild().getGroup().getPage().getLabel(), pageObject);
}
}
}
Expand All @@ -376,9 +376,9 @@ private static void loadAttachments() {
}

for (Attachment attachment : Icarus.getWindow().attachments) {
JsonObject pageObject = json.getAsJsonObject(attachment.getChild().group.page.getLabel().replaceAll(" ", "_")); //get page object
JsonObject pageObject = json.getAsJsonObject(attachment.getChild().getGroup().getPage().getLabel().replaceAll(" ", "_")); //get page object
if (pageObject == null) continue;
JsonObject groupObject = pageObject.getAsJsonObject(attachment.getChild().group.getLabel().replaceAll(" ", "_")); //get group object
JsonObject groupObject = pageObject.getAsJsonObject(attachment.getChild().getGroup().getLabel().replaceAll(" ", "_")); //get group object
if (groupObject == null) continue;

if (attachment instanceof Keybind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.GL11;
import studio.dreamys.icarus.util.RenderUtils;

import java.awt.*;
Expand Down Expand Up @@ -50,16 +48,16 @@ public Notification(String title, String message, int ticksToStay, Color backgro
if (RenderUtils.getStringWidth(message) + 20 > 150) {
lines = new ArrayList<>();
String[] words = message.split(" ");
String line = "";
StringBuilder line = new StringBuilder();
for (String word : words) {
if (RenderUtils.getStringWidth(line + word) + 20 > 150) {
lines.add(line);
line = word + " ";
lines.add(line.toString());
line = new StringBuilder(word + " ");
} else {
line += word + " ";
line.append(word).append(" ");
}
}
lines.add(line);
lines.add(line.toString());
height = lines.size() * 10 + 20;
} else {
height = 30;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package studio.dreamys.icarus.extra.notification;

import net.minecraftforge.common.MinecraftForge;

import java.util.ArrayList;

public class NotificationManager {
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/studio/dreamys/icarus/util/font/GlyphPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ public void generateGlyphPage(char[] chars) {
glyph.width = bounds.getBounds().width + 8; // Leave some additional space
glyph.height = bounds.getBounds().height;

if (posY + glyph.height >= imgSize) {
// throw new IllegalStateException("Not all characters will fit");
}

if (posX + glyph.width >= imgSize) {
posX = 0;
posY += currentCharHeight;
Expand Down Expand Up @@ -170,30 +166,12 @@ public int getMaxFontHeight() {
return maxFontHeight;
}

public boolean isAntiAliasingEnabled() {
return antiAliasing;
}

public boolean isFractionalMetricsEnabled() {
return fractionalMetrics;
}

static class Glyph {
private int x;
private int y;
private int width;
private int height;

Glyph(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}

Glyph() {
}

public int getX() {
return x;
}
Expand Down
Loading

0 comments on commit 6980b41

Please sign in to comment.