RockUI
A handy dependency for making ingame UI
Screenshots 1 screenshots
About this mod Author’s original text
Rock UI
Ever dreaded making UI for your mods? Well, say goodbye to slightly adjusting positions and copying RUMBLE objects, because RockUI solves it all!
Thats all it does though this mod is just a dependency
For Users
Just drag the mod into your mods folder and start up RUMBLE!
For Mod Developers
Be warned this is my first time making a mod like this so if you see some horrible way of doing something please lmk.
The Basics
RockUI is made up of 2 main parts: UIElements and the UIBuilder.
UIElements are the building blocks of UI. There are a few types currently:
- RockPanel
- RockButton
- RockText
- RockSlider
- RockLever
Creating one of these is very simple:
RockPanel panel = new RockPanel()
Then you can set properties easily:
panel.size = new Vector2(10,10)
I will go further into the properties of each UIElement further down.
The UI works off of a parent-child system. You can add any UIElement as a child of another like so:
RockPanel panel = new RockPanel()
RockButton button = new RockButton()
panel.AddChildUI(button)
When an element is a child of another it will be placed at the same position as its parent. Alternatively, if the parent node is a panel, you can set the object to be positioned at one of 9 anchor points on the panel with anchor:
- TopLeft
- TopRight
- BottomLeft
- BottomRight
- LeftMiddle
- RightMiddle
- TopMiddle
- BottomMiddle
- Center
You can offset the element from its parent/anchor using anchorOffset
Once you have created your UIElements and applied them as children you are ready to build the UI.
All you have to do is write RockUI.CreateFinalisedUI(-Your Topmost UIElement-). The UIElement you pass in should be the topmost element (has no parent element). You can also pass in either true or false to make the UI follow the player around. The UIBuilder will then create that element and all of it's children and return it as a GameObject.
List of All UIElements
UIElement
Default UIElement. All other types inherit this.
Properties:
- anchor: Defines what anchor the element snaps to if child of a RockPanel
- anchorOffset: Defines the position offset from the anchor or the parent element
Methods:
- AddChildUI(UIElement): Adds another element as a child of this element
RockPanel
A plain slab of rock for placing UI on. I recommend using this as your topmost UIElement.
UIElements as children of it can choose one of 9 Anchors on it to be anchored to.
Properties:
- size: Vector2 that defines the size of the panel.
RockButton
A button that calls a method when pressed.
Properties:
- pressAction: The method that is called when the button is pressed. Must have no parameters
RockText
A text label.
Properties:
- text: The text of the label
- fontColor: The color of the label
- fontSize: The size of the text (Honestly doesnt need to be higher than 1 most of the time)
RockSlider
RUMBLE's built in slider object. Can be stepped or a smooth slider.
Properties:
- useSteps: Whether or not the slider has steps. If true, the slider stops at certain points based on stepCount
- stepCount: The amount of steps the slider stops at
- valueChangedAction: The method that is called when the value of the slider changes. Must have a float parameter, which is the value of the slider, from 0 to 1
- stepReachedAction: The method that is called when a step in the slider is reached. Must have an int parameter, which is the step that was reached, starting at 0
RockLever
RUMBLE's built in lever/switch object. Can be on or off.
Properties:
- leverToggledAction: Method that is called when the lever is toggled. Must have an integer parameter. Outputs 1 for toggled on and 0 for toggled off
Example UI Setup
public override void OnLateInitializeMelon()
{
RumbleModdingAPI.RMAPI.Actions.onMapInitialized += debug;
}
private float a = 0.0f;
private string t = "";
private void debug()
{
RockPanel mainpanel = new RockPanel();
mainpanel.size = new Vector2(10, 15);
RockButton debugbutton = new RockButton();
debugbutt
Install & use Install: follow the bundled instructions
- Unzip the archive from playbuff and read the bundled readme / instructions first.
- Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
- For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
- Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.
Install locations vary a lot between mods — the bundled readme is the most reliable guide.
Install these first, or the mod will not work: