diff --git a/README.md b/README.md index 7b6fc60..21523a1 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,6 @@ A BepInEx plugin for SPT-AKI that allows you to skip quests in-game. ### How to build from source 1. Download/clone this repository -2. Open your current SPT directory and copy all files from `\EscapeFromTarkov_Data\Managed` into this solution's `\References\EFT_Managed` folder. +2. In the `Terkoiz.Skipper.csproj` under `PathToSPT` Change `D:\SP-AKI\Server-3.10-DEVELOPMENT` to your SPT folder. 3. Rebuild the project in the Release configuration. -4. Grab the `Terkoiz.Skipper.dll` file from the `bin/Release` folder and use it wherever. Refer to the "How to install" section if you need help here. \ No newline at end of file +4. The `Terkoiz.Skipper.dll` will now be in your `\BepInEx\plugins` folder. \ No newline at end of file diff --git a/project/References/EFT_Managed/.keep b/project/References/EFT_Managed/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/project/Terkoiz.Skipper/QuestObjectiveViewPatch.cs b/project/Terkoiz.Skipper/QuestObjectiveViewPatch.cs index dacfa00..6513b81 100644 --- a/project/Terkoiz.Skipper/QuestObjectiveViewPatch.cs +++ b/project/Terkoiz.Skipper/QuestObjectiveViewPatch.cs @@ -1,11 +1,11 @@ using System.Linq; using System.Reflection; -using Aki.Reflection.Patching; using EFT; using EFT.Quests; using EFT.UI; using HarmonyLib; using JetBrains.Annotations; +using SPT.Reflection.Patching; using UnityEngine; namespace Terkoiz.Skipper @@ -53,15 +53,15 @@ namespace Terkoiz.Skipper var skipButton = Object.Instantiate(____handoverButton, ____handoverButton.transform.parent.transform); - skipButton.SetRawText("SKIP", 22); + skipButton.SetRawText("SKIP OBJECTIVE", 22); skipButton.gameObject.name = SkipperPlugin.SkipButtonName; skipButton.gameObject.GetComponent().minWidth = 100f; skipButton.gameObject.SetActive(SkipperPlugin.AlwaysDisplay.Value && !quest.IsConditionDone(condition)); skipButton.OnClick.RemoveAllListeners(); - skipButton.OnClick.AddListener(() => ItemUiContext.Instance.ShowMessageWindow( - description: "Are you sure you want to autocomplete this quest objective?", - acceptAction: () => + if (SkipperPlugin.SkipConfirmation.Value) + { + skipButton.OnClick.AddListener(() => { if (quest.IsConditionDone(condition)) { @@ -79,9 +79,34 @@ namespace Terkoiz.Skipper AccessTools.DeclaredMethod(conditionController.GetType().BaseType, "SetConditionCurrentValue").Invoke(conditionController, new object[] { quest, EQuestStatus.AvailableForFinish, condition, condition.value, true }); skipButton.gameObject.SetActive(false); - }, - cancelAction: () => {}, - caption: "Confirmation")); + }); + } + else + { + skipButton.OnClick.AddListener(() => ItemUiContext.Instance.ShowMessageWindow( + description: "Are you sure you want to complete this quest objective?", + acceptAction: () => + { + if (quest.IsConditionDone(condition)) + { + skipButton.gameObject.SetActive(false); + return; + } + + SkipperPlugin.Logger.LogDebug($"Setting condition {condition.id} value to {condition.value}"); + + // This line will force any condition checker to pass, as the 'condition.value' field contains the "goal" of any quest condition + quest.ProgressCheckers[condition].SetCurrentValueGetter(_ => condition.value); + + // We call 'SetConditionCurrentValue' to trigger all the code needed to make the condition completion appear visually in-game + var conditionController = AccessTools.Field(questController.GetType(), $"{UnderlyingQuestControllerClassName.ToLowerInvariant()}_0").GetValue(questController); + AccessTools.DeclaredMethod(conditionController.GetType().BaseType, "SetConditionCurrentValue").Invoke(conditionController, new object[] { quest, EQuestStatus.AvailableForFinish, condition, condition.value, true }); + + skipButton.gameObject.SetActive(false); + }, + cancelAction: () => {}, + caption: "Confirmation")); + } } } } \ No newline at end of file diff --git a/project/Terkoiz.Skipper/SkipperPlugin.cs b/project/Terkoiz.Skipper/SkipperPlugin.cs index 2da0ada..17955e0 100644 --- a/project/Terkoiz.Skipper/SkipperPlugin.cs +++ b/project/Terkoiz.Skipper/SkipperPlugin.cs @@ -17,6 +17,7 @@ namespace Terkoiz.Skipper private const string MainSectionName = "Main"; internal static ConfigEntry ModEnabled; internal static ConfigEntry AlwaysDisplay; + internal static ConfigEntry SkipConfirmation; internal static ConfigEntry DisplayHotkey; [UsedImplicitly] @@ -47,6 +48,12 @@ namespace Terkoiz.Skipper "3. Display hotkey", new KeyboardShortcut(KeyCode.LeftControl), "Holding down this key will make the Skip buttons appear."); + + SkipConfirmation = Config.Bind( + MainSectionName, + "4. Skip confirmation", + true, + "If disabled, a confirmation dialog will appear when you press the Skip button."); } [UsedImplicitly] @@ -54,6 +61,11 @@ namespace Terkoiz.Skipper { if (!ModEnabled.Value || AlwaysDisplay.Value) { + if (AlwaysDisplay.Value && QuestObjectiveViewPatch.LastSeenObjectivesBlock != null && !QuestObjectiveViewPatch.LastSeenObjectivesBlock.activeSelf) + { + ChangeButtonVisibility(true); + } + return; } diff --git a/project/Terkoiz.Skipper/Terkoiz.Skipper.csproj b/project/Terkoiz.Skipper/Terkoiz.Skipper.csproj index cd38329..646dabd 100644 --- a/project/Terkoiz.Skipper/Terkoiz.Skipper.csproj +++ b/project/Terkoiz.Skipper/Terkoiz.Skipper.csproj @@ -12,47 +12,66 @@ + + D:\SP-AKI\Server-3.10-DEVELOPMENT + + - - ..\References\EFT_Managed\Aki.Reflection.dll - False + + $(PathToSPT)\EscapeFromTarkov_Data\Managed\bsg.console.core.dll + + + $(PathToSPT)\BepInEx\plugins\spt\spt-common.dll + + + $(PathToSPT)\BepInEx\plugins\spt\spt-reflection.dll - ..\References\EFT_Managed\Assembly-CSharp.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll - ..\References\EFT_Managed\Comfort.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\Comfort.dll - ..\References\EFT_Managed\Comfort.Unity.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\Comfort.Unity.dll + + + $(PathToSPT)\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll + + + $(PathToSPT)\EscapeFromTarkov_Data\Managed\Newtonsoft.Json.dll - ..\References\EFT_Managed\Sirenix.Serialization.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\Sirenix.Serialization.dll - ..\References\EFT_Managed\Unity.TextMeshPro.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\Unity.TextMeshPro.dll - ..\References\EFT_Managed\UnityEngine.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.dll - ..\References\EFT_Managed\UnityEngine.CoreModule.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll + + + $(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.IMGUIModule.dll - ..\References\EFT_Managed\UnityEngine.InputLegacyModule.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.InputLegacyModule.dll + + + $(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.TextRenderingModule.dll - ..\References\EFT_Managed\UnityEngine.UI.dll - False + $(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.UI.dll + + + +