MCPcopy Create free account
hub / github.com/Card-Forge/forge / LoadingOverlay

Class LoadingOverlay

forge-gui-mobile/src/forge/screens/LoadingOverlay.java:20–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18import forge.util.Utils;
19
20public class LoadingOverlay extends FOverlay {
21 private static final float INSETS = Utils.scale(10);
22 private static final float LOGO_SIZE_FACTOR = 0.7f;
23 private static final float INSETS_FACTOR = 0.025f;
24 private static final FSkinFont FONT = FSkinFont.get(22);
25 private BGAnimation bgAnimation;
26 private Runnable runnable;
27 private boolean afterMatch, alternate;
28
29 private static FSkinColor getOverlayColor() {
30 if (Forge.isMobileAdventureMode)
31 return FSkinColor.get(Colors.ADV_CLR_ACTIVE).alphaColor(0.75f);
32 return FSkinColor.get(Colors.CLR_ACTIVE).alphaColor(0.75f);
33 }
34
35 private static FSkinColor getForeColor() {
36 if (Forge.isMobileAdventureMode)
37 return FSkinColor.get(Colors.ADV_CLR_TEXT);
38 return FSkinColor.get(Colors.CLR_TEXT);
39 }
40
41 public static void show(String caption0, final Runnable runnable) {
42 show(caption0, false, runnable);
43 }
44
45 public static void show(String caption0, boolean textMode, final Runnable runnable) {
46 final LoadingOverlay loader = new LoadingOverlay(caption0, textMode);
47 loader.show(); //show loading overlay then delay running remaining logic so UI can respond
48 ThreadUtil.invokeInGameThread(() -> FThreads.invokeInEdtLater(() -> {
49 runnable.run();
50 loader.hide();
51 loader.finishedloading(); //setLoadingaMatch to false
52 }));
53 }
54
55 public static void runBackgroundTask(String caption0, final Runnable task) {
56 final LoadingOverlay loader = new LoadingOverlay(caption0, true);
57 loader.show();
58 FThreads.invokeInBackgroundThread(() -> {
59 task.run();
60 FThreads.invokeInEdtLater(loader::hide);
61 });
62 }
63
64 private String caption;
65 private boolean textMode = false, match = false;
66 private TextureRegion textureRegion;
67
68 public LoadingOverlay(String caption0, boolean textOnly) {
69 caption = caption0;
70 textMode = textOnly;
71 }
72
73 public LoadingOverlay(Runnable runnable) {
74 this(runnable, false, false);
75 }
76 public LoadingOverlay(Runnable toRun, boolean aftermatch, boolean otherTransition) {
77 caption = "";

Callers

nothing calls this directly

Calls 2

scaleMethod · 0.95
getMethod · 0.95

Tested by

no test coverage detected