Ziggfreed's CommonLib

Common Library for Ziggfreed's Mods

File Details

ZiggfreedCommon-1.3.0.jar

  • R
  • Jul 8, 2026
  • 503.66 KB
  • 2.4K
  • 0.5

File Name

ZiggfreedCommon-1.3.0.jar

Supported Versions

  • 0.5

A settings-UI toolkit, AND a generic settings-form engine built on it: the reusable pieces an in-game config page needs - a JSON override write-back, a HUD layout value, a form-binding helper, a list-row fragment, and a full field-spec-driven form engine with its own row templates - so a settings page in any mod reuses ONE layer instead of re-deriving it. Plus two per-world-config primitives (a world-name matcher and a generic Parent-chain resolver) backing a consumer's "one file per world, inherit from a base" schema. All additive over 1.2.0; nothing here is breaking, a consumer picks up only what it calls.

  • New: world/WorldNameMatcher - the generic per-world selector. A pre-parsed pattern list resolved with exact > longest literal core across trailing-* prefix (Foo* = starts with), leading-* suffix (*Foo = ends with), and leading+trailing contains (*Foo* = contains anywhere) > bare * precedence (case-insensitive; on an equal core length ties favour the more anchored form, prefix then suffix then contains), returning the bound payload or null so the caller falls back to its global settings. The contains form catches an instance world whose live name carries BOTH a leading instance- prefix and a random suffix (instance-KweebecNightmare_Chase-<uuid>), which a plain trailing-* prefix cannot reach. Feature-matched to the MMO's own world-rules matcher; one matcher for every consumer with per-world config semantics.
  • New: codec/JsonParentResolver - generic Parent-chain resolution over a raw-JSON pool. For asset families whose bodies must merge across layers the engine store cannot see (store bodies plus owner-dir files): resolves multi-level parent chains transitively (memoized, cycle-guarded, warn-and-standalone on a cycle or unknown parent), deep-merging the child over the parent per leaf (arrays replace wholesale) and stripping the parent key. A body kept in the pool but not requested as output is a shared base that is never emitted.
  • New: util/JsonOverrideWriter - partial write-back for a codec-authored owner file. Sets or removes leaves addressed by dotted PascalCase codec paths ("ZoneHud.Position", "Difficulty.DistanceEscalation.Enabled"), preserving every sibling key and a leading $Comment, plus a top-level array upsert / remove keyed by a match field (whole-element replace / append / remove, other elements preserved). The counterpart to a read/fold config that has no save(). Number type fidelity is the caller's contract (an Integer for a Codec.INTEGER leaf, a Double for Codec.DOUBLE); a List or String[] value instead becomes a JSON array leaf (replacing it wholesale, the same as any other leaf); a null value removes a leaf; the public API is plain-Java-typed so a consumer needs no Gson of its own. Atomic write, fully guarded (a malformed existing file is never overwritten), unit-tested.
  • New: ui/hud/HudPosition - the mod-agnostic HUD layout value, lifted. A vertical + horizontal edge + pixel offsets, with named corner presets (parse / isValidPreset) and toAnchor(w, h) / toAnchorContentHeight(w) that pin exactly one edge per axis so an offset actually moves the panel. Carries no consumer-specific defaults (a consumer supplies its own default position). Every mod's HUD now reads ONE layout authority instead of a per-mod copy.
  • New: ui/SettingsUiUtil - a domain-free form-binding + widget helper. Dropdown populate / bindDropdown, bindTextField, bindButton, bindNavigation, plus setStatus / setToggle / setTabActive. Every text-bearing helper targets a Label's .TextSpans (never a TextButton.Text String sink) so a client-resolved / parameterized Message substitutes params and renders markup correctly. The engine-typed twin of a consumer's own UIUtil, with no i18n keys or content enums.
  • New: Pages/ZigListRow.ui - a generic appendable CRUD list row. A title + subtitle text column that flexes, an optional badge, and Edit / Remove action buttons; appended into a consumer's list container, with the indexed parent scoping the bare descendant ids so rows never collide across many entries or many mods. For a fixed form (one instance per control) the reusable unit is the STYLE (ZigButtons.ui), not a whole-row doc - a consumer authors its static knobs directly and reuses this fragment only for the repeated list.
  • New: ui/form/ - a generic settings-form engine. A consumer describes its fields once as an ordered FieldSpec list (by kind: text, number, a 0..1 chance, an any-sign int, a comma-separated id list, an instant toggle, an Inherit/On/Off tristate, a fixed dropdown, plus label-only header/note rows), each carrying an optional dotted codec leaf path and an opaque label key the consumer resolves to its own localized text. SettingsForm then renders the whole spec list as appended rows in one call, refreshes just the values on an already-open page for a partial update, and parses everything back into a leaf map (or the first validation failure) ready for a write-back. Any field except a header/note row can also carry an optional wrapping grey hint line under its control (FieldSpec.withHint), for static per-setting help text or a value composed at render time (e.g. "Inherits: 30"); a consumer sets or hides it directly with SettingsForm.applyHint, independent of the rest of the row. No i18n keys, no consumer content types, and no persistence policy live in the engine itself - a settings page in any mod reuses ONE binding + parsing layer instead of re-deriving it per config.
  • New: five appendable settings-row templates, following the existing generic list-row convention so many rows - and many mods - never collide. The field/dropdown/toggle rows reserve space for that optional second hint line, which stays collapsed to zero height until a form actually uses it.