Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
- Add config class to manage loading/saving config
- Move classes into packages
- Delete unused assets
  • Loading branch information
MaT1g3R committed Oct 9, 2023
1 parent c14213d commit 1430271
Show file tree
Hide file tree
Showing 26 changed files with 708 additions and 794 deletions.
57 changes: 30 additions & 27 deletions src/main/java/str_exporter/CustomTipsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ public class CustomTipsAPI implements PostInitializeSubscriber {

private static final String CUSTOM_TIP_HITBOX_NAME = "slayTheRelicsHitboxes";
private static final String CUSTOM_TIP_POWERTIPS_NAME = "slayTheRelicsPowerTips";

private ArrayList<Field> externalHitboxFields = new ArrayList<>();
private ArrayList<Field> externalPowerTipsFields = new ArrayList<>();

private static Logger logger = SlayTheRelicsExporter.logger;

public static CustomTipsAPI instance;
private static final Logger logger = SlayTheRelicsExporter.logger;
private final ArrayList<Field> externalHitboxFields = new ArrayList<>();
private final ArrayList<Field> externalPowerTipsFields = new ArrayList<>();

private CustomTipsAPI() {
BaseMod.subscribe(this);
Expand All @@ -36,6 +33,22 @@ public static void initialize() {
instance = new CustomTipsAPI();
}

private static ArrayList<ArrayList<PowerTip>> removeImagesFromPowerTipsLists(ArrayList<ArrayList<PowerTip>> tip_lists) {
// removes any images
ArrayList<ArrayList<PowerTip>> new_tip_lists = new ArrayList<>(tip_lists.size());

for (int i = 0; i < tip_lists.size(); i++) {
ArrayList<PowerTip> list = tip_lists.get(i);

new_tip_lists.add(new ArrayList<>(list.size()));
for (int j = 0; j < list.size(); j++) {
new_tip_lists.get(i).add(new PowerTip(list.get(j).header, list.get(j).body));
}
}

return new_tip_lists;
}

@Override
public void receivePostInitialize() {
findCustomTipImplementingClasses();
Expand All @@ -48,7 +61,11 @@ private void findCustomTipImplementingClasses() {

for (ModInfo info : Loader.MODINFOS) {
if (Patcher.annotationDBMap.containsKey(info.jarURL)) {
Set<String> initializers = Patcher.annotationDBMap.get(info.jarURL).getAnnotationIndex().get(SpireInitializer.class.getName());
Set<String>
initializers =
Patcher.annotationDBMap.get(info.jarURL)
.getAnnotationIndex()
.get(SpireInitializer.class.getName());
if (initializers != null) {
System.out.println(" - " + info.Name);
for (String initializer : initializers) {
Expand All @@ -75,7 +92,9 @@ private void findCustomTipImplementingClasses() {
long duration = endTime - startTime;
logger.info(" - " + (duration / 1000000) + "ms");
} catch (ClassNotFoundException e) {
logger.info("WARNING: Unable to find method initialize() on class marked @SpireInitializer: " + initializer);
logger.info(
"WARNING: Unable to find method initialize() on class marked @SpireInitializer: " +
initializer);
}
}
}
Expand All @@ -97,7 +116,9 @@ public Object[] getTipsFromMods() {
// logger.info("class: " + hitbox_fields.get(i).getDeclaringClass().getSimpleName());

ArrayList<Hitbox> mod_hitboxes = (ArrayList<Hitbox>) externalHitboxFields.get(i).get(null);
ArrayList<ArrayList<PowerTip>> mod_tip_lists = (ArrayList<ArrayList<PowerTip>>) externalPowerTipsFields.get(i).get(null);
ArrayList<ArrayList<PowerTip>>
mod_tip_lists =
(ArrayList<ArrayList<PowerTip>>) externalPowerTipsFields.get(i).get(null);

if (mod_hitboxes.size() == mod_tip_lists.size()) {
// logger.info("found fields, adding " + mod_hitboxes.size() + " entries");
Expand All @@ -114,22 +135,4 @@ public Object[] getTipsFromMods() {

return new Object[]{hitboxes, tip_lists};
}



private static ArrayList<ArrayList<PowerTip>> removeImagesFromPowerTipsLists(ArrayList<ArrayList<PowerTip>> tip_lists) {
// removes any images
ArrayList<ArrayList<PowerTip>> new_tip_lists = new ArrayList<>(tip_lists.size());

for (int i = 0; i < tip_lists.size(); i++) {
ArrayList<PowerTip> list = tip_lists.get(i);

new_tip_lists.add(new ArrayList<>(list.size()));
for (int j = 0; j < list.size(); j++) {
new_tip_lists.get(i).add(new PowerTip(list.get(j).header, list.get(j).body));
}
}

return new_tip_lists;
}
}
91 changes: 0 additions & 91 deletions src/main/java/str_exporter/ModLabelButton.java

This file was deleted.

24 changes: 12 additions & 12 deletions src/main/java/str_exporter/ModStatusImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
import java.util.concurrent.atomic.AtomicBoolean;

public class ModStatusImage implements IUIElement {
private Hitbox hb;
private Texture greenTexture;
private Texture redTexture;
private Texture orangeTexture;
private float x;
private float y;
private float w;
private float h;
private AtomicBoolean healthy;
private AtomicBoolean inProgress;
private final Hitbox hb;
private final Texture greenTexture;
private final Texture redTexture;
private final Texture orangeTexture;
private final float x;
private final float y;
private final float w;
private final float h;
private final AtomicBoolean healthy;
private final AtomicBoolean inProgress;

public ModStatusImage(float xPos, float yPos, AtomicBoolean healthy, AtomicBoolean inProgress) {
this.greenTexture = ImageMaster.loadImage("SlayTheRelicsExporterResources/img/twitch_green-70.png");
Expand All @@ -30,8 +30,8 @@ public ModStatusImage(float xPos, float yPos, AtomicBoolean healthy, AtomicBoole
this.w = (float) this.greenTexture.getWidth();
this.h = (float) this.greenTexture.getHeight();
this.hb =
new Hitbox(this.x + 1F * Settings.scale,
this.y + 1F * Settings.scale,
new Hitbox(this.x + Settings.scale,
this.y + Settings.scale,
(this.w - 2F) * Settings.scale,
(this.h - 2F) * Settings.scale);
this.healthy = healthy;
Expand Down
Loading

0 comments on commit 1430271

Please sign in to comment.