private static bool DrawDragDropTargetSources(CooldownTrigger trigger, IList <int> toSwap) { const string payloadIdentifier = "PRIORITY_PAYLOAD"; if (ImGui.BeginDragDropSource(ImGuiDragDropFlags.SourceNoHoldToOpenOthers | ImGuiDragDropFlags.SourceNoPreviewTooltip)) { unsafe { var prio = trigger.Priority; var ptr = new IntPtr(&prio); ImGui.SetDragDropPayload(payloadIdentifier, ptr, sizeof(int)); } ImGui.SameLine(); ImGui.AlignTextToFramePadding(); #if DEBUG ImGui.Text($"{trigger.Priority + 1} Dragging {trigger.ActionName}."); #else ImGui.Text($"Dragging {trigger.ActionName}."); #endif ImGui.EndDragDropSource(); return(true); } if (!ImGui.BeginDragDropTarget()) { return(false); } var imGuiPayloadPtr = ImGui.AcceptDragDropPayload(payloadIdentifier, ImGuiDragDropFlags.AcceptNoPreviewTooltip | ImGuiDragDropFlags.AcceptNoDrawDefaultRect); unsafe { if (imGuiPayloadPtr.NativePtr is not null) { var prio = *(int *)imGuiPayloadPtr.Data; toSwap[0] = prio; toSwap[1] = trigger.Priority; } } ImGui.SameLine(); ImGui.AlignTextToFramePadding(); #if DEBUG ImGui.Text($"{trigger.Priority + 1} Swap with {trigger.ActionName}"); #else ImGui.Text($"Swap with {trigger.ActionName}"); #endif ImGui.EndDragDropTarget(); return(true); }
private static bool DrawActionCombo(IEnumerable <FFXIVAction> actions, CooldownTrigger trigger) { if (!ImGui.BeginCombo($"##Action{trigger.Priority}", #if DEBUG trigger.ActionCooldownGroup == CooldownTrigger.GCDCooldownGroup ? $"{trigger.ActionName} (GCD)" : trigger.ActionName #else trigger.ActionCooldownGroup == CooldownTrigger.GCDCooldownGroup ? "GCD" : trigger.ActionName #endif ) ) { return(false); } var changed = false; foreach (var a in actions) { var isSelected = a.RowId == trigger.ActionId; if (ImGui.Selectable( #if DEBUG a.CooldownGroup == CooldownTrigger.GCDCooldownGroup ? $"{a.Name} (GCD)" : a.Name, #else a.CooldownGroup == CooldownTrigger.GCDCooldownGroup ? "GCD" : a.Name, #endif isSelected)) { trigger.ActionId = a.RowId; trigger.ActionName = a.Name; trigger.ActionCooldownGroup = a.CooldownGroup; changed = true; } if (isSelected) { ImGui.SetItemDefaultFocus(); } } ImGui.EndCombo(); return(changed); }
private static bool DrawPatternCombo(IEnumerable <VibrationPattern> patterns, CooldownTrigger trigger) { if (!ImGui.BeginCombo($"##Pattern{trigger.Priority}", trigger.Pattern.Name)) { return(false); } var changed = false; foreach (var p in patterns) { var isSelected = p.Guid == trigger.PatternGuid; if (ImGui.Selectable(p.Name, isSelected)) { trigger.Pattern = p; trigger.PatternGuid = p.Guid; changed = true; } if (isSelected) { ImGui.SetItemDefaultFocus(); } } ImGui.EndCombo(); return(changed); }