Skip to content

Commit

Permalink
Free cam keybind overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 15, 2024
1 parent d21a140 commit 9104573
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 38 deletions.
29 changes: 29 additions & 0 deletions Fika.Core/Coop/FreeCamera/FreeCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using EFT;
using Fika.Core.Coop.Components;
using Fika.Core.Coop.Players;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
Expand All @@ -25,6 +26,7 @@ public class FreeCamera : MonoBehaviour
private bool isFollowing = false;
private bool leftMode = false;
private bool disableInput = false;
private bool showOverlay;

private KeyCode forwardKey = KeyCode.W;
private KeyCode backKey = KeyCode.S;
Expand All @@ -47,6 +49,33 @@ protected void Start()
relUpKey = KeyCode.E;
relDownKey = KeyCode.A;
}

showOverlay = FikaPlugin.KeybindOverlay.Value;
FikaPlugin.KeybindOverlay.SettingChanged += KeybindOverlay_SettingChanged;
}

private void KeybindOverlay_SettingChanged(object sender, EventArgs e)
{
showOverlay = FikaPlugin.KeybindOverlay.Value;
}

protected void OnGUI()
{
if (IsActive && showOverlay)
{
Rect rect = new(20, 20, 800, 800);
GUI.Label(rect, $"Left/Right Mouse Button: Jump between players");
rect.y += 15;
GUI.Label(rect, $"CTRL/Spacebar + Left/Right Mouse Button: Jump and spectate in 3rd person or head cam");
rect.y += 15;
GUI.Label(rect, $"T: Teleport to cam position");
rect.y += 15;
GUI.Label(rect, $"N: Toggle nightvision/thermals");
rect.y += 15;
GUI.Label(rect, $"HOME: Disable input");
rect.y += 15;
GUI.Label(rect, $"Shift + Ctrl: Turbo Speed");
}
}

protected void Update()
Expand Down
42 changes: 4 additions & 38 deletions Fika.Core/FikaPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EFT.UI;
Expand Down Expand Up @@ -36,7 +35,6 @@
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
using System.Text;
using UnityEngine;

namespace Fika.Core
Expand All @@ -54,18 +52,8 @@ namespace Fika.Core
[BepInDependency("com.SPT.debugging", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-custom, that way we can disable its patches
public class FikaPlugin : BaseUnityPlugin
{
/// <summary>
/// Stores the Instance of this Plugin
/// </summary>
public static FikaPlugin Instance;
public static InternalBundleLoader BundleLoaderPlugin { get; private set; }
/// <summary>
/// If any mod dependencies fail, show an error. This is a flag to say it has occurred.
/// </summary>
private bool ShownDependencyError { get; set; }
/// <summary>
/// This is the Official EFT Version defined by BSG
/// </summary>
public static string EFTVersionMajor { get; internal set; }
public ManualLogSource FikaLogger { get => Logger; }
public BotDifficulties BotDifficulties;
Expand Down Expand Up @@ -141,6 +129,7 @@ public class FikaPlugin : BaseUnityPlugin
// Coop | Debug
public static ConfigEntry<KeyboardShortcut> FreeCamButton { get; set; }
public static ConfigEntry<bool> AZERTYMode { get; set; }
public static ConfigEntry<bool> KeybindOverlay { get; set; }

// Performance
public static ConfigEntry<bool> DynamicAI { get; set; }
Expand Down Expand Up @@ -189,12 +178,12 @@ public class FikaPlugin : BaseUnityPlugin
public bool AllowItemSending;
public string[] BlacklistedItems;
public bool ForceSaveOnDeath;
public bool QuestSharing;
#endregion

protected void Awake()
{
Instance = this;
LogDependencyErrors();

SetupConfig();

Expand Down Expand Up @@ -344,6 +333,8 @@ private void SetupConfig()

AZERTYMode = Config.Bind("Coop | Debug", "AZERTY Mode", false, "If free camera should use AZERTY keys for input.");

KeybindOverlay = Config.Bind("Coop | Debug", "Keybind Overlay", true, "If an overlay with all free cam keybinds should show.");

// Performance

DynamicAI = Config.Bind("Performance", "Dynamic AI", false, new ConfigDescription("Use the dynamic AI system, disabling AI when they are outside of any player's range.", tags: new ConfigurationManagerAttributes() { Order = 5 }));
Expand Down Expand Up @@ -484,31 +475,6 @@ private void EnableOverridePatches()
new FikaAirdropFlare_Patch().Enable();
}

private void LogDependencyErrors()
{
// Skip if we've already shown the message, or there are no errors
if (ShownDependencyError || Chainloader.DependencyErrors.Count == 0)
{
return;
}

StringBuilder stringBuilder = new();
stringBuilder.AppendLine("Errors occurred during plugin loading");
stringBuilder.AppendLine("-------------------------------------");
stringBuilder.AppendLine();
foreach (string error in Chainloader.DependencyErrors)
{
stringBuilder.AppendLine(error);
stringBuilder.AppendLine();
}
string errorMessage = stringBuilder.ToString();

// Show an error in the BepInEx console/log file
Logger.LogError(errorMessage);

ShownDependencyError = true;
}

public enum DynamicAIRates
{
Low,
Expand Down

0 comments on commit 9104573

Please sign in to comment.