Skip to content

Commit

Permalink
Fixed for 2024r176
Browse files Browse the repository at this point in the history
  • Loading branch information
kafeijao committed Jul 25, 2024
1 parent 0c9b3ca commit 055a025
Show file tree
Hide file tree
Showing 59 changed files with 424 additions and 490 deletions.
4 changes: 2 additions & 2 deletions BetterAFK/Properties/CVRMG.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": 148,
"name": "BetterAFK",
"modversion": "0.0.8",
"gameversion": "2024r175",
"gameversion": "2024r176",
"loaderversion": "v0.6.1",
"modtype": "Mod",
"author": "kafeijao",
Expand All @@ -13,7 +13,7 @@
"better"
],
"requirements": [],
"downloadlink": "https://github.com/kafeijao/Kafe_CVR_Mods/releases/download/r68/BetterAFK.dll",
"downloadlink": "https://github.com/kafeijao/Kafe_CVR_Mods/releases/download/r72/BetterAFK.dll",
"sourcelink": "https://github.com/kafeijao/Kafe_CVR_Mods/tree/master/BetterAFK",
"changelog": "- Fixed for 2024r175",
"embedcolor": "16C60C"
Expand Down
4 changes: 2 additions & 2 deletions BetterPortals/Properties/CVRMG.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_id": 167,
"name": "BetterPortals",
"modversion": "0.0.6",
"gameversion": "2024r175",
"gameversion": "2024r176",
"loaderversion": "v0.6.1",
"modtype": "Mod",
"author": "kafeijao",
Expand All @@ -13,7 +13,7 @@
"drop"
],
"requirements": [],
"downloadlink": "https://github.com/kafeijao/Kafe_CVR_Mods/releases/download/r68/BetterPortals.dll",
"downloadlink": "https://github.com/kafeijao/Kafe_CVR_Mods/releases/download/r72/BetterPortals.dll",
"sourcelink": "https://github.com/kafeijao/Kafe_CVR_Mods/tree/master/BetterPortals",
"changelog": "- Fixed for 2024r174",
"embedcolor": "16C60C"
Expand Down
2 changes: 2 additions & 0 deletions CCK.Debugger/Components/CohtmlDataObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public Core(string menuName, bool showControls = false, string controlsInfo = ""
[JsonProperty("Buttons")] private List<Button> Buttons { get; } = new();

public Section AddSection(string title, bool collapsable = false) {
if (ModConfig.MeDisableCollapsible.Value) collapsable = false;
var section = new Section(this) { Title = title, Collapsable = collapsable };
Sections.Add(CacheSection(section));
return section;
Expand Down Expand Up @@ -208,6 +209,7 @@ public class Section {
[JsonIgnore] private List<Section> _dynamicSubsectionsLatest;
public Section(Core core) => _core = core;
public Section AddSection(string title, string value = "", bool collapsable = false, bool dynamicSubsections = false) {
if (ModConfig.MeDisableCollapsible.Value) collapsable = false;
var section = new Section(_core) { Title = title, Collapsable = collapsable, Value = value, DynamicSubsections = dynamicSubsections};
SubSections.Add(_core.CacheSection(section));
return section;
Expand Down
239 changes: 22 additions & 217 deletions CCK.Debugger/Components/CohtmlMenuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ private void FullReload() {
}

_cohtmlControlledView.View.Reload();

// Reload current handler
ICohtmlHandler.Reload();

// Mark as initialized and update state
Initialized = true;
UpdateMenuState();
}

internal void UpdateMenuState() {
Expand Down Expand Up @@ -237,6 +244,7 @@ private void SetupControlledView(CVR_MenuManager quickMenu) {
CohtmlInputHandler.Input.OnTouchEvent += OnTouchEvent;

_cohtmlControlledView.Listener.ReadyForBindings += RegisterMenuViewEvents;
// _cohtmlControlledView.Listener.FinishLoad += OnFinishedLoad;

// Calculate the resolution
var resolutionX = (int)(_scaleX * 2500);
Expand Down Expand Up @@ -303,224 +311,21 @@ private void RegisterMenuViewEvents() {
view.RegisterForEvent("CCKDebuggerMenuReady", () => {
MelonLogger.Msg("Cohtml menu has loaded successfully!");

view.TriggerEvent("CCKDebuggerModReady");
// Todo: Move next to _cohtmlControlledView.Listener.ReadyForBindings when we get a better callback
_cohtmlControlledView.Listener.FinishLoad += OnFinishedLoad;
});
}

// Reload current handler
ICohtmlHandler.Reload();
private void OnFinishedLoad(string url) {
_cohtmlControlledView.Listener.FinishLoad -= OnFinishedLoad;

// Mark as initialized and update state
Initialized = true;
UpdateMenuState();
});
_cohtmlControlledView.View.TriggerEvent("CCKDebuggerModReady");

// Reload current handler
ICohtmlHandler.Reload();

// Mark as initialized and update state
Initialized = true;
UpdateMenuState();
}
//
// [HarmonyPatch]
// private class HarmonyPatches {
//
// private static bool _vrMInteractDownOnMenu;
// private static Vector2 _vrQuickMenuLastCoords;
//
// [HarmonyPostfix]
// [HarmonyPatch(typeof(ControllerRay), nameof(ControllerRay.LateUpdate))]
// private static void After_ControllerRay_LateUpdate(ControllerRay __instance) {
// if (_errored) return;
// try {
// LateUpdateCCKRayController(__instance);
// }
// catch (Exception e) {
// _errored = true;
// MelonLogger.Error(e);
// MelonLogger.Error("Execution of the menu will stop. Report this error to the creator.");
// throw;
// }
// }
//
// // private static bool RaycastCohtmlPlane(CohtmlView view, Ray ray, out float distance, out Vector2 viewCoords) {
// // if (new Plane(view.transform.forward, view.transform.position).Raycast(ray, out distance)) {
// // Vector3 vector3 = view.transform.InverseTransformPoint(ray.origin + ray.direction * distance);
// // viewCoords = new Vector2(vector3.x + 0.5f, vector3.y + 0.5f);
// // return viewCoords.x >= 0.0 && viewCoords.x <= 1.0 && viewCoords.y >= 0.0 && viewCoords.y <= 1.0;
// // }
// // distance = -1f;
// // viewCoords = Vector2.zero;
// // return false;
// // }
// //
// // private static void LateUpdateCCKRayController(ControllerRay controllerRay) {
// //
// // if (!Initialized || !Instance._cohtmlControlledView.enabled) return;
// //
// // // Check the ray hands
// // var interactingWithCurrentHand = controllerRay.hand
// // ? CVRInputManager.Instance.interactLeftDown
// // : CVRInputManager.Instance.interactRightDown;
// // var stoppedInteractingWithCurrentHand = controllerRay.hand
// // ? CVRInputManager.Instance.interactLeftUp
// // : CVRInputManager.Instance.interactRightUp;
// //
// // var ray = new Ray(controllerRay.transform.position,
// // controllerRay.transform.TransformDirection(controllerRay.RayDirection));
// //
// // // Check if the raycast intercepts the menu
// // if (RaycastCohtmlPlane(Instance._cohtmlControlledView, ray, out var distance, out var viewCoords)) {
// //
// // // Mark as pointing the menu
// // // CVRInputManager.Instance.controllerPointingMenu = true;
// //
// // if (!controllerRay.uiActive) return;
// //
// // // Get the values for x and y
// // var x = (int)(viewCoords.x * Instance._cohtmlControlledView.Width);
// // var y = (int)((1.0 - viewCoords.y) * Instance._cohtmlControlledView.Height);
// //
// // _vrQuickMenuLastCoords.x = x;
// // _vrQuickMenuLastCoords.y = y;
// //
// // // Mouse move event
// // var mouseMove = new MouseEventData { X = x, Y = y, Type = MouseEventData.EventType.MouseMove };
// // Instance._cohtmlControlledView.View.MouseEvent(mouseMove);
// //
// // // Mouse down event
// // if (interactingWithCurrentHand && !_vrMInteractDownOnMenu) {
// // var mouseDown = new MouseEventData { X = x, Y = y, Type = MouseEventData.EventType.MouseDown };
// // Instance._cohtmlControlledView.View.MouseEvent(mouseDown);
// // _vrMInteractDownOnMenu = true;
// // }
// //
// // // Mouse up event
// // if (stoppedInteractingWithCurrentHand && _vrMInteractDownOnMenu) {
// // var mouseup = new MouseEventData { X = x, Y = y, Type = MouseEventData.EventType.MouseUp };
// // Instance._cohtmlControlledView.View.MouseEvent(mouseup);
// // _vrMInteractDownOnMenu = false;
// // }
// //
// // // Mouse wheel event
// // if (CVRInputManager.Instance.scrollValue > 0.0 || CVRInputManager.Instance.scrollValue < 0.0) {
// // var mouseWheel = new MouseEventData {
// // WheelX = 0.0f, WheelY = CVRInputManager.Instance.scrollValue * -750f,
// // Type = MouseEventData.EventType.MouseWheel
// // };
// // Instance._cohtmlControlledView.View.MouseEvent(mouseWheel);
// // }
// //
// // // Clear targeted candidates and highlights, because we're selecting our menu. I could've used a
// // // transpiler to properly fix this, but Daky hates me if I do
// // controllerRay.clearTelepathicGrabTargetHighlight();
// // controllerRay._telepathicPickupCandidate = null;
// // controllerRay._telepathicPickupTargeted = false;
// //
// // // If the line renderer doesn't exist, ignore
// // if (!controllerRay.lineRenderer) return;
// //
// // controllerRay.lineRenderer.enabled = true;
// // var rayPos = controllerRay.transform.position + controllerRay.transform.TransformDirection(controllerRay.RayDirection) * distance;
// // controllerRay.lineRenderer.SetPosition(1, controllerRay.transform.InverseTransformPoint(rayPos));
// // }
// //
// // // If it was being hold down, release
// // else if (stoppedInteractingWithCurrentHand && _vrMInteractDownOnMenu) {
// // Instance._cohtmlControlledView.View.MouseEvent(new MouseEventData {
// // X = (int) _vrQuickMenuLastCoords.x,
// // Y = (int) _vrQuickMenuLastCoords.y,
// // Type = MouseEventData.EventType.MouseUp,
// // });
// // _vrMInteractDownOnMenu = false;
// // }
// // }
//
//
// // [HarmonyPostfix]
// // [HarmonyPatch(typeof(CVR_MenuManager), nameof(CVR_MenuManager.Update))]
// // private static void After_CVR_MenuManager_LateUpdate(CVR_MenuManager __instance) {
// // if (_errored) return;
// // try {
// // LateUpdateMenuManager(__instance);
// // }
// // catch (Exception e) {
// // _errored = true;
// // MelonLogger.Error(e);
// // MelonLogger.Error("Execution of the menu will stop. Report this error to the creator.");
// // throw;
// // }
// // }
// //
// // private static bool _desktopMouseDownOnMenu;
// // private static bool _desktopMouseMovingOnMenu;
// // private static Vector2 _desktopQuickMenuLastCoords;
// //
// // private static void LateUpdateMenuManager(CVR_MenuManager menuManager) {
// // if (!Initialized) return;
// //
// // var cckView = Instance._cohtmlControlledView;
// // var isCursorLocked = Cursor.lockState == CursorLockMode.Locked;
// //
// // var camera = menuManager._camera;
// //
// // if (!cckView.enabled || InputManager.Instance.isMenuFreeLook || MetaPort.Instance.isUsingVr || camera == null) return;
// //
// // int x = -1, y = -1;
// // bool hasHit;
// //
// // // Calculate menu raycast using the camera as a raycast source point (when the menu is in world space)
// // if (isCursorLocked) {
// // var ray = new Ray(camera.transform.position, camera.transform.TransformDirection(Vector3.forward));
// // hasHit = RaycastCohtmlPlane(cckView, ray, out var hitInfoCamera, out var viewCoords);
// // if (hasHit) {
// // x = (int)(viewCoords.x * cckView.Width);
// // y = (int)((1.0 - viewCoords.y) * cckView.Height);
// // }
// // }
// // // Calculate menu raycast using the cursor as the raycast source point (when menu is on quick menu or hud)
// // else {
// // var ray = camera.ScreenPointToRay(Input.mousePosition);
// // hasHit = Instance._cohtmlViewCollider.Raycast(ray, out var hitInfoCursor, 1000f);
// // if (hasHit) {
// // x = (int) (hitInfoCursor.textureCoord.x * cckView.Width);
// // y = (int) ((1.0 - hitInfoCursor.textureCoord.y) * cckView.Height);
// // }
// // }
// //
// // if (hasHit) {
// // // Mark as pointing the menu
// // // CVRInputManager.Instance.controllerPointingMenu = true;
// //
// // // Grab the x and y positions
// // _desktopQuickMenuLastCoords.x = x;
// // _desktopQuickMenuLastCoords.y = y;
// //
// // // Mouse move event
// // cckView.View.MouseEvent(new MouseEventData { X = x, Y = y, Type = MouseEventData.EventType.MouseMove });
// // _desktopMouseMovingOnMenu = true;
// //
// // // Mouse down event
// // if (Input.GetMouseButtonDown(0)) {
// // cckView.View.MouseEvent(new MouseEventData { X = x, Y = y, Type = MouseEventData.EventType.MouseDown });
// // _desktopMouseDownOnMenu = true;
// // }
// //
// // // Mouse up event
// // if (Input.GetMouseButtonUp(0)) {
// // cckView.View.MouseEvent(new MouseEventData { X = x, Y = y, Type = MouseEventData.EventType.MouseUp });
// // _desktopMouseDownOnMenu = false;
// // }
// //
// // // Mouse scroll event
// // if (CVRInputManager.Instance.scrollValue > 0.0 || CVRInputManager.Instance.scrollValue < 0.0) {
// // cckView.View.MouseEvent(new MouseEventData { WheelX = 0.0f, WheelY = CVRInputManager.Instance.scrollValue * -750f, Type = MouseEventData.EventType.MouseWheel });
// // }
// // }
// //
// // // Detect the mouse got out of the menu
// // if (_desktopMouseMovingOnMenu) {
// // cckView.View.MouseEvent(new MouseEventData { X = -1, Y = -1, Type = MouseEventData.EventType.MouseMove });
// // _desktopMouseMovingOnMenu = false;
// // }
// //
// // // Mouse up event when stopped clicking
// // if (Input.GetMouseButtonUp(0) && _desktopMouseDownOnMenu) {
// // cckView.View.MouseEvent(new MouseEventData { X = (int) _desktopQuickMenuLastCoords.x, Y = (int) _desktopQuickMenuLastCoords.y, Type = MouseEventData.EventType.MouseUp });
// // _desktopMouseDownOnMenu = false;
// // }
// // }
// }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ABI_RC.Systems.GameEventSystem;
using ABI.CCK.Components;
using MelonLoader;
using UnityEngine;

namespace Kafe.CCK.Debugger.Components.CohtmlMenuHandlers;
Expand All @@ -13,7 +14,8 @@ static WorldCohtmlHandler() {
_isLoaded = true;
SetupWorld();
});
CVRGameEventSystem.World.OnUnload.AddListener(_ => {
CVRGameEventSystem.World.OnUnload.AddListener(worldId => {
if (string.IsNullOrEmpty(worldId)) return;
_isLoaded = false;
SetupWorld();
});
Expand All @@ -27,8 +29,8 @@ private static void SetupWorld() {
var world = CVRWorld.Instance;

var attributesSection = core.AddSection("Attributes");
attributesSection.AddSection("World Id").Value = _isLoaded ? world.assetInfo.objectId : "N/A";
attributesSection.AddSection("World Name").AddValueGetter(() => _isLoaded && Events.World.WorldNamesCache.TryGetValue(world.assetInfo.objectId, out var worldName) ? worldName : "N/A");
attributesSection.AddSection("World Id").Value = _isLoaded ? world.AssetInfo.objectId : "N/A";
attributesSection.AddSection("World Name").AddValueGetter(() => _isLoaded && Events.World.WorldNamesCache.TryGetValue(world.AssetInfo.objectId, out var worldName) ? worldName : "N/A");
attributesSection.AddSection("Has Custom Matrix").Value = ToString(world.useCustomCollisionMatrix);

var colMatrixSection = attributesSection.AddSection("Collision Matrix", "", true);
Expand Down
6 changes: 4 additions & 2 deletions CCK.Debugger/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using ABI_RC.Core.Player.EyeMovement;
using ABI_RC.Core.Player.EyeMovement.Targets;
using ABI_RC.Core.Savior;
using ABI_RC.Systems.InputManagement;
using ABI_RC.Systems.Movement;
using ABI_RC.Systems.RuntimeDebug;
using ABI.CCK.Components;
Expand Down Expand Up @@ -57,8 +58,9 @@ public override void OnInitializeMelon() {
#endif
}

public override void OnLateUpdate() {
if (Input.GetKeyDown(KeyCode.F5)) Events.DebuggerMenuCohtml.OnCohtmlMenuReload();
public override void OnUpdate()
{
if (CVRInputManager.Instance != null && CVRInputManager.Instance.reload) Events.DebuggerMenuCohtml.OnCohtmlMenuReload();
}

[HarmonyPatch]
Expand Down
4 changes: 4 additions & 0 deletions CCK.Debugger/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static class ModConfig {
private static MelonPreferences_Category _melonCategory;
internal static MelonPreferences_Entry<bool> MeIsHidden;
internal static MelonPreferences_Entry<bool> MeOverwriteUIResources;
internal static MelonPreferences_Entry<bool> MeDisableCollapsible;

public static void InitializeMelonPrefs() {

Expand All @@ -26,6 +27,9 @@ public static void InitializeMelonPrefs() {
CohtmlMenuController.Instance.UpdateMenuState();
Core.PinToQuickMenu();
});

MeDisableCollapsible = _melonCategory.CreateEntry("DisableCollapsible", false,
description: "Whether to disable all collapsible info or not. Warning: Disabling it may cause a huge performance impact.");
}

public enum ShaderType {
Expand Down
2 changes: 1 addition & 1 deletion CCK.Debugger/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace Kafe.CCK.Debugger.Properties;
internal static class AssemblyInfoParams {
public const string Version = "2.0.13";
public const string Version = "2.0.14";
public const string Author = "kafeijao";
public const string AstroDoge = "AstroDoge";
public const string Name = "CCK.Debugger";
Expand Down
Loading

0 comments on commit 055a025

Please sign in to comment.