major cleanup

This commit is contained in:
NotAKidoS 2023-04-26 15:32:02 -05:00
parent b33e15377f
commit e5242f76c7
85 changed files with 584 additions and 571 deletions

View file

@ -44,14 +44,14 @@ static class AssetsHandler
ms_loadedAssets.Add(l_assetName, l_assetBundle);
}
else
MelonLoader.MelonLogger.Warning("Unable to load bundled '" + l_assetName + "' asset");
Blackout.Logger.Warning("Unable to load bundled '" + l_assetName + "' asset");
}
else
MelonLoader.MelonLogger.Warning("Unable to get bundled '" + l_assetName + "' asset stream");
Blackout.Logger.Warning("Unable to get bundled '" + l_assetName + "' asset stream");
}
catch (System.Exception e)
{
MelonLoader.MelonLogger.Warning("Unable to load bundled '" + l_assetName + "' asset, reason: " + e.Message);
Blackout.Logger.Warning("Unable to load bundled '" + l_assetName + "' asset, reason: " + e.Message);
}
}
}

View file

@ -30,7 +30,7 @@ namespace NAK.Blackout;
public class BlackoutController : MonoBehaviour
{
public static BlackoutController Instance;
// The current state of the player's consciousness.
public BlackoutState CurrentState = BlackoutState.Awake;
@ -134,7 +134,7 @@ public class BlackoutController : MonoBehaviour
blackoutAnimator = blackoutGO.GetComponent<Animator>();
if (!blackoutAnimator)
{
MelonLogger.Error("Blackout: Could not find blackout animator component!");
Blackout.Logger.Error("Blackout: Could not find blackout animator component!");
return;
}
@ -229,7 +229,7 @@ public class BlackoutController : MonoBehaviour
//broken, needs to run next frame
private void SendHUDMessage(string message)
{
MelonLogger.Msg(message);
Blackout.Logger.Msg(message);
if (!CohtmlHud.Instance || !HudMessages) return;
StringBuilder secondmessage = new StringBuilder();

View file

@ -1,7 +1,6 @@
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using HarmonyLib;
using MelonLoader;
namespace NAK.Blackout.HarmonyPatches;
@ -15,7 +14,7 @@ internal class HarmonyPatches
{
if (Blackout.inVR != MetaPort.Instance.isUsingVr)
{
MelonLogger.Msg("VRMode change detected! Reinitializing Blackout Instance...");
Blackout.Logger.Msg("VRMode change detected! Reinitializing Blackout Instance...");
Blackout.inVR = MetaPort.Instance.isUsingVr;
BlackoutController.Instance.SetupBlackoutInstance();
BlackoutController.Instance.ChangeBlackoutState(BlackoutController.BlackoutState.Awake);

View file

@ -13,7 +13,7 @@ public static class BTKUIAddon
Page miscPage = QuickMenuAPI.MiscTabPage;
Category miscCategory = miscPage.AddCategory(Blackout.SettingsCategory);
AddMelonToggle(ref miscCategory, Blackout.m_entryEnabled);
AddMelonToggle(ref miscCategory, Blackout.EntryEnabled);
//Add my own page to not clog up Misc Menu
@ -23,7 +23,7 @@ public static class BTKUIAddon
Category blackoutCategory = blackoutPage.AddCategory("Blackout");
AddMelonToggle(ref blackoutCategory, Blackout.m_entryEnabled);
AddMelonToggle(ref blackoutCategory, Blackout.EntryEnabled);
//manual state changing
var state_Awake = blackoutCategory.AddButton("Awake State", null, "Enter the Awake State.");
@ -32,21 +32,21 @@ public static class BTKUIAddon
state_Drowsy.OnPress += () => BlackoutController.Instance?.ChangeBlackoutState(BlackoutController.BlackoutState.Drowsy);
var state_Sleeping = blackoutCategory.AddButton("Sleeping State", null, "Enter the Sleeping State.");
state_Sleeping.OnPress += () => BlackoutController.Instance?.ChangeBlackoutState(BlackoutController.BlackoutState.Sleeping);
//dimming strength
AddMelonSlider(ref blackoutPage, Blackout.m_entryDrowsyDimStrength, 0f, 1f);
AddMelonSlider(ref blackoutPage, Blackout.EntryDrowsyDimStrength, 0f, 1f);
//velocity dim multiplier
AddMelonToggle(ref blackoutCategory, Blackout.m_entryDrowsyVelocityMultiplier);
AddMelonToggle(ref blackoutCategory, Blackout.EntryDrowsyVelocityMultiplier);
//hud messages
AddMelonToggle(ref blackoutCategory, Blackout.m_entryHudMessages);
AddMelonToggle(ref blackoutCategory, Blackout.EntryHudMessages);
//lower fps while sleep (desktop)
AddMelonToggle(ref blackoutCategory, Blackout.m_entryDropFPSOnSleep);
AddMelonToggle(ref blackoutCategory, Blackout.EntryDropFPSOnSleep);
//auto sleep state
AddMelonToggle(ref blackoutCategory, Blackout.m_entryAutoSleepState);
AddMelonToggle(ref blackoutCategory, Blackout.EntryAutoSleepState);
//i will add the rest of the settings once BTKUILib supports int input
}
@ -55,7 +55,7 @@ public static class BTKUIAddon
{
category.AddToggle(entry.DisplayName, entry.Description, entry.Value).OnValueUpdated += b => entry.Value = b;
}
private static void AddMelonSlider(ref Page page, MelonLoader.MelonPreferences_Entry<float> entry, float min, float max)
{
page.AddSlider(entry.DisplayName, entry.Description, entry.Value, min, max).OnValueUpdated += f => entry.Value = f;

View file

@ -15,7 +15,6 @@ public static class UIExpansionKitAddon
also because it **used to work**... a game update broke it and uiexpansionkit hasnt updated since
what pisses me off more, is that DesktopVRSwitch works, and that was originally copied from Blackout -_-
https://github.com/NotAKidOnSteam/DesktopVRSwitch/blob/main/DesktopVRSwitch/UIExpansionKitAddon.cs
**/
var settings = ExpansionKitApi.GetSettingsCategory(Blackout.SettingsCategory);
settings.AddSimpleButton("Awake State", AwakeState);

View file

@ -7,52 +7,65 @@ namespace NAK.Blackout;
public class Blackout : MelonMod
{
internal static bool inVR;
internal const string SettingsCategory = "Blackout";
internal static MelonLogger.Instance Logger;
internal const string SettingsCategory = nameof(Blackout);
internal static MelonPreferences_Category m_categoryBlackout;
internal static MelonPreferences_Entry<bool>
m_entryEnabled,
m_entryAutoSleepState,
m_entryHudMessages,
m_entryDropFPSOnSleep,
m_entryDrowsyVelocityMultiplier;
internal static MelonPreferences_Entry<float>
m_entryDrowsyThreshold, m_entryAwakeThreshold,
m_entryDrowsyModeTimer, m_entrySleepModeTimer,
m_entryDrowsyDimStrength;
public static readonly MelonPreferences_Category CategoryBlackout =
MelonPreferences.CreateCategory(SettingsCategory);
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
CategoryBlackout.CreateEntry("Automatic State Change", true, "Should the screen automatically dim if head is still for enough time?");
public static readonly MelonPreferences_Entry<bool> EntryHudMessages =
CategoryBlackout.CreateEntry("Hud Messages", true, "Notify on state change.");
public static readonly MelonPreferences_Entry<bool> EntryDropFPSOnSleep =
CategoryBlackout.CreateEntry("Limit FPS While Sleep", false, "Limits FPS to 5 while in Sleep State. This only works in Desktop, as SteamVR/HMD handles VR FPS.");
public static readonly MelonPreferences_Entry<bool> EntryDrowsyVelocityMultiplier =
CategoryBlackout.CreateEntry("Drowsy Velocity Multiplier", true, "Should head velocity act as a multiplier to Drowsy Dim Strength?");
public static readonly MelonPreferences_Entry<bool> EntryAutoSleepState =
CategoryBlackout.CreateEntry("Auto Sleep State", true, "Should the sleep state be used during Automatic State Change?");
public static readonly MelonPreferences_Entry<float> EntryDrowsyThreshold =
CategoryBlackout.CreateEntry("Drowsy Threshold", 2f, "Velocity to return partial vision.");
public static readonly MelonPreferences_Entry<float> EntryAwakeThreshold =
CategoryBlackout.CreateEntry("Awake Threshold", 4f, "Velocity to return full vision.");
public static readonly MelonPreferences_Entry<float> EntryDrowsyModeTimer =
CategoryBlackout.CreateEntry("Enter Drowsy Time (Minutes)", 3f, "How many minutes without movement until enter drowsy mode.");
public static readonly MelonPreferences_Entry<float> EntrySleepModeTimer =
CategoryBlackout.CreateEntry("Enter Sleep Time (Seconds)", 10f, "How many seconds without movement until enter sleep mode.");
public static readonly MelonPreferences_Entry<float> EntryDrowsyDimStrength =
CategoryBlackout.CreateEntry("Drowsy Dim Strength", 0.6f, "How strong of a dimming effect should drowsy mode have.");
public override void OnInitializeMelon()
{
m_categoryBlackout = MelonPreferences.CreateCategory(SettingsCategory);
m_entryEnabled = m_categoryBlackout.CreateEntry<bool>("Automatic State Change", true, description: "Should the screen automatically dim if head is still for enough time?");
m_entryEnabled.OnEntryValueChangedUntyped.Subscribe(OnUpdateEnabled);
m_entryHudMessages = m_categoryBlackout.CreateEntry<bool>("Hud Messages", true, description: "Notify on state change.");
m_entryDropFPSOnSleep = m_categoryBlackout.CreateEntry<bool>("Limit FPS While Sleep", false, description: "Limits FPS to 5 while in Sleep State. This only works in Desktop, as SteamVR/HMD handles VR FPS.");
m_entryDrowsyVelocityMultiplier = m_categoryBlackout.CreateEntry<bool>("Drowsy Velocity Multiplier", true, description: "Should head velocity act as a multiplier to Drowsy Dim Strength?");
m_entryAutoSleepState = m_categoryBlackout.CreateEntry<bool>("Auto Sleep State", true, description: "Should the sleep state be used during Automatic State Change?");
m_entryDrowsyThreshold = m_categoryBlackout.CreateEntry<float>("Drowsy Threshold", 2f, description: "Velocity to return partial vision.");
m_entryAwakeThreshold = m_categoryBlackout.CreateEntry<float>("Awake Threshold", 4f, description: "Velocity to return full vision.");
m_entryDrowsyModeTimer = m_categoryBlackout.CreateEntry<float>("Enter Drowsy Time (Minutes)", 3f, description: "How many minutes without movement until enter drowsy mode.");
m_entrySleepModeTimer = m_categoryBlackout.CreateEntry<float>("Enter Sleep Time (Seconds)", 10f, description: "How many seconds without movement until enter sleep mode.");
m_entryDrowsyDimStrength = m_categoryBlackout.CreateEntry<float>("Drowsy Dim Strength", 0.6f, description: "How strong of a dimming effect should drowsy mode have.");
foreach (var setting in m_categoryBlackout.Entries)
Logger = LoggerInstance;
EntryEnabled.OnEntryValueChangedUntyped.Subscribe(OnUpdateEnabled);
foreach (var entry in CategoryBlackout.Entries)
{
if (!setting.OnEntryValueChangedUntyped.GetSubscribers().Any())
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
if (entry != EntryEnabled && !entry.OnEntryValueChangedUntyped.GetSubscribers().Any())
{
entry.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
}
}
//UIExpansionKit addon
if (MelonMod.RegisteredMelons.Any(it => it.Info.Name == "UI Expansion Kit"))
{
MelonLogger.Msg("Initializing UIExpansionKit support.");
Logger.Msg("Initializing UIExpansionKit support.");
UIExpansionKitAddon.Init();
}
//BTKUILib addon
if (MelonMod.RegisteredMelons.Any(it => it.Info.Name == "BTKUILib"))
{
MelonLogger.Msg("Initializing BTKUILib support.");
Logger.Msg("Initializing BTKUILib support.");
BTKUIAddon.Init();
}
@ -81,7 +94,7 @@ public class Blackout : MelonMod
private void OnEnabled()
{
if (!BlackoutController.Instance) return;
if (m_entryEnabled.Value)
if (EntryEnabled.Value)
{
BlackoutController.Instance.OnEnable();
}
@ -89,21 +102,21 @@ public class Blackout : MelonMod
{
BlackoutController.Instance.OnDisable();
}
BlackoutController.Instance.AutomaticStateChange = m_entryEnabled.Value;
BlackoutController.Instance.AutomaticStateChange = EntryEnabled.Value;
}
private void UpdateAllSettings()
{
if (!BlackoutController.Instance) return;
BlackoutController.Instance.HudMessages = m_entryHudMessages.Value;
BlackoutController.Instance.AutoSleepState = m_entryAutoSleepState.Value;
BlackoutController.Instance.DropFPSOnSleep = m_entryDropFPSOnSleep.Value;
BlackoutController.Instance.drowsyThreshold = m_entryDrowsyThreshold.Value;
BlackoutController.Instance.wakeThreshold = m_entryAwakeThreshold.Value;
BlackoutController.Instance.DrowsyModeTimer = m_entryDrowsyModeTimer.Value;
BlackoutController.Instance.SleepModeTimer = m_entrySleepModeTimer.Value;
BlackoutController.Instance.DrowsyDimStrength = m_entryDrowsyDimStrength.Value;
BlackoutController.Instance.DrowsyVelocityMultiplier = m_entryDrowsyVelocityMultiplier.Value;
BlackoutController.Instance.HudMessages = EntryHudMessages.Value;
BlackoutController.Instance.AutoSleepState = EntryAutoSleepState.Value;
BlackoutController.Instance.DropFPSOnSleep = EntryDropFPSOnSleep.Value;
BlackoutController.Instance.drowsyThreshold = EntryDrowsyThreshold.Value;
BlackoutController.Instance.wakeThreshold = EntryAwakeThreshold.Value;
BlackoutController.Instance.DrowsyModeTimer = EntryDrowsyModeTimer.Value;
BlackoutController.Instance.SleepModeTimer = EntrySleepModeTimer.Value;
BlackoutController.Instance.DrowsyDimStrength = EntryDrowsyDimStrength.Value;
BlackoutController.Instance.DrowsyVelocityMultiplier = EntryDrowsyVelocityMultiplier.Value;
}
private void OnUpdateEnabled(object arg1, object arg2) => OnEnabled();

View file

@ -1,5 +1,5 @@
using NAK.Blackout.Properties;
using MelonLoader;
using MelonLoader;
using NAK.Blackout.Properties;
using System.Reflection;
@ -15,7 +15,7 @@ using System.Reflection;
nameof(NAK.Blackout),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidOnSteam/Blackout"
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/Blackout"
)]
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]

View file

@ -17,8 +17,8 @@
"BTKUILib",
"UIExpansionKit"
],
"downloadlink": "https://github.com/NotAKidOnSteam/Blackout/releases/download/v2.0.0/Blackout.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/Blackout/",
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/Blackout.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/Blackout/",
"changelog": "- Added BTKUILib support.\n- Added dimming strength velocity multiplier option.\n- Added option to not use Automatic Sleep State.\n- Dimming strengh now updates in realtime when configuring.",
"embedcolor": "#161b22"
}