private static void DrawPresetList() { var currentPreset = CurrentPreset; var hasSelectedPreset = currentPreset != null; ImGui.PushFont(UiBuilder.IconFont); if (ImGui.Button(FontAwesomeIcon.PlusCircle.ToIconString())) { Cammy.Config.Presets.Add(new()); Cammy.Config.Save(); } ImGui.SameLine(); if (ImGui.Button(FontAwesomeIcon.Copyright.ToIconString()) && hasSelectedPreset) { Cammy.Config.Presets.Add(CurrentPreset.Clone()); Cammy.Config.Save(); } ImGui.SameLine(); if (ImGui.Button(FontAwesomeIcon.ArrowCircleUp.ToIconString()) && hasSelectedPreset) { var preset = CurrentPreset; Cammy.Config.Presets.RemoveAt(selectedPreset); selectedPreset = Math.Max(selectedPreset - 1, 0); Cammy.Config.Presets.Insert(selectedPreset, preset); Cammy.Config.Save(); } ImGui.SameLine(); if (ImGui.Button(FontAwesomeIcon.ArrowCircleDown.ToIconString()) && hasSelectedPreset) { var preset = CurrentPreset; Cammy.Config.Presets.RemoveAt(selectedPreset); selectedPreset = Math.Min(selectedPreset + 1, Cammy.Config.Presets.Count); Cammy.Config.Presets.Insert(selectedPreset, preset); Cammy.Config.Save(); } ImGui.SameLine(); ImGui.Button(FontAwesomeIcon.TimesCircle.ToIconString()); if (hasSelectedPreset && ImGui.BeginPopupContextItem(null, ImGuiPopupFlags.MouseButtonLeft)) { if (ImGui.Selectable(FontAwesomeIcon.TrashAlt.ToIconString())) { Cammy.Config.Presets.RemoveAt(selectedPreset); selectedPreset = Math.Min(selectedPreset, Cammy.Config.Presets.Count - 1); currentPreset = CurrentPreset; hasSelectedPreset = currentPreset != null; Cammy.Config.Save(); } ImGui.EndPopup(); } ImGui.SameLine(); ImGui.TextUnformatted(FontAwesomeIcon.InfoCircle.ToIconString()); ImGui.PopFont(); if (ImGui.IsItemHovered()) { ImGui.SetTooltip("You can CTRL + Left Click sliders to input values manually."); } ImGui.BeginChild("CammyPresetList", new Vector2(250 * ImGuiHelpers.GlobalScale, 0), true); for (int i = 0; i < Cammy.Config.Presets.Count; i++) { var preset = Cammy.Config.Presets[i]; ImGui.PushID(i); var isActive = preset == PresetManager.activePreset; var isOverride = preset == PresetManager.presetOverride; if (isActive) { ImGui.PushStyleColor(ImGuiCol.Text, !isOverride ? 0xFF00FF00 : 0xFFFFAF00); } if (ImGui.Selectable(preset.Name, selectedPreset == i)) { selectedPreset = i; } if (isActive) { ImGui.PopStyleColor(); } if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left)) { PresetManager.SetPresetOverride(!isOverride ? preset : null); } ImGui.PopID(); } ImGui.EndChild(); if (!hasSelectedPreset) { return; } ImGui.SameLine(); ImGui.BeginChild("CammyPresetEditor", ImGui.GetContentRegionAvail(), true); DrawPresetEditor(currentPreset); ImGui.EndChild(); }
private unsafe void ToggleConfig(string command, string argument) { if (string.IsNullOrEmpty(argument)) { ToggleConfig(); return; } var regex = Regex.Match(argument, "^(\\w+) ?(.*)"); var subcommand = regex.Success && regex.Groups.Count > 1 ? regex.Groups[1].Value : string.Empty; switch (subcommand.ToLower()) { case "preset": { if (regex.Groups.Count < 2 || string.IsNullOrEmpty(regex.Groups[2].Value)) { PresetManager.SetPresetOverride(null); PrintEcho("Removed preset override."); return; } var arg = regex.Groups[2].Value; var preset = Config.Presets.FirstOrDefault(preset => preset.Name == arg); if (preset == null) { PrintError($"Failed to find preset \"{arg}\""); return; } PresetManager.SetPresetOverride(preset); PrintEcho($"Preset set to \"{arg}\""); break; } case "zoom": { if (regex.Groups.Count < 2 || !float.TryParse(regex.Groups[2].Value, out var amount)) { PrintError("Invalid amount."); return; } Game.cameraManager->WorldCamera->CurrentZoom = amount; break; } case "fov": { if (regex.Groups.Count < 2 || !float.TryParse(regex.Groups[2].Value, out var amount)) { PrintError("Invalid amount."); return; } Game.cameraManager->WorldCamera->CurrentFoV = amount; break; } case "spectate": { Game.ToggleSpectate(); PrintEcho($"Spectating is now {(Game.GetCameraTargetHook.IsEnabled ? "enabled" : "disabled")}!"); break; } case "nocollide": { Game.cameraNoCollideReplacer.Toggle(); PrintEcho($"Camera collision is now {(Game.cameraNoCollideReplacer.IsEnabled ? "disabled" : "enabled")}!"); break; } case "freecam": { FreeCam.Toggle(); break; } case "help": { PrintEcho("Subcommands:" + "\npreset <name> - Applies a preset to override automatic presets, specified by name. Use without a name to disable." + "\nzoom <amount> - Sets the current zoom level." + "\nfov <amount> - Sets the current FoV level." + "\nspectate - Toggles the \"Spectate Focus / Soft Target\" option." + "\nnocollide - Toggles the \"Disable Camera Collision\" option." + "\nfreecam - Toggles the \"Free Cam\" option."); break; } default: { PrintError("Invalid usage: " + cammySubcommands); break; } } }