public static void Toggle(bool death = false) { var enable = !Enabled; var isMainMenu = !DalamudApi.Condition.Any(); if (enable) { locked = false; speed = 1; position = DalamudApi.ClientState.LocalPlayer?.Position is { } pos ? new(pos.X, pos.Z, pos.Y + 1) : new(); onDeath = death; gameCamera = isMainMenu ? Game.cameraManager->MenuCamera : Game.cameraManager->WorldCamera; if (isMainMenu) { *(byte *)((IntPtr)gameCamera + 0x2A0) = 0; } gameCamera->MinVRotation = -1.559f; gameCamera->MaxVRotation = 1.559f; gameCamera->CurrentFoV = gameCamera->MinFoV = gameCamera->MaxFoV = 0.78f; gameCamera->CurrentZoom = gameCamera->MinZoom = gameCamera->MaxZoom = 0.1f; Game.zoomDelta = 0; gameCamera->LookAtHeightOffset = 0; gameCamera->Mode = 1; Game.cameraNoCollideReplacer.Enable(); if (!isMainMenu) { Game.ForceDisableMovement++; Cammy.PrintEcho("Additional Controls:" + //"\nMove Keybinds - Move," + //"\nJump / Ascend - Up," + //"\nDescend - Down," + "\nShift (Hold) - Speed up" + "\nZoom / Controller Zoom (Autorun + Look Up / Down) - Change Speed" + "\nC / Controller Dismount (Autorun + Change Hotbar Set) - Reset" + "\nCycle through Enemies (Nearest to Farthest) / Controller Select HUD - Lock" + "\nCycle through Enemies (Farthest to Nearest) / Controller Open Main Menu - Stop"); } } else { gameCamera = null; Game.cameraNoCollideReplacer.Disable(); if (!isMainMenu) { if (!locked && Game.ForceDisableMovement > 0) { Game.ForceDisableMovement--; } new CameraConfigPreset().Apply(); PresetManager.DisableCameraPresets(); } } if (!isMainMenu) { return; }
private void TerritoryChanged(object sender, ushort id) { if (!pluginReady) { return; } Game.isChangingAreas = true; Game.changingAreaDelay = 1; PresetManager.DisableCameraPresets(); }
private void Logout(object sender, EventArgs e) { if (!pluginReady) { return; } Game.cachedDefaultLookAtHeight = null; Game.isLoggedIn = false; PresetManager.DisableCameraPresets(); }
private void Update(Framework framework) { if (!pluginReady) { return; } Game.Update(); FreeCam.Update(); PresetManager.Update(); }
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; } } }