seneaL-SeneaL_API icon

SeneaL API

Public API for Valheim UI mods: notices, dialogs and HUD elements, with a bridge that routes the game's own windows to any UI that registers as a provider.

CHANGELOG

1.0.1

  • Linked slots: SlotDef.Put and SlotDef.Take (Func<Player, ItemData, bool>) let a mod store and take out the item itself instead of the game's EquipItem / UnequipItem, for cells that hold items without wearing them (potions, keys, a mod's own storage cells). Without them a Linked slot works as before. Feature slots.handlers.

1.0.0

  • Mod settings: ModSettings.Add puts another mod's BepInEx entries into the UI mod's settings window (keys into its key list with clash warnings, switches, choices and sliders into its mods page); labels, tips and choice names are functions so they follow the language. Feature settings.

  • Theme: Themes.Icon(name) returns an icon by its Phosphor name. Feature theme.icons.

  • Dialogs: Dialogs.Choose opens a dialog with up to four buttons (DialogButton: text, click, primary), CancelIndex sets what Esc picks; Dialog.Centered centers the text of any dialog. Without a provider the game's yes / no window takes the first two buttons. Feature dialogs.choice.

  • Theme: Themes hands out the installed UI mod's fonts, 9-sliced sprites (window, card, button, field, row, tab, track, chip) and colors, so another mod can build its own window that looks like the rest of the interface; without a provider every call returns nothing and the mod keeps its own look. Feature theme.

First version.

New:

  • Notices: show top-left, center, unlock and biome banners through Notices, with a vanilla fallback when no UI provider is registered.
  • Dialogs: confirm, message and text input windows through Dialogs, with a vanilla fallback.
  • HUD elements: any mod can register a RectTransform with HudElements so a UI provider can move, resize and style it.
  • Providers: a UI mod registers one provider per feature; dialogs open in a provider that goes away are shown again by the next one or by the vanilla window, and dialogs left over from the previous scene are dropped.
  • Slots: mods add their own inventory slots with CustomSlots (Stored or Worn, with an accept check, visibility, order and a change callback); the UI provider stores, draws and persists them.
  • Linked slots: SlotMode.Linked with a Source shows an item that lives somewhere else (usually the inventory) in a slot; putting an item in equips it through the game (an item already in the slot is unequipped first, so the new one takes that slot), emptying the slot unequips it, and Changed fires when the item changes. Contract 2.
  • AzuEPI bridge: when Azumatt's AzuEPI is installed, the equipment slots other mods add through its API are mirrored as Linked slots, so a UI provider shows them next to the slots of this API. AzuEPI keeps running them. Bridge / AzuEPI turns it off.
  • AzuEPI API stubs: a small patcher (BepInEx/patchers/SeneaL-API) loads before the plugins and routes the AzuEPI API stub that some mods carry inside their own dll (all its methods do nothing, so such a mod never reaches AzuEPI) to this API. IsLoaded() answers true when AzuEPI or SeneaL UI is installed, AddSlot goes to the real AzuEPI if it is installed and is emulated as a Linked slot (merged by name, like AzuEPI does) otherwise. Mods the UI mod already supports itself (Jewelcrafting, BowsBeforeHoes, BetterArchery, EpicLoot and AdventureBackpacks) are left alone by default: Bridge / AzuEPIStubIgnore; Bridge / AzuEPIStubs turns it off. Needs a game restart. A slot that reaches this API through AzuEPI or a stub carries the name of the mod that added it in SlotDef.Origin.
  • HUD placement: HudElement.Placed is set by the UI provider while the player has put the element at a place of their own, so a mod that moves its element itself can leave it alone then; HudElements.Find(owner, id) returns one element. Feature hud.placed.
  • Slot origin: the API now notes which mod adds a slot at the moment of the AddSlot call (a hook on the real AzuEPI API and the stub calls), so SlotDef.Origin names the right mod even when the mod passes a prefab name instead of functions or keeps its functions in a helper dll.
  • CustomSlots.AzuManaged: a UI provider that gives the inventory to AzuEPI turns the AzuEPI mirroring and the stub emulation off, so AzuEPI shows the slots of other mods itself.
  • Slots: SlotDef.IconName names a Phosphor icon (regular weight, e.g. "flask") for the empty slot; the UI provider draws it, Icon (a Sprite) still wins. Feature slots.icon.
  • Slots: using an item that a mod slot accepts (right click, hotbar key, gamepad) puts it into that slot instead of the game's own equipment slot (a ring of type Utility used to replace the belt). SlotDef.EquipOnUse = false keeps the game's use. Feature slots.use. The README says when to pick Worn and when Linked.
  • Slots: SlotDef.EquipTime (Worn slots wait for the game's equip bar: the item's own time by default, 0 for instant, or seconds) and SlotDef.Place (Auto, Row or Doll: the slot can sit on the equipment block instead of the Mod slots row). Features slots.time and slots.place.
  • Bridge: the game's own MessageHud, UnifiedPopup and TextInput calls are routed to the registered providers, so every mod that uses the vanilla windows gets the provider's look. Each bridge can be turned off in the config.

Fixed:

  • Dialogs: the text input and popup bridge runs after other mods' prefixes and stays out when one of them already took the call over (XPortal opens its own portal window from TextInput.RequestText; a second, empty name window used to open over it).