Commit 8f9462891658063103e837091165cd86cabcbce5
1 parent
99fe86cb
refactoring ModList to separate class
Showing
6 changed files
with
430 additions
and
226 deletions
java/client/com/mumfrey/liteloader/client/gui/GuiModListPanel.java
@@ -38,7 +38,7 @@ public class GuiModListPanel extends Gui | @@ -38,7 +38,7 @@ public class GuiModListPanel extends Gui | ||
38 | static final int HANGER_COLOUR_MOUSEOVER = GuiModListPanel.WHITE; | 38 | static final int HANGER_COLOUR_MOUSEOVER = GuiModListPanel.WHITE; |
39 | 39 | ||
40 | static final int PANEL_HEIGHT = 32; | 40 | static final int PANEL_HEIGHT = 32; |
41 | - static final int PANEL_SPACING = 4; | 41 | + static final int PANEL_SPACING = 3; |
42 | 42 | ||
43 | private ModListEntry owner; | 43 | private ModListEntry owner; |
44 | 44 | ||
@@ -75,6 +75,18 @@ public class GuiModListPanel extends Gui | @@ -75,6 +75,18 @@ public class GuiModListPanel extends Gui | ||
75 | decorator.addIcons(modInfo, this.modIcons); | 75 | decorator.addIcons(modInfo, this.modIcons); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | + | ||
79 | + public void draw(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected, int pass) | ||
80 | + { | ||
81 | + if (pass == 0) | ||
82 | + { | ||
83 | + this.render(mouseX, mouseY, partialTicks, xPosition, yPosition, width, selected); | ||
84 | + } | ||
85 | + else if (pass == 1) | ||
86 | + { | ||
87 | + this.postRender(mouseX, mouseY, partialTicks, xPosition, yPosition, width, selected); | ||
88 | + } | ||
89 | + } | ||
78 | 90 | ||
79 | /** | 91 | /** |
80 | * Draw this list entry as a list item | 92 | * Draw this list entry as a list item |
@@ -86,9 +98,8 @@ public class GuiModListPanel extends Gui | @@ -86,9 +98,8 @@ public class GuiModListPanel extends Gui | ||
86 | * @param yPosition | 98 | * @param yPosition |
87 | * @param width | 99 | * @param width |
88 | * @param selected | 100 | * @param selected |
89 | - * @return calculated height of this panel, used by the list view to calculate spacing | ||
90 | */ | 101 | */ |
91 | - public int draw(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected) | 102 | + protected void render(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected) |
92 | { | 103 | { |
93 | int gradientColour = this.getGradientColour(selected); | 104 | int gradientColour = this.getGradientColour(selected); |
94 | int titleColour = this.getTitleColour(selected); | 105 | int titleColour = this.getTitleColour(selected); |
@@ -118,11 +129,9 @@ public class GuiModListPanel extends Gui | @@ -118,11 +129,9 @@ public class GuiModListPanel extends Gui | ||
118 | { | 129 | { |
119 | decorator.onDrawListEntry(mouseX, mouseY, partialTicks, xPosition, yPosition, width, GuiModListPanel.PANEL_HEIGHT, selected, this.modInfo, gradientColour, titleColour, statusColour); | 130 | decorator.onDrawListEntry(mouseX, mouseY, partialTicks, xPosition, yPosition, width, GuiModListPanel.PANEL_HEIGHT, selected, this.modInfo, gradientColour, titleColour, statusColour); |
120 | } | 131 | } |
121 | - | ||
122 | - return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING; | ||
123 | } | 132 | } |
124 | - | ||
125 | - public int postRender(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected) | 133 | + |
134 | + protected void postRender(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected) | ||
126 | { | 135 | { |
127 | xPosition += (width - 14); | 136 | xPosition += (width - 14); |
128 | yPosition += (GuiModListPanel.PANEL_HEIGHT - 14); | 137 | yPosition += (GuiModListPanel.PANEL_HEIGHT - 14); |
@@ -133,8 +142,6 @@ public class GuiModListPanel extends Gui | @@ -133,8 +142,6 @@ public class GuiModListPanel extends Gui | ||
133 | { | 142 | { |
134 | xPosition = this.drawPropertyIcon(xPosition, yPosition, icon, mouseX, mouseY); | 143 | xPosition = this.drawPropertyIcon(xPosition, yPosition, icon, mouseX, mouseY); |
135 | } | 144 | } |
136 | - | ||
137 | - return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING; | ||
138 | } | 145 | } |
139 | 146 | ||
140 | protected int drawPropertyIcon(int xPosition, int yPosition, IconTextured icon, int mouseX, int mouseY) | 147 | protected int drawPropertyIcon(int xPosition, int yPosition, IconTextured icon, int mouseX, int mouseY) |
@@ -190,8 +197,23 @@ public class GuiModListPanel extends Gui | @@ -190,8 +197,23 @@ public class GuiModListPanel extends Gui | ||
190 | return this.owner.isExternal() ? GuiModListPanel.EXTERNAL_ENTRY_COLOUR : this.brandColour; | 197 | return this.owner.isExternal() ? GuiModListPanel.EXTERNAL_ENTRY_COLOUR : this.brandColour; |
191 | } | 198 | } |
192 | 199 | ||
200 | + public boolean isVisible() | ||
201 | + { | ||
202 | + return true; | ||
203 | + } | ||
204 | + | ||
205 | + public int getSpacing() | ||
206 | + { | ||
207 | + return GuiModListPanel.PANEL_SPACING; | ||
208 | + } | ||
209 | + | ||
193 | public int getHeight() | 210 | public int getHeight() |
194 | { | 211 | { |
212 | + return GuiModListPanel.PANEL_HEIGHT; | ||
213 | + } | ||
214 | + | ||
215 | + public int getTotalHeight() | ||
216 | + { | ||
195 | return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING; | 217 | return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING; |
196 | } | 218 | } |
197 | 219 |
java/client/com/mumfrey/liteloader/client/gui/GuiPanelMods.java
@@ -3,10 +3,7 @@ package com.mumfrey.liteloader.client.gui; | @@ -3,10 +3,7 @@ package com.mumfrey.liteloader.client.gui; | ||
3 | import static com.mumfrey.liteloader.gl.GL.*; | 3 | import static com.mumfrey.liteloader.gl.GL.*; |
4 | import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; | 4 | import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; |
5 | 5 | ||
6 | -import java.util.ArrayList; | ||
7 | import java.util.List; | 6 | import java.util.List; |
8 | -import java.util.Map; | ||
9 | -import java.util.TreeMap; | ||
10 | 7 | ||
11 | import net.minecraft.client.Minecraft; | 8 | import net.minecraft.client.Minecraft; |
12 | import net.minecraft.client.gui.GuiButton; | 9 | import net.minecraft.client.gui.GuiButton; |
@@ -17,9 +14,6 @@ import org.lwjgl.input.Keyboard; | @@ -17,9 +14,6 @@ import org.lwjgl.input.Keyboard; | ||
17 | import com.mumfrey.liteloader.LiteMod; | 14 | import com.mumfrey.liteloader.LiteMod; |
18 | import com.mumfrey.liteloader.api.ModInfoDecorator; | 15 | import com.mumfrey.liteloader.api.ModInfoDecorator; |
19 | import com.mumfrey.liteloader.core.LiteLoaderMods; | 16 | import com.mumfrey.liteloader.core.LiteLoaderMods; |
20 | -import com.mumfrey.liteloader.core.ModInfo; | ||
21 | -import com.mumfrey.liteloader.interfaces.Loadable; | ||
22 | -import com.mumfrey.liteloader.interfaces.LoadableMod; | ||
23 | import com.mumfrey.liteloader.launch.LoaderEnvironment; | 17 | import com.mumfrey.liteloader.launch.LoaderEnvironment; |
24 | import com.mumfrey.liteloader.modconfig.ConfigManager; | 18 | import com.mumfrey.liteloader.modconfig.ConfigManager; |
25 | import com.mumfrey.liteloader.modconfig.ConfigPanel; | 19 | import com.mumfrey.liteloader.modconfig.ConfigPanel; |
@@ -29,7 +23,7 @@ import com.mumfrey.liteloader.modconfig.ConfigPanel; | @@ -29,7 +23,7 @@ import com.mumfrey.liteloader.modconfig.ConfigPanel; | ||
29 | * | 23 | * |
30 | * @author Adam Mummery-Smith | 24 | * @author Adam Mummery-Smith |
31 | */ | 25 | */ |
32 | -public class GuiPanelMods extends GuiPanel | 26 | +public class GuiPanelMods extends GuiPanel implements ModListContainer |
33 | { | 27 | { |
34 | private static final int SCROLLBAR_WIDTH = 5; | 28 | private static final int SCROLLBAR_WIDTH = 5; |
35 | 29 | ||
@@ -40,17 +34,7 @@ public class GuiPanelMods extends GuiPanel | @@ -40,17 +34,7 @@ public class GuiPanelMods extends GuiPanel | ||
40 | /** | 34 | /** |
41 | * List of enumerated mods | 35 | * List of enumerated mods |
42 | */ | 36 | */ |
43 | - private List<ModListEntry> mods = new ArrayList<ModListEntry>(); | ||
44 | - | ||
45 | - /** | ||
46 | - * Currently selected mod | ||
47 | - */ | ||
48 | - private ModListEntry selectedMod = null; | ||
49 | - | ||
50 | - /** | ||
51 | - * Timer used to handle double-clicking on a mod | ||
52 | - */ | ||
53 | - private int doubleClickTime = 0; | 37 | + private ModList modList; |
54 | 38 | ||
55 | /** | 39 | /** |
56 | * Enable / disable button | 40 | * Enable / disable button |
@@ -72,57 +56,38 @@ public class GuiPanelMods extends GuiPanel | @@ -72,57 +56,38 @@ public class GuiPanelMods extends GuiPanel | ||
72 | */ | 56 | */ |
73 | private GuiSimpleScrollBar scrollBar = new GuiSimpleScrollBar(); | 57 | private GuiSimpleScrollBar scrollBar = new GuiSimpleScrollBar(); |
74 | 58 | ||
75 | - private int brandColour; | ||
76 | - | ||
77 | public GuiPanelMods(GuiLiteLoaderPanel parentScreen, Minecraft minecraft, LiteLoaderMods mods, LoaderEnvironment environment, ConfigManager configManager, int brandColour, List<ModInfoDecorator> decorators) | 59 | public GuiPanelMods(GuiLiteLoaderPanel parentScreen, Minecraft minecraft, LiteLoaderMods mods, LoaderEnvironment environment, ConfigManager configManager, int brandColour, List<ModInfoDecorator> decorators) |
78 | { | 60 | { |
79 | super(minecraft); | 61 | super(minecraft); |
80 | 62 | ||
81 | this.parentScreen = parentScreen; | 63 | this.parentScreen = parentScreen; |
82 | this.configManager = configManager; | 64 | this.configManager = configManager; |
83 | - this.brandColour = brandColour; | ||
84 | 65 | ||
85 | - this.populateModList(mods, environment, decorators); | 66 | + this.modList = new ModList(this, minecraft, mods, environment, configManager, brandColour, decorators); |
86 | } | 67 | } |
87 | 68 | ||
88 | - /** | ||
89 | - * Populate the mods list | ||
90 | - * | ||
91 | - * @param mods | ||
92 | - * @param environment | ||
93 | - */ | ||
94 | - private void populateModList(LiteLoaderMods mods, LoaderEnvironment environment, List<ModInfoDecorator> decorators) | 69 | + @Override |
70 | + public GuiLiteLoaderPanel getParentScreen() | ||
95 | { | 71 | { |
96 | - // Add mods to this treeset first, in order to sort them | ||
97 | - Map<String, ModListEntry> sortedMods = new TreeMap<String, ModListEntry>(); | ||
98 | - | ||
99 | - // Active mods | ||
100 | - for (ModInfo<LoadableMod<?>> mod : mods.getLoadedMods()) | ||
101 | - { | ||
102 | - ModListEntry modListEntry = new ModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, mod); | ||
103 | - sortedMods.put(modListEntry.getKey(), modListEntry); | ||
104 | - } | ||
105 | - | ||
106 | - // Disabled mods | ||
107 | - for (ModInfo<?> disabledMod : mods.getDisabledMods()) | ||
108 | - { | ||
109 | - ModListEntry modListEntry = new ModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, disabledMod); | ||
110 | - sortedMods.put(modListEntry.getKey(), modListEntry); | ||
111 | - } | ||
112 | - | ||
113 | - // Injected tweaks | ||
114 | - for (ModInfo<Loadable<?>> injectedTweak : mods.getInjectedTweaks()) | ||
115 | - { | ||
116 | - ModListEntry modListEntry = new ModListEntry(mods, environment, this.mc.fontRendererObj, this.brandColour, decorators, injectedTweak); | ||
117 | - sortedMods.put(modListEntry.getKey(), modListEntry); | ||
118 | - } | ||
119 | - | ||
120 | - // Add the sorted mods to the mods list | ||
121 | - this.mods.addAll(sortedMods.values()); | ||
122 | - | ||
123 | - // Select the first mod in the list | ||
124 | - if (this.mods.size() > 0) | ||
125 | - this.selectedMod = this.mods.get(0); | 72 | + return this.parentScreen; |
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public void setConfigButtonVisible(boolean visible) | ||
77 | + { | ||
78 | + this.btnConfig.visible = visible; | ||
79 | + } | ||
80 | + | ||
81 | + @Override | ||
82 | + public void setEnableButtonVisible(boolean visible) | ||
83 | + { | ||
84 | + this.btnToggle.visible = visible; | ||
85 | + } | ||
86 | + | ||
87 | + @Override | ||
88 | + public void setEnableButtonText(String displayString) | ||
89 | + { | ||
90 | + this.btnToggle.displayString = displayString; | ||
126 | } | 91 | } |
127 | 92 | ||
128 | @Override | 93 | @Override |
@@ -141,15 +106,14 @@ public class GuiPanelMods extends GuiPanel | @@ -141,15 +106,14 @@ public class GuiPanelMods extends GuiPanel | ||
141 | this.controls.clear(); | 106 | this.controls.clear(); |
142 | this.controls.add(this.btnToggle = new GuiButton(0, rightPanelLeftEdge, this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - 24, 90, 20, I18n.format("gui.enablemod"))); | 107 | this.controls.add(this.btnToggle = new GuiButton(0, rightPanelLeftEdge, this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - 24, 90, 20, I18n.format("gui.enablemod"))); |
143 | this.controls.add(this.btnConfig = new GuiButton(1, rightPanelLeftEdge + 92, this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - 24, 69, 20, I18n.format("gui.modsettings"))); | 108 | this.controls.add(this.btnConfig = new GuiButton(1, rightPanelLeftEdge + 92, this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - 24, 69, 20, I18n.format("gui.modsettings"))); |
144 | - | ||
145 | - this.selectMod(this.selectedMod); | 109 | + |
110 | + this.modList.setSize(width, height); | ||
146 | } | 111 | } |
147 | 112 | ||
148 | @Override | 113 | @Override |
149 | void onTick() | 114 | void onTick() |
150 | { | 115 | { |
151 | - if (this.doubleClickTime > 0) | ||
152 | - this.doubleClickTime--; | 116 | + this.modList.onTick(); |
153 | } | 117 | } |
154 | 118 | ||
155 | @Override | 119 | @Override |
@@ -174,35 +138,7 @@ public class GuiPanelMods extends GuiPanel | @@ -174,35 +138,7 @@ public class GuiPanelMods extends GuiPanel | ||
174 | 138 | ||
175 | if (mouseY > GuiLiteLoaderPanel.PANEL_TOP && mouseY < this.height - GuiLiteLoaderPanel.PANEL_BOTTOM) | 139 | if (mouseY > GuiLiteLoaderPanel.PANEL_TOP && mouseY < this.height - GuiLiteLoaderPanel.PANEL_BOTTOM) |
176 | { | 140 | { |
177 | - ModListEntry lastSelectedMod = this.selectedMod; | ||
178 | - | ||
179 | - for (ModListEntry mod : this.mods) | ||
180 | - { | ||
181 | - if (mod.getListPanel().isMouseOver()) | ||
182 | - { | ||
183 | - this.selectMod(mod); | ||
184 | - | ||
185 | - if (mod.getListPanel().isMouseOverIcon()) | ||
186 | - { | ||
187 | - mod.getListPanel().iconClick(this.parentScreen); | ||
188 | - } | ||
189 | - else | ||
190 | - { | ||
191 | - // handle double-click | ||
192 | - if (mod == lastSelectedMod && this.doubleClickTime > 0 && this.btnConfig.visible) | ||
193 | - { | ||
194 | - this.actionPerformed(this.btnConfig); | ||
195 | - } | ||
196 | - } | ||
197 | - | ||
198 | - this.doubleClickTime = 5; | ||
199 | - } | ||
200 | - } | ||
201 | - | ||
202 | - if (this.selectedMod != null && this.selectedMod == lastSelectedMod) | ||
203 | - { | ||
204 | - this.selectedMod.getInfoPanel().mousePressed(); | ||
205 | - } | 141 | + this.modList.mousePressed(mouseX, mouseY, mouseButton); |
206 | } | 142 | } |
207 | } | 143 | } |
208 | 144 | ||
@@ -217,21 +153,9 @@ public class GuiPanelMods extends GuiPanel | @@ -217,21 +153,9 @@ public class GuiPanelMods extends GuiPanel | ||
217 | this.parentScreen.onToggled(); | 153 | this.parentScreen.onToggled(); |
218 | return; | 154 | return; |
219 | } | 155 | } |
220 | - else if (keyCode == Keyboard.KEY_UP) | ||
221 | - { | ||
222 | - int selectedIndex = this.mods.indexOf(this.selectedMod) - 1; | ||
223 | - if (selectedIndex > -1) this.selectMod(this.mods.get(selectedIndex)); | ||
224 | - this.scrollSelectedModIntoView(); | ||
225 | - } | ||
226 | - else if (keyCode == Keyboard.KEY_DOWN) | ||
227 | - { | ||
228 | - int selectedIndex = this.mods.indexOf(this.selectedMod); | ||
229 | - if (selectedIndex > -1 && selectedIndex < this.mods.size() - 1) this.selectMod(this.mods.get(selectedIndex + 1)); | ||
230 | - this.scrollSelectedModIntoView(); | ||
231 | - } | ||
232 | - else if (keyCode == Keyboard.KEY_SPACE || keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER || keyCode == Keyboard.KEY_RIGHT) | 156 | + else if (this.modList.keyPressed(keyChar, keyCode)) |
233 | { | 157 | { |
234 | - this.toggleSelectedMod(); | 158 | + // Suppress further handling |
235 | } | 159 | } |
236 | else if (keyCode == Keyboard.KEY_F3) | 160 | else if (keyCode == Keyboard.KEY_F3) |
237 | { | 161 | { |
@@ -254,37 +178,41 @@ public class GuiPanelMods extends GuiPanel | @@ -254,37 +178,41 @@ public class GuiPanelMods extends GuiPanel | ||
254 | if (mouseButton == 0) | 178 | if (mouseButton == 0) |
255 | { | 179 | { |
256 | this.scrollBar.setDragging(false); | 180 | this.scrollBar.setDragging(false); |
257 | - | ||
258 | - if (this.selectedMod != null) | ||
259 | - { | ||
260 | - this.selectedMod.getInfoPanel().mouseReleased(); | ||
261 | - } | 181 | + this.modList.mouseReleased(mouseX, mouseY, mouseButton); |
262 | } | 182 | } |
263 | } | 183 | } |
264 | 184 | ||
265 | @Override | 185 | @Override |
266 | void mouseWheelScrolled(int mouseWheelDelta) | 186 | void mouseWheelScrolled(int mouseWheelDelta) |
267 | { | 187 | { |
268 | - if (this.selectedMod == null || !this.selectedMod.getInfoPanel().mouseWheelScrolled(mouseWheelDelta)) | 188 | + if (!this.modList.mouseWheelScrolled(mouseWheelDelta)) |
269 | { | 189 | { |
270 | this.scrollBar.offsetValue(-mouseWheelDelta / 8); | 190 | this.scrollBar.offsetValue(-mouseWheelDelta / 8); |
271 | } | 191 | } |
272 | } | 192 | } |
273 | 193 | ||
274 | @Override | 194 | @Override |
195 | + public void showConfig() | ||
196 | + { | ||
197 | + this.actionPerformed(this.btnConfig); | ||
198 | + } | ||
199 | + | ||
200 | + @Override | ||
275 | void actionPerformed(GuiButton control) | 201 | void actionPerformed(GuiButton control) |
276 | { | 202 | { |
277 | if (control.id == 0) | 203 | if (control.id == 0) |
278 | { | 204 | { |
279 | - this.toggleSelectedMod(); | 205 | + this.modList.toggleSelectedMod(); |
280 | } | 206 | } |
281 | 207 | ||
282 | if (control.id == 1) | 208 | if (control.id == 1) |
283 | { | 209 | { |
284 | - if (this.selectedMod != null && this.selectedMod.getModClass() != null) | 210 | + Class<? extends LiteMod> modClass = this.modList.getSelectedModClass(); |
211 | + | ||
212 | + if (modClass != null) | ||
285 | { | 213 | { |
286 | - ConfigPanel panel = this.configManager.getPanel(this.selectedMod.getModClass()); | ||
287 | - LiteMod mod = this.selectedMod.getModInstance(); | 214 | + ConfigPanel panel = this.configManager.getPanel(modClass); |
215 | + LiteMod mod = this.modList.getSelectedModInstance(); | ||
288 | this.parentScreen.openConfigPanel(panel, mod); | 216 | this.parentScreen.openConfigPanel(panel, mod); |
289 | } | 217 | } |
290 | } | 218 | } |
@@ -298,9 +226,17 @@ public class GuiPanelMods extends GuiPanel | @@ -298,9 +226,17 @@ public class GuiPanelMods extends GuiPanel | ||
298 | int innerWidth = this.width - MARGIN - MARGIN - 4; | 226 | int innerWidth = this.width - MARGIN - MARGIN - 4; |
299 | int panelWidth = innerWidth / 2; | 227 | int panelWidth = innerWidth / 2; |
300 | int panelHeight = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - GuiLiteLoaderPanel.PANEL_TOP; | 228 | int panelHeight = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - GuiLiteLoaderPanel.PANEL_TOP; |
301 | - | 229 | + |
302 | this.drawModsList(mouseX, mouseY, partialTicks, panelWidth, panelHeight); | 230 | this.drawModsList(mouseX, mouseY, partialTicks, panelWidth, panelHeight); |
303 | - this.drawSelectedMod(mouseX, mouseY, partialTicks, panelWidth, panelHeight); | 231 | + |
232 | + int left = MARGIN + panelWidth; | ||
233 | + int top = GuiLiteLoaderPanel.PANEL_TOP; | ||
234 | + int spaceForButtons = (this.btnConfig.visible || this.btnToggle.visible ? 28 : 0); | ||
235 | + int bottom = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - spaceForButtons; | ||
236 | + | ||
237 | + glEnableClipping(left, this.width - MARGIN, top, bottom); | ||
238 | + this.modList.drawModPanel(mouseX, mouseY, partialTicks, left, top, this.width - MARGIN - left, panelHeight - spaceForButtons); | ||
239 | + glDisableClipping(); | ||
304 | 240 | ||
305 | super.draw(mouseX, mouseY, partialTicks); | 241 | super.draw(mouseX, mouseY, partialTicks); |
306 | } | 242 | } |
@@ -324,108 +260,30 @@ public class GuiPanelMods extends GuiPanel | @@ -324,108 +260,30 @@ public class GuiPanelMods extends GuiPanel | ||
324 | glTranslatef(0.0F, GuiLiteLoaderPanel.PANEL_TOP - this.scrollBar.getValue(), 0.0F); | 260 | glTranslatef(0.0F, GuiLiteLoaderPanel.PANEL_TOP - this.scrollBar.getValue(), 0.0F); |
325 | 261 | ||
326 | mouseY -= (GuiLiteLoaderPanel.PANEL_TOP - this.scrollBar.getValue()); | 262 | mouseY -= (GuiLiteLoaderPanel.PANEL_TOP - this.scrollBar.getValue()); |
327 | - | ||
328 | - int yPos = 0; | ||
329 | - for (ModListEntry mod : this.mods) | ||
330 | - { | ||
331 | - // drawListEntry returns a value indicating the height of the item drawn | ||
332 | - yPos += mod.getListPanel().draw(mouseX, mouseY, partialTicks, MARGIN, yPos, width - 6, mod == this.selectedMod); | ||
333 | - } | ||
334 | - | ||
335 | - yPos = 0; | ||
336 | - for (ModListEntry mod : this.mods) | ||
337 | - { | ||
338 | - yPos += mod.getListPanel().postRender(mouseX, mouseY, partialTicks, MARGIN, yPos, width - 6, mod == this.selectedMod); | ||
339 | - } | 263 | + |
264 | + this.listHeight = this.modList.drawModList(mouseX, mouseY, partialTicks, MARGIN, 0, width - SCROLLBAR_WIDTH - 1, height); | ||
265 | + this.scrollBar.setMaxValue(this.listHeight - height); | ||
340 | 266 | ||
341 | glPopMatrix(); | 267 | glPopMatrix(); |
342 | glDisableClipping(); | 268 | glDisableClipping(); |
343 | - | ||
344 | - this.listHeight = yPos; | ||
345 | - this.scrollBar.setMaxValue(this.listHeight - height); | ||
346 | - } | ||
347 | - | ||
348 | - /** | ||
349 | - * @param mouseX | ||
350 | - * @param mouseY | ||
351 | - * @param partialTicks | ||
352 | - * @param width | ||
353 | - * @param height | ||
354 | - */ | ||
355 | - private void drawSelectedMod(int mouseX, int mouseY, float partialTicks, int width, int height) | ||
356 | - { | ||
357 | - if (this.selectedMod != null) | ||
358 | - { | ||
359 | - int left = MARGIN + width; | ||
360 | - int right = this.width - MARGIN; | ||
361 | - | ||
362 | - int spaceForButtons = this.btnConfig.visible || this.btnToggle.visible ? 28 : 0; | ||
363 | - glEnableClipping(left, right, GuiLiteLoaderPanel.PANEL_TOP, this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - spaceForButtons); | ||
364 | - this.selectedMod.getInfoPanel().draw(mouseX, mouseY, partialTicks, left, GuiLiteLoaderPanel.PANEL_TOP, right - left, height - spaceForButtons); | ||
365 | - glDisableClipping(); | ||
366 | - } | ||
367 | - } | ||
368 | - | ||
369 | - /** | ||
370 | - * @param mod Mod list entry to select | ||
371 | - */ | ||
372 | - private void selectMod(ModListEntry mod) | ||
373 | - { | ||
374 | - if (this.selectedMod != null) | ||
375 | - { | ||
376 | - this.selectedMod.getInfoPanel().mouseReleased(); | ||
377 | - } | ||
378 | - | ||
379 | - this.selectedMod = mod; | ||
380 | - this.btnToggle.visible = false; | ||
381 | - this.btnConfig.visible = false; | ||
382 | - | ||
383 | - if (this.selectedMod != null && this.selectedMod.canBeToggled()) | ||
384 | - { | ||
385 | - this.btnToggle.visible = true; | ||
386 | - this.btnToggle.displayString = this.selectedMod.willBeEnabled() ? I18n.format("gui.disablemod") : I18n.format("gui.enablemod"); | ||
387 | - | ||
388 | - this.btnConfig.visible = this.configManager.hasPanel(this.selectedMod.getModClass()); | ||
389 | - } | ||
390 | } | 269 | } |
391 | - | ||
392 | - /** | ||
393 | - * Toggle the selected mod's enabled status | ||
394 | - */ | ||
395 | - private void toggleSelectedMod() | ||
396 | - { | ||
397 | - if (this.selectedMod != null) | ||
398 | - { | ||
399 | - this.selectedMod.toggleEnabled(); | ||
400 | - this.selectMod(this.selectedMod); | ||
401 | - } | ||
402 | - } | ||
403 | - | ||
404 | - private void scrollSelectedModIntoView() | 270 | + |
271 | + @Override | ||
272 | + public void scrollTo(int yPosTop, int yPosBottom) | ||
405 | { | 273 | { |
406 | - if (this.selectedMod == null) return; | ||
407 | - | ||
408 | - int yPos = 0; | ||
409 | - for (ModListEntry mod : this.mods) | ||
410 | - { | ||
411 | - if (mod == this.selectedMod) break; | ||
412 | - yPos += mod.getListPanel().getHeight(); | ||
413 | - } | ||
414 | - | ||
415 | // Mod is above the top of the visible window | 274 | // Mod is above the top of the visible window |
416 | - if (yPos < this.scrollBar.getValue()) | 275 | + if (yPosTop < this.scrollBar.getValue()) |
417 | { | 276 | { |
418 | - this.scrollBar.setValue(yPos); | 277 | + this.scrollBar.setValue(yPosTop); |
419 | return; | 278 | return; |
420 | } | 279 | } |
421 | 280 | ||
422 | int panelHeight = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - GuiLiteLoaderPanel.PANEL_TOP; | 281 | int panelHeight = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - GuiLiteLoaderPanel.PANEL_TOP; |
423 | - int modHeight = this.selectedMod.getListPanel().getHeight(); | ||
424 | 282 | ||
425 | // Mod is below the bottom of the visible window | 283 | // Mod is below the bottom of the visible window |
426 | - if (yPos - this.scrollBar.getValue() + modHeight > panelHeight) | 284 | + if (yPosBottom - this.scrollBar.getValue() > panelHeight) |
427 | { | 285 | { |
428 | - this.scrollBar.setValue(yPos - panelHeight + modHeight); | 286 | + this.scrollBar.setValue(yPosBottom - panelHeight); |
429 | } | 287 | } |
430 | } | 288 | } |
431 | } | 289 | } |
java/client/com/mumfrey/liteloader/client/gui/ModList.java
0 โ 100644
1 | +package com.mumfrey.liteloader.client.gui; | ||
2 | + | ||
3 | +import java.util.ArrayList; | ||
4 | +import java.util.List; | ||
5 | +import java.util.Map; | ||
6 | +import java.util.TreeMap; | ||
7 | + | ||
8 | +import net.minecraft.client.Minecraft; | ||
9 | +import net.minecraft.client.resources.I18n; | ||
10 | + | ||
11 | +import org.lwjgl.input.Keyboard; | ||
12 | + | ||
13 | +import com.mumfrey.liteloader.LiteMod; | ||
14 | +import com.mumfrey.liteloader.api.ModInfoDecorator; | ||
15 | +import com.mumfrey.liteloader.core.LiteLoaderMods; | ||
16 | +import com.mumfrey.liteloader.core.ModInfo; | ||
17 | +import com.mumfrey.liteloader.interfaces.Loadable; | ||
18 | +import com.mumfrey.liteloader.interfaces.LoadableMod; | ||
19 | +import com.mumfrey.liteloader.launch.LoaderEnvironment; | ||
20 | +import com.mumfrey.liteloader.modconfig.ConfigManager; | ||
21 | + | ||
22 | +public class ModList | ||
23 | +{ | ||
24 | + private final ModListContainer container; | ||
25 | + | ||
26 | + private final ConfigManager configManager; | ||
27 | + | ||
28 | + /** | ||
29 | + * List of enumerated mods | ||
30 | + */ | ||
31 | + private final List<ModListEntry> mods = new ArrayList<ModListEntry>(); | ||
32 | + | ||
33 | + /** | ||
34 | + * Currently selected mod | ||
35 | + */ | ||
36 | + private ModListEntry selectedMod = null; | ||
37 | + | ||
38 | + private boolean hasConfig = false; | ||
39 | + | ||
40 | + public ModList(ModListContainer container, Minecraft minecraft, LiteLoaderMods mods, LoaderEnvironment environment, ConfigManager configManager, int brandColour, List<ModInfoDecorator> decorators) | ||
41 | + { | ||
42 | + this.container = container; | ||
43 | + this.configManager = configManager; | ||
44 | + | ||
45 | + this.populate(minecraft, mods, environment, brandColour, decorators); | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * @param minecraft | ||
50 | + * @param mods | ||
51 | + * @param environment | ||
52 | + * @param brandColour | ||
53 | + * @param decorators | ||
54 | + */ | ||
55 | + protected void populate(Minecraft minecraft, LiteLoaderMods mods, LoaderEnvironment environment, int brandColour, List<ModInfoDecorator> decorators) | ||
56 | + { | ||
57 | + // Add mods to this treeset first, in order to sort them | ||
58 | + Map<String, ModListEntry> sortedMods = new TreeMap<String, ModListEntry>(); | ||
59 | + | ||
60 | + // Active mods | ||
61 | + for (ModInfo<LoadableMod<?>> mod : mods.getLoadedMods()) | ||
62 | + { | ||
63 | + ModListEntry modListEntry = new ModListEntry(this, mods, environment, minecraft.fontRendererObj, brandColour, decorators, mod); | ||
64 | + sortedMods.put(modListEntry.getKey(), modListEntry); | ||
65 | + } | ||
66 | + | ||
67 | + // Disabled mods | ||
68 | + for (ModInfo<?> disabledMod : mods.getDisabledMods()) | ||
69 | + { | ||
70 | + ModListEntry modListEntry = new ModListEntry(this, mods, environment, minecraft.fontRendererObj, brandColour, decorators, disabledMod); | ||
71 | + sortedMods.put(modListEntry.getKey(), modListEntry); | ||
72 | + } | ||
73 | + | ||
74 | + // Injected tweaks | ||
75 | + for (ModInfo<Loadable<?>> injectedTweak : mods.getInjectedTweaks()) | ||
76 | + { | ||
77 | + ModListEntry modListEntry = new ModListEntry(this, mods, environment, minecraft.fontRendererObj, brandColour, decorators, injectedTweak); | ||
78 | + sortedMods.put(modListEntry.getKey(), modListEntry); | ||
79 | + } | ||
80 | + | ||
81 | + // Add the sorted mods to the mods list | ||
82 | + this.mods.addAll(sortedMods.values()); | ||
83 | + | ||
84 | + // Select the first mod in the list | ||
85 | + if (this.mods.size() > 0) | ||
86 | + this.selectedMod = this.mods.get(0); | ||
87 | + } | ||
88 | + | ||
89 | + public GuiLiteLoaderPanel getParentScreen() | ||
90 | + { | ||
91 | + return this.container.getParentScreen(); | ||
92 | + } | ||
93 | + | ||
94 | + public LiteMod getSelectedModInstance() | ||
95 | + { | ||
96 | + return this.selectedMod != null ? this.selectedMod.getModInstance() : null; | ||
97 | + } | ||
98 | + | ||
99 | + public Class<? extends LiteMod> getSelectedModClass() | ||
100 | + { | ||
101 | + return this.selectedMod != null ? this.selectedMod.getModClass() : null; | ||
102 | + } | ||
103 | + | ||
104 | + public void setSize(int width, int height) | ||
105 | + { | ||
106 | + this.selectMod(this.selectedMod); | ||
107 | + } | ||
108 | + | ||
109 | + public void onTick() | ||
110 | + { | ||
111 | + for (ModListEntry mod : this.mods) | ||
112 | + { | ||
113 | + mod.onTick(); | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | + public void mousePressed(int mouseX, int mouseY, int mouseButton) | ||
118 | + { | ||
119 | + ModListEntry lastSelectedMod = this.selectedMod; | ||
120 | + | ||
121 | + for (ModListEntry mod : this.mods) | ||
122 | + { | ||
123 | + mod.mousePressed(mouseX, mouseY, mouseButton); | ||
124 | + } | ||
125 | + | ||
126 | + if (this.selectedMod != null && this.selectedMod == lastSelectedMod) | ||
127 | + { | ||
128 | + this.selectedMod.getInfoPanel().mousePressed(); | ||
129 | + } | ||
130 | + } | ||
131 | + | ||
132 | + public boolean keyPressed(char keyChar, int keyCode) | ||
133 | + { | ||
134 | + if (keyCode == Keyboard.KEY_UP) | ||
135 | + { | ||
136 | + int selectedIndex = this.mods.indexOf(this.selectedMod) - 1; | ||
137 | + if (selectedIndex > -1) this.selectMod(this.mods.get(selectedIndex)); | ||
138 | + this.scrollSelectedModIntoView(); | ||
139 | + return true; | ||
140 | + } | ||
141 | + else if (keyCode == Keyboard.KEY_DOWN) | ||
142 | + { | ||
143 | + int selectedIndex = this.mods.indexOf(this.selectedMod); | ||
144 | + if (selectedIndex > -1 && selectedIndex < this.mods.size() - 1) this.selectMod(this.mods.get(selectedIndex + 1)); | ||
145 | + this.scrollSelectedModIntoView(); | ||
146 | + return true; | ||
147 | + } | ||
148 | + else if (keyCode == Keyboard.KEY_SPACE || keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER || keyCode == Keyboard.KEY_RIGHT) | ||
149 | + { | ||
150 | + this.toggleSelectedMod(); | ||
151 | + return true; | ||
152 | + } | ||
153 | + | ||
154 | + return false; | ||
155 | + } | ||
156 | + | ||
157 | + public void mouseReleased(int mouseX, int mouseY, int mouseButton) | ||
158 | + { | ||
159 | + if (this.selectedMod != null) | ||
160 | + { | ||
161 | + this.selectedMod.getInfoPanel().mouseReleased(); | ||
162 | + } | ||
163 | + } | ||
164 | + | ||
165 | + public boolean mouseWheelScrolled(int mouseWheelDelta) | ||
166 | + { | ||
167 | + return this.selectedMod != null && this.selectedMod.getInfoPanel().mouseWheelScrolled(mouseWheelDelta); | ||
168 | + } | ||
169 | + | ||
170 | + public int drawModList(int mouseX, int mouseY, float partialTicks, int left, int top, int width, int height) | ||
171 | + { | ||
172 | + this.drawModListPass(mouseX, mouseY, partialTicks, left, top, width, 0); | ||
173 | + return this.drawModListPass(mouseX, mouseY, partialTicks, left, top, width, 1); | ||
174 | + } | ||
175 | + | ||
176 | + protected int drawModListPass(int mouseX, int mouseY, float partialTicks, int left, int top, int width, int pass) | ||
177 | + { | ||
178 | + int yPos = top; | ||
179 | + for (ModListEntry mod : this.mods) | ||
180 | + { | ||
181 | + GuiModListPanel panel = mod.getListPanel(); | ||
182 | + if (panel.isVisible()) | ||
183 | + { | ||
184 | + if (yPos > 0) yPos += panel.getSpacing(); | ||
185 | + panel.draw(mouseX, mouseY, partialTicks, left, yPos, width, mod == this.selectedMod, pass); | ||
186 | + yPos += panel.getHeight(); | ||
187 | + } | ||
188 | + } | ||
189 | + return yPos; | ||
190 | + } | ||
191 | + | ||
192 | + public void drawModPanel(int mouseX, int mouseY, float partialTicks, int left, int top, int width, int height) | ||
193 | + { | ||
194 | + if (this.selectedMod != null) | ||
195 | + { | ||
196 | + this.selectedMod.getInfoPanel().draw(mouseX, mouseY, partialTicks, left, top, width, height); | ||
197 | + } | ||
198 | + } | ||
199 | + | ||
200 | + /** | ||
201 | + * @param mod Mod list entry to select | ||
202 | + */ | ||
203 | + void selectMod(ModListEntry mod) | ||
204 | + { | ||
205 | + if (this.selectedMod != null) | ||
206 | + { | ||
207 | + this.selectedMod.getInfoPanel().mouseReleased(); | ||
208 | + } | ||
209 | + | ||
210 | + this.selectedMod = mod; | ||
211 | + this.hasConfig = false; | ||
212 | + this.container.setEnableButtonVisible(false); | ||
213 | + this.container.setConfigButtonVisible(false); | ||
214 | + | ||
215 | + if (this.selectedMod != null && this.selectedMod.canBeToggled()) | ||
216 | + { | ||
217 | + this.container.setEnableButtonVisible(true); | ||
218 | + this.container.setEnableButtonText(this.selectedMod.willBeEnabled() ? I18n.format("gui.disablemod") : I18n.format("gui.enablemod")); | ||
219 | + this.hasConfig = this.configManager.hasPanel(this.selectedMod.getModClass()); | ||
220 | + this.container.setConfigButtonVisible(this.hasConfig); | ||
221 | + } | ||
222 | + } | ||
223 | + | ||
224 | + /** | ||
225 | + * Toggle the selected mod's enabled status | ||
226 | + */ | ||
227 | + public void toggleSelectedMod() | ||
228 | + { | ||
229 | + if (this.selectedMod != null) | ||
230 | + { | ||
231 | + this.selectedMod.toggleEnabled(); | ||
232 | + this.selectMod(this.selectedMod); | ||
233 | + } | ||
234 | + } | ||
235 | + | ||
236 | + private void scrollSelectedModIntoView() | ||
237 | + { | ||
238 | + if (this.selectedMod == null) return; | ||
239 | + | ||
240 | + int yPos = 0; | ||
241 | + for (ModListEntry mod : this.mods) | ||
242 | + { | ||
243 | + if (mod == this.selectedMod) break; | ||
244 | + yPos += mod.getListPanel().getTotalHeight(); | ||
245 | + } | ||
246 | + | ||
247 | + int modHeight = this.selectedMod.getListPanel().getTotalHeight(); | ||
248 | + this.container.scrollTo(yPos, yPos + modHeight); | ||
249 | + } | ||
250 | + | ||
251 | + public void showConfig(ModListEntry modListEntry) | ||
252 | + { | ||
253 | + this.container.showConfig(); | ||
254 | + } | ||
255 | +} |
java/client/com/mumfrey/liteloader/client/gui/ModListContainer.java
0 โ 100644
1 | +package com.mumfrey.liteloader.client.gui; | ||
2 | + | ||
3 | +public interface ModListContainer | ||
4 | +{ | ||
5 | + public abstract GuiLiteLoaderPanel getParentScreen(); | ||
6 | + | ||
7 | + public abstract void setEnableButtonVisible(boolean visible); | ||
8 | + | ||
9 | + public abstract void setConfigButtonVisible(boolean visible); | ||
10 | + | ||
11 | + public abstract void setEnableButtonText(String displayString); | ||
12 | + | ||
13 | + public abstract void showConfig(); | ||
14 | + | ||
15 | + public abstract void scrollTo(int yPos, int modHeight); | ||
16 | +} |
java/client/com/mumfrey/liteloader/client/gui/ModListEntry.java
@@ -22,13 +22,15 @@ import com.mumfrey.liteloader.launch.LoaderEnvironment; | @@ -22,13 +22,15 @@ import com.mumfrey.liteloader.launch.LoaderEnvironment; | ||
22 | */ | 22 | */ |
23 | public class ModListEntry | 23 | public class ModListEntry |
24 | { | 24 | { |
25 | + private final ModList modList; | ||
26 | + | ||
25 | private final LiteLoaderMods mods; | 27 | private final LiteLoaderMods mods; |
26 | 28 | ||
27 | private final ModInfo<?> modInfo; | 29 | private final ModInfo<?> modInfo; |
28 | 30 | ||
29 | - private final GuiModListPanel listPanel; | 31 | + private GuiModListPanel listPanel; |
30 | 32 | ||
31 | - private final GuiModInfoPanel infoPanel; | 33 | + private GuiModInfoPanel infoPanel; |
32 | 34 | ||
33 | /** | 35 | /** |
34 | * Whether the mod is currently active | 36 | * Whether the mod is currently active |
@@ -68,8 +70,12 @@ public class ModListEntry | @@ -68,8 +70,12 @@ public class ModListEntry | ||
68 | private boolean isExternal; | 70 | private boolean isExternal; |
69 | 71 | ||
70 | /** | 72 | /** |
71 | - * Mod list entry for an ACTIVE mod | ||
72 | - * | 73 | + * Timer used to handle double-clicking on a mod |
74 | + */ | ||
75 | + private int doubleClickTime = 0; | ||
76 | + | ||
77 | + /** | ||
78 | + * @param modList | ||
73 | * @param mods | 79 | * @param mods |
74 | * @param environment | 80 | * @param environment |
75 | * @param fontRenderer | 81 | * @param fontRenderer |
@@ -77,8 +83,9 @@ public class ModListEntry | @@ -77,8 +83,9 @@ public class ModListEntry | ||
77 | * @param decorators | 83 | * @param decorators |
78 | * @param modInfo | 84 | * @param modInfo |
79 | */ | 85 | */ |
80 | - ModListEntry(LiteLoaderMods mods, LoaderEnvironment environment, FontRenderer fontRenderer, int brandColour, List<ModInfoDecorator> decorators, ModInfo<?> modInfo) | 86 | + ModListEntry(ModList modList, LiteLoaderMods mods, LoaderEnvironment environment, FontRenderer fontRenderer, int brandColour, List<ModInfoDecorator> decorators, ModInfo<?> modInfo) |
81 | { | 87 | { |
88 | + this.modList = modList; | ||
82 | this.mods = mods; | 89 | this.mods = mods; |
83 | this.modInfo = modInfo; | 90 | this.modInfo = modInfo; |
84 | 91 | ||
@@ -104,10 +111,55 @@ public class ModListEntry | @@ -104,10 +111,55 @@ public class ModListEntry | ||
104 | } | 111 | } |
105 | } | 112 | } |
106 | 113 | ||
114 | + this.initPanels(fontRenderer, brandColour, decorators, modInfo); | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * @param fontRenderer | ||
119 | + * @param brandColour | ||
120 | + * @param decorators | ||
121 | + * @param modInfo | ||
122 | + */ | ||
123 | + protected void initPanels(FontRenderer fontRenderer, int brandColour, List<ModInfoDecorator> decorators, ModInfo<?> modInfo) | ||
124 | + { | ||
107 | this.infoPanel = new GuiModInfoPanel(this, fontRenderer, brandColour, modInfo); | 125 | this.infoPanel = new GuiModInfoPanel(this, fontRenderer, brandColour, modInfo); |
108 | this.listPanel = new GuiModListPanel(this, fontRenderer, brandColour, modInfo, decorators); | 126 | this.listPanel = new GuiModListPanel(this, fontRenderer, brandColour, modInfo, decorators); |
109 | } | 127 | } |
110 | - | 128 | + |
129 | + public void onTick() | ||
130 | + { | ||
131 | + if (this.doubleClickTime > 0) | ||
132 | + this.doubleClickTime--; | ||
133 | + } | ||
134 | + | ||
135 | + public void mousePressed(int mouseX, int mouseY, int mouseButton) | ||
136 | + { | ||
137 | + if (this.getListPanel().isMouseOver()) | ||
138 | + { | ||
139 | + this.modList.selectMod(this); | ||
140 | + | ||
141 | + if (this.getListPanel().isMouseOverIcon()) | ||
142 | + { | ||
143 | + this.getListPanel().iconClick(this.modList.getParentScreen()); | ||
144 | + } | ||
145 | + else | ||
146 | + { | ||
147 | + // handle double-click | ||
148 | + if (this.doubleClickTime > 0) | ||
149 | + { | ||
150 | + this.onDoubleClicked(); | ||
151 | + } | ||
152 | + } | ||
153 | + | ||
154 | + this.doubleClickTime = 5; | ||
155 | + } | ||
156 | + } | ||
157 | + | ||
158 | + protected void onDoubleClicked() | ||
159 | + { | ||
160 | + this.modList.showConfig(this); | ||
161 | + } | ||
162 | + | ||
111 | protected String getTitleText() | 163 | protected String getTitleText() |
112 | { | 164 | { |
113 | return this.modInfo.getDisplayName(); | 165 | return this.modInfo.getDisplayName(); |
@@ -163,6 +215,11 @@ public class ModListEntry | @@ -163,6 +215,11 @@ public class ModListEntry | ||
163 | return (this.isErrored ? "0000" : "") + this.modInfo.getIdentifier() + Integer.toHexString(this.hashCode()); | 215 | return (this.isErrored ? "0000" : "") + this.modInfo.getIdentifier() + Integer.toHexString(this.hashCode()); |
164 | } | 216 | } |
165 | 217 | ||
218 | + public ModInfo<?> getModInfo() | ||
219 | + { | ||
220 | + return this.modInfo; | ||
221 | + } | ||
222 | + | ||
166 | public LiteMod getModInstance() | 223 | public LiteMod getModInstance() |
167 | { | 224 | { |
168 | return this.modInfo.getMod(); | 225 | return this.modInfo.getMod(); |
java/common/com/mumfrey/liteloader/core/LiteLoaderMods.java
@@ -8,8 +8,6 @@ import java.util.List; | @@ -8,8 +8,6 @@ import java.util.List; | ||
8 | import java.util.Map; | 8 | import java.util.Map; |
9 | import java.util.Set; | 9 | import java.util.Set; |
10 | 10 | ||
11 | -import javax.activity.InvalidActivityException; | ||
12 | - | ||
13 | import net.minecraft.client.resources.IResourcePack; | 11 | import net.minecraft.client.resources.IResourcePack; |
14 | 12 | ||
15 | import com.mumfrey.liteloader.LiteMod; | 13 | import com.mumfrey.liteloader.LiteMod; |
@@ -268,10 +266,8 @@ public class LiteLoaderMods | @@ -268,10 +266,8 @@ public class LiteLoaderMods | ||
268 | * @param modNameOrId | 266 | * @param modNameOrId |
269 | * @param metaDataKey | 267 | * @param metaDataKey |
270 | * @param defaultValue | 268 | * @param defaultValue |
271 | - * @throws InvalidActivityException Thrown by getMod if init is not complete | ||
272 | - * @throws IllegalArgumentException Thrown by getMod if argument is null | ||
273 | */ | 269 | */ |
274 | - public String getModMetaData(String modNameOrId, String metaDataKey, String defaultValue) throws InvalidActivityException, IllegalArgumentException | 270 | + public String getModMetaData(String modNameOrId, String metaDataKey, String defaultValue) throws IllegalArgumentException |
275 | { | 271 | { |
276 | return this.getModMetaData(this.getMod(modNameOrId), metaDataKey, defaultValue); | 272 | return this.getModMetaData(this.getMod(modNameOrId), metaDataKey, defaultValue); |
277 | } | 273 | } |