Commit d2870158bd7b2964c67c0cecb2de28c8dc9338b0

Authored by Mumfrey
1 parent 8e79bf84

Add loader info to debug overlay

src/client/java/com/mumfrey/liteloader/client/gui/GuiLiteLoaderPanel.java
... ... @@ -166,7 +166,7 @@ public class GuiLiteLoaderPanel extends GuiScreen
166 166 this.toggleable = true;
167 167  
168 168 this.versionText = I18n.format("gui.about.versiontext", LiteLoader.getVersion());
169   - this.activeModText = I18n.format("gui.about.modsloaded", mods.getLoadedMods().size());
  169 + this.activeModText = I18n.format("gui.about.modsloaded", LiteLoader.getLoadedModsCount());
170 170  
171 171 this.initBranding();
172 172  
... ...
src/client/java/com/mumfrey/liteloader/client/mixin/MixinGuiOverlayDebug.java
... ... @@ -5,6 +5,7 @@
5 5 */
6 6 package com.mumfrey.liteloader.client.mixin;
7 7  
  8 +import java.util.ArrayList;
8 9 import java.util.List;
9 10  
10 11 import org.spongepowered.asm.mixin.Mixin;
... ... @@ -14,28 +15,47 @@ import org.spongepowered.asm.mixin.injection.Inject;
14 15 import org.spongepowered.asm.mixin.injection.Redirect;
15 16 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16 17  
  18 +import com.google.common.collect.Lists;
  19 +import com.mumfrey.liteloader.core.LiteLoader;
17 20 import com.mumfrey.liteloader.util.debug.DebugMessage;
18 21 import com.mumfrey.liteloader.util.debug.DebugMessage.Position;
19 22  
20 23 import net.minecraft.client.gui.Gui;
21 24 import net.minecraft.client.gui.GuiOverlayDebug;
  25 +import net.minecraft.client.resources.I18n;
22 26  
23 27 @Mixin(GuiOverlayDebug.class)
24 28 public abstract class MixinGuiOverlayDebug extends Gui
25 29 {
26 30 @Shadow protected abstract List<String> call();
27   -
28 31 @Shadow protected abstract <T extends Comparable<T>> List<String> getDebugInfoRight();
29 32  
30 33 private boolean captureNextCall = false;
31 34  
  35 + @SuppressWarnings("unchecked")
  36 + @Redirect(method = "getDebugInfoRight", at = @At(value = "INVOKE", remap = false,
  37 + target = "Lcom/google/common/collect/Lists;newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;"))
  38 + private <E> ArrayList<E> addLoaderBranding(E... elements)
  39 + {
  40 + ArrayList<E> list = Lists.newArrayList(elements);
  41 + list.add((E)"");
  42 + list.add((E)LiteLoader.getVersionDisplayString());
  43 + String branding = LiteLoader.getBranding();
  44 + if (branding != null)
  45 + {
  46 + list.add((E)branding);
  47 + }
  48 + list.add((E)I18n.format("gui.about.modsloaded", LiteLoader.getLoadedModsCount()));
  49 + return list;
  50 + }
  51 +
32 52 @Inject(method = "renderDebugInfoLeft()V", at = @At(value = "HEAD"))
33 53 private void onRenderDebugInfoLeft(CallbackInfo ci)
34 54 {
35 55 this.captureNextCall = true;
36 56 }
37 57  
38   - @Redirect(method = "renderDebugInfoLeft()V", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I"))
  58 + @Redirect(method = "renderDebugInfoLeft()V", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/List;size()I"))
39 59 private int getSize(List<String> list)
40 60 {
41 61 if (this.captureNextCall)
... ... @@ -53,7 +73,7 @@ public abstract class MixinGuiOverlayDebug extends Gui
53 73  
54 74 @Redirect(method = "renderDebugInfoLeft()V", at = @At(value = "INVOKE",
55 75 target = "Lnet/minecraft/client/gui/GuiOverlayDebug;call()Ljava/util/List;"))
56   - private List<String> onCall(GuiOverlayDebug self)
  76 + private List<String> onGetDebugInfoLeft(GuiOverlayDebug self)
57 77 {
58 78 List<String> list = this.call();
59 79  
... ...
src/main/java/com/mumfrey/liteloader/core/LiteLoader.java
... ... @@ -318,10 +318,20 @@ public final class LiteLoader
318 318 /**
319 319 * Get LiteLoader version
320 320 */
321   - public static final String getVersion()
  321 + public static String getVersion()
322 322 {
323 323 return LiteLoaderVersion.CURRENT.getLoaderVersion();
324 324 }
  325 +
  326 + /**
  327 + * Used for status displays, returns the total number of loaded mods
  328 + *
  329 + * @return number of loaded litemods
  330 + */
  331 + public static int getLoadedModsCount()
  332 + {
  333 + return LiteLoader.instance.mods.getLoadedMods().size();
  334 + }
325 335  
326 336 /**
327 337 * Get LiteLoader version
... ...