Kraken Community ImGui in Java - RSKrakenCommunity/CommunityAPI GitHub Wiki

Alt Text Alt Text

User Interface Wrapper for Krakens ImGui UI

ImGui module requires Java 8

Setting up for UI

import com.rshub.api.plugin.JavaPlugin;
import com.rshub.imgui.nodes.pane.panes.VerticalPane;

public class ImGuiExample extends JavaPlugin {

    public ImGuiExample() {
        super("ImGui Example");
    }

    @Override
    public int onLoop() {
        return super.onLoop();
    }

    private VerticalPane vpane = new VerticalPane();
    
    @Override
    protected void onLoad() {
        
    }

    @Override
    public void onPaint() {
        vpane.getSkin().paint();
    }
}

Button

import com.rshub.imgui.nodes.button.Button;

Creating the button

Button button = new Button("Click me!");
vpane.add(button);

Dynamically Updating Button Text

Button button = new Button("Click me!");
SimpleStringProperty btnText = new SimpleStringProperty();
button.getLabelProperty().bind(btnText);
btnText.set("Better Click me!");

Setting the buttons' action

Button button = new Button("Click me!");
button.setOnAction(() -> {
     Debug.log("Clicked me!");
     return Unit.INSTANCE;
});

Label

import com.rshub.imgui.nodes.label.Label;

Dynamically Updating Label Text

Label label = new Label("XP Gained: 0");
SimpleIntegerProperty xp = new SimpleIntegerProperty();
label.getLabelProperty().bind(Bindings.createStringBinding(() -> "XP Gained: " + xp.get(), xp));
xp.set(xp.get() + 1000);

Tab Pane

import com.rshub.imgui.nodes.tabs.Tab;
import com.rshub.imgui.nodes.tabs.TabPane;

Create Tab

TabPane tp = new TabPane("Debug Tabs");
Tab tab = new Tab("Player");
tp.addTab(tab);
vpane.add(tp);

Populating Tab with content

VerticalPane playerTabContent = new VerticalPane();
playerTabContent.add(new Label("Player name: Bob"));
tab.setContent(playerTabContent);

Input Fields

import com.rshub.imgui.nodes.inputs.integer.IntegerInput;
import com.rshub.imgui.nodes.inputs.text.PasswordField;
import com.rshub.imgui.nodes.inputs.text.TextField;

Integer Input Field

IntegerInput ii = new IntegerInput("Enter Item Id");
SimpleIntegerProperty value = new SimpleIntegerProperty();
ii.getInput().bind(value);
value.set(50);

Text Field

TextField textf = new TextField("Enter name", 50);
SimpleStringProperty text = new SimpleStringProperty();
textf.getInput().bind(text);
text.set("Hello, World");

Password Field

PasswordField passf = new PasswordField("Enter Password");
SimpleStringProperty text = new SimpleStringProperty();
passf.getInput().bind(text);
text.set("Hello, World");

Checkbox

import com.rshub.imgui.nodes.checkbox.Checkbox;

Checkbox Creation

Checkbox box = new Checkbox("Collect Spirits");
SimpleBooleanProperty value = new SimpleBooleanProperty();
box.getInput().bind(value);
value.set(true);
⚠️ **GitHub.com Fallback** ⚠️