Skip to content

Commit

Permalink
Added player selector qm redirect toggle, removed unneeded debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ddakebono committed Oct 1, 2024
1 parent 13b7bee commit 815a95f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 11 additions & 1 deletion BTKUILib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static class BuildInfo
public const string Name = "BTKUILib";
public const string Author = "BTK Development Team";
public const string Company = "BTK Development";
public const string Version = "2.3.0";
public const string Version = "2.3.1";
}

internal class BTKUILib : MelonMod
Expand All @@ -26,6 +26,7 @@ internal class BTKUILib : MelonMod
internal Queue<Action> MainThreadQueue = new();
internal Dictionary<string, Page> MLPrefsPages = new();
internal MelonPreferences_Entry<PlayerListStyleEnum> PlayerListStyle;
internal MelonPreferences_Entry<bool> QMPlayerSelectorRedirect;

private MelonPreferences_Entry<bool> _displayPrefsTab;
private MelonPreferences_Entry<bool> _miscTabFirst;
Expand Down Expand Up @@ -54,6 +55,8 @@ public override void OnInitializeMelon()
PlayerListStyle = MelonPreferences.CreateEntry("BTKUILib", "PlayerListStyleNew", PlayerListStyleEnum.TabBar, "PlayerList Button Style", "Sets where the playerlist button will appear");

_miscTabFirst = MelonPreferences.CreateEntry("BTKUILib", "MiscTabFirst", false, "Misc Tab Always First", "Makes sure the misc tab is always first in the tab row");

QMPlayerSelectorRedirect = MelonPreferences.CreateEntry("BTKUILib", "PlayerSelectorRedirect", true, "Redirect Player QM Selector", "Chooses if the player selector should open the QM player details or always go to the big menu");

Patches.Initialize(HarmonyInstance);

Expand Down Expand Up @@ -101,6 +104,13 @@ internal void GenerateSettingsPage()
QuickMenuAPI.ShowNotice("Restart Required!", "To change the Misc tab first setting you must restart your game! This setting will be applied on the next startup!");
};

var playerSelector = mainCat.AddToggle("Player Selector QM Redirect", "Sets if the player selector should open the QM Player Details page or the big menu", QMPlayerSelectorRedirect.Value);
playerSelector.OnValueUpdated += b =>
{
QMPlayerSelectorRedirect.Value = b;
MelonPreferences.Save();
};

_playerListStyleNames = Enum.GetNames(typeof(PlayerListStyleEnum));

_playerListButtonStyle = new MultiSelection("PlayerList Button Position", _playerListStyleNames, (int)PlayerListStyle.Value);
Expand Down
6 changes: 1 addition & 5 deletions Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class UsersPatch
[HarmonyPrefix]
static bool ShowDetailsPrefix(string userId)
{
if (!CVR_MenuManager.Instance.IsQuickMenuOpen) return true;
if (!CVR_MenuManager.Instance.IsQuickMenuOpen || !BTKUILib.Instance.QMPlayerSelectorRedirect.Value) return true;

//QM is open, redirect selection to playerlist
QuickMenuAPI.OpenPlayerListByUserID(userId);
Expand All @@ -187,8 +187,6 @@ static void SendToWorldUi(string value)
{
var elapsedTime = DateTime.Now.Subtract(QuickMenuAPI.TimeSinceKeyboardOpen);

BTKUILib.Log.Msg($"SendToWorldUI fired | seconds: {elapsedTime.TotalSeconds} minutes: {elapsedTime.TotalMinutes} fired: {QuickMenuAPI.KeyboardCloseFired}");

//Ensure that we check if the keyboard action was used within 3 minutes, this will avoid the next keyboard usage triggering the action
if (elapsedTime.TotalMinutes <= 3 && (!QuickMenuAPI.KeyboardCloseFired || elapsedTime.TotalSeconds <= 10))
QuickMenuAPI.OnKeyboardSubmitted?.Invoke(value);
Expand All @@ -200,8 +198,6 @@ static void SendToWorldUi(string value)
[HarmonyPostfix]
static void KeyboardClosedPatch()
{
BTKUILib.Log.Msg("Keyboard Closed Fired");

//Update cause the keyboard has been closed
QuickMenuAPI.TimeSinceKeyboardOpen = DateTime.Now;
QuickMenuAPI.KeyboardCloseFired = true;
Expand Down

0 comments on commit 815a95f

Please sign in to comment.