60 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
61 auto& Selection = SelectionContextMap.at(Context);
63 auto Iter = std::find(Selection.begin(), Selection.end(), Handle);
64 if (Iter != Selection.end())
70 Selection.push_back(Handle);
73 SelectedHandle = Handle;
78 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
79 LK_CORE_TRACE_TAG(
"SelectionContext",
"Deselecting: {}", Handle);
80 if (Context == ESelectionContext::Global)
82 for (
auto& [Context, Selection] : SelectionContextMap)
84 const std::size_t Erased = std::erase_if(Selection, [Handle](
const LUUID& CurrentHandle)
86 return (Handle == CurrentHandle);
104 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
105 std::vector<LUUID>& SelectionContext = SelectionContextMap.at(Context);
106 std::erase_if(SelectionContext, [Handle](
const LUUID& CurrentHandle)
108 return (Handle == CurrentHandle);
119 LK_CORE_TRACE_TAG(
"SelectionContext",
"DeselectAll");
120 for (
auto& [Context, Selection] : SelectionContextMap)
131 LK_CORE_TRACE_TAG(
"SelectionContext",
"DeselectAll: {}", Enum::ToString(Context));
132 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
133 if (Context != ESelectionContext::Global)
135 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
136 SelectionContextMap.at(Context).clear();
140 for (
auto& [Context, Selection] : SelectionContextMap)
149 LK_CORE_ASSERT(Handle > 0,
"Handle is 0");
150 const auto& Selection = SelectionContextMap.at(Context);
151 if (Context != ESelectionContext::Global)
153 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
154 return (std::find(Selection.begin(), Selection.end(), Handle) != Selection.end());
158 for (
auto& [Context, Selection] : SelectionContextMap)
160 if (std::find(Selection.begin(), Selection.end(), Handle) != Selection.end())
170 FORCEINLINE
static const std::vector<LUUID>& GetSelected(
const ESelectionContext Context)
172 if (Context == ESelectionContext::Global)
174 static std::vector<LUUID> Combined;
177 auto AllRanges = SelectionContextMap | std::views::values | std::views::join;
178 Combined.reserve(std::ranges::distance(AllRanges));
179 std::ranges::copy(AllRanges, std::back_inserter(Combined));
184 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
185 return SelectionContextMap.at(Context);
189 FORCEINLINE
static LUUID GetSelected(
const ESelectionContext Context,
const std::size_t Index)
191 LK_CORE_ASSERT(Context != ESelectionContext::Global,
"Global selection context cannot be used in GetSelected when using indices");
192 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
193 auto& Selection = SelectionContextMap.at(Context);
194 LK_CORE_VERIFY((Index >= 0) && (Index < Selection.size()));
196 return Selection.at(Index);
204 if (Context == ESelectionContext::Global)
206 auto AllRanges = SelectionContextMap | std::views::values | std::views::join;
207 return std::ranges::distance(AllRanges);
211 LK_CORE_ASSERT(SelectionContextMap.contains(Context),
"Selection context '{}' is missing", Enum::ToString(Context));
212 return SelectionContextMap[Context].size();
222 static LUUID SelectedHandle;
224 static std::unordered_map<ESelectionContext, std::vector<LUUID>> SelectionContextMap;
Definition SelectionContext.h:51
static FORCEINLINE void DeselectAll()
Definition SelectionContext.h:117
static FORCEINLINE void DeselectAll(const ESelectionContext Context)
Definition SelectionContext.h:129
static FORCEINLINE std::size_t GetSelectionCount(const ESelectionContext Context)
Definition SelectionContext.h:202