Commit b3097a72c9ee9a3373075a8438e9f50a556ce8e2

Authored by Mumfrey
1 parent f6840e83

move mod list panel to separate class

java/client/com/mumfrey/liteloader/client/gui/GuiModInfoPanel.java
... ... @@ -10,10 +10,12 @@ import com.mumfrey.liteloader.core.ModInfo;
10 10  
11 11 public class GuiModInfoPanel extends Gui
12 12 {
13   - private static final int TITLE_COLOUR = GuiModListEntry.WHITE;
14   - private static final int AUTHORS_COLOUR = GuiModListEntry.WHITE;
15   - private static final int DIVIDER_COLOUR = GuiModListEntry.GREY;
16   - private static final int DESCRIPTION_COLOUR = GuiModListEntry.WHITE;
  13 + private static final int TITLE_COLOUR = GuiModListPanel.WHITE;
  14 + private static final int AUTHORS_COLOUR = GuiModListPanel.WHITE;
  15 + private static final int DIVIDER_COLOUR = GuiModListPanel.GREY;
  16 + private static final int DESCRIPTION_COLOUR = GuiModListPanel.WHITE;
  17 +
  18 + private final ModListEntry owner;
17 19  
18 20 private final FontRenderer fontRenderer;
19 21  
... ... @@ -25,8 +27,9 @@ public class GuiModInfoPanel extends Gui
25 27  
26 28 private boolean mouseOverPanel, mouseOverScrollBar;
27 29  
28   - public GuiModInfoPanel(FontRenderer fontRenderer, int brandColour, ModInfo<?> modInfo)
  30 + public GuiModInfoPanel(ModListEntry owner, FontRenderer fontRenderer, int brandColour, ModInfo<?> modInfo)
29 31 {
  32 + this.owner = owner;
30 33 this.fontRenderer = fontRenderer;
31 34 this.brandColour = brandColour;
32 35 this.modInfo = modInfo;
... ... @@ -39,15 +42,15 @@ public class GuiModInfoPanel extends Gui
39 42  
40 43 this.mouseOverPanel = this.isMouseOver(mouseX, mouseY, xPosition, yPos, width, height);
41 44  
42   - this.fontRenderer.drawString(this.modInfo.getDisplayName(), xPosition + 5, yPos, GuiModInfoPanel.TITLE_COLOUR); yPos += 10;
43   - this.fontRenderer.drawString(I18n.format("gui.about.versiontext", this.modInfo.getVersion()), xPosition + 5, yPos, GuiModListEntry.VERSION_TEXT_COLOUR); yPos += 10;
  45 + this.fontRenderer.drawString(this.owner.getTitleText(), xPosition + 5, yPos, GuiModInfoPanel.TITLE_COLOUR); yPos += 10;
  46 + this.fontRenderer.drawString(this.owner.getVersionText(), xPosition + 5, yPos, GuiModListPanel.VERSION_TEXT_COLOUR); yPos += 10;
44 47  
45 48 drawRect(xPosition + 5, yPos, xPosition + width, yPos + 1, GuiModInfoPanel.DIVIDER_COLOUR); yPos += 4; // divider
46 49  
47 50 this.fontRenderer.drawString(I18n.format("gui.about.authors") + ": \2477" + this.modInfo.getAuthor(), xPosition + 5, yPos, GuiModInfoPanel.AUTHORS_COLOUR); yPos += 10;
48 51 if (!Strings.isNullOrEmpty(this.modInfo.getURL()))
49 52 {
50   - this.fontRenderer.drawString(this.modInfo.getURL(), xPosition + 5, yPos, GuiModListEntry.BLEND_2THRDS & this.brandColour); yPos += 10;
  53 + this.fontRenderer.drawString(this.modInfo.getURL(), xPosition + 5, yPos, GuiModListPanel.BLEND_2THRDS & this.brandColour); yPos += 10;
51 54 }
52 55  
53 56 drawRect(xPosition + 5, yPos, xPosition + width, yPos + 1, GuiModInfoPanel.DIVIDER_COLOUR); yPos += 4; // divider
... ...
java/client/com/mumfrey/liteloader/client/gui/GuiModListPanel.java 0 → 100644
  1 +package com.mumfrey.liteloader.client.gui;
  2 +
  3 +import static com.mumfrey.liteloader.client.util.GLClippingPlanes.*;
  4 +import static org.lwjgl.opengl.GL11.*;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.List;
  8 +
  9 +import net.minecraft.client.Minecraft;
  10 +import net.minecraft.client.gui.FontRenderer;
  11 +import net.minecraft.client.gui.Gui;
  12 +
  13 +import com.mumfrey.liteloader.api.ModInfoDecorator;
  14 +import com.mumfrey.liteloader.core.ModInfo;
  15 +import com.mumfrey.liteloader.util.render.IconClickable;
  16 +import com.mumfrey.liteloader.util.render.IconTextured;
  17 +
  18 +public class GuiModListPanel extends Gui
  19 +{
  20 + static final int BLACK = 0xFF000000;
  21 + static final int DARK_GREY = 0xB0333333;
  22 + static final int GREY = 0xFF999999;
  23 + static final int WHITE = 0xFFFFFFFF;
  24 +
  25 + static final int BLEND_2THRDS = 0xB0FFFFFF;
  26 + static final int BLEND_HALF = 0x80FFFFFF;
  27 +
  28 + static final int API_COLOUR = 0xFFAA00AA;
  29 + static final int EXTERNAL_ENTRY_COLOUR = 0xFF47D1AA;
  30 + static final int MISSING_DEPENDENCY_COLOUR = 0xFFFFAA00;
  31 + static final int ERROR_COLOUR = 0xFFFF5555;
  32 + static final int ERROR_GRADIENT_COLOUR = 0xFFAA0000;
  33 + static final int ERROR_GRADIENT_COLOUR2 = 0xFF550000;
  34 +
  35 + static final int VERSION_TEXT_COLOUR = GuiModListPanel.GREY;
  36 + static final int GRADIENT_COLOUR2 = GuiModListPanel.BLEND_2THRDS & GuiModListPanel.DARK_GREY;
  37 + static final int HANGER_COLOUR = GuiModListPanel.GREY;
  38 + static final int HANGER_COLOUR_MOUSEOVER = GuiModListPanel.WHITE;
  39 +
  40 + static final int PANEL_HEIGHT = 32;
  41 + static final int PANEL_SPACING = 4;
  42 +
  43 + private ModListEntry owner;
  44 +
  45 + /**
  46 + * For text display
  47 + */
  48 + private final FontRenderer fontRenderer;
  49 +
  50 + private final int brandColour;
  51 +
  52 + private final List<ModInfoDecorator> decorators;
  53 +
  54 + private final ModInfo<?> modInfo;
  55 +
  56 + /**
  57 + * True if the mouse was over this mod on the last render
  58 + */
  59 + private boolean mouseOver;
  60 +
  61 + private IconClickable mouseOverIcon = null;
  62 +
  63 + private List<IconTextured> modIcons = new ArrayList<IconTextured>();
  64 +
  65 + public GuiModListPanel(ModListEntry owner, FontRenderer fontRenderer, int brandColour, ModInfo<?> modInfo, List<ModInfoDecorator> decorators)
  66 + {
  67 + this.owner = owner;
  68 + this.fontRenderer = fontRenderer;
  69 + this.brandColour = brandColour;
  70 + this.modInfo = modInfo;
  71 + this.decorators = decorators;
  72 +
  73 + for (ModInfoDecorator decorator : this.decorators)
  74 + {
  75 + decorator.addIcons(modInfo, this.modIcons);
  76 + }
  77 + }
  78 +
  79 + /**
  80 + * Draw this list entry as a list item
  81 + *
  82 + * @param mouseX
  83 + * @param mouseY
  84 + * @param partialTicks
  85 + * @param xPosition
  86 + * @param yPosition
  87 + * @param width
  88 + * @param selected
  89 + * @return
  90 + */
  91 + public int draw(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected)
  92 + {
  93 + int gradientColour = this.getGradientColour(selected);
  94 + int titleColour = this.getTitleColour(selected);
  95 + int statusColour = this.getStatusColour(selected);
  96 +
  97 + this.drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + GuiModListPanel.PANEL_HEIGHT, gradientColour, GuiModListPanel.GRADIENT_COLOUR2);
  98 +
  99 + String titleText = this.owner.getTitleText();
  100 + String versionText = this.owner.getVersionText();
  101 + String statusText = this.owner.getStatusText();
  102 +
  103 + for (ModInfoDecorator decorator : this.decorators)
  104 + {
  105 + String newStatusText = decorator.modifyStatusText(this.modInfo, statusText);
  106 + if (newStatusText != null) statusText = newStatusText;
  107 + }
  108 +
  109 + this.fontRenderer.drawString(titleText, xPosition + 5, yPosition + 2, titleColour);
  110 + this.fontRenderer.drawString(versionText, xPosition + 5, yPosition + 12, GuiModListPanel.VERSION_TEXT_COLOUR);
  111 + this.fontRenderer.drawString(statusText, xPosition + 5, yPosition + 22, statusColour);
  112 +
  113 + this.mouseOver = this.isMouseOver(mouseX, mouseY, xPosition, yPosition, width, PANEL_HEIGHT);
  114 + int hangerColour = this.mouseOver ? GuiModListPanel.HANGER_COLOUR_MOUSEOVER : GuiModListPanel.HANGER_COLOUR;
  115 + drawRect(xPosition, yPosition, xPosition + 1, yPosition + PANEL_HEIGHT, hangerColour);
  116 +
  117 + for (ModInfoDecorator decorator : this.decorators)
  118 + {
  119 + decorator.onDrawListEntry(mouseX, mouseY, partialTicks, xPosition, yPosition, width, GuiModListPanel.PANEL_HEIGHT, selected, this.modInfo, gradientColour, titleColour, statusColour);
  120 + }
  121 +
  122 + return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING;
  123 + }
  124 +
  125 + public int postRender(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected)
  126 + {
  127 + xPosition += (width - 14);
  128 + yPosition += (GuiModListPanel.PANEL_HEIGHT - 14);
  129 +
  130 + this.mouseOverIcon = null;
  131 +
  132 + for (IconTextured icon : this.modIcons)
  133 + {
  134 + xPosition = this.drawPropertyIcon(xPosition, yPosition, icon, mouseX, mouseY);
  135 + }
  136 +
  137 + return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING;
  138 + }
  139 +
  140 + protected int drawPropertyIcon(int xPosition, int yPosition, IconTextured icon, int mouseX, int mouseY)
  141 + {
  142 + glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  143 + Minecraft.getMinecraft().getTextureManager().bindTexture(icon.getTextureResource());
  144 +
  145 + glEnable(GL_BLEND);
  146 + this.drawTexturedModalRect(xPosition, yPosition, icon.getUPos(), icon.getVPos(), icon.getIconWidth(), icon.getIconHeight());
  147 + glDisable(GL_BLEND);
  148 +
  149 + if (mouseX >= xPosition && mouseX <= xPosition + 12 && mouseY >= yPosition && mouseY <= yPosition + 12)
  150 + {
  151 + String tooltipText = icon.getDisplayText();
  152 + if (tooltipText != null)
  153 + {
  154 + glDisableClipping();
  155 + GuiLiteLoaderPanel.drawTooltip(this.fontRenderer, tooltipText, mouseX, mouseY, 4096, 4096, GuiModListPanel.WHITE, GuiModListPanel.BLEND_HALF & GuiModListPanel.BLACK);
  156 + glEnableClipping();
  157 + }
  158 +
  159 + if (icon instanceof IconClickable) this.mouseOverIcon = (IconClickable)icon;
  160 + }
  161 +
  162 + return xPosition - 14;
  163 + }
  164 +
  165 + /**
  166 + * @param external
  167 + * @param selected
  168 + * @return
  169 + */
  170 + protected int getGradientColour(boolean selected)
  171 + {
  172 + return GuiModListPanel.BLEND_2THRDS & (this.owner.isErrored() ? (selected ? GuiModListPanel.ERROR_GRADIENT_COLOUR : GuiModListPanel.ERROR_GRADIENT_COLOUR2) : (selected ? (this.owner.isExternal() ? GuiModListPanel.EXTERNAL_ENTRY_COLOUR : this.brandColour) : GuiModListPanel.BLACK));
  173 + }
  174 +
  175 + /**
  176 + * @param missingDependencies
  177 + * @param enabled
  178 + * @param external
  179 + * @param selected
  180 + * @return
  181 + */
  182 + protected int getTitleColour(boolean selected)
  183 + {
  184 + if (this.owner.isMissingDependencies()) return GuiModListPanel.MISSING_DEPENDENCY_COLOUR;
  185 + if (this.owner.isMissingAPIs()) return GuiModListPanel.API_COLOUR;
  186 + if (this.owner.isErrored()) return GuiModListPanel.ERROR_COLOUR;
  187 + if (!this.owner.isActive()) return GuiModListPanel.GREY;
  188 + return this.owner.isExternal() ? GuiModListPanel.EXTERNAL_ENTRY_COLOUR : GuiModListPanel.WHITE;
  189 + }
  190 +
  191 + /**
  192 + * @param external
  193 + * @param selected
  194 + * @return
  195 + */
  196 + protected int getStatusColour(boolean selected)
  197 + {
  198 + return this.owner.isExternal() ? GuiModListPanel.EXTERNAL_ENTRY_COLOUR : this.brandColour;
  199 + }
  200 +
  201 + public int getHeight()
  202 + {
  203 + return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING;
  204 + }
  205 +
  206 + private boolean isMouseOver(int mouseX, int mouseY, int x, int y, int width, int height)
  207 + {
  208 + return mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + height;
  209 + }
  210 +
  211 + public boolean isMouseOverIcon()
  212 + {
  213 + return this.mouseOver && this.mouseOverIcon != null;
  214 + }
  215 +
  216 + public boolean isMouseOver()
  217 + {
  218 + return this.mouseOver;
  219 + }
  220 +
  221 + public void iconClick(Object source)
  222 + {
  223 + if (this.mouseOverIcon != null)
  224 + {
  225 + this.mouseOverIcon.onClicked(source, this);
  226 + }
  227 + }
  228 +}
... ...
java/client/com/mumfrey/liteloader/client/gui/GuiPanelMods.java
... ... @@ -40,12 +40,12 @@ public class GuiPanelMods extends GuiPanel
40 40 /**
41 41 * List of enumerated mods
42 42 */
43   - private List<GuiModListEntry> mods = new ArrayList<GuiModListEntry>();
  43 + private List<ModListEntry> mods = new ArrayList<ModListEntry>();
44 44  
45 45 /**
46 46 * Currently selected mod
47 47 */
48   - private GuiModListEntry selectedMod = null;
  48 + private ModListEntry selectedMod = null;
49 49  
50 50 /**
51 51 * Timer used to handle double-clicking on a mod
... ... @@ -94,26 +94,26 @@ public class GuiPanelMods extends GuiPanel
94 94 private void populateModList(LiteLoaderMods mods, LoaderEnvironment environment, List<ModInfoDecorator> decorators)
95 95 {
96 96 // Add mods to this treeset first, in order to sort them
97   - Map<String, GuiModListEntry> sortedMods = new TreeMap<String, GuiModListEntry>();
  97 + Map<String, ModListEntry> sortedMods = new TreeMap<String, ModListEntry>();
98 98  
99 99 // Active mods
100 100 for (ModInfo<LoadableMod<?>> mod : mods.getLoadedMods())
101 101 {
102   - GuiModListEntry modListEntry = new GuiModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, mod);
  102 + ModListEntry modListEntry = new ModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, mod);
103 103 sortedMods.put(modListEntry.getKey(), modListEntry);
104 104 }
105 105  
106 106 // Disabled mods
107 107 for (ModInfo<?> disabledMod : mods.getDisabledMods())
108 108 {
109   - GuiModListEntry modListEntry = new GuiModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, disabledMod);
  109 + ModListEntry modListEntry = new ModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, disabledMod);
110 110 sortedMods.put(modListEntry.getKey(), modListEntry);
111 111 }
112 112  
113 113 // Injected tweaks
114 114 for (ModInfo<Loadable<?>> injectedTweak : mods.getInjectedTweaks())
115 115 {
116   - GuiModListEntry modListEntry = new GuiModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, injectedTweak);
  116 + ModListEntry modListEntry = new ModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, injectedTweak);
117 117 sortedMods.put(modListEntry.getKey(), modListEntry);
118 118 }
119 119  
... ... @@ -174,17 +174,17 @@ public class GuiPanelMods extends GuiPanel
174 174  
175 175 if (mouseY > GuiLiteLoaderPanel.PANEL_TOP && mouseY < this.height - GuiLiteLoaderPanel.PANEL_BOTTOM)
176 176 {
177   - GuiModListEntry lastSelectedMod = this.selectedMod;
  177 + ModListEntry lastSelectedMod = this.selectedMod;
178 178  
179   - for (GuiModListEntry mod : this.mods)
  179 + for (ModListEntry mod : this.mods)
180 180 {
181   - if (mod.isMouseOver())
  181 + if (mod.getListPanel().isMouseOver())
182 182 {
183 183 this.selectMod(mod);
184 184  
185   - if (mod.isMouseOverIcon())
  185 + if (mod.getListPanel().isMouseOverIcon())
186 186 {
187   - mod.iconClick(this.parentScreen);
  187 + mod.getListPanel().iconClick(this.parentScreen);
188 188 }
189 189 else
190 190 {
... ... @@ -326,16 +326,16 @@ public class GuiPanelMods extends GuiPanel
326 326 mouseY -= (GuiLiteLoaderPanel.PANEL_TOP - this.scrollBar.getValue());
327 327  
328 328 int yPos = 0;
329   - for (GuiModListEntry mod : this.mods)
  329 + for (ModListEntry mod : this.mods)
330 330 {
331 331 // drawListEntry returns a value indicating the height of the item drawn
332   - yPos += mod.draw(mouseX, mouseY, partialTicks, MARGIN, yPos, width - 6, mod == this.selectedMod);
  332 + yPos += mod.getListPanel().draw(mouseX, mouseY, partialTicks, MARGIN, yPos, width - 6, mod == this.selectedMod);
333 333 }
334 334  
335 335 yPos = 0;
336   - for (GuiModListEntry mod : this.mods)
  336 + for (ModListEntry mod : this.mods)
337 337 {
338   - yPos += mod.postRenderListEntry(mouseX, mouseY, partialTicks, MARGIN, yPos, width - 6, mod == this.selectedMod);
  338 + yPos += mod.getListPanel().postRender(mouseX, mouseY, partialTicks, MARGIN, yPos, width - 6, mod == this.selectedMod);
339 339 }
340 340  
341 341 glPopMatrix();
... ... @@ -370,7 +370,7 @@ public class GuiPanelMods extends GuiPanel
370 370 * @param mod
371 371 * @return
372 372 */
373   - private void selectMod(GuiModListEntry mod)
  373 + private void selectMod(ModListEntry mod)
374 374 {
375 375 if (this.selectedMod != null)
376 376 {
... ... @@ -407,10 +407,10 @@ public class GuiPanelMods extends GuiPanel
407 407 if (this.selectedMod == null) return;
408 408  
409 409 int yPos = 0;
410   - for (GuiModListEntry mod : this.mods)
  410 + for (ModListEntry mod : this.mods)
411 411 {
412 412 if (mod == this.selectedMod) break;
413   - yPos += mod.getHeight();
  413 + yPos += mod.getListPanel().getHeight();
414 414 }
415 415  
416 416 // Mod is above the top of the visible window
... ... @@ -421,7 +421,7 @@ public class GuiPanelMods extends GuiPanel
421 421 }
422 422  
423 423 int panelHeight = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - GuiLiteLoaderPanel.PANEL_TOP;
424   - int modHeight = this.selectedMod.getHeight();
  424 + int modHeight = this.selectedMod.getListPanel().getHeight();
425 425  
426 426 // Mod is below the bottom of the visible window
427 427 if (yPos - this.scrollBar.getValue() + modHeight > panelHeight)
... ...
java/client/com/mumfrey/liteloader/client/gui/GuiModListEntry.java renamed to java/client/com/mumfrey/liteloader/client/gui/ModListEntry.java
1 1 package com.mumfrey.liteloader.client.gui;
2 2  
3   -import static com.mumfrey.liteloader.client.util.GLClippingPlanes.*;
4   -import static org.lwjgl.opengl.GL11.*;
5   -
6   -import java.util.ArrayList;
7 3 import java.util.List;
8 4 import java.util.Set;
9 5  
10   -import net.minecraft.client.Minecraft;
11 6 import net.minecraft.client.gui.FontRenderer;
12   -import net.minecraft.client.gui.Gui;
13 7 import net.minecraft.client.resources.I18n;
14 8  
15 9 import com.mumfrey.liteloader.LiteMod;
... ... @@ -19,8 +13,6 @@ import com.mumfrey.liteloader.core.ModInfo;
19 13 import com.mumfrey.liteloader.interfaces.Loadable;
20 14 import com.mumfrey.liteloader.interfaces.LoadableMod;
21 15 import com.mumfrey.liteloader.launch.LoaderEnvironment;
22   -import com.mumfrey.liteloader.util.render.IconClickable;
23   -import com.mumfrey.liteloader.util.render.IconTextured;
24 16  
25 17 /**
26 18 * Represents a mod in the mod info screen, keeps track of mod information and provides methods
... ... @@ -28,44 +20,14 @@ import com.mumfrey.liteloader.util.render.IconTextured;
28 20 *
29 21 * @author Adam Mummery-Smith
30 22 */
31   -public class GuiModListEntry extends Gui
  23 +public class ModListEntry
32 24 {
33   - static final int BLACK = 0xFF000000;
34   - static final int DARK_GREY = 0xB0333333;
35   - static final int GREY = 0xFF999999;
36   - static final int WHITE = 0xFFFFFFFF;
37   -
38   - static final int BLEND_2THRDS = 0xB0FFFFFF;
39   - static final int BLEND_HALF = 0x80FFFFFF;
40   -
41   - static final int API_COLOUR = 0xFFAA00AA;
42   - static final int EXTERNAL_ENTRY_COLOUR = 0xFF47D1AA;
43   - static final int MISSING_DEPENDENCY_COLOUR = 0xFFFFAA00;
44   - static final int ERROR_COLOUR = 0xFFFF5555;
45   - static final int ERROR_GRADIENT_COLOUR = 0xFFAA0000;
46   - static final int ERROR_GRADIENT_COLOUR2 = 0xFF550000;
47   -
48   - static final int VERSION_TEXT_COLOUR = GuiModListEntry.GREY;
49   - static final int GRADIENT_COLOUR2 = GuiModListEntry.BLEND_2THRDS & GuiModListEntry.DARK_GREY;
50   - static final int HANGER_COLOUR = GuiModListEntry.GREY;
51   - static final int HANGER_COLOUR_MOUSEOVER = GuiModListEntry.WHITE;
52   -
53   - static final int PANEL_HEIGHT = 32;
54   - static final int PANEL_SPACING = 4;
55   -
56   - /**
57   - * For text display
58   - */
59   - private final FontRenderer fontRenderer;
60   -
61   - private final int brandColour;
62   -
63   - private final List<ModInfoDecorator> decorators;
64   -
65 25 private final LiteLoaderMods mods;
66 26  
67 27 private final ModInfo<?> modInfo;
68 28  
  29 + private final GuiModListPanel listPanel;
  30 +
69 31 private final GuiModInfoPanel infoPanel;
70 32  
71 33 /**
... ... @@ -101,18 +63,9 @@ public class GuiModListEntry extends Gui
101 63 private boolean willBeEnabled;
102 64  
103 65 /**
104   - * True if the mouse was over this mod on the last render
105   - */
106   - private boolean mouseOver;
107   -
108   - private IconClickable mouseOverIcon = null;
109   -
110   - /**
111 66 * True if this is not a mod but an external jar
112 67 */
113   - private boolean external;
114   -
115   - private List<IconTextured> modIcons = new ArrayList<IconTextured>();
  68 + private boolean isExternal;
116 69  
117 70 /**
118 71 * Mod list entry for an ACTIVE mod
... ... @@ -120,20 +73,15 @@ public class GuiModListEntry extends Gui
120 73 * @param modInfo
121 74 * @param enabledMods
122 75 */
123   - GuiModListEntry(LiteLoaderMods mods, LoaderEnvironment environment, FontRenderer fontRenderer, int brandColour, List<ModInfoDecorator> decorators, ModInfo<?> modInfo)
  76 + ModListEntry(LiteLoaderMods mods, LoaderEnvironment environment, FontRenderer fontRenderer, int brandColour, List<ModInfoDecorator> decorators, ModInfo<?> modInfo)
124 77 {
125 78 this.mods = mods;
126   - this.fontRenderer = fontRenderer;
127   - this.brandColour = brandColour;
128   - this.decorators = decorators;
129 79 this.modInfo = modInfo;
130 80  
131   - this.infoPanel = new GuiModInfoPanel(fontRenderer, brandColour, modInfo);
132   -
133 81 this.isActive = modInfo.isActive();
134 82 this.canBeToggled = modInfo.isToggleable() && mods.getEnabledModsList().saveAllowed();
135 83 this.willBeEnabled = mods.isModEnabled(this.modInfo.getIdentifier());;
136   - this.external = modInfo.getContainer().isExternalJar();
  84 + this.isExternal = modInfo.getContainer().isExternalJar();
137 85 this.isErrored = modInfo.getStartupErrors() != null && modInfo.getStartupErrors().size() > 0;
138 86  
139 87 if (!modInfo.isActive())
... ... @@ -151,97 +99,25 @@ public class GuiModListEntry extends Gui
151 99 this.isMissingAPIs = this.missingAPIs.size() > 0;
152 100 }
153 101 }
154   -
155   - for (ModInfoDecorator decorator : this.decorators)
156   - {
157   - decorator.addIcons(modInfo, this.modIcons);
158   - }
159   - }
160 102  
  103 + this.infoPanel = new GuiModInfoPanel(this, fontRenderer, brandColour, modInfo);
  104 + this.listPanel = new GuiModListPanel(this, fontRenderer, brandColour, modInfo, decorators);
  105 + }
  106 +
161 107 /**
162   - * Draw this list entry as a list item
163   - *
164   - * @param mouseX
165   - * @param mouseY
166   - * @param partialTicks
167   - * @param xPosition
168   - * @param yPosition
169   - * @param width
170   - * @param selected
171 108 * @return
172 109 */
173   - public int draw(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected)
  110 + protected String getTitleText()
174 111 {
175   - int gradientColour = this.getGradientColour(selected);
176   - int titleColour = this.getTitleColour(selected);
177   - int statusColour = this.getStatusColour(selected);
178   -
179   - this.drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + GuiModListEntry.PANEL_HEIGHT, gradientColour, GuiModListEntry.GRADIENT_COLOUR2);
180   -
181   - String titleText = this.modInfo.getDisplayName();
182   - String versionText = I18n.format("gui.about.versiontext", this.modInfo.getVersion());
183   - String statusText = this.getStatusText();
184   -
185   - for (ModInfoDecorator decorator : this.decorators)
186   - {
187   - String newStatusText = decorator.modifyStatusText(this.modInfo, statusText);
188   - if (newStatusText != null) statusText = newStatusText;
189   - }
190   -
191   - this.fontRenderer.drawString(titleText, xPosition + 5, yPosition + 2, titleColour);
192   - this.fontRenderer.drawString(versionText, xPosition + 5, yPosition + 12, GuiModListEntry.VERSION_TEXT_COLOUR);
193   - this.fontRenderer.drawString(statusText, xPosition + 5, yPosition + 22, statusColour);
194   -
195   - this.mouseOver = this.isMouseOver(mouseX, mouseY, xPosition, yPosition, width, PANEL_HEIGHT);
196   - int hangerColour = this.mouseOver ? GuiModListEntry.HANGER_COLOUR_MOUSEOVER : GuiModListEntry.HANGER_COLOUR;
197   - drawRect(xPosition, yPosition, xPosition + 1, yPosition + PANEL_HEIGHT, hangerColour);
198   -
199   - for (ModInfoDecorator decorator : this.decorators)
200   - {
201   - decorator.onDrawListEntry(mouseX, mouseY, partialTicks, xPosition, yPosition, width, GuiModListEntry.PANEL_HEIGHT, selected, this.modInfo, gradientColour, titleColour, statusColour);
202   - }
203   -
204   - return GuiModListEntry.PANEL_HEIGHT + GuiModListEntry.PANEL_SPACING;
205   - }
206   -
207   - public int postRenderListEntry(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected)
208   - {
209   - xPosition += (width - 14);
210   - yPosition += (GuiModListEntry.PANEL_HEIGHT - 14);
211   -
212   - this.mouseOverIcon = null;
213   -
214   - for (IconTextured icon : this.modIcons)
215   - {
216   - xPosition = this.drawPropertyIcon(xPosition, yPosition, icon, mouseX, mouseY);
217   - }
218   -
219   - return GuiModListEntry.PANEL_HEIGHT + GuiModListEntry.PANEL_SPACING;
  112 + return this.modInfo.getDisplayName();
220 113 }
221 114  
222   - protected int drawPropertyIcon(int xPosition, int yPosition, IconTextured icon, int mouseX, int mouseY)
  115 + /**
  116 + * @return
  117 + */
  118 + protected String getVersionText()
223 119 {
224   - glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
225   - Minecraft.getMinecraft().getTextureManager().bindTexture(icon.getTextureResource());
226   -
227   - glEnable(GL_BLEND);
228   - this.drawTexturedModalRect(xPosition, yPosition, icon.getUPos(), icon.getVPos(), icon.getIconWidth(), icon.getIconHeight());
229   - glDisable(GL_BLEND);
230   -
231   - if (mouseX >= xPosition && mouseX <= xPosition + 12 && mouseY >= yPosition && mouseY <= yPosition + 12)
232   - {
233   - String tooltipText = icon.getDisplayText();
234   - if (tooltipText != null)
235   - {
236   - glDisableClipping();
237   - GuiLiteLoaderPanel.drawTooltip(this.fontRenderer, tooltipText, mouseX, mouseY, 4096, 4096, GuiModListEntry.WHITE, GuiModListEntry.BLEND_HALF & GuiModListEntry.BLACK);
238   - glEnableClipping();
239   - }
240   -
241   - if (icon instanceof IconClickable) this.mouseOverIcon = (IconClickable)icon;
242   - }
243   -
244   - return xPosition - 14;
  120 + return I18n.format("gui.about.versiontext", this.modInfo.getVersion());
245 121 }
246 122  
247 123 /**
... ... @@ -249,7 +125,7 @@ public class GuiModListEntry extends Gui
249 125 */
250 126 protected String getStatusText()
251 127 {
252   - String statusText = this.external ? I18n.format("gui.status.loaded") : I18n.format("gui.status.active");
  128 + String statusText = this.isExternal ? I18n.format("gui.status.loaded") : I18n.format("gui.status.active");
253 129  
254 130 if (this.isMissingAPIs)
255 131 {
... ... @@ -276,61 +152,6 @@ public class GuiModListEntry extends Gui
276 152 }
277 153  
278 154 /**
279   - * @param external
280   - * @param selected
281   - * @return
282   - */
283   - protected int getGradientColour(boolean selected)
284   - {
285   - return GuiModListEntry.BLEND_2THRDS & (this.isErrored ? (selected ? GuiModListEntry.ERROR_GRADIENT_COLOUR : GuiModListEntry.ERROR_GRADIENT_COLOUR2) : (selected ? (this.external ? GuiModListEntry.EXTERNAL_ENTRY_COLOUR : this.brandColour) : GuiModListEntry.BLACK));
286   - }
287   -
288   - /**
289   - * @param missingDependencies
290   - * @param enabled
291   - * @param external
292   - * @param selected
293   - * @return
294   - */
295   - protected int getTitleColour(boolean selected)
296   - {
297   - if (this.isMissingDependencies) return GuiModListEntry.MISSING_DEPENDENCY_COLOUR;
298   - if (this.isMissingAPIs) return GuiModListEntry.API_COLOUR;
299   - if (this.isErrored) return GuiModListEntry.ERROR_COLOUR;
300   - if (!this.isActive) return GuiModListEntry.GREY;
301   - return this.external ? GuiModListEntry.EXTERNAL_ENTRY_COLOUR : GuiModListEntry.WHITE;
302   - }
303   -
304   - /**
305   - * @param external
306   - * @param selected
307   - * @return
308   - */
309   - protected int getStatusColour(boolean selected)
310   - {
311   - return this.external ? GuiModListEntry.EXTERNAL_ENTRY_COLOUR : this.brandColour;
312   - }
313   -
314   - public int getHeight()
315   - {
316   - return GuiModListEntry.PANEL_HEIGHT + GuiModListEntry.PANEL_SPACING;
317   - }
318   -
319   - /**
320   - * @param mouseX
321   - * @param mouseY
322   - * @param x
323   - * @param y
324   - * @param width
325   - * @param height
326   - * @return
327   - */
328   - private boolean isMouseOver(int mouseX, int mouseY, int x, int y, int width, int height)
329   - {
330   - return mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + height;
331   - }
332   -
333   - /**
334 155 * Toggle the enablement status of this mod, if supported
335 156 */
336 157 public void toggleEnabled()
... ... @@ -392,22 +213,34 @@ public class GuiModListEntry extends Gui
392 213 return this.willBeEnabled;
393 214 }
394 215  
395   - public boolean isMouseOverIcon()
  216 + public boolean isActive()
396 217 {
397   - return this.mouseOver && this.mouseOverIcon != null;
  218 + return this.isActive;
398 219 }
399   -
400   - public boolean isMouseOver()
  220 +
  221 + public boolean isErrored()
401 222 {
402   - return this.mouseOver;
  223 + return this.isErrored;
403 224 }
404 225  
405   - public void iconClick(Object source)
  226 + public boolean isExternal()
406 227 {
407   - if (this.mouseOverIcon != null)
408   - {
409   - this.mouseOverIcon.onClicked(source, this);
410   - }
  228 + return this.isExternal;
  229 + }
  230 +
  231 + public boolean isMissingAPIs()
  232 + {
  233 + return this.isMissingAPIs;
  234 + }
  235 +
  236 + public boolean isMissingDependencies()
  237 + {
  238 + return this.isMissingDependencies;
  239 + }
  240 +
  241 + public GuiModListPanel getListPanel()
  242 + {
  243 + return this.listPanel;
411 244 }
412 245  
413 246 public GuiModInfoPanel getInfoPanel()
... ...