SparrohUILib

v2.1.0·Updated 2026-08-05

Shared UI library for Sparroh Mycopunk mods. Provides themed widgets, HUD builders, windows, and resolution-aware layout.

About this mod Author’s original text

SparrohUILib

Shared UI library for Sparroh Mycopunk mods. One theme, one set of widgets, resolution-aware layout.

Features

  • Theme system — Mycopunk-inspired teal/slate surfaces with bioluminescent accents
  • Resolution scaling — Reference 1920×1080; scales cleanly across aspect ratios via CanvasScaler + UITheme.Scale
  • HUD builder — Single- and multi-line HUD text under the player reticle (normalized anchors); respects vanilla Hide HUD
  • HUD reposition — Soft-dependency helpers for ModSettingsMenu drag-reposition (HudAnchors, HudRepositionClient, HudHandle.EnableReposition)
  • Gear action bar — Shared top toolbar on the gear/menu canvas for cross-mod action buttons
  • Widgets — Text, Button, Toggle, InputField, Panel, ScrollView, Separator, Dropdown, Slider, ProgressBar, Tabs, Tooltip, DragList
  • Windows & dialogs — Overlay windows (per-window canvas), confirm/alert dialogs
  • Rich text helpers — Label: value unit formatting with colored values
  • Config colors — Bind hex color config entries with cached Color values

Install

r2modman: install Sparroh-SparrohUILib as a dependency of your mod.

Manual: place SparrohUILib.dll in BepInEx/plugins.

Consumer setup

csproj..\SparrohUILib\bin\Release\netstandard2.1\SparrohUILib.dll

Plugin

[BepInDependency("sparroh.uilibrary")]

[BepInPlugin(...)]

public class MyPlugin: BaseUnityPlugin { }.toml

[package.dependencies]

BepInEx-BepInExPack_Mycopunk = "5.4.2403"

Sparroh-SparrohUILib = "1.2.0"

Quick examples

using Sparroh.UI;

// HUD anchors (config) + rebuild when the handle dies after quit-to-menu

var anchors = HudAnchors.Bind(Config, "Altimeter", 0.15f, 0.84f);

if (!HudHandle.IsValid(hud))

{

hud = HudBuilder.Create("AltimeterHUD").ParentToReticle().Anchor(anchors.XValue, anchors.YValue).Size(300, 25).AddText("AltitudeText").Build();

// Soft-dep ModSettingsMenu: drag in F9 mode, SettingChanged → SetAnchor, auto-unregister on destroy

if (HudHandle.IsValid(hud))

hud.EnableReposition("my.mod.guid", "Altimeter", anchors);

}

if (HudHandle.IsValid(hud))

hud.Primary.SetRich("Altitude", 12.3f, UIColors.Shamrock, "m");

// Multi-line HUD

var meter = HudBuilder.Create("Carnometer").ParentToReticle().Anchor(0.15f, 0.95f).Size(320, 100).AddLines(4).Build();

meter.Lines[0].SetRichWithRate("Total Damage", total, dps, UIColors.Rose);

// Overlay window

var window = UIWindow.Create("Settings", new Vector2(800, 600), "Mod Settings", scrollable: true);

UIWindow.CreateSectionHeader(window.Content, "General");

UIToggle.Create(window.Content, "Enable HUD", true, on => { /... / });

UISlider.Create(window.Content, "Opacity", 0f, 1f, 0.8f, v => { /... / });

UIButton.Create(window.Content, "Save", () => { /... / }, UIButtonStyle.Primary);

// Dialogs

UIDialog.Confirm("Scrap upgrades?", "This cannot be undone.", onConfirm: DoScrap);

UIDialog.Alert("Done", "Upgrades scrapped.");

// Tooltip

UITooltip.Attach(someButton.GameObject, "Does the thing");

// Gear menu action bar (library hosts/ticks the bar)

GearActionBar.Register("mymod.scrap", "Scrap", GearActionBar.OrderScrapMarked, DoScrap, UIButtonStyle.Danger);

Theme & scaling

| API | Purpose |

|-----|---------|

| UIColors.* | Palette (Sky, Rose, Shamrock, PanelBg, ButtonPrimary, …) |

| UIColors.TryParseHex / ParseHex | Parse RRGGBB / #RRGGBB / RRGGBBAA / #RRGGBBAA |

| UIColors.ToHex / WithAlpha | Convert Color ↔ hex; adjust alpha |

| ConfigColor.Bind(...) | Bind a hex color config entry with cached Color |

| UITheme.S(px) / UITheme.Scale | Scale reference pixels to current resolution |

| UITheme.ScaledSize(w, h) | Scaled Vector2 |

| UITheme.ClampToScreen(size) | Keep windows on-screen |

| RichText.Labeled(...) | Colored label/value strings |

Configurable HUD colors

// In your mod constructor:

valueColor = ConfigColor.Bind(Config, "Colors", "ValueColor", UIColors.Sky,

"Rich-text value color (hex RRGGBB or #RRGGBB).");

// When drawing:

hud.Primary.SetRich("Speed", speed, valueColor.Value, "m/s");

Install & use Install: follow the bundled instructions

  1. Unzip the archive from playbuff and read the bundled readme / instructions first.
  2. 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.
  3. For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
  4. 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.

Dependencies

Install these first, or the mod will not work:

BepInEx-BepInExPack_Mycopunk

File & checksum

Filename
SparrohUILib-2.1.0.zip
File size
114.8 KiB