Compare commits

..

No commits in common. "master" and "1.0.0" have entirely different histories.

3 changed files with 7 additions and 62 deletions

View File

@ -13,7 +13,6 @@ namespace Terkoiz.Skipper
public class QuestObjectiveViewPatch : ModulePatch
{
private static string UnderlyingQuestControllerClassName;
internal static GameObject LastSeenObjectivesBlock;
protected override MethodBase GetTargetMethod()
{
@ -21,7 +20,7 @@ namespace Terkoiz.Skipper
}
[PatchPostfix]
private static void PatchPostfix([CanBeNull]DefaultUIButton ____handoverButton, AbstractQuestControllerClass questController, Condition condition, IConditionCounter quest, QuestObjectiveView __instance)
private static void PatchPostfix([CanBeNull]DefaultUIButton ____handoverButton, AbstractQuestControllerClass questController, Condition condition, IConditionCounter quest)
{
if (!SkipperPlugin.ModEnabled.Value)
{
@ -48,15 +47,13 @@ namespace Terkoiz.Skipper
UnderlyingQuestControllerClassName = type.Name.Split('`')[0];
SkipperPlugin.Logger.LogDebug($"Resolved {nameof(UnderlyingQuestControllerClassName)} to be {UnderlyingQuestControllerClassName}");
}
LastSeenObjectivesBlock = __instance.transform.parent.gameObject;
var skipButton = Object.Instantiate(____handoverButton, ____handoverButton.transform.parent.transform);
skipButton.SetRawText("SKIP", 22);
skipButton.gameObject.name = SkipperPlugin.SkipButtonName;
skipButton.gameObject.name = "SkipButton";
skipButton.gameObject.GetComponent<UnityEngine.UI.LayoutElement>().minWidth = 100f;
skipButton.gameObject.SetActive(SkipperPlugin.AlwaysDisplay.Value && !quest.IsConditionDone(condition));
skipButton.gameObject.SetActive(!quest.IsConditionDone(condition));
skipButton.OnClick.RemoveAllListeners();
skipButton.OnClick.AddListener(() => ItemUiContext.Instance.ShowMessageWindow(

View File

@ -1,23 +1,17 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EFT.UI;
using JetBrains.Annotations;
using UnityEngine;
namespace Terkoiz.Skipper
{
[BepInPlugin("com.terkoiz.skipper", "Terkoiz.Skipper", "1.1.0")]
[BepInPlugin("com.terkoiz.skipper", "Terkoiz.Skipper", "1.0.0")]
public class SkipperPlugin : BaseUnityPlugin
{
internal const string SkipButtonName = "SkipButton";
internal new static ManualLogSource Logger { get; private set; }
private const string MainSectionName = "Main";
internal static ConfigEntry<bool> ModEnabled;
internal static ConfigEntry<bool> AlwaysDisplay;
internal static ConfigEntry<KeyboardShortcut> DisplayHotkey;
[UsedImplicitly]
internal void Start()
@ -32,55 +26,9 @@ namespace Terkoiz.Skipper
{
ModEnabled = Config.Bind(
MainSectionName,
"1. Enabled",
"Enabled",
true,
"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);
}
}
}
}

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<Version>1.1.0</Version>
<Version>1.0.0</Version>
<Authors>Terkoiz</Authors>
</PropertyGroup>