using System; using UnityEngine; namespace Jovian.PopupSystem { /// /// Value type identifying a popup element prefab. Compared by string ID using ordinal /// comparison. Built-in types cover common popup elements. Define custom types as static /// fields or create instances for game-specific elements and variants. /// [Serializable] public struct PopupElementType : IEquatable { [SerializeField] private string id; /// The string identifier for this element type. public string Id => id; public PopupElementType(string id) { this.id = id; } // --- Built-in types --- /// Bold header text element. public static readonly PopupElementType Header = new("header"); /// Body text element. public static readonly PopupElementType Text = new("text"); /// Label + value stat row element. public static readonly PopupElementType LabelValueText = new("label_value_text"); /// Image/icon element. public static readonly PopupElementType Image = new("image"); /// Horizontal separator line. public static readonly PopupElementType Separator = new("separator"); // --- Variant helper --- /// /// Creates a variant of this element type by appending a suffix. /// e.g. PopupElementType.Header.Variant("gold") produces "header_gold". /// public PopupElementType Variant(string variant) { return new PopupElementType($"{id}_{variant}"); } // --- Equality --- public bool Equals(PopupElementType other) { return string.Equals(id, other.id, StringComparison.Ordinal); } public override bool Equals(object obj) { return obj is PopupElementType other && Equals(other); } public override int GetHashCode() { return id != null ? id.GetHashCode() : 0; } public override string ToString() { return id ?? string.Empty; } public static bool operator ==(PopupElementType left, PopupElementType right) { return left.Equals(right); } public static bool operator !=(PopupElementType left, PopupElementType right) { return !left.Equals(right); } } }