Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
35f87c9b4c |
@ -13,6 +13,7 @@ namespace Terkoiz.Skipper
|
|||||||
public class QuestObjectiveViewPatch : ModulePatch
|
public class QuestObjectiveViewPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static string UnderlyingQuestControllerClassName;
|
private static string UnderlyingQuestControllerClassName;
|
||||||
|
internal static GameObject LastSeenObjectivesBlock;
|
||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
@ -20,7 +21,7 @@ namespace Terkoiz.Skipper
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void PatchPostfix([CanBeNull]DefaultUIButton ____handoverButton, AbstractQuestControllerClass questController, Condition condition, IConditionCounter quest)
|
private static void PatchPostfix([CanBeNull]DefaultUIButton ____handoverButton, AbstractQuestControllerClass questController, Condition condition, IConditionCounter quest, QuestObjectiveView __instance)
|
||||||
{
|
{
|
||||||
if (!SkipperPlugin.ModEnabled.Value)
|
if (!SkipperPlugin.ModEnabled.Value)
|
||||||
{
|
{
|
||||||
@ -48,12 +49,14 @@ namespace Terkoiz.Skipper
|
|||||||
SkipperPlugin.Logger.LogDebug($"Resolved {nameof(UnderlyingQuestControllerClassName)} to be {UnderlyingQuestControllerClassName}");
|
SkipperPlugin.Logger.LogDebug($"Resolved {nameof(UnderlyingQuestControllerClassName)} to be {UnderlyingQuestControllerClassName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LastSeenObjectivesBlock = __instance.transform.parent.gameObject;
|
||||||
|
|
||||||
var skipButton = Object.Instantiate(____handoverButton, ____handoverButton.transform.parent.transform);
|
var skipButton = Object.Instantiate(____handoverButton, ____handoverButton.transform.parent.transform);
|
||||||
|
|
||||||
skipButton.SetRawText("SKIP", 22);
|
skipButton.SetRawText("SKIP", 22);
|
||||||
skipButton.gameObject.name = "SkipButton";
|
skipButton.gameObject.name = SkipperPlugin.SkipButtonName;
|
||||||
skipButton.gameObject.GetComponent<UnityEngine.UI.LayoutElement>().minWidth = 100f;
|
skipButton.gameObject.GetComponent<UnityEngine.UI.LayoutElement>().minWidth = 100f;
|
||||||
skipButton.gameObject.SetActive(!quest.IsConditionDone(condition));
|
skipButton.gameObject.SetActive(SkipperPlugin.AlwaysDisplay.Value && !quest.IsConditionDone(condition));
|
||||||
|
|
||||||
skipButton.OnClick.RemoveAllListeners();
|
skipButton.OnClick.RemoveAllListeners();
|
||||||
skipButton.OnClick.AddListener(() => ItemUiContext.Instance.ShowMessageWindow(
|
skipButton.OnClick.AddListener(() => ItemUiContext.Instance.ShowMessageWindow(
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
using BepInEx;
|
using BepInEx;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using BepInEx.Logging;
|
using BepInEx.Logging;
|
||||||
|
using EFT.UI;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Terkoiz.Skipper
|
namespace Terkoiz.Skipper
|
||||||
{
|
{
|
||||||
[BepInPlugin("com.terkoiz.skipper", "Terkoiz.Skipper", "1.0.0")]
|
[BepInPlugin("com.terkoiz.skipper", "Terkoiz.Skipper", "1.1.0")]
|
||||||
public class SkipperPlugin : BaseUnityPlugin
|
public class SkipperPlugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
|
internal const string SkipButtonName = "SkipButton";
|
||||||
|
|
||||||
internal new static ManualLogSource Logger { get; private set; }
|
internal new static ManualLogSource Logger { get; private set; }
|
||||||
|
|
||||||
private const string MainSectionName = "Main";
|
private const string MainSectionName = "Main";
|
||||||
internal static ConfigEntry<bool> ModEnabled;
|
internal static ConfigEntry<bool> ModEnabled;
|
||||||
|
internal static ConfigEntry<bool> AlwaysDisplay;
|
||||||
|
internal static ConfigEntry<KeyboardShortcut> DisplayHotkey;
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
internal void Start()
|
internal void Start()
|
||||||
@ -26,9 +32,55 @@ namespace Terkoiz.Skipper
|
|||||||
{
|
{
|
||||||
ModEnabled = Config.Bind(
|
ModEnabled = Config.Bind(
|
||||||
MainSectionName,
|
MainSectionName,
|
||||||
"Enabled",
|
"1. Enabled",
|
||||||
true,
|
true,
|
||||||
"Global mod toggle. Will need to re-open the quest window for the setting change to take effect.");
|
"Global mod toggle. Will need to re-open the quest window for the setting change to take effect.");
|
||||||
|
|
||||||
|
AlwaysDisplay = Config.Bind(
|
||||||
|
MainSectionName,
|
||||||
|
"2. Always display Skip button",
|
||||||
|
false,
|
||||||
|
"If enabled, the Skip button will always be visible.");
|
||||||
|
|
||||||
|
DisplayHotkey = Config.Bind(
|
||||||
|
MainSectionName,
|
||||||
|
"3. Display hotkey",
|
||||||
|
new KeyboardShortcut(KeyCode.LeftControl),
|
||||||
|
"Holding down this key will make the Skip buttons appear.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
|
internal void Update()
|
||||||
|
{
|
||||||
|
if (!ModEnabled.Value || AlwaysDisplay.Value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QuestObjectiveViewPatch.LastSeenObjectivesBlock == null || !QuestObjectiveViewPatch.LastSeenObjectivesBlock.activeSelf)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisplayHotkey.Value.IsDown())
|
||||||
|
{
|
||||||
|
ChangeButtonVisibility(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisplayHotkey.Value.IsUp())
|
||||||
|
{
|
||||||
|
ChangeButtonVisibility(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ChangeButtonVisibility(bool setVisibilityTo)
|
||||||
|
{
|
||||||
|
foreach (var button in QuestObjectiveViewPatch.LastSeenObjectivesBlock.GetComponentsInChildren<DefaultUIButton>(includeInactive: true))
|
||||||
|
{
|
||||||
|
if (button.name != SkipButtonName) continue;
|
||||||
|
|
||||||
|
button.gameObject.SetActive(setVisibilityTo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net471</TargetFramework>
|
<TargetFramework>net471</TargetFramework>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.1.0</Version>
|
||||||
<Authors>Terkoiz</Authors>
|
<Authors>Terkoiz</Authors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user