Skip to content

Commit

Permalink
cooler optimization
Browse files Browse the repository at this point in the history
now the L2D is killed when it loaded in-game
  • Loading branch information
WilloIzCitron committed Dec 25, 2024
1 parent 66f2f44 commit 88748d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/bluearchive/ui/ArchivDBackground.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.atomic.AtomicReference;

import static bluearchive.ui.overrides.ArchivDLoadingFragment.*;
import static mindustry.Vars.*;

public class ArchivDBackground implements Disposable {
Expand All @@ -26,12 +26,11 @@ public class ArchivDBackground implements Disposable {
private static float l2dImportProg;
static boolean cancel = false;
static final String version = "v1.5";
protected static int animBGFrame;
protected static TextureRegion[] tex;

public static void buildL2D(String name){
// Nullable, can kill every mod with custom MenuRenderer
try {
if(!headless) {
Live2DBackgrounds.LoadedL2D l2dLoaded = Live2DBackgrounds.getL2D(name);
if (l2dLoaded.isSoundTrackLocal) {
ArchiveDustry.recollectionMusic = tree.loadMusic(l2dLoaded.localSoundTrack);
Expand All @@ -52,13 +51,17 @@ public static void buildL2D(String name){
group.addChildAt(0, animBG);
Log.infoTag("ArchiveDustry", "Background Loaded!");
Events.run(EventType.Trigger.update, () -> {
if (!state.isMenu()) {
setRegion(animBG, new TextureRegion(l2dLoaded.loadedL2ds.get(0)));
} else {
setRegion(animBG, new TextureRegion(l2dLoaded.loadedL2ds.get(((int) (Time.globalTime / l2dLoaded.frameSpeed) % l2dLoaded.loadedL2ds.size))));
}
if (!state.isMenu() || loadFragShow) {
//failsafe if it is still running in game
setRegion(animBG, new TextureRegion(l2dLoaded.loadedL2ds.get(0)));
return;
}
setRegion(animBG, new TextureRegion(l2dLoaded.loadedL2ds.get(((int) (Time.globalTime / l2dLoaded.frameSpeed) % l2dLoaded.loadedL2ds.size))));
});
});
} else {
Log.infoTag("ArchiveDustry", "Headless detected! Background loading skipped.");
}
} catch (Exception error) {
throw new RuntimeException(error);
}
Expand Down
3 changes: 3 additions & 0 deletions src/bluearchive/ui/overrides/ArchivDLoadingFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ArchivDLoadingFragment extends LoadingFragment {
private Label tooltipTitle;
private Label tooltipInfo;
private static float scale;
public static boolean loadFragShow;

public static void init() {
ui.loadfrag = new ArchivDLoadingFragment();
Expand Down Expand Up @@ -117,13 +118,15 @@ public void show(String text){
table.visible = true;
table.color.a = 1f;
table.toFront();
loadFragShow = true;
}

public void hide(){
table.clearActions();
table.toFront();
table.touchable = Touchable.disabled;
table.actions(Actions.fadeOut(0.5f), Actions.visible(false));
loadFragShow = false;
}

private void updateLabel(boolean isTooltip, @Nullable String text) {
Expand Down

0 comments on commit 88748d5

Please sign in to comment.