settings extensions; proper enable/disable multiselect
This commit is contained in:
@@ -10,8 +10,8 @@ namespace UIFixes
|
||||
{
|
||||
public class MultiSelect
|
||||
{
|
||||
private static GameObject SelectedMarkTemplate;
|
||||
private static GameObject SelectedBackgroundTemplate;
|
||||
private static GameObject SelectedMarkTemplate = null;
|
||||
private static GameObject SelectedBackgroundTemplate = null;
|
||||
|
||||
private static readonly Dictionary<ItemContextClass, GridItemView> SelectedItems = [];
|
||||
private static readonly Dictionary<ItemContextClass, GridItemView> SecondaryItems = [];
|
||||
@@ -31,11 +31,18 @@ namespace UIFixes
|
||||
// Grab the selection objects from ragfair as templates
|
||||
RagfairNewOfferItemView ragfairNewOfferItemView = ItemViewFactory.CreateFromPool<RagfairNewOfferItemView>("ragfair_layout");
|
||||
|
||||
SelectedMarkTemplate = UnityEngine.Object.Instantiate(ragfairNewOfferItemView.R().SelectedMark, null, false);
|
||||
UnityEngine.Object.DontDestroyOnLoad(SelectedMarkTemplate);
|
||||
|
||||
SelectedBackgroundTemplate = UnityEngine.Object.Instantiate(ragfairNewOfferItemView.R().SelectedBackground, null, false);
|
||||
UnityEngine.Object.DontDestroyOnLoad(SelectedBackgroundTemplate);
|
||||
if (SelectedMarkTemplate == null)
|
||||
{
|
||||
SelectedMarkTemplate = UnityEngine.Object.Instantiate(ragfairNewOfferItemView.R().SelectedMark, null, false);
|
||||
UnityEngine.Object.DontDestroyOnLoad(SelectedMarkTemplate);
|
||||
}
|
||||
|
||||
if (SelectedBackgroundTemplate == null)
|
||||
{
|
||||
SelectedBackgroundTemplate = UnityEngine.Object.Instantiate(ragfairNewOfferItemView.R().SelectedBackground, null, false);
|
||||
UnityEngine.Object.DontDestroyOnLoad(SelectedBackgroundTemplate);
|
||||
}
|
||||
|
||||
ragfairNewOfferItemView.ReturnToPool();
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace UIFixes
|
||||
new RememberAutoselectPatch().Enable();
|
||||
new RestoreAutoselectPatch().Enable();
|
||||
|
||||
Settings.RememberAutoselectSimilar.SettingChanged += (sender, args) =>
|
||||
Settings.RememberAutoselectSimilar.Subscribe(enabled =>
|
||||
{
|
||||
if (!Settings.RememberAutoselectSimilar.Value)
|
||||
if (!enabled)
|
||||
{
|
||||
PlayerPrefs.DeleteKey(PlayerPrefKey);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public class RememberAutoselectPatch : ModulePatch
|
||||
|
||||
@@ -33,15 +33,15 @@ namespace UIFixes
|
||||
new OfferViewListDoneLoadingPatch().Enable();
|
||||
new ChangedViewListTypePatch().Enable();
|
||||
|
||||
Settings.EnableFleaHistory.SettingChanged += (object sender, EventArgs args) =>
|
||||
Settings.EnableFleaHistory.Subscribe(enabled =>
|
||||
{
|
||||
if (!Settings.EnableFleaHistory.Value && PreviousFilterButton.Instance != null)
|
||||
if (!enabled && PreviousFilterButton.Instance != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(PreviousFilterButton.Instance.gameObject);
|
||||
PreviousFilterButton.Instance = null;
|
||||
History.Clear();
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public class PreviousFilterButton : MonoBehaviour
|
||||
|
||||
@@ -92,21 +92,22 @@ namespace UIFixes
|
||||
[PatchPostfix]
|
||||
public static void Postfix(CommonUI __instance)
|
||||
{
|
||||
if (!MultiSelect.Enabled)
|
||||
Settings.EnableMultiSelect.Bind(enabled =>
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
MultiSelect.Initialize();
|
||||
}
|
||||
|
||||
MultiSelect.Initialize();
|
||||
__instance.InventoryScreen.transform.Find("Items Panel").gameObject.GetOrAddComponent<DrawMultiSelect>().enabled = enabled;
|
||||
__instance.TransferItemsInRaidScreen.GetOrAddComponent<DrawMultiSelect>().enabled = enabled;
|
||||
__instance.TransferItemsScreen.GetOrAddComponent<DrawMultiSelect>().enabled = enabled;
|
||||
__instance.ScavengerInventoryScreen.GetOrAddComponent<DrawMultiSelect>().enabled = enabled;
|
||||
});
|
||||
|
||||
__instance.InventoryScreen.transform.Find("Items Panel").gameObject.GetOrAddComponent<DrawMultiSelect>();
|
||||
__instance.TransferItemsInRaidScreen.GetOrAddComponent<DrawMultiSelect>();
|
||||
__instance.TransferItemsScreen.GetOrAddComponent<DrawMultiSelect>();
|
||||
__instance.ScavengerInventoryScreen.GetOrAddComponent<DrawMultiSelect>();
|
||||
|
||||
static void ToggleDebug()
|
||||
Settings.ShowMultiSelectDebug.Bind(enabled =>
|
||||
{
|
||||
if (Settings.ShowMultiSelectDebug.Value)
|
||||
if (enabled)
|
||||
{
|
||||
Singleton<PreloaderUI>.Instance.GetOrAddComponent<MultiSelectDebug>();
|
||||
}
|
||||
@@ -115,9 +116,7 @@ namespace UIFixes
|
||||
var debug = Singleton<PreloaderUI>.Instance.GetComponent<MultiSelectDebug>();
|
||||
UnityEngine.Object.Destroy(debug);
|
||||
}
|
||||
};
|
||||
ToggleDebug();
|
||||
Settings.ShowMultiSelectDebug.SettingChanged += (s, a) => ToggleDebug();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,12 +130,10 @@ namespace UIFixes
|
||||
[PatchPostfix]
|
||||
public static void Postfix(MenuUI __instance)
|
||||
{
|
||||
if (!MultiSelect.Enabled)
|
||||
Settings.EnableMultiSelect.Bind(enabled =>
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__instance.TraderScreensGroup.transform.Find("Deal Screen").gameObject.GetOrAddComponent<DrawMultiSelect>();
|
||||
__instance.TraderScreensGroup.transform.Find("Deal Screen").gameObject.GetOrAddComponent<DrawMultiSelect>().enabled = enabled;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
Settings.cs
20
Settings.cs
@@ -1,4 +1,5 @@
|
||||
using BepInEx.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
@@ -623,10 +624,6 @@ namespace UIFixes
|
||||
if (!primaryConfig.Value)
|
||||
{
|
||||
dependentConfig.Value = false;
|
||||
if (dependentConfig.Description.Tags[0] is ConfigurationManagerAttributes attributes)
|
||||
{
|
||||
attributes.ReadOnly = true;
|
||||
}
|
||||
}
|
||||
|
||||
primaryConfig.SettingChanged += (_, _) =>
|
||||
@@ -653,4 +650,19 @@ namespace UIFixes
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static class SettingExtensions
|
||||
{
|
||||
public static void Subscribe<T>(this ConfigEntry<T> configEntry, Action<T> onChange)
|
||||
{
|
||||
configEntry.SettingChanged += (_, _) => onChange(configEntry.Value);
|
||||
}
|
||||
|
||||
|
||||
public static void Bind<T>(this ConfigEntry<T> configEntry, Action<T> onChange)
|
||||
{
|
||||
configEntry.Subscribe(onChange);
|
||||
onChange(configEntry.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user