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,7 +166,7 @@ public class GuiLiteLoaderPanel extends GuiScreen
166 this.toggleable = true; 166 this.toggleable = true;
167 167
168 this.versionText = I18n.format("gui.about.versiontext", LiteLoader.getVersion()); 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 this.initBranding(); 171 this.initBranding();
172 172
src/client/java/com/mumfrey/liteloader/client/mixin/MixinGuiOverlayDebug.java
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 */ 5 */
6 package com.mumfrey.liteloader.client.mixin; 6 package com.mumfrey.liteloader.client.mixin;
7 7
  8 +import java.util.ArrayList;
8 import java.util.List; 9 import java.util.List;
9 10
10 import org.spongepowered.asm.mixin.Mixin; 11 import org.spongepowered.asm.mixin.Mixin;
@@ -14,28 +15,47 @@ import org.spongepowered.asm.mixin.injection.Inject; @@ -14,28 +15,47 @@ import org.spongepowered.asm.mixin.injection.Inject;
14 import org.spongepowered.asm.mixin.injection.Redirect; 15 import org.spongepowered.asm.mixin.injection.Redirect;
15 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 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 import com.mumfrey.liteloader.util.debug.DebugMessage; 20 import com.mumfrey.liteloader.util.debug.DebugMessage;
18 import com.mumfrey.liteloader.util.debug.DebugMessage.Position; 21 import com.mumfrey.liteloader.util.debug.DebugMessage.Position;
19 22
20 import net.minecraft.client.gui.Gui; 23 import net.minecraft.client.gui.Gui;
21 import net.minecraft.client.gui.GuiOverlayDebug; 24 import net.minecraft.client.gui.GuiOverlayDebug;
  25 +import net.minecraft.client.resources.I18n;
22 26
23 @Mixin(GuiOverlayDebug.class) 27 @Mixin(GuiOverlayDebug.class)
24 public abstract class MixinGuiOverlayDebug extends Gui 28 public abstract class MixinGuiOverlayDebug extends Gui
25 { 29 {
26 @Shadow protected abstract List<String> call(); 30 @Shadow protected abstract List<String> call();
27 -  
28 @Shadow protected abstract <T extends Comparable<T>> List<String> getDebugInfoRight(); 31 @Shadow protected abstract <T extends Comparable<T>> List<String> getDebugInfoRight();
29 32
30 private boolean captureNextCall = false; 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 @Inject(method = "renderDebugInfoLeft()V", at = @At(value = "HEAD")) 52 @Inject(method = "renderDebugInfoLeft()V", at = @At(value = "HEAD"))
33 private void onRenderDebugInfoLeft(CallbackInfo ci) 53 private void onRenderDebugInfoLeft(CallbackInfo ci)
34 { 54 {
35 this.captureNextCall = true; 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 private int getSize(List<String> list) 59 private int getSize(List<String> list)
40 { 60 {
41 if (this.captureNextCall) 61 if (this.captureNextCall)
@@ -53,7 +73,7 @@ public abstract class MixinGuiOverlayDebug extends Gui @@ -53,7 +73,7 @@ public abstract class MixinGuiOverlayDebug extends Gui
53 73
54 @Redirect(method = "renderDebugInfoLeft()V", at = @At(value = "INVOKE", 74 @Redirect(method = "renderDebugInfoLeft()V", at = @At(value = "INVOKE",
55 target = "Lnet/minecraft/client/gui/GuiOverlayDebug;call()Ljava/util/List;")) 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 List<String> list = this.call(); 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,10 +318,20 @@ public final class LiteLoader
318 /** 318 /**
319 * Get LiteLoader version 319 * Get LiteLoader version
320 */ 320 */
321 - public static final String getVersion() 321 + public static String getVersion()
322 { 322 {
323 return LiteLoaderVersion.CURRENT.getLoaderVersion(); 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 * Get LiteLoader version 337 * Get LiteLoader version