Skip to content

Commit

Permalink
Merge pull request #2 from DxxxxY/v2
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
dxxxxy authored Jan 4, 2023
2 parents 36cc982 + 6980b41 commit ed9eb96
Show file tree
Hide file tree
Showing 41 changed files with 1,136 additions and 1,199 deletions.
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Icarus
> rebranded from MineSenseUI
A simple and extremely [lightweight](#lightweightness) Gui and config library for Minecraft Forge 1.8.9 modding heavily inspired by the GameSense/Skeet CS:GO cheat (not an exact copy). A fully working example mod using this library can be found at [test](src/main/java/studio/dreamys/test).
A very simple and [lightweight](#lightweightness) GUI and Config library for Minecraft Forge 1.8.9 modding heavily inspired by the GameSense/Skeet CS:GO cheat (not an exact copy). A fully working example mod using this library can be found at [test](src/main/java/studio/dreamys/test).

## Importing
## Setup
### Gradle
```
repositories {
Expand All @@ -16,31 +16,42 @@ dependencies {
}
```

Replace $VERSION with any version from the [repo](https://github.com/DxxxxY/repo/tree/master/studio/dreamys/Icarus).
Replace `$VERSION` with the latest from the [repo](https://github.com/DxxxxY/repo/tree/master/studio/dreamys/Icarus).

## Components
> Some components have secondary constructors with default values.
## What's new in v2
- **.json**
- **Same look (skeet)**
- **Customizability (font, components)**
- **~90% code rewrite**
- **New and redesigned config system (reflection)**
- **Complete separation of UI and Config**
- **Enhanced and simplified developer experience**

## [Wiki](https://github.com/DxxxxY/Icarus/wiki/)

## UI Components
- Button
- Checkbox
- Choice
- ~~Color~~ (coming soon)
- Combo
- Field
- Group
- Keybind
- Slider
- Keybind
- Group
- Page
- Window

## Extra
- [Notification](https://www.youtube.com/watch?v=624J5kAZqNw&ab_channel=DxxxxY)
- Watermark ![Watermark](.github/watermark.png)


## Lightweightness
- Everything is created and stored on client init.
- Everything is rendered using libraries present on runtime.
- Small size, no extra-dependencies, no bloatware.
- Other than importing this library, nothing is needed.
- Everything is created and stored on client preInit.
- Reflected data is cached and accessed quicker.
- Only dependent on the Reflections library.

## Menu (as of 09/02/2022) is fully functional:
![icarus.gif](.github/icarus.gif)
25 changes: 24 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ buildscript {

plugins {
id "java"
id "com.github.johnrengelman.shadow" version "2.0.4"
}

apply plugin: "net.minecraftforge.gradle.forge"

version = "1.4.2"
version = "2.0.0"
group = "dreamys.studio" //http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Icarus" //name of the output jar

Expand All @@ -28,12 +29,34 @@ minecraft {
makeObfSourceJar = false //disable creation of sources jar
}

configurations {
shade
compile.extendsFrom(shade)
}


repositories {
mavenCentral()
}

dependencies {
compile "org.projectlombok:lombok:1.18.24"
shade "org.reflections:reflections:0.10.2"
}

shadowJar {
dependencies {
//we remove gson because it belongs to the public api and will break shading
//exclude(dependency("com.google.code.gson:gson:2.8.6"))
}
configurations = [project.configurations.shade]
duplicatesStrategy DuplicatesStrategy.EXCLUDE //prevent duplicates
classifier "" //prevent creation of unshadowed jar
}

reobf {
//reobfuscate the shadowed jar
shadowJar {}
}

//exclude test files in jar build
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
@rem Add default JVM dropdownOptions here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM dropdownOptions to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
Expand Down
80 changes: 42 additions & 38 deletions src/main/java/studio/dreamys/icarus/Icarus.java
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);
}
}
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 src/main/java/studio/dreamys/icarus/annotation/field/IKeybind.java
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();
}
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 src/main/java/studio/dreamys/icarus/annotation/type/IGroup.java
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 src/main/java/studio/dreamys/icarus/annotation/type/IPage.java
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 src/main/java/studio/dreamys/icarus/component/Attachment.java

This file was deleted.

Loading

0 comments on commit ed9eb96

Please sign in to comment.