Commit e01dd5f516a16a01fc088c54e7fb450d45184c3f
1 parent
53506bde
propagate event injection through to the mod list, and provide help screens for …
…tweak/transformer/event icons
Showing
13 changed files
with
219 additions
and
28 deletions
java/client/com/mumfrey/liteloader/client/api/LiteLoaderModInfoDecorator.java
@@ -6,6 +6,7 @@ import net.minecraft.client.resources.I18n; | @@ -6,6 +6,7 @@ import net.minecraft.client.resources.I18n; | ||
6 | 6 | ||
7 | import com.mumfrey.liteloader.api.ModInfoDecorator; | 7 | import com.mumfrey.liteloader.api.ModInfoDecorator; |
8 | import com.mumfrey.liteloader.client.gui.GuiLiteLoaderPanel; | 8 | import com.mumfrey.liteloader.client.gui.GuiLiteLoaderPanel; |
9 | +import com.mumfrey.liteloader.client.gui.modlist.GuiModListPanel; | ||
9 | import com.mumfrey.liteloader.client.util.render.IconAbsolute; | 10 | import com.mumfrey.liteloader.client.util.render.IconAbsolute; |
10 | import com.mumfrey.liteloader.client.util.render.IconAbsoluteClickable; | 11 | import com.mumfrey.liteloader.client.util.render.IconAbsoluteClickable; |
11 | import com.mumfrey.liteloader.core.ModInfo; | 12 | import com.mumfrey.liteloader.core.ModInfo; |
@@ -26,12 +27,44 @@ public class LiteLoaderModInfoDecorator implements ModInfoDecorator | @@ -26,12 +27,44 @@ public class LiteLoaderModInfoDecorator implements ModInfoDecorator | ||
26 | { | 27 | { |
27 | if (mod.hasTweakClass()) | 28 | if (mod.hasTweakClass()) |
28 | { | 29 | { |
29 | - icons.add(new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, I18n.format("gui.mod.providestweak"), 12, 12, 158, 80, 170, 92)); | 30 | + icons.add(new IconAbsoluteClickable(LiteLoaderBrandingProvider.ABOUT_TEXTURE, I18n.format("gui.mod.providestweak"), 12, 12, 158, 80, 170, 92){ |
31 | + @Override | ||
32 | + public void onClicked(Object source, Object container) | ||
33 | + { | ||
34 | + if (container instanceof GuiModListPanel) | ||
35 | + { | ||
36 | + ((GuiModListPanel)container).displayModHelpMessage(mod, "gui.mod.providestweak", "gui.mod.help.tweak"); | ||
37 | + } | ||
38 | + } | ||
39 | + }); | ||
40 | + } | ||
41 | + | ||
42 | + if (mod.hasEventTransformers()) | ||
43 | + { | ||
44 | + icons.add(new IconAbsoluteClickable(LiteLoaderBrandingProvider.ABOUT_TEXTURE, I18n.format("gui.mod.providesevents"), 12, 12, 170, 92, 182, 104){ | ||
45 | + @Override | ||
46 | + public void onClicked(Object source, Object container) | ||
47 | + { | ||
48 | + if (container instanceof GuiModListPanel) | ||
49 | + { | ||
50 | + ((GuiModListPanel)container).displayModHelpMessage(mod, "gui.mod.providesevents", "gui.mod.help.events"); | ||
51 | + } | ||
52 | + } | ||
53 | + }); | ||
30 | } | 54 | } |
31 | 55 | ||
32 | if (mod.hasClassTransformers()) | 56 | if (mod.hasClassTransformers()) |
33 | { | 57 | { |
34 | - icons.add(new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, I18n.format("gui.mod.providestransformer"), 12, 12, 170, 80, 182, 92)); | 58 | + icons.add(new IconAbsoluteClickable(LiteLoaderBrandingProvider.ABOUT_TEXTURE, I18n.format("gui.mod.providestransformer"), 12, 12, 170, 80, 182, 92){ |
59 | + @Override | ||
60 | + public void onClicked(Object source, Object container) | ||
61 | + { | ||
62 | + if (container instanceof GuiModListPanel) | ||
63 | + { | ||
64 | + ((GuiModListPanel)container).displayModHelpMessage(mod, "gui.mod.providestransformer", "gui.mod.help.transformer"); | ||
65 | + } | ||
66 | + } | ||
67 | + }); | ||
35 | } | 68 | } |
36 | 69 | ||
37 | if (mod.usesAPI()) | 70 | if (mod.usesAPI()) |
java/client/com/mumfrey/liteloader/client/gui/modlist/GuiModInfoPanel.java
1 | package com.mumfrey.liteloader.client.gui.modlist; | 1 | package com.mumfrey.liteloader.client.gui.modlist; |
2 | 2 | ||
3 | +import static com.mumfrey.liteloader.gl.GL.*; | ||
3 | import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; | 4 | import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; |
5 | +import net.minecraft.client.Minecraft; | ||
4 | import net.minecraft.client.gui.FontRenderer; | 6 | import net.minecraft.client.gui.FontRenderer; |
5 | import net.minecraft.client.gui.Gui; | 7 | import net.minecraft.client.gui.Gui; |
6 | import net.minecraft.client.resources.I18n; | 8 | import net.minecraft.client.resources.I18n; |
7 | 9 | ||
8 | import com.google.common.base.Strings; | 10 | import com.google.common.base.Strings; |
11 | +import com.mumfrey.liteloader.client.api.LiteLoaderBrandingProvider; | ||
9 | import com.mumfrey.liteloader.client.gui.GuiSimpleScrollBar; | 12 | import com.mumfrey.liteloader.client.gui.GuiSimpleScrollBar; |
13 | +import com.mumfrey.liteloader.client.util.render.IconAbsolute; | ||
10 | import com.mumfrey.liteloader.core.ModInfo; | 14 | import com.mumfrey.liteloader.core.ModInfo; |
15 | +import com.mumfrey.liteloader.util.render.IconTextured; | ||
11 | 16 | ||
12 | public class GuiModInfoPanel extends Gui | 17 | public class GuiModInfoPanel extends Gui |
13 | { | 18 | { |
@@ -16,6 +21,8 @@ public class GuiModInfoPanel extends Gui | @@ -16,6 +21,8 @@ public class GuiModInfoPanel extends Gui | ||
16 | private static final int DIVIDER_COLOUR = GuiModListPanel.GREY; | 21 | private static final int DIVIDER_COLOUR = GuiModListPanel.GREY; |
17 | private static final int DESCRIPTION_COLOUR = GuiModListPanel.WHITE; | 22 | private static final int DESCRIPTION_COLOUR = GuiModListPanel.WHITE; |
18 | 23 | ||
24 | + private static final IconAbsolute infoIcon = new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, "Info", 12, 12, 146, 92, 158, 104); | ||
25 | + | ||
19 | private final ModListEntry owner; | 26 | private final ModListEntry owner; |
20 | 27 | ||
21 | private final FontRenderer fontRenderer; | 28 | private final FontRenderer fontRenderer; |
@@ -27,6 +34,10 @@ public class GuiModInfoPanel extends Gui | @@ -27,6 +34,10 @@ public class GuiModInfoPanel extends Gui | ||
27 | private GuiSimpleScrollBar scrollBar = new GuiSimpleScrollBar(); | 34 | private GuiSimpleScrollBar scrollBar = new GuiSimpleScrollBar(); |
28 | 35 | ||
29 | private boolean mouseOverPanel, mouseOverScrollBar; | 36 | private boolean mouseOverPanel, mouseOverScrollBar; |
37 | + | ||
38 | + private boolean showHelp; | ||
39 | + | ||
40 | + private String helpTitle, helpText; | ||
30 | 41 | ||
31 | public GuiModInfoPanel(ModListEntry owner, FontRenderer fontRenderer, int brandColour, ModInfo<?> modInfo) | 42 | public GuiModInfoPanel(ModListEntry owner, FontRenderer fontRenderer, int brandColour, ModInfo<?> modInfo) |
32 | { | 43 | { |
@@ -57,18 +68,48 @@ public class GuiModInfoPanel extends Gui | @@ -57,18 +68,48 @@ public class GuiModInfoPanel extends Gui | ||
57 | drawRect(xPosition + 5, yPos, xPosition + width, yPos + 1, GuiModInfoPanel.DIVIDER_COLOUR); yPos += 4; // divider | 68 | drawRect(xPosition + 5, yPos, xPosition + width, yPos + 1, GuiModInfoPanel.DIVIDER_COLOUR); yPos += 4; // divider |
58 | drawRect(xPosition + 5, bottom - 1, xPosition + width, bottom, GuiModInfoPanel.DIVIDER_COLOUR); // divider | 69 | drawRect(xPosition + 5, bottom - 1, xPosition + width, bottom, GuiModInfoPanel.DIVIDER_COLOUR); // divider |
59 | 70 | ||
71 | + glEnableClipping(-1, -1, yPos, bottom - 3); | ||
72 | + | ||
60 | int scrollHeight = bottom - yPos - 3; | 73 | int scrollHeight = bottom - yPos - 3; |
61 | - int totalHeight = this.fontRenderer.splitStringWidth(this.modInfo.getDescription(), width - 11); | 74 | + int contentHeight = this.drawContent(xPosition, width, yPos); |
62 | 75 | ||
63 | - this.scrollBar.setMaxValue(totalHeight - scrollHeight); | ||
64 | - this.scrollBar.drawScrollBar(mouseX, mouseY, partialTicks, xPosition + width - 5, yPos, 5, scrollHeight, totalHeight); | 76 | + this.scrollBar.setMaxValue(contentHeight - scrollHeight); |
77 | + this.scrollBar.drawScrollBar(mouseX, mouseY, partialTicks, xPosition + width - 5, yPos, 5, scrollHeight, contentHeight); | ||
65 | 78 | ||
66 | this.mouseOverScrollBar = this.isMouseOver(mouseX, mouseY, xPosition + width - 5, yPos, 5, scrollHeight); | 79 | this.mouseOverScrollBar = this.isMouseOver(mouseX, mouseY, xPosition + width - 5, yPos, 5, scrollHeight); |
80 | + } | ||
67 | 81 | ||
68 | - glEnableClipping(-1, -1, yPos, bottom - 3); | ||
69 | - this.fontRenderer.drawSplitString(this.modInfo.getDescription(), xPosition + 5, yPos - this.scrollBar.getValue(), width - 11, GuiModInfoPanel.DESCRIPTION_COLOUR); | 82 | + private int drawContent(int xPosition, int width, int yPos) |
83 | + { | ||
84 | + yPos -= this.scrollBar.getValue(); | ||
85 | + | ||
86 | + if (this.showHelp) | ||
87 | + { | ||
88 | + this.drawIcon(xPosition + 3, yPos, GuiModInfoPanel.infoIcon); yPos += 2; | ||
89 | + this.fontRenderer.drawString(this.helpTitle, xPosition + 17, yPos, this.brandColour); yPos += 12; | ||
90 | + return this.drawText(xPosition + 17, width - 24, yPos, this.helpText, GuiModInfoPanel.DESCRIPTION_COLOUR) + 15; | ||
91 | + } | ||
92 | + | ||
93 | + return this.drawText(xPosition + 5, width - 11, yPos, this.modInfo.getDescription(), GuiModInfoPanel.DESCRIPTION_COLOUR); | ||
70 | } | 94 | } |
71 | 95 | ||
96 | + protected void drawIcon(int xPosition, int yPosition, IconTextured icon) | ||
97 | + { | ||
98 | + glColor4f(1.0F, 1.0F, 1.0F, 1.0F); | ||
99 | + Minecraft.getMinecraft().getTextureManager().bindTexture(icon.getTextureResource()); | ||
100 | + | ||
101 | + glEnableBlend(); | ||
102 | + this.drawTexturedModalRect(xPosition, yPosition, icon.getUPos(), icon.getVPos(), icon.getIconWidth(), icon.getIconHeight()); | ||
103 | + glDisableBlend(); | ||
104 | + } | ||
105 | + | ||
106 | + private int drawText(int xPosition, int width, int yPos, String text, int colour) | ||
107 | + { | ||
108 | + int totalHeight = this.fontRenderer.splitStringWidth(text, width); | ||
109 | + this.fontRenderer.drawSplitString(text, xPosition, yPos, width, colour); | ||
110 | + return totalHeight; | ||
111 | + } | ||
112 | + | ||
72 | private boolean isMouseOver(int mouseX, int mouseY, int x, int y, int width, int height) | 113 | private boolean isMouseOver(int mouseX, int mouseY, int x, int y, int width, int height) |
73 | { | 114 | { |
74 | return mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + height; | 115 | return mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + height; |
@@ -97,4 +138,17 @@ public class GuiModInfoPanel extends Gui | @@ -97,4 +138,17 @@ public class GuiModInfoPanel extends Gui | ||
97 | 138 | ||
98 | return false; | 139 | return false; |
99 | } | 140 | } |
141 | + | ||
142 | + public void displayHelpMessage(String title, String text) | ||
143 | + { | ||
144 | + this.showHelp = true; | ||
145 | + this.helpTitle = I18n.format(title); | ||
146 | + this.helpText = I18n.format(text); | ||
147 | + this.scrollBar.setValue(0); | ||
148 | + } | ||
149 | + | ||
150 | + public void clearHelpMessage() | ||
151 | + { | ||
152 | + this.showHelp = false; | ||
153 | + } | ||
100 | } | 154 | } |
java/client/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanel.java
@@ -252,4 +252,14 @@ public class GuiModListPanel extends Gui | @@ -252,4 +252,14 @@ public class GuiModListPanel extends Gui | ||
252 | this.mouseOverIcon.onClicked(source, this); | 252 | this.mouseOverIcon.onClicked(source, this); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | + | ||
256 | + public void mousePressed(int mouseX, int mouseY, int mouseButton) | ||
257 | + { | ||
258 | + this.owner.clearHelpMessage(); | ||
259 | + } | ||
260 | + | ||
261 | + public void displayModHelpMessage(ModInfo<?> mod, String title, String text) | ||
262 | + { | ||
263 | + this.owner.displayHelpMessage(title, text); | ||
264 | + } | ||
255 | } | 265 | } |
java/client/com/mumfrey/liteloader/client/gui/modlist/ModListEntry.java
@@ -149,6 +149,11 @@ public class ModListEntry | @@ -149,6 +149,11 @@ public class ModListEntry | ||
149 | { | 149 | { |
150 | this.modList.selectMod(this); | 150 | this.modList.selectMod(this); |
151 | 151 | ||
152 | + if (this.getListPanel().isMouseOver()) | ||
153 | + { | ||
154 | + this.getListPanel().mousePressed(mouseX, mouseY, mouseButton); | ||
155 | + } | ||
156 | + | ||
152 | if (this.getListPanel().isMouseOverIcon()) | 157 | if (this.getListPanel().isMouseOverIcon()) |
153 | { | 158 | { |
154 | this.getListPanel().iconClick(this.modList.getParentScreen()); | 159 | this.getListPanel().iconClick(this.modList.getParentScreen()); |
@@ -221,6 +226,16 @@ public class ModListEntry | @@ -221,6 +226,16 @@ public class ModListEntry | ||
221 | } | 226 | } |
222 | } | 227 | } |
223 | 228 | ||
229 | + protected void displayHelpMessage(String title, String text) | ||
230 | + { | ||
231 | + this.infoPanel.displayHelpMessage(title, text); | ||
232 | + } | ||
233 | + | ||
234 | + public void clearHelpMessage() | ||
235 | + { | ||
236 | + this.infoPanel.clearHelpMessage(); | ||
237 | + } | ||
238 | + | ||
224 | public String getKey() | 239 | public String getKey() |
225 | { | 240 | { |
226 | return (this.isErrored ? "0000" : "") + this.modInfo.getIdentifier() + Integer.toHexString(this.hashCode()); | 241 | return (this.isErrored ? "0000" : "") + this.modInfo.getIdentifier() + Integer.toHexString(this.hashCode()); |
java/common/com/mumfrey/liteloader/core/LiteLoaderVersion.java
@@ -37,7 +37,7 @@ public enum LiteLoaderVersion | @@ -37,7 +37,7 @@ public enum LiteLoaderVersion | ||
37 | MC_1_7_10_R1(28, 1404673785, "1.7.10", "1.7.10_01", "1.7.10"), | 37 | MC_1_7_10_R1(28, 1404673785, "1.7.10", "1.7.10_01", "1.7.10"), |
38 | MC_1_7_10_R2(29, 1405369406, "1.7.10", "1.7.10_02", "1.7.10"), | 38 | MC_1_7_10_R2(29, 1405369406, "1.7.10", "1.7.10_02", "1.7.10"), |
39 | MC_1_7_10_R3(30, 1407687918, "1.7.10", "1.7.10_03", "1.7.10", "1.7.10_03"), | 39 | MC_1_7_10_R3(30, 1407687918, "1.7.10", "1.7.10_03", "1.7.10", "1.7.10_03"), |
40 | - MC_1_7_10_R4(31, 1412718533, "1.7.10", "1.7.10_04", "1.7.10", "1.7.10_03", "1.7.10_04"), | 40 | + MC_1_7_10_R4(31, 1414368553, "1.7.10", "1.7.10_04", "1.7.10", "1.7.10_03", "1.7.10_04"), |
41 | MC_1_8_0_R0(32, 0, "1.8", "1.8.0", "1.8", "1.8.0"); | 41 | MC_1_8_0_R0(32, 0, "1.8", "1.8.0", "1.8", "1.8.0"); |
42 | 42 | ||
43 | /** | 43 | /** |
java/common/com/mumfrey/liteloader/core/ModInfo.java
@@ -172,6 +172,14 @@ public abstract class ModInfo<TContainer extends Loadable<?>> | @@ -172,6 +172,14 @@ public abstract class ModInfo<TContainer extends Loadable<?>> | ||
172 | } | 172 | } |
173 | 173 | ||
174 | /** | 174 | /** |
175 | + * If this has JSON event transformers | ||
176 | + */ | ||
177 | + public boolean hasEventTransformers() | ||
178 | + { | ||
179 | + return (this.container instanceof TweakContainer && ((TweakContainer<?>)this.container).hasEventTransformers()); | ||
180 | + } | ||
181 | + | ||
182 | + /** | ||
175 | * Get whether this mod uses external (3rd-party) API | 183 | * Get whether this mod uses external (3rd-party) API |
176 | */ | 184 | */ |
177 | public boolean usesAPI() | 185 | public boolean usesAPI() |
java/common/com/mumfrey/liteloader/interfaces/LoadableFile.java
@@ -71,6 +71,8 @@ public class LoadableFile extends File implements TweakContainer<File> | @@ -71,6 +71,8 @@ public class LoadableFile extends File implements TweakContainer<File> | ||
71 | 71 | ||
72 | protected String author = "Unknown"; | 72 | protected String author = "Unknown"; |
73 | 73 | ||
74 | + protected boolean hasEventTransformers; | ||
75 | + | ||
74 | /** | 76 | /** |
75 | * Create a new tweak container wrapping the specified file | 77 | * Create a new tweak container wrapping the specified file |
76 | */ | 78 | */ |
@@ -297,6 +299,17 @@ public class LoadableFile extends File implements TweakContainer<File> | @@ -297,6 +299,17 @@ public class LoadableFile extends File implements TweakContainer<File> | ||
297 | { | 299 | { |
298 | return new ArrayList<String>(); | 300 | return new ArrayList<String>(); |
299 | } | 301 | } |
302 | + | ||
303 | + @Override | ||
304 | + public boolean hasEventTransformers() | ||
305 | + { | ||
306 | + return this.hasEventTransformers; | ||
307 | + } | ||
308 | + | ||
309 | + public void onEventsInjected() | ||
310 | + { | ||
311 | + this.hasEventTransformers = true; | ||
312 | + } | ||
300 | 313 | ||
301 | public boolean isInjectionForced() | 314 | public boolean isInjectionForced() |
302 | { | 315 | { |
java/common/com/mumfrey/liteloader/interfaces/TweakContainer.java
@@ -38,4 +38,9 @@ public interface TweakContainer<L> extends Loadable<L>, Injectable | @@ -38,4 +38,9 @@ public interface TweakContainer<L> extends Loadable<L>, Injectable | ||
38 | * Get class transformers defined in the metadata | 38 | * Get class transformers defined in the metadata |
39 | */ | 39 | */ |
40 | public abstract List<String> getClassTransformerClassNames(); | 40 | public abstract List<String> getClassTransformerClassNames(); |
41 | + | ||
42 | + /** | ||
43 | + * True if this container defines event transformers via JSON | ||
44 | + */ | ||
45 | + public abstract boolean hasEventTransformers(); | ||
41 | } | 46 | } |
42 | \ No newline at end of file | 47 | \ No newline at end of file |
java/common/com/mumfrey/liteloader/transformers/event/Event.java
@@ -98,12 +98,15 @@ public class Event implements Comparable<Event> | @@ -98,12 +98,15 @@ public class Event implements Comparable<Event> | ||
98 | 98 | ||
99 | private int injectionCount = 0; | 99 | private int injectionCount = 0; |
100 | 100 | ||
101 | + protected boolean verbose; | ||
102 | + | ||
101 | protected Event(String name, boolean cancellable, int priority) | 103 | protected Event(String name, boolean cancellable, int priority) |
102 | { | 104 | { |
103 | this.name = name.toLowerCase(); | 105 | this.name = name.toLowerCase(); |
104 | this.priority = priority; | 106 | this.priority = priority; |
105 | this.order = Event.eventOrder++; | 107 | this.order = Event.eventOrder++; |
106 | this.cancellable = cancellable; | 108 | this.cancellable = cancellable; |
109 | + this.verbose = true; | ||
107 | 110 | ||
108 | if (Event.events.contains(this)) | 111 | if (Event.events.contains(this)) |
109 | { | 112 | { |
@@ -191,6 +194,23 @@ public class Event implements Comparable<Event> | @@ -191,6 +194,23 @@ public class Event implements Comparable<Event> | ||
191 | { | 194 | { |
192 | return this.priority; | 195 | return this.priority; |
193 | } | 196 | } |
197 | + | ||
198 | + /** | ||
199 | + * Set whether to log at INFO or DEBUG | ||
200 | + */ | ||
201 | + public Event setVerbose(boolean verbose) | ||
202 | + { | ||
203 | + this.verbose = verbose; | ||
204 | + return this; | ||
205 | + } | ||
206 | + | ||
207 | + /** | ||
208 | + * Get whether to log at INFO or DEBUG | ||
209 | + */ | ||
210 | + public boolean isVerbose() | ||
211 | + { | ||
212 | + return this.verbose; | ||
213 | + } | ||
194 | 214 | ||
195 | /** | 215 | /** |
196 | * Get whether this event is currently attached to a method | 216 | * Get whether this event is currently attached to a method |
java/common/com/mumfrey/liteloader/transformers/event/json/ModEventInjectionTransformer.java
1 | package com.mumfrey.liteloader.transformers.event.json; | 1 | package com.mumfrey.liteloader.transformers.event.json; |
2 | 2 | ||
3 | -import java.util.Map.Entry; | ||
4 | - | ||
5 | import com.mumfrey.liteloader.transformers.ClassTransformer; | 3 | import com.mumfrey.liteloader.transformers.ClassTransformer; |
6 | import com.mumfrey.liteloader.transformers.ObfProvider; | 4 | import com.mumfrey.liteloader.transformers.ObfProvider; |
7 | import com.mumfrey.liteloader.transformers.event.Event; | 5 | import com.mumfrey.liteloader.transformers.event.Event; |
8 | import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer; | 6 | import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer; |
9 | import com.mumfrey.liteloader.transformers.event.InjectionPoint; | 7 | import com.mumfrey.liteloader.transformers.event.InjectionPoint; |
10 | import com.mumfrey.liteloader.transformers.event.MethodInfo; | 8 | import com.mumfrey.liteloader.transformers.event.MethodInfo; |
9 | +import com.mumfrey.liteloader.transformers.event.json.ModEvents.ModEventDefinition; | ||
11 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | 10 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
12 | 11 | ||
13 | /** | 12 | /** |
@@ -20,12 +19,9 @@ public class ModEventInjectionTransformer extends EventInjectionTransformer | @@ -20,12 +19,9 @@ public class ModEventInjectionTransformer extends EventInjectionTransformer | ||
20 | @Override | 19 | @Override |
21 | protected void addEvents() | 20 | protected void addEvents() |
22 | { | 21 | { |
23 | - for (Entry<String, String> eventsDefinition : ModEvents.getEvents().entrySet()) | 22 | + for (ModEventDefinition eventsDefinition : ModEvents.getEvents().values()) |
24 | { | 23 | { |
25 | - String identifier = eventsDefinition.getKey(); | ||
26 | - String json = eventsDefinition.getValue(); | ||
27 | - | ||
28 | - this.addEvents(identifier, json); | 24 | + this.addEvents(eventsDefinition); |
29 | } | 25 | } |
30 | } | 26 | } |
31 | 27 | ||
@@ -33,41 +29,42 @@ public class ModEventInjectionTransformer extends EventInjectionTransformer | @@ -33,41 +29,42 @@ public class ModEventInjectionTransformer extends EventInjectionTransformer | ||
33 | * @param identifier | 29 | * @param identifier |
34 | * @param json | 30 | * @param json |
35 | */ | 31 | */ |
36 | - private void addEvents(String identifier, String json) | 32 | + private void addEvents(ModEventDefinition def) |
37 | { | 33 | { |
38 | JsonEvents events = null; | 34 | JsonEvents events = null; |
39 | 35 | ||
40 | try | 36 | try |
41 | { | 37 | { |
42 | - LiteLoaderLogger.info("Parsing events for mod with id %s", identifier); | ||
43 | - events = JsonEvents.parse(json); | 38 | + LiteLoaderLogger.info("Parsing events for mod with id %s", def.getIdentifier()); |
39 | + events = JsonEvents.parse(def.getJson()); | ||
44 | events.register(this); | 40 | events.register(this); |
41 | + def.onEventsInjected(); | ||
45 | } | 42 | } |
46 | catch (InvalidEventJsonException ex) | 43 | catch (InvalidEventJsonException ex) |
47 | { | 44 | { |
48 | LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); | 45 | LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); |
49 | LiteLoaderLogger.debug(ex.getMessage()); | 46 | LiteLoaderLogger.debug(ex.getMessage()); |
50 | LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); | 47 | LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); |
51 | - LiteLoaderLogger.debug(json); | 48 | + LiteLoaderLogger.debug(def.getJson()); |
52 | LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); | 49 | LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); |
53 | - LiteLoaderLogger.severe(ex, "Invalid JSON event declarations for mod with id %s", identifier); | 50 | + LiteLoaderLogger.severe(ex, "Invalid JSON event declarations for mod with id %s", def.getIdentifier()); |
54 | } | 51 | } |
55 | catch (Throwable ex) | 52 | catch (Throwable ex) |
56 | { | 53 | { |
57 | - LiteLoaderLogger.severe(ex, "Error whilst parsing event declarations for mod with id %s", identifier); | 54 | + LiteLoaderLogger.severe(ex, "Error whilst parsing event declarations for mod with id %s", def.getIdentifier()); |
58 | } | 55 | } |
59 | 56 | ||
60 | try | 57 | try |
61 | { | 58 | { |
62 | if (events != null) | 59 | if (events != null) |
63 | { | 60 | { |
64 | - LiteLoaderLogger.info("Registering events for mod with id %s", identifier); | 61 | + LiteLoaderLogger.info("Registering events for mod with id %s", def.getIdentifier()); |
65 | events.register(this); | 62 | events.register(this); |
66 | } | 63 | } |
67 | } | 64 | } |
68 | catch (Throwable ex) | 65 | catch (Throwable ex) |
69 | { | 66 | { |
70 | - LiteLoaderLogger.severe(ex, "Error whilst parsing event declarations for mod with id %s", identifier); | 67 | + LiteLoaderLogger.severe(ex, "Error whilst parsing event declarations for mod with id %s", def.getIdentifier()); |
71 | } | 68 | } |
72 | } | 69 | } |
73 | 70 |
java/common/com/mumfrey/liteloader/transformers/event/json/ModEvents.java
@@ -16,9 +16,40 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | @@ -16,9 +16,40 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
16 | 16 | ||
17 | public class ModEvents implements EnumerationObserver | 17 | public class ModEvents implements EnumerationObserver |
18 | { | 18 | { |
19 | + public static class ModEventDefinition | ||
20 | + { | ||
21 | + private final LoadableModFile file; | ||
22 | + | ||
23 | + private final String identifier; | ||
24 | + | ||
25 | + private final String json; | ||
26 | + | ||
27 | + public ModEventDefinition(LoadableModFile file, String json) | ||
28 | + { | ||
29 | + this.file = file; | ||
30 | + this.identifier = file.getIdentifier(); | ||
31 | + this.json = json; | ||
32 | + } | ||
33 | + | ||
34 | + public String getIdentifier() | ||
35 | + { | ||
36 | + return this.identifier; | ||
37 | + } | ||
38 | + | ||
39 | + public String getJson() | ||
40 | + { | ||
41 | + return this.json; | ||
42 | + } | ||
43 | + | ||
44 | + public void onEventsInjected() | ||
45 | + { | ||
46 | + this.file.onEventsInjected(); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
19 | private static final String DEFINITION_FILENAME = "events.json"; | 50 | private static final String DEFINITION_FILENAME = "events.json"; |
20 | 51 | ||
21 | - private static Map<String, String> events = new HashMap<String, String>(); | 52 | + private static Map<String, ModEventDefinition> events = new HashMap<String, ModEventDefinition>(); |
22 | 53 | ||
23 | @Override | 54 | @Override |
24 | public void onRegisterEnabledContainer(LoaderEnumerator enumerator, LoadableMod<?> container) | 55 | public void onRegisterEnabledContainer(LoaderEnumerator enumerator, LoadableMod<?> container) |
@@ -32,7 +63,7 @@ public class ModEvents implements EnumerationObserver | @@ -32,7 +63,7 @@ public class ModEvents implements EnumerationObserver | ||
32 | if (json == null) return; | 63 | if (json == null) return; |
33 | 64 | ||
34 | LiteLoaderLogger.info("Registering %s for mod with id %s", ModEvents.DEFINITION_FILENAME, file.getIdentifier()); | 65 | LiteLoaderLogger.info("Registering %s for mod with id %s", ModEvents.DEFINITION_FILENAME, file.getIdentifier()); |
35 | - ModEvents.events.put(file.getIdentifier(), json); | 66 | + ModEvents.events.put(file.getIdentifier(), new ModEventDefinition(file, json)); |
36 | } | 67 | } |
37 | } | 68 | } |
38 | 69 | ||
@@ -51,7 +82,7 @@ public class ModEvents implements EnumerationObserver | @@ -51,7 +82,7 @@ public class ModEvents implements EnumerationObserver | ||
51 | { | 82 | { |
52 | } | 83 | } |
53 | 84 | ||
54 | - static Map<String, String> getEvents() | 85 | + static Map<String, ModEventDefinition> getEvents() |
55 | { | 86 | { |
56 | return events; | 87 | return events; |
57 | } | 88 | } |
resources/assets/liteloader/lang/en_US.lang
@@ -38,11 +38,16 @@ gui.status.startuperror=Startup errors detected | @@ -38,11 +38,16 @@ gui.status.startuperror=Startup errors detected | ||
38 | gui.description.missingdeps=Missing dependencies: %s | 38 | gui.description.missingdeps=Missing dependencies: %s |
39 | gui.description.missingapis=Missing APIs: %s | 39 | gui.description.missingapis=Missing APIs: %s |
40 | 40 | ||
41 | -gui.mod.providestweak=Provides Tweak | ||
42 | -gui.mod.providestransformer=Provides Transformer | 41 | +gui.mod.providestweak=Tweak |
42 | +gui.mod.providestransformer=Transformer | ||
43 | +gui.mod.providesevents=Injector | ||
43 | gui.mod.usingapi=Uses additional API | 44 | gui.mod.usingapi=Uses additional API |
44 | gui.mod.startuperror=%d startup error(s) | 45 | gui.mod.startuperror=%d startup error(s) |
45 | 46 | ||
47 | +gui.mod.help.tweak=A tweaker is a special type of mod. Tweakers have almost unlimited control of the game and are usually mods which alter the game engine fundamentally, for example APIs or performance-enhancement mods like Optifine. Because they have the greatest amount of control, they are also the most likely to cause instability when not compatible with each other, if you are experiencing crashes or serious problems, you should always try disabling tweak mods first. | ||
48 | +gui.mod.help.transformer=A transformer mod uses bytecode injection to hook extra functionality within the game which LiteLoader does not normally provide. Because transformers access functionality outside of LiteLoader's core, it is possible for them to have unforseen side-effects when combined with other mods. If you are experiencing crashes or other unexpected behaviour, you should disable transformer mods before regular mods to determine whether they are the source of the issue. | ||
49 | +gui.mod.help.events=An injector mod uses a restricted form of bytecode injection which makes it somewhat safer than a full transformer mod, but can still cause instability under some circumstances. If you are experiencing crashes or other issues, then you should disable injector mods before regular mods to determine whether they are the source of the issue. | ||
50 | + | ||
46 | gui.settings.title=%s Settings | 51 | gui.settings.title=%s Settings |
47 | gui.saveandclose=Save & Close | 52 | gui.saveandclose=Save & Close |
48 | 53 |
resources/assets/liteloader/textures/gui/about.png