13#include "../../system/system_utils.h"
17#ifndef OLYMPE_HEADLESS
18# include "../../third_party/imgui/imgui.h"
70 const std::map<std::string, std::vector<std::string>>&
refMap)
75std::vector<std::string>
79 std::vector<std::string> nodes;
82 const std::string& nodeID =
kv.first;
83 const std::vector<std::string>&
presets =
kv.second;
89 nodes.push_back(nodeID);
127 const std::string& presetID)
188#ifndef OLYMPE_HEADLESS
192 if (!ImGui::Begin(
"Condition Preset Library", &
m_isOpen))
217#ifndef OLYMPE_HEADLESS
227 ImGui::SetNextItemWidth(160.0f);
237#ifndef OLYMPE_HEADLESS
250#ifndef OLYMPE_HEADLESS
253 ImGui::PushID(presetID.c_str());
259 const std::string label =
preset.name +
" " +
preset.GetPreview();
260 bool open = ImGui::CollapsingHeader(label.c_str(),
flags);
262 if (ImGui::IsItemClicked())
269 if (ImGui::SmallButton(
"Dup"))
274 if (ImGui::SmallButton(
"X"))
282 ImGui::TextUnformatted(
preset.GetPreview().c_str());
293#ifndef OLYMPE_HEADLESS
294 ImGui::OpenPopup(
"Delete Preset?");
295 if (ImGui::BeginPopupModal(
"Delete Preset?",
nullptr,
301 ImGui::Text(
"Delete \"%s\"?",
preset->name.c_str());
305 ImGui::TextColored(
ImVec4(1.f, 0.4f, 0.4f, 1.f),
306 "Warning: used by %d node(s)",
307 static_cast<int>(
users.size()));
311 if (ImGui::Button(
"Delete"))
314 ImGui::CloseCurrentPopup();
317 if (ImGui::Button(
"Cancel"))
320 ImGui::CloseCurrentPopup();
330#ifndef OLYMPE_HEADLESS
334 std::string
usedBy =
"Used by: ";
335 for (
size_t i = 0;
i <
users.size(); ++
i)
340 ImGui::TextDisabled(
"%s",
usedBy.c_str());
UI panel for managing Condition Presets globally (Phase 24.1).
ComponentTypeID GetComponentTypeID_Static()
void RenderReferenceAnalysis(const std::string &presetID)
std::vector< ConditionPreset > GetFilteredPresets() const
Returns filtered presets based on the current search filter.
bool m_showDeleteConfirmation
void RenderPresetItem(const std::string &presetID, const ConditionPreset &preset)
std::string m_selectedPresetID
Highlighted preset ID.
std::string m_searchFilter
Current search text.
void SetSelectedPresetID(const std::string &id)
Selects the preset with the given ID.
std::string OnDuplicatePresetClicked(const std::string &presetID)
Handles the "Duplicate" button for a preset.
void OnPresetSelected(const std::string &presetID)
Selects a preset (highlights it in the list).
void OnDeleteCancelled()
Cancels the pending deletion and hides the confirmation dialog.
std::map< std::string, std::vector< std::string > > m_refMap
External reference map: nodeID -> list of preset IDs that node references.
ConditionPresetRegistry & m_registry
Global preset registry.
void SetSearchFilter(const std::string &filter)
Sets the search filter string (case-insensitive substring).
void SetReferenceMap(const std::map< std::string, std::vector< std::string > > &refMap)
Sets the reference analysis map (nodeID -> list of preset IDs used).
void OnDeletePresetClicked(const std::string &presetID)
Handles the "Delete" button for a preset.
ConditionPresetLibraryPanel(ConditionPresetRegistry ®istry)
Constructs the panel with a reference to the preset registry.
void OnDeleteConfirmed(const std::string &presetID)
Confirms the pending deletion.
void RenderDeleteConfirmationDialog()
std::function< void(const std::string &)> OnPresetDeleted
Invoked after a preset is deleted.
std::string OnAddPresetClicked()
Handles the "Add Preset" button.
void Render()
Renders the full panel window using ImGui.
std::string m_presetToDelete
ID queued for deletion.
std::function< void(const std::string &)> OnPresetCreated
Invoked after a new preset is added.
std::vector< std::string > GetReferencingNodes(const std::string &presetID) const
Returns a list of node IDs that reference the given preset.
Manages the global pool of ConditionPreset objects.
void DeletePreset(const std::string &id)
Removes a preset from the registry.
std::string CreatePreset(const ConditionPreset &preset)
Adds a preset to the registry.
std::string DuplicatePreset(const std::string &id)
Creates an independent copy of an existing preset with a new UUID.
bool Save(const std::string &filepath) const
Saves all presets to a JSON file.
std::vector< ConditionPreset > GetFilteredPresets(const std::string &filter) const
Returns all presets whose name contains the filter substring.
ConditionPreset * GetPreset(const std::string &id)
Returns a mutable pointer to the preset, or nullptr if not found.
< Provides AssetID and INVALID_ASSET_ID
A globally-stored, reusable condition expression.
std::string name
Human-readable display name (e.g. "Condition #1")
static Operand CreateVariable(const std::string &variableID)
Factory — creates a Variable-mode operand.
static Operand CreateConst(double constVal)
Factory — creates a Const-mode operand.
std::string ResolveResourcePath(const std::string &relativePath)