Skip to content
DxxxxY edited this page Jan 4, 2023 · 1 revision

Generating the UI

To begin, let's create a class with the page name.

@IPage('v')
public class Combat {

}

Notice the annotation @IPage. This tells Icarus to create a page with the icon that the char represents in the icon font.

Next, lets create a group.

@IPage('v')
public class Combat {
    @IGroup(x = 47.5, y = 10)
    public static class KillAura {
        
    }
}

Again, notice the annotation @IGroup. This tells Icarus to create a group inside the page with the given x and y coordinates.

Finally, lets add components to the group.

@IPage('v')
public class Combat {
    @IGroup(x = 47.5, y = 10)
    public static class KillAura {
        @IKeybind(Keyboard.KEY_6)
        public static Runnable Button = () -> {
            NotificationManager.send(new Notification("Button", "You pressed the button!"));
            System.out.println("Button pressed!");
        };

        @IKeybind(Keyboard.KEY_7)
        public static boolean Checkbox = true;

        @DropdownOptions({"Option 1", "Option 2", "Option 3"})
        public static String Choice = "Option 1";

        @DropdownOptions({"Option 1", "Option 2", "Option 3"})
        public static String[] Combo = {"Option 1", "Option 3"};

        public static String Field = "Hello World!";

        @SliderOptions(min = 0, max = 100, onlyInt = true, units = "%")
        public static double Slider = 1;
    }
}

Components

Note, im referring to fields as variables as to not confuse them with the Field component.

Component Description Variable Type Possible annotations
Button A button that runs a function when clicked. Runnable @IKeybind
Checkbox A checkbox that toggles a boolean. boolean @IKeybind
Choice A dropdown that allows you to choose one option. String @DropdownOptions
Combo A dropdown that allows you to choose multiple options. String[] @DropdownOptions
Field A text field that allows you to type in a string. String
Slider A slider that allows you to choose a number. double @SliderOptions

A few notes:

  • The names of the variables are the labels of the components. Underscores (_) are replaced with spaces.
  • The values of the variables are the default values. These values are updated in real time by Icarus. This is the same for @IKeybind.
  • The Button component isn't for configuration purposes. Therefore, it is not saved by the config and cannot be updated, however its keybind can.
  • The @DropdownOptions annotation is used to set an array of options for the Choice and Combo components.
  • The @SliderOptions annotation is used to set the min, max, and if the slider should only allow integers. It also allows you to set the units that are displayed next to the slider. Min and max are required, the rest are optional and have their defaults.

Accessing the config

To get a value from the config, simply use the field as a reference.

System.out.println(Combat.KillAura.Field);

This will return the value of the Field component.

Updating the config

To update a value in the config, simply set the field to the new value. Call Config.save() afterwards if you want to save it to the config.

Combat.KillAura.Field = "Hello Icarus!";
Config.save();

This will update the value of the Field component in Accessing the Config and save the config.

Clone this wiki locally