mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2026-02-09 18:26:12 +00:00
mass commit of laziness
This commit is contained in:
parent
ce992c70ee
commit
6d4fc549d9
167 changed files with 5471 additions and 675 deletions
103
.Experimental/DummyMenu/Components/DummyMenuManager.cs
Normal file
103
.Experimental/DummyMenu/Components/DummyMenuManager.cs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
using ABI_RC.Core.UI.UIRework;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DummyMenu;
|
||||
|
||||
public class DummyMenuManager : CVRUIManagerBaseInput
|
||||
{
|
||||
#region Boilerplate
|
||||
|
||||
public static DummyMenuManager Instance { get; private set; }
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
if (Instance && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
Instance = this;
|
||||
base.Start();
|
||||
|
||||
ListenForModSettingChanges();
|
||||
}
|
||||
|
||||
public override void ReloadView()
|
||||
{
|
||||
if (IsViewShown && !ModSettings.EntryReloadMenuEvenWhenOpen.Value) return;
|
||||
TrySetMenuPage();
|
||||
base.ReloadView();
|
||||
}
|
||||
|
||||
public override void OnFinishedLoad(string _)
|
||||
{
|
||||
base.OnFinishedLoad(_);
|
||||
|
||||
// Usually done in OnReadyForBindings, but that isn't called for my menu :)
|
||||
_cohtmlRenderMaterial = _uiRenderer.sharedMaterial;
|
||||
// ReSharper disable thrice Unity.PreferAddressByIdToGraphicsParams
|
||||
_cohtmlRenderMaterial.SetTexture("_DesolvePattern", pattern);
|
||||
_cohtmlRenderMaterial.SetTexture("_DesolveTiming", timing);
|
||||
_cohtmlRenderMaterial.SetTextureScale("_DesolvePattern", new Vector2(16, 9));
|
||||
}
|
||||
|
||||
public void ToggleView()
|
||||
{
|
||||
bool invertShown = !IsViewShown;
|
||||
ToggleView(invertShown);
|
||||
CursorLockManager.Instance.SetUnlockWithId(invertShown, nameof(DummyMenuManager));
|
||||
}
|
||||
|
||||
#endregion Boilerplate
|
||||
|
||||
private void ListenForModSettingChanges()
|
||||
{
|
||||
ModSettings.EntryPageCouiPath.OnEntryValueChanged.Subscribe((oldValue, newValue) =>
|
||||
{
|
||||
DummyMenuMod.Logger.Msg($"Changing COUI page from {oldValue} to {newValue}");
|
||||
cohtmlView.Page = newValue;
|
||||
});
|
||||
|
||||
ModSettings.EntryPageWidth.OnEntryValueChanged.Subscribe((oldValue, newValue) =>
|
||||
{
|
||||
DummyMenuMod.Logger.Msg($"Changing COUI width from {oldValue} to {newValue}");
|
||||
cohtmlView.Width = newValue;
|
||||
DummyMenuPositionHelper.Instance.UpdateAspectRatio(cohtmlView.Width, cohtmlView.Height);
|
||||
});
|
||||
|
||||
ModSettings.EntryPageHeight.OnEntryValueChanged.Subscribe((oldValue, newValue) =>
|
||||
{
|
||||
DummyMenuMod.Logger.Msg($"Changing COUI height from {oldValue} to {newValue}");
|
||||
cohtmlView.Height = newValue;
|
||||
DummyMenuPositionHelper.Instance.UpdateAspectRatio(cohtmlView.Width, cohtmlView.Height);
|
||||
});
|
||||
|
||||
ModSettings.EntryToggleMeToResetModifiers.OnEntryValueChanged.Subscribe((_, newValue) =>
|
||||
{
|
||||
if (!newValue) return;
|
||||
DummyMenuMod.Logger.Msg("Resetting modifiers to default because the toggle was enabled");
|
||||
ModSettings.EntryToggleMeToResetModifiers.Value = false;
|
||||
ModSettings.EntryDesktopMenuScaleModifier.ResetToDefault();
|
||||
ModSettings.EntryDesktopMenuDistanceModifier.ResetToDefault();
|
||||
ModSettings.EntryVrMenuScaleModifier.ResetToDefault();
|
||||
ModSettings.EntryVrMenuDistanceModifier.ResetToDefault();
|
||||
});
|
||||
}
|
||||
|
||||
public void TrySetMenuPage()
|
||||
{
|
||||
string couiPath = ModSettings.EntryPageCouiPath.Value;
|
||||
string fullCouiPath = CreateDummyMenu.GetFullCouiPath(couiPath);
|
||||
if (File.Exists(fullCouiPath))
|
||||
{
|
||||
DummyMenuMod.Logger.Msg($"Found COUI page at {fullCouiPath}. Setting it as the controlledview page.");
|
||||
cohtmlView.Page = "coui://" + couiPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
DummyMenuMod.Logger.Error($"No COUI page found at {fullCouiPath}. Please create one at that path, or change the mod setting to point to an existing file. Using default example page instead.");
|
||||
cohtmlView.Page = "coui://" + CreateDummyMenu.ExampleDummyMenuPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Savior;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DummyMenu;
|
||||
|
||||
[DefaultExecutionOrder(16000)] // just before ControllerRay
|
||||
public class DummyMenuPositionHelper : MenuPositionHelperBase
|
||||
{
|
||||
public static DummyMenuPositionHelper Instance { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance && Instance != this)
|
||||
{
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public override bool IsMenuOpen => DummyMenuManager.Instance.IsViewShown;
|
||||
public override float MenuScaleModifier => MetaPort.Instance.isUsingVr ? ModSettings.EntryVrMenuScaleModifier.Value : ModSettings.EntryDesktopMenuScaleModifier.Value;
|
||||
public override float MenuDistanceModifier => MetaPort.Instance.isUsingVr ? ModSettings.EntryVrMenuDistanceModifier.Value : ModSettings.EntryDesktopMenuDistanceModifier.Value;
|
||||
|
||||
public void UpdateAspectRatio(float width, float height)
|
||||
{
|
||||
if (width <= 0f || height <= 0f)
|
||||
return;
|
||||
|
||||
_menuAspectRatio = width / height;
|
||||
|
||||
float normalizedWidth = width / Mathf.Max(width, height);
|
||||
float normalizedHeight = height / Mathf.Max(width, height);
|
||||
menuTransform.localScale = new Vector3(normalizedWidth, normalizedHeight, 1f);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue