-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from DxxxxY/v2
v2
- Loading branch information
Showing
41 changed files
with
1,136 additions
and
1,199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,62 @@ | ||
package studio.dreamys.icarus; | ||
|
||
import lombok.Getter; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.common.gameevent.InputEvent; | ||
import org.lwjgl.input.Keyboard; | ||
import studio.dreamys.icarus.component.Component; | ||
import studio.dreamys.icarus.component.Window; | ||
import studio.dreamys.icarus.component.sub.Button; | ||
import studio.dreamys.icarus.component.sub.Checkbox; | ||
import studio.dreamys.icarus.component.sub.Keybind; | ||
import studio.dreamys.icarus.config.Config; | ||
import studio.dreamys.icarus.handler.KeybindHandler; | ||
import studio.dreamys.icarus.component.Component; | ||
import studio.dreamys.icarus.util.RenderUtils; | ||
import studio.dreamys.icarus.util.font.GlyphPageFontRenderer; | ||
|
||
import java.awt.*; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
@SuppressWarnings("unused") | ||
public class Icarus { | ||
@Getter private static Config config; | ||
@Getter private static Window window; | ||
@Getter private static String modid; | ||
|
||
public static void init(String modid, Window window) { | ||
RenderUtils.loadFonts(); | ||
Icarus.window = window; //create window object and store it forever | ||
|
||
Icarus.window = window; | ||
Icarus.modid = modid; | ||
config = new Config(modid); //create config which will load settings into window | ||
config.load(); //load settings from config | ||
MinecraftForge.EVENT_BUS.register(new Icarus()); | ||
|
||
MinecraftForge.EVENT_BUS.register(new KeybindHandler()); | ||
|
||
Config.init(modid); | ||
} | ||
|
||
public static void provideTextFont(InputStream fontStream, String fontName, int fontSize, boolean bold, boolean italic, boolean boldItalic) { | ||
try { | ||
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(Font.createFont(Font.TRUETYPE_FONT, fontStream)); | ||
RenderUtils.textRenderer = GlyphPageFontRenderer.create(fontName, fontSize, bold, italic, boldItalic); | ||
} catch (FontFormatException | IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void key(InputEvent.KeyInputEvent e) { | ||
if (Minecraft.getMinecraft().theWorld == null || Minecraft.getMinecraft().thePlayer == null) return; | ||
if (Keyboard.getEventKeyState()) { //if the key is down | ||
int keyCode = Keyboard.getEventKey(); //get keycode | ||
if (keyCode <= 0) return; //ignore invalid keycode | ||
if (keyCode == window.key) { | ||
Minecraft.getMinecraft().displayGuiScreen(window); | ||
return; | ||
} | ||
for (Component attachment : window.all) { //for every attachment | ||
if (attachment instanceof Keybind) { //if it's a keybind | ||
Keybind keybind = (Keybind) attachment; //cast to keybind | ||
if (keybind.getKey() == keyCode) { //if the keys match | ||
if (keybind.getChild() instanceof Checkbox) { //if the child is a checkbox | ||
((Checkbox) keybind.getChild()).toggle(); //toggle the checkbox | ||
config.save(); //save the config | ||
keybind.getChild().fireChange(); //fire change event | ||
} | ||
if (keybind.getChild() instanceof Button) { //if the child is a button | ||
((Button) keybind.getChild()).getRunnable().run(); //click the button | ||
} | ||
} | ||
} | ||
} | ||
public static void provideTitleFont(InputStream fontStream, String fontName, int fontSize, boolean bold, boolean italic, boolean boldItalic) { | ||
try { | ||
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(Font.createFont(Font.TRUETYPE_FONT, fontStream)); | ||
RenderUtils.titleRenderer = GlyphPageFontRenderer.create(fontName, fontSize, bold, italic, boldItalic); | ||
} catch (FontFormatException | IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static void provideIconFont(InputStream fontStream, String fontName, int fontSize, boolean bold, boolean italic, boolean boldItalic) { | ||
try { | ||
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(Font.createFont(Font.TRUETYPE_FONT, fontStream)); | ||
RenderUtils.iconRenderer = GlyphPageFontRenderer.create(fontName, fontSize, bold, italic, boldItalic); | ||
} catch (FontFormatException | IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static void provideComponent(Class<? extends Component> newComponent, Class<? extends Component> oldComponent) { | ||
Config.componentReplacements.put(oldComponent, newComponent); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/studio/dreamys/icarus/annotation/field/DropdownOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package studio.dreamys.icarus.annotation.field; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.FIELD) | ||
public @interface DropdownOptions { | ||
String[] value(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/studio/dreamys/icarus/annotation/field/IKeybind.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package studio.dreamys.icarus.annotation.field; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.FIELD) | ||
public @interface IKeybind { | ||
int value(); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/studio/dreamys/icarus/annotation/field/SliderOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package studio.dreamys.icarus.annotation.field; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.FIELD) | ||
public @interface SliderOptions { | ||
double min(); | ||
double max(); | ||
boolean onlyInt() default false; | ||
String units() default ""; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/studio/dreamys/icarus/annotation/type/IGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package studio.dreamys.icarus.annotation.type; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface IGroup { | ||
double x(); | ||
double y(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/studio/dreamys/icarus/annotation/type/IPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package studio.dreamys.icarus.annotation.type; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface IPage { | ||
char value(); | ||
} |
11 changes: 0 additions & 11 deletions
11
src/main/java/studio/dreamys/icarus/component/Attachment.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.