diff options
| author | Roman / Nea <roman.graef@gmail.com> | 2021-12-18 12:27:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-18 12:27:12 +0100 |
| commit | 4e06a3b0ff9389ef75ee4e407ce4262e1b050ffc (patch) | |
| tree | 8fad6665dbba933a75de2e1e81e3fdb36172a465 /src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java | |
| parent | aca006bb4d379b6afe79357f24957f035184636e (diff) | |
| download | notenoughupdates-4e06a3b0ff9389ef75ee4e407ce4262e1b050ffc.tar.gz notenoughupdates-4e06a3b0ff9389ef75ee4e407ce4262e1b050ffc.tar.bz2 notenoughupdates-4e06a3b0ff9389ef75ee4e407ce4262e1b050ffc.zip | |
Load wiki pages asynchronously. (#30)
Previous to this commit, wiki pages would be downloaded on the main
rendering thread, preventing all rendering and user interaction while
the download was occuring. This has now been shifted to the common
forkpool provided by the JVM.
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java index 945b1bbf..3ceb0425 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java @@ -8,6 +8,7 @@ import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import java.awt.*; +import java.util.concurrent.CompletableFuture; public abstract class InfoPane extends Gui { @@ -48,4 +49,21 @@ public abstract class InfoPane extends Gui { height - overlay.getBoxPadding() + 5, bg.getRGB()); } + public static CompletableFuture<? extends InfoPane> create(NEUOverlay overlay, NEUManager manager, String infoType, + String name, String internalName, String infoText) { + switch (infoType.intern()) { + case "WIKI_URL": + return HTMLInfoPane.createFromWikiUrl(overlay, manager, name, infoText); + case "WIKI": + return CompletableFuture.completedFuture( + HTMLInfoPane.createFromWikiText(overlay, manager, name, internalName, infoText)); + case "HTML": + return CompletableFuture.completedFuture( + new HTMLInfoPane(overlay, manager, name, internalName, infoText)); + default: + return CompletableFuture.completedFuture( + new TextInfoPane(overlay, manager, name, infoText)); + } + } + } |
