Table of Contents

Class UITKSlotPanelBase

Namespace
FishMMO.Client
Assembly
FishMMO.Client.dll

Shared behaviour for every panel that draws a character's item slots — the bag, the bank, and the equipment sockets.

public abstract class UITKSlotPanelBase : UITKCharacterControl
Inheritance
Object
Component
Behaviour
MonoBehaviour
UITKSlotPanelBase
Derived
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.MemberwiseClone()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Remarks

UITKItemGridPanel already unified the bank and the inventory, and the comment at the top of it explains why. What it did not reach was the equipment panel, which sat beside it re-implementing eighteen identically named members: the tracker subscription and both of its handlers, the slot-blocked test, the slot painters, the lock overlay, the tooltip refresh and the enter/leave pair, the drag start and the container lookup. Same names, same jobs, two bodies.

AND THEY HAD ALREADY DRIFTED, which is the whole argument for this class rather than a preference about tidiness. Three ways, found by reading them side by side:

  • IsSlotBlocked: the grid refused a slot holding an item with no database identity yet (ID <= 0), because the server keeps such a slot locked until the row lands and would refuse any request naming it. The equipment copy did not, so a socket could offer a drag the server was certain to reject.
  • A slot update repainted the lock overlay in the grid and did not in the equipment panel.
  • Shift-click quick transfer (issue #197) existed only in the grid. See UITKEquipment.OnSlotPointerDown, where that is now fixed and said out loud.

The first two are settled here, in the single body, in the grid's favour — it is the one that had the reasoning written down. What is NOT settled here is anything that is genuinely two operations wearing one name: a drop onto a bag slot is a swap or a split, a drop onto a socket is an equip, and those speak different halves of the protocol. Those stay in the two panels, and the click dispatch that reaches them stays with them, because hoisting a dispatcher whose every branch is abstract buys indirection and no shared behaviour. SlotPanelSharingTests is what stops that seam from drifting again.

A move between slots is a PRESS to pick the item up and a PRESS to put it down, never a release. That rule is stated where the release handler used to be — near the bottom of this file, above Notify — because the absence of a PointerUpEvent registration otherwise reads as an oversight, and it has already been "fixed" once.

The one thing every slot panel must keep for itself is how its slots come into existence. The equipment sockets are authored in UICharacterSheet.uxml and found by name; the grids build theirs in code from the container's slot count. So this class owns what a slot DOES and never how it is made: it holds the slotViews list, and the derived panel fills it.

Fields

DRAG_OBJECT_NAME

Name of the shared drag object overlay.

protected const string DRAG_OBJECT_NAME = "UIDragObject"

Field Value

string

TOAST_NAME

Name of the shared transient-notice overlay.

protected const string TOAST_NAME = "UIToast"

Field Value

string

TOOLTIP_NAME

Name of the shared tooltip overlay.

protected const string TOOLTIP_NAME = "UITooltip"

Field Value

string

Remarks

Aliased rather than repeated: the same overlay is now opened by UITKSlotPainter for panels that do not derive from this class, and two literals that agree by hand are how a rename half-lands.

slotViews

Slot views indexed by container slot index.

protected readonly List<UITKSlotPanelBase.SlotView> slotViews

Field Value

List<UITKSlotPanelBase.SlotView>

Remarks

Filled by the derived panel, because the two sources of a slot element are not alike: the grids create one element per container slot, the equipment panel queries ten authored sockets out of its UXML. What both owe this list is that index i is container slot i — for equipment that means a missing UXML element still occupies its place as a default UITKSlotPanelBase.SlotView rather than being skipped, or every socket after it would draw the wrong item.

A list rather than an array, and empty rather than null before the tree has been read. The equipment panel used a null array and had to test for it in eight places; one of those tests read .Length first and was an NRE on the first equip of any session in which the player had not opened the window. An empty list fails every bounds check the same way without a special case.

Properties

CssHidden

USS class hiding an element.

protected virtual string CssHidden { get; }

Property Value

string

CssLockPending

USS class marking a slot as waiting on the server.

protected virtual string CssLockPending { get; }

Property Value

string

Remarks

The same overlay carries two meanings — the container's own slot lock and a request this panel is waiting on — because to the player they are one statement: this slot is busy, do not click it. This modifier distinguishes them visually without a second element in every slot.

DragType

The drag and operation-tracker identity of this panel's slots.

protected abstract ReferenceButtonType DragType { get; }

Property Value

ReferenceButtonType

OwnContainer

This panel's own container, or null when the character does not have one yet.

protected IItemContainer OwnContainer { get; }

Property Value

IItemContainer

Prefix

Element and USS name prefix for this panel, without a trailing dash.

protected abstract string Prefix { get; }

Property Value

string

Remarks

"bank", "inv", "eq". Every panel-specific class name is this prefix plus a fixed suffix, which is what lets the two USS names this class needs be derived rather than declared three times. A panel whose markup does not follow the pattern overrides the names below instead of bending the prefix.

Methods

ApplyPerOpenContent()

Re-reads everything this panel shows from the character, without rebuilding the tree.

protected abstract void ApplyPerOpenContent()

Remarks

Abstract rather than shared, deliberately. The two bodies do not merely differ in content, they differ in ORDER, and the order is the part that was hard won: the grid repaints its currency chip ahead of the container null check because a character with no container still has money, and the equipment panel clears previewFramed after the slots so the camera re-frames against the silhouette it can now see. Averaging two carefully sequenced methods into one is how a refactor quietly undoes both.

ApplySlotLockVisual(int, bool)

Shows or hides the lock overlay on a slot.

protected void ApplySlotLockVisual(int slotIndex, bool isLocked)

Parameters

slotIndex int
isLocked bool

ApplySlotUpdate(IItemContainer, Item, int)

Applies a slot the server has sent back: releases its pending mark, repaints it, and tells any drag that was started from it.

protected void ApplySlotUpdate(IItemContainer container, Item item, int slotIndex)

Parameters

container IItemContainer

The container the update came from.

item Item

What the slot now holds, as the event reported it.

slotIndex int

The slot that changed.

Remarks

The slot arriving from the server IS the acknowledgement of whatever this panel asked for, so the pending mark is released here rather than on a separate reply message. What the player is waiting to see is the slot.

/* DELIBERATE BEHAVIOUR CHANGE, equipment panel. */ The grid repainted the lock overlay after applying an update and the equipment copy did not. The item itself can be the reason a slot is blocked (no identity yet), and the slot arriving with its identity is what unblocks it, so the repaint belongs on every path. It is idempotent — the release above already raises SlotPendingChanged, which repaints the same overlay — so the socket gains correctness in the one case it was missing and nothing else.

BeginDragFromSlot(UITKDragObject, IItemContainer, int)

Starts a drag from an occupied slot.

protected void BeginDragFromSlot(UITKDragObject dragObject, IItemContainer container, int slotIndex)

Parameters

dragObject UITKDragObject
container IItemContainer
slotIndex int

Remarks

The refusal is logged, not just the success. A drag that will not start looks identical to a click the game did not receive, and the three reasons it can refuse — the slot is waiting, the slot is empty, the item is gone — are indistinguishable from the outside.

ClearSlot(int)

Clears a slot's icon and hides its stack-count badge.

protected void ClearSlot(int slotIndex)

Parameters

slotIndex int

Hide(bool)

Hides the panel and abandons anything it had in flight.

public override void Hide(bool overrideIsAlwaysOpen)

Parameters

overrideIsAlwaysOpen bool

When true, the call is a no-op.

Remarks

Closing is not a neutral act: walking out of range of the interactable that opened the panel is one of the ways the server refuses an operation, so a slot left marked as waiting after the panel closes has a very good chance of never being answered.

Hide(bool) and not Hide(): Hide() delegates here, but Escape (UIManager.CloseNext) and quit-to-login (Hide(false)) both arrive at this overload directly.

IsDragInFlight()

True while a drag is in flight, wherever it was started.

protected static bool IsDragInFlight()

Returns

bool

Remarks

A left-click that lands while the player is carrying something is the DROP, not a click. The panel it lands on completes the drag rather than acting on whatever occupies the slot underneath, and that completing press reads no modifier at all — so a modifier held at that moment cannot be allowed to divert it. Shift-click's "send this to the other container" is an answer to a click on a slot's OWN item, and while a drag is in flight the item that gesture would send away is not the one the player is holding.

Shared rather than written into each router, because the routers having their own copy of a click rule is exactly how the two of them came apart in the first place — see the class remarks, and DRAG_OBJECT_NAME above for the overlay this asks.

IsSlotBlocked(int)

Reports whether a slot is unavailable for a new request, for any reason.

protected bool IsSlotBlocked(int slotIndex)

Parameters

slotIndex int

Returns

bool

Remarks

/* DELIBERATE BEHAVIOUR CHANGE, equipment panel. */ The two copies of this test had drifted: the grid refused a slot whose item has no database identity yet, and the equipment copy stopped at the container's own lock. The grid is right and the socket was wrong, so the socket now follows it. An item with ID <= 0 is one the database has not written yet; the server keeps its slot locked until the row lands and re-sends the slot with the assigned id, so until then every request naming it would be refused. Showing it as waiting costs the player nothing and saves a round trip that ends in a refusal they did not ask for. The practical effect on sockets is small — equipped items have identities — which is exactly why the divergence survived unnoticed.

Notify(string, ToastSeverity)

Shows a transient notice, if the toast panel is up.

protected static void Notify(string text, ToastSeverity severity)

Parameters

text string
severity ToastSeverity

Remarks

Hoisted from the two panels that had written it identically, five lines each. A drop the panel refuses is a gesture the player made and expects an answer to, and in a slot panel there is nowhere else for that answer to surface — which is why every refusal path in both panels reaches for this.

Nothing about the overlay is per-panel: TOAST_NAME is already declared here for both of them.

OnAfterShow()

Re-applies per-open content on every show, including the very first one.

protected override void OnAfterShow()

Remarks

THE CONTRACT, and both panels had written it out separately. When hiding disabled the document, every show re-cloned the UXML and discarded anything written before Show(). The tree persists across hide/show now, but OnAfterStarting runs once at startup and only again on a genuine tree replacement, so it cannot carry per-open content: this hook runs on every open. Both hooks do the work, and both are idempotent.

OnAfterStarting()

Applies per-open content once the visual tree exists, and again if it is ever replaced.

protected override void OnAfterStarting()

OnClientSet()

Joins the shared operation tracker. Derived panels extend this to register broadcasts.

public override void OnClientSet()

OnClientUnset()

Leaves the shared operation tracker. Derived panels extend this to unregister broadcasts.

public override void OnClientUnset()

OnDestroying()

Drops every subscription this class holds when the control is destroyed.

public override void OnDestroying()

OnPanelDestroying()

Lets a panel release what only it holds, after the shared subscriptions are gone.

protected virtual void OnPanelDestroying()

OnPanelHidden()

Lets a panel release what only it holds once it has actually gone off screen.

protected virtual void OnPanelHidden()

Remarks

Runs before the drag is abandoned, which is the order the equipment panel already used: it hands its preview camera back here, and the cost of that camera is paid every frame whether or not anyone is looking at it.

OnSlotContentChanged()

Told whenever what a slot holds has been repainted.

protected virtual void OnSlotContentChanged()

Remarks

The grids recompute their capacity readout from here. The hook exists rather than a call to a capacity method because the equipment panel has no capacity: its ten sockets are not a resource that fills up, and "8 / 10 sockets used" is not a fact a player needs. That asymmetry was the only real difference between the two SetSlotItem bodies, so it is the only thing left configurable.

OnSlotPointerEnter(int, VisualElement)

Shows the item tooltip when the pointer enters a slot that contains an item.

protected void OnSlotPointerEnter(int slotIndex, VisualElement owner)

Parameters

slotIndex int

The slot the pointer entered.

owner VisualElement

The slot element, so the tooltip can close itself if it is rebuilt.

Remarks

This class answers WHERE the item is — it is the one that knows what its own container holds — and hands the item to the painter, which answers what a tooltip does.

OnSlotPointerLeave(VisualElement)

Hides the item tooltip when the pointer leaves a slot.

protected void OnSlotPointerLeave(VisualElement owner)

Parameters

owner VisualElement

OnSlotUpdateReceived(int)

Told that a slot update has been accepted, before the slot is repainted.

protected virtual void OnSlotUpdateReceived(int slotIndex)

Parameters

slotIndex int

Remarks

The equipment panel invalidates its preview framing here: equipment changes the silhouette, a two-handed weapon reaches further than a dagger, and a frame sized before it existed crops it.

OnTick()

Times out item operations whose reply never arrived.

protected override void OnTick()

Remarks

The tracker is shared and self-clearing, so it does not matter that all three item panels drive it; whichever ticks first in a frame does the work and the others find nothing outstanding.

RefreshAllSlots(IItemContainer)

Repaints every slot's item and lock state from the container.

protected void RefreshAllSlots(IItemContainer container)

Parameters

container IItemContainer

Remarks

Clamped to the container as well as to the view, because the two can disagree: a grid built before the character had a container is a grid of zero slots, and one built against a tree that has since been replaced still reports a length. A slot with no root element is skipped rather than treated as broken — the equipment panel deliberately keeps a placeholder for a socket its UXML does not declare, so that the indices after it still line up with the container.

ReleaseAndClearDrag()

Abandons this panel's in-flight operations and any drag that started here.

protected void ReleaseAndClearDrag()

ResolveContainer(ReferenceButtonType)

Resolves the character's container for a drag source type.

protected IItemContainer ResolveContainer(ReferenceButtonType type)

Parameters

type ReferenceButtonType

Returns

IItemContainer

Remarks

Every one of these controllers derives from IItemContainer — IEquipmentController included — which is what lets one body serve a panel that thinks in sockets and a panel that thinks in bag slots. That was already true before this class existed; the panels simply were not leaning on it.

SetSlotItem(int, Item)

Populates a slot's icon and stack-count badge from an item.

protected void SetSlotItem(int slotIndex, Item item)

Parameters

slotIndex int
item Item

Remarks

The painting itself is Paint(VisualElement, Label, Item, string). What stays here is what is genuinely this class's: which slot it is, whether it exists, and the capacity hook the grids override.

SubscribeTracker()

Joins the shared item-operation tracker, once.

protected void SubscribeTracker()

Remarks

-= before += on a static event. OnClientSet can run more than once in a session (quit to login does SetClient(null) then SetClient(client)), and a static event outlives this component, so a missed unsubscribe is a handler running forever on a destroyed panel.

TryGrowSlotsFor(int)

Asked to make room for a slot index the view does not have. Returns true if it grew.

protected virtual bool TryGrowSlotsFor(int slotIndex)

Parameters

slotIndex int

Returns

bool

Remarks

False by default, because not every panel can: the equipment sockets are authored in UXML and there is no eleventh one to create, so an out-of-range socket index is a bug upstream rather than a view to repair. The grids rebuild from the container's count.

UnsubscribeTracker()

Leaves the shared item-operation tracker, once.

protected void UnsubscribeTracker()