SelectionHistoryBuffer¶
Namespace:
SideXP.Selection
Ordered list of selection snapshots, with a cursor on the current one. Works like a web browser history: adding a snapshot after going back discards the "forward" entries.
Fields¶
DefaultMaxCount¶
The default maximum number of entries in the history.
Properties¶
Entries¶
The entries of the history, from the oldest to the most recent.
Count¶
The number of entries in the history.
CurrentIndex¶
The index of the current entry, or -1 if the history is empty.
Current¶
The current entry, or null if the history is empty.
MaxCount¶
The maximum number of entries in the history. The oldest entries are discarded when this limit is exceeded.
Remarks
Can't be lower than 1. Setting a lower value than the current number of entries discards the oldest ones.
Methods¶
Push(SelectionSnapshot)¶
Adds a snapshot after the current entry, and makes it the current one. The entries after the current one are discarded.
Parameters
snapshot: The snapshot to add.
Returns
Returns true if the snapshot has been added, or false if it matches the current entry.
Exceptions
ArgumentNullException: Thrown if the given snapshot is null.
FindTarget(int)¶
Finds the entry to move to when going back or forward from the current entry. Entries that can't be resolved are skipped.
Parameters
steps: The number of entries to move by. Negative values go back, positive values go forward.
Returns
Returns the index of the found entry. If there are fewer valid entries than the given number of steps, returns the furthest valid entry in that direction. Returns -1 if there's no valid entry in that direction.
SetCurrentIndex(int)¶
Makes the entry at the given index the current one.
Parameters
index: The index of the entry.
Returns
Returns true if the current entry has changed, or false if the index is out of range.
Clear()¶
Removes all the entries.
Clean()¶
Removes the objects that don't exist anymore from the entries, and the entries that become empty. If the current entry is removed, the previous remaining entry becomes the current one.
Returns
Returns true if at least one object or entry has been removed.
Remarks
The objects that don't have a stable id but are still resolved are refreshed, so they get one if possible (for example, an object selected in play mode that also exists in edit mode).
Refresh()¶
Captures again the identifiers of the objects that are still alive in all the entries.
Returns
Returns true if the identifiers have been captured again.
Remarks
Does nothing in play mode, so the stable ids captured in edit mode are not lost.