Commit bd15e763be763d3c59fb2aa367752ed204c0fa32

Authored by Mumfrey
1 parent f69d71c7

add more caps to ModInfoDecorator, change mod status text when errored

java/client/com/mumfrey/liteloader/client/api/LiteLoaderModInfoDecorator.java
@@ -54,4 +54,21 @@ public class LiteLoaderModInfoDecorator implements ModInfoDecorator @@ -54,4 +54,21 @@ public class LiteLoaderModInfoDecorator implements ModInfoDecorator
54 }); 54 });
55 } 55 }
56 } 56 }
  57 +
  58 + /* (non-Javadoc)
  59 + * @see com.mumfrey.liteloader.api.ModInfoDecorator#modifyStatusText(com.mumfrey.liteloader.core.ModInfo, java.lang.String)
  60 + */
  61 + @Override
  62 + public String modifyStatusText(ModInfo<?> mod, String statusText)
  63 + {
  64 + return null;
  65 + }
  66 +
  67 + /* (non-Javadoc)
  68 + * @see com.mumfrey.liteloader.api.ModInfoDecorator#onDrawListEntry(int, int, float, int, int, int, int, boolean, com.mumfrey.liteloader.core.ModInfo, int, int, int)
  69 + */
  70 + @Override
  71 + public void onDrawListEntry(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, int height, boolean selected, ModInfo<?> mod, int gradientColour, int titleColour, int statusColour)
  72 + {
  73 + }
57 } 74 }
java/client/com/mumfrey/liteloader/client/gui/GuiModListEntry.java
@@ -219,13 +219,28 @@ public class GuiModListEntry extends Gui @@ -219,13 +219,28 @@ public class GuiModListEntry extends Gui
219 219
220 this.drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + GuiModListEntry.PANEL_HEIGHT, gradientColour, GuiModListEntry.GRADIENT_COLOUR2); 220 this.drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + GuiModListEntry.PANEL_HEIGHT, gradientColour, GuiModListEntry.GRADIENT_COLOUR2);
221 221
222 - this.fontRenderer.drawString(this.getTitleText(), xPosition + 5, yPosition + 2, titleColour);  
223 - this.fontRenderer.drawString(this.getVersionText(), xPosition + 5, yPosition + 12, GuiModListEntry.VERSION_TEXT_COLOUR);  
224 - this.fontRenderer.drawString(this.getStatusText(), xPosition + 5, yPosition + 22, statusColour); 222 + String titleText = this.getTitleText();
  223 + String versionText = this.getVersionText();
  224 + String statusText = this.getStatusText();
  225 +
  226 + for (ModInfoDecorator decorator : this.decorators)
  227 + {
  228 + String newStatusText = decorator.modifyStatusText(this.modInfo, statusText);
  229 + if (newStatusText != null) statusText = newStatusText;
  230 + }
  231 +
  232 + this.fontRenderer.drawString(titleText, xPosition + 5, yPosition + 2, titleColour);
  233 + this.fontRenderer.drawString(versionText, xPosition + 5, yPosition + 12, GuiModListEntry.VERSION_TEXT_COLOUR);
  234 + this.fontRenderer.drawString(statusText, xPosition + 5, yPosition + 22, statusColour);
225 235
226 this.mouseOverListEntry = this.isMouseOver(mouseX, mouseY, xPosition, yPosition, width, PANEL_HEIGHT); 236 this.mouseOverListEntry = this.isMouseOver(mouseX, mouseY, xPosition, yPosition, width, PANEL_HEIGHT);
227 drawRect(xPosition, yPosition, xPosition + 1, yPosition + PANEL_HEIGHT, this.mouseOverListEntry ? GuiModListEntry.HANGER_COLOUR_MOUSEOVER : GuiModListEntry.HANGER_COLOUR); 237 drawRect(xPosition, yPosition, xPosition + 1, yPosition + PANEL_HEIGHT, this.mouseOverListEntry ? GuiModListEntry.HANGER_COLOUR_MOUSEOVER : GuiModListEntry.HANGER_COLOUR);
228 238
  239 + for (ModInfoDecorator decorator : this.decorators)
  240 + {
  241 + decorator.onDrawListEntry(mouseX, mouseY, partialTicks, xPosition, yPosition, width, GuiModListEntry.PANEL_HEIGHT, selected, this.modInfo, gradientColour, titleColour, statusColour);
  242 + }
  243 +
229 return GuiModListEntry.PANEL_HEIGHT + GuiModListEntry.PANEL_SPACING; 244 return GuiModListEntry.PANEL_HEIGHT + GuiModListEntry.PANEL_SPACING;
230 } 245 }
231 246
@@ -345,6 +360,10 @@ public class GuiModListEntry extends Gui @@ -345,6 +360,10 @@ public class GuiModListEntry extends Gui
345 statusText = "\247e" + I18n.format("gui.status.missingdeps"); 360 statusText = "\247e" + I18n.format("gui.status.missingdeps");
346 if (this.canBeToggled && !this.willBeEnabled) statusText = "\247c" + I18n.format("gui.status.pending.disabled"); 361 if (this.canBeToggled && !this.willBeEnabled) statusText = "\247c" + I18n.format("gui.status.pending.disabled");
347 } 362 }
  363 + else if (this.isErrored)
  364 + {
  365 + statusText = "\247c" + I18n.format("gui.status.startuperror");
  366 + }
348 else if (this.canBeToggled) 367 else if (this.canBeToggled)
349 { 368 {
350 if (!this.enabled && !this.willBeEnabled) statusText = "\2477" + I18n.format("gui.status.disabled"); 369 if (!this.enabled && !this.willBeEnabled) statusText = "\2477" + I18n.format("gui.status.disabled");
java/common/com/mumfrey/liteloader/api/ModInfoDecorator.java
@@ -21,4 +21,29 @@ public interface ModInfoDecorator extends CustomisationProvider @@ -21,4 +21,29 @@ public interface ModInfoDecorator extends CustomisationProvider
21 * @param icons 21 * @param icons
22 */ 22 */
23 public abstract void addIcons(ModInfo<?> mod, List<IconTextured> icons); 23 public abstract void addIcons(ModInfo<?> mod, List<IconTextured> icons);
  24 +
  25 + /**
  26 + * Allows this decorator to modify the status text for the specified mod, return null if no modification required
  27 + *
  28 + * @param statusText
  29 + * @return
  30 + */
  31 + public abstract String modifyStatusText(ModInfo<?> mod, String statusText);
  32 +
  33 + /**
  34 + * Allow decorators to draw custom content on the mod list entries
  35 + *
  36 + * @param mouseX Mouse X position
  37 + * @param mouseY Mouse Y position
  38 + * @param partialTicks
  39 + * @param xPosition Panel X position
  40 + * @param yPosition Panel Y position
  41 + * @param width Panel width
  42 + * @param selected Panel height
  43 + * @param mod ModInfo
  44 + * @param gradientColour
  45 + * @param titleColour
  46 + * @param statusColour
  47 + */
  48 + public abstract void onDrawListEntry(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, int height, boolean selected, ModInfo<?> mod, int gradientColour, int titleColour, int statusColour);
24 } 49 }
resources/assets/liteloader/lang/en_US.lang
@@ -31,6 +31,7 @@ gui.status.pending.enabled=Enabled on next startup @@ -31,6 +31,7 @@ gui.status.pending.enabled=Enabled on next startup
31 gui.status.pending.disabled=Disabled on next startup 31 gui.status.pending.disabled=Disabled on next startup
32 gui.status.missingdeps=Missing dependencies 32 gui.status.missingdeps=Missing dependencies
33 gui.status.missingapis=Missing required APIs 33 gui.status.missingapis=Missing required APIs
  34 +gui.status.startuperror=Startup errors detected
34 gui.description.missingdeps=Missing dependencies: %s 35 gui.description.missingdeps=Missing dependencies: %s
35 gui.description.missingapis=Missing APIs: %s 36 gui.description.missingapis=Missing APIs: %s
36 37