diff --git a/Stickers/Integrations/BTKUI/UIAddon.Category.StickersMod.cs b/Stickers/Integrations/BTKUI/UIAddon.Category.StickersMod.cs index 0dfb059..0e9c0c6 100644 --- a/Stickers/Integrations/BTKUI/UIAddon.Category.StickersMod.cs +++ b/Stickers/Integrations/BTKUI/UIAddon.Category.StickersMod.cs @@ -8,6 +8,8 @@ namespace NAK.Stickers.Integrations; public static partial class BTKUIAddon { private static Category _ourCategory; + + private static Button _placeStickersButton; private static readonly MultiSelection _sfxSelection = MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_SelectedSFX); @@ -17,17 +19,15 @@ public static partial class BTKUIAddon private static readonly MultiSelection _tabDoubleClickSelection = MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_TabDoubleClick); - - public static Button placeStickersButton; - + #region Category Setup private static void Setup_StickersModCategory() { _ourCategory = _rootPage.AddMelonCategory(ModSettings.Hidden_Foldout_SettingsCategory); - placeStickersButton = _ourCategory.AddButton("Place Stickers", "Stickers-magic-wand", "Place stickers via raycast.", ButtonStyle.TextWithIcon); - placeStickersButton.OnPress += OnPlaceStickersButtonClick; + _placeStickersButton = _ourCategory.AddButton("Place Stickers", "Stickers-magic-wand", "Place stickers via raycast.", ButtonStyle.TextWithIcon); + _placeStickersButton.OnPress += OnPlaceStickersButtonClick; Button clearSelfStickersButton = _ourCategory.AddButton("Clear Self", "Stickers-eraser", "Clear own stickers.", ButtonStyle.TextWithIcon); clearSelfStickersButton.OnPress += OnClearSelfStickersButtonClick; @@ -62,16 +62,15 @@ public static partial class BTKUIAddon { if (!_isOurTabOpened) return; - if (StickerSystem.RestrictedInstance == false) - { - string mode = StickerSystem.Instance.IsInStickerMode ? "Exiting" : "Entering"; - QuickMenuAPI.ShowAlertToast($"{mode} sticker placement mode...", 2); - StickerSystem.Instance.IsInStickerMode = !StickerSystem.Instance.IsInStickerMode; - } - else + if (StickerSystem.Instance.IsRestrictedInstance) { QuickMenuAPI.ShowAlertToast("Stickers are not allowed in this world!", 2); + return; } + + string mode = StickerSystem.Instance.IsInStickerMode ? "Exiting" : "Entering"; + QuickMenuAPI.ShowAlertToast($"{mode} sticker placement mode...", 2); + StickerSystem.Instance.IsInStickerMode = !StickerSystem.Instance.IsInStickerMode; } private static void OnClearSelfStickersButtonClick() @@ -95,28 +94,25 @@ public static partial class BTKUIAddon StickerSystem.OpenStickersFolder(); } - public static void UpdateStickerMenu() //TODO: add Icon changing, Bono needs to expose the value first. + public static void OnStickerRestrictionUpdated(bool isRestricted = false) //TODO: add Icon changing, Bono needs to expose the value first. { - if (StickerSystem.RestrictedInstance == true) + if (isRestricted) { _rootPage.MenuSubtitle = "Stickers... are sadly disabled in this world."; - placeStickersButton.Disabled = true; - placeStickersButton.ButtonText = "Stickers Disabled"; - placeStickersButton.ButtonTooltip = "This world is not allowing Stickers."; - placeStickersButton.ButtonIcon = "Stickers-magic-wand-broken"; - - } - else - { - _rootPage.MenuSubtitle = "Stickers! Double-click the tab to quickly toggle Sticker Mode."; - - placeStickersButton.Disabled = false; - placeStickersButton.ButtonText = "Place Stickers"; - placeStickersButton.ButtonTooltip = "Place stickers via raycast."; - placeStickersButton.ButtonIcon = "Stickers-magic-wand"; + _placeStickersButton.Disabled = true; + _placeStickersButton.ButtonText = "Stickers Disabled"; + _placeStickersButton.ButtonTooltip = "This world is not allowing Stickers."; + _placeStickersButton.ButtonIcon = "Stickers-magic-wand-broken"; + return; } + _rootPage.MenuSubtitle = "Stickers! Double-click the tab to quickly toggle Sticker Mode."; + + _placeStickersButton.Disabled = false; + _placeStickersButton.ButtonText = "Place Stickers"; + _placeStickersButton.ButtonTooltip = "Place stickers via raycast."; + _placeStickersButton.ButtonIcon = "Stickers-magic-wand"; } #endregion Button Actions diff --git a/Stickers/Integrations/BTKUI/UIAddon.Main.cs b/Stickers/Integrations/BTKUI/UIAddon.Main.cs index e741432..327949b 100644 --- a/Stickers/Integrations/BTKUI/UIAddon.Main.cs +++ b/Stickers/Integrations/BTKUI/UIAddon.Main.cs @@ -22,30 +22,36 @@ public static partial class BTKUIAddon } #region Setup - + private static void Setup_Icons() { + Assembly assembly = Assembly.GetExecutingAssembly(); + string assemblyName = assembly.GetName().Name; + // All icons used - https://www.flaticon.com/authors/gohsantosadrive - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-alphabet", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-alphabet.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-eraser", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-eraser.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-folder", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-folder.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-headset", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-headset.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magnifying-glass", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magnifying-glass.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magic-wand.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand-broken", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magic-wand-broken.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-mouse", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-mouse.png")); - //QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-pencil", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-pencil.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-puzzle.png")); - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle-disabled", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-puzzle-disabled.png")); //Disabled Sticker Puzzle - QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-rubbish-bin", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-rubbish-bin.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-alphabet", GetIconStream("Gohsantosadrive_Icons.Stickers-alphabet.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-eraser", GetIconStream("Gohsantosadrive_Icons.Stickers-eraser.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-folder", GetIconStream("Gohsantosadrive_Icons.Stickers-folder.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-headset", GetIconStream("Gohsantosadrive_Icons.Stickers-headset.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magnifying-glass", GetIconStream("Gohsantosadrive_Icons.Stickers-magnifying-glass.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand", GetIconStream("Gohsantosadrive_Icons.Stickers-magic-wand.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand-broken", GetIconStream("Gohsantosadrive_Icons.Stickers-magic-wand-broken.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-mouse", GetIconStream("Gohsantosadrive_Icons.Stickers-mouse.png")); + //QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-pencil", GetIconStream("Gohsantosadrive_Icons.Stickers-pencil.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle", GetIconStream("Gohsantosadrive_Icons.Stickers-puzzle.png")); + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle-disabled", GetIconStream("Gohsantosadrive_Icons.Stickers-puzzle-disabled.png")); // disabled Sticker Puzzle + QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-rubbish-bin", GetIconStream("Gohsantosadrive_Icons.Stickers-rubbish-bin.png")); + + return; + Stream GetIconStream(string iconName) => assembly.GetManifestResourceStream($"{assemblyName}.Resources.{iconName}"); } - + private static void Setup_StickerModTab() { - _rootPage = new Page(ModSettings.ModName, ModSettings.SM_SettingsCategory, true, "Stickers-Puzzle") //Sticker Icon will be left blank as it is updated on world join, AFTER Icon value is exposed.. + _rootPage = new Page(ModSettings.ModName, ModSettings.SM_SettingsCategory, true, "Stickers-Puzzle") // sticker icon will be left blank as it is updated on world join, AFTER Icon value is exposed.. { MenuTitle = ModSettings.SM_SettingsCategory, - MenuSubtitle = "", //Left this blank as it is defined when the world loads + MenuSubtitle = "", // left this blank as it is defined when the world loads }; _rootPageElementID = _rootPage.ElementID; @@ -91,10 +97,7 @@ public static partial class BTKUIAddon { default: case TabDoubleClick.ToggleStickerMode: - if (StickerSystem.RestrictedInstance == false) - { - OnPlaceStickersButtonClick(); - } + OnPlaceStickersButtonClick(); break; case TabDoubleClick.ClearAllStickers: OnClearAllStickersButtonClick(); diff --git a/Stickers/Main.cs b/Stickers/Main.cs index 87e6824..80ebd6b 100644 --- a/Stickers/Main.cs +++ b/Stickers/Main.cs @@ -23,10 +23,10 @@ public class StickerMod : MelonMod ModSettings.Initialize(); StickerSystem.Initialize(); - ApplyPatches(typeof(Patches.PlayerSetupPatches)); - ApplyPatches(typeof(Patches.ControllerRayPatches)); - ApplyPatches(typeof(Patches.ShaderFilterHelperPatches)); - ApplyPatches(typeof(Patches.CVRToolsPatches)); + ApplyPatches(typeof(Patches.PlayerSetup_Patches)); + ApplyPatches(typeof(Patches.ControllerRay_Patches)); + ApplyPatches(typeof(Patches.ShaderFilterHelper_Patches)); + ApplyPatches(typeof(Patches.CVRTools_Patches)); LoadAssetBundle(); @@ -38,17 +38,10 @@ public class StickerMod : MelonMod if (StickerSystem.Instance == null) return; - if (!MetaPort.Instance.isUsingVr - && StickerSystem.Instance.IsInStickerMode) - { - if (Input.mouseScrollDelta.y != 0f - && Cursor.lockState == CursorLockMode.Locked // prevent scrolling while in menus - && !CVRInputManager.Instance.zoom) // prevent scrolling while using scroll zoom - { - StickerSystem.Instance.SelectedStickerSlot += (int)Input.mouseScrollDelta.y; - } - StickerSystem.Instance.PlaceStickerFromControllerRay(PlayerSetup.Instance.activeCam.transform, CVRHand.Left, true); - } + if (Input.mouseScrollDelta.y != 0f + && Cursor.lockState == CursorLockMode.Locked // prevent scrolling while in menus + && !CVRInputManager.Instance.zoom) // prevent scrolling while using scroll zoom + StickerSystem.Instance.SelectedStickerSlot += (int)Input.mouseScrollDelta.y; StickerSystem.Instance.UpdateStickerPreview(); // flashy flash @@ -57,6 +50,9 @@ public class StickerMod : MelonMod if (!Input.GetKeyDown((KeyCode)ModSettings.Entry_PlaceBinding.Value)) return; + + if (CVRInputManager.Instance.textInputFocused) + return; // prevent placing stickers while typing StickerSystem.Instance.PlaceStickerFromControllerRay(PlayerSetup.Instance.activeCam.transform); } diff --git a/Stickers/Patches.cs b/Stickers/Patches.cs index 4c9ff63..0bb5921 100644 --- a/Stickers/Patches.cs +++ b/Stickers/Patches.cs @@ -8,7 +8,7 @@ using UnityEngine; namespace NAK.Stickers.Patches; -internal static class PlayerSetupPatches +internal static class PlayerSetup_Patches { [HarmonyPostfix] [HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.GetCurrentPropSelectionMode))] @@ -18,7 +18,7 @@ internal static class PlayerSetupPatches } } -internal static class ControllerRayPatches +internal static class ControllerRay_Patches { [HarmonyPrefix] [HarmonyPatch(typeof(ControllerRay), nameof(ControllerRay.HandlePropSpawn))] @@ -30,14 +30,14 @@ internal static class ControllerRayPatches StickerSystem.Instance.PlaceStickerFromControllerRay(__instance.rayDirectionTransform, __instance.hand, true); // preview if (__instance._gripDown) StickerSystem.Instance.IsInStickerMode = false; - if (__instance._hitUIInternal || !__instance._interactDown) + if (__instance._hitUIInternal || !__instance._interactDown) return; StickerSystem.Instance.PlaceStickerFromControllerRay(__instance.rayDirectionTransform, __instance.hand); } } -internal static class ShaderFilterHelperPatches +internal static class ShaderFilterHelper_Patches { [HarmonyPrefix] [HarmonyPatch(typeof(ShaderFilterHelper), nameof(ShaderFilterHelper.SetupFilter))] @@ -51,7 +51,7 @@ internal static class ShaderFilterHelperPatches } } -internal static class CVRToolsPatches +internal static class CVRTools_Patches { [HarmonyPrefix] [HarmonyPatch(typeof(CVRTools), nameof(CVRTools.ReplaceShaders), typeof(Material), typeof(string))] diff --git a/Stickers/Resources/Gohsantosadrive_Icons/Stickers-puzzle-Disabled.png b/Stickers/Resources/Gohsantosadrive_Icons/Stickers-puzzle-disabled.png similarity index 100% rename from Stickers/Resources/Gohsantosadrive_Icons/Stickers-puzzle-Disabled.png rename to Stickers/Resources/Gohsantosadrive_Icons/Stickers-puzzle-disabled.png diff --git a/Stickers/Stickers.csproj b/Stickers/Stickers.csproj index de4a315..e4f12ab 100644 --- a/Stickers/Stickers.csproj +++ b/Stickers/Stickers.csproj @@ -32,6 +32,10 @@ + + + + diff --git a/Stickers/Stickers/Networking/ModNetwork.Constants.cs b/Stickers/Stickers/Networking/ModNetwork.Constants.cs index 0f24904..5cc7a16 100644 --- a/Stickers/Stickers/Networking/ModNetwork.Constants.cs +++ b/Stickers/Stickers/Networking/ModNetwork.Constants.cs @@ -1,15 +1,12 @@ -using ABI_RC.Core.Util.AnimatorManager; -using NAK.Stickers.Properties; - -namespace NAK.Stickers.Networking; +namespace NAK.Stickers.Networking; public static partial class ModNetwork { #region Constants internal const int MaxTextureSize = 1024 * 256; // 256KB - - private const string NetworkVersion = "1.0.2"; // change each time network protocol changes + + private const string NetworkVersion = "1.0.3"; // change each time network protocol changes private const string ModId = $"MelonMod.NAK.Stickers_v{NetworkVersion}"; private const int ChunkSize = 1024; // roughly 1KB per ModNetworkMessage private const int MaxChunkCount = MaxTextureSize / ChunkSize; diff --git a/Stickers/Stickers/Networking/ModNetwork.Inbound.cs b/Stickers/Stickers/Networking/ModNetwork.Inbound.cs index ad04daf..e769006 100644 --- a/Stickers/Stickers/Networking/ModNetwork.Inbound.cs +++ b/Stickers/Stickers/Networking/ModNetwork.Inbound.cs @@ -43,7 +43,8 @@ public static partial class ModNetwork if (ModSettings.Entry_FriendsOnly.Value && !Friends.FriendsWith(sender)) return false; // ignore messages from non-friends if friends only is enabled - if (StickerSystem.RestrictedInstance == true) // ignore messages from users when the world is restricted. This also includes older or modified version of Stickers mod. + + if (StickerSystem.Instance.IsRestrictedInstance) // ignore messages from users when the world is restricted. This also includes older or modified version of Stickers mod. return false; return true; diff --git a/Stickers/Stickers/StickerData.cs b/Stickers/Stickers/StickerData.cs index 4b4aaa9..2ca96bd 100644 --- a/Stickers/Stickers/StickerData.cs +++ b/Stickers/Stickers/StickerData.cs @@ -69,16 +69,16 @@ namespace NAK.Stickers } } - public Guid GetTextureHash(int spawnerIndex = 0) - { - if (spawnerIndex < 0 || spawnerIndex >= _decalSpawners.Length) - { - StickerMod.Logger.Warning("Invalid spawner index!"); - return Guid.Empty; - } - - return _textureHashes[spawnerIndex]; - } + // public Guid GetTextureHash(int spawnerIndex = 0) + // { + // if (spawnerIndex < 0 || spawnerIndex >= _decalSpawners.Length) + // { + // StickerMod.Logger.Warning("Invalid spawner index!"); + // return Guid.Empty; + // } + // + // return _textureHashes[spawnerIndex]; + // } public bool CheckHasTextureHash(Guid textureHash) { @@ -132,7 +132,7 @@ namespace NAK.Stickers Transform rootObject = null; GameObject hitGO = hit.transform.gameObject; if (hitGO.scene.buildIndex == 4 // additive (dynamic) content - || hitGO.TryGetComponent(out Animator _) // potentially movable + || hitGO.GetComponentInParent() != null // potentially movable || hitGO.GetComponentInParent() != null) // movable rootObject = hitGO.transform; @@ -244,21 +244,18 @@ namespace NAK.Stickers if (_previewDecalSpawner == null) return; // uh fuck - // clear previous - ClearPreview(); - // place at hit pos Transform rootObject = null; GameObject hitGO = hit.transform.gameObject; - if (hitGO.scene.buildIndex == 4 || hitGO.TryGetComponent(out Animator _) || hitGO.GetComponentInParent() != null) + if (hitGO.scene.buildIndex == 4 // additive (dynamic) content + || hitGO.GetComponentInParent() != null // potentially movable + || hitGO.GetComponentInParent() != null) // movable rootObject = hitGO.transform; - Vector3 position = hit.point; - _previewDecalSpawner.AddDecal(position, - Quaternion.LookRotation(forwardDirection, upDirection), - hitGO, - DECAL_SIZE, DECAL_SIZE, 1f, 1f, 0f, - rootObject); + _previewDecalSpawner.AddDecal( + hit.point, Quaternion.LookRotation(forwardDirection, upDirection), + hitGO, + DECAL_SIZE, DECAL_SIZE, 1f, 1f, 0f, rootObject); } public void UpdatePreview(int spawnerIndex) diff --git a/Stickers/Stickers/StickerSystem.Main.cs b/Stickers/Stickers/StickerSystem.Main.cs index 0a5a4ef..9cd8fcf 100644 --- a/Stickers/Stickers/StickerSystem.Main.cs +++ b/Stickers/Stickers/StickerSystem.Main.cs @@ -16,9 +16,7 @@ namespace NAK.Stickers; public partial class StickerSystem { #region Singleton - - public static bool RestrictedInstance = false; - + public static StickerSystem Instance { get; private set; } public static void Initialize() @@ -45,8 +43,9 @@ public partial class StickerSystem private void OnPlayerSetupStart() { + // TODO: this can be spammed by world author toggling CVRWorld.enabled state + CVRGameEventSystem.World.OnLoad.AddListener(_ => OnWorldLoad()); CVRGameEventSystem.World.OnUnload.AddListener(_ => OnWorldUnload()); - CVRGameEventSystem.World.OnLoad.AddListener(_ => OnWorldLoad()); CVRGameEventSystem.Instance.OnConnected.AddListener((_) => { if (!Instances.IsReconnecting) OnInitialConnection(); }); CVRGameEventSystem.Player.OnJoinEntity.AddListener(Instance.OnPlayerJoined); @@ -61,30 +60,21 @@ public partial class StickerSystem private void OnInitialConnection() { - OnWorldLoad(); //Checks the world again in case the bundle updated. ClearStickersSelf(); // clear stickers on remotes just in case we rejoined ModNetwork.Reset(); // reset network buffers and metadata } private void OnWorldLoad() { - GameObject StickerWorldRestriction = GameObject.Find("[DisableStickers]"); - if (StickerWorldRestriction != null) - { - RestrictedInstance = true; - MelonLogger.Msg("This is a Restricted Instance"); - } - else - { - MelonLogger.Msg("This is NOT a Restricted Instance"); - } - BTKUIAddon.UpdateStickerMenu(); + IsRestrictedInstance = GameObject.Find("[DisableStickers]") != null; + if (IsRestrictedInstance) StickerMod.Logger.Msg("Stickers are restricted by the world author."); + BTKUIAddon.OnStickerRestrictionUpdated(IsRestrictedInstance); } private void OnWorldUnload() { - RestrictedInstance = false; - CleanupAllButSelf(); // release all stickers except for self + IsRestrictedInstance = false; + CleanupAllButSelf(); } #endregion Game Events @@ -107,6 +97,8 @@ public partial class StickerSystem // } // } + public bool IsRestrictedInstance { get; internal set; } + private string SelectedStickerName => ModSettings.Hidden_SelectedStickerNames.Value[_selectedStickerSlot]; private const float StickerKillTime = 30f; @@ -131,7 +123,7 @@ public partial class StickerSystem get => _isInStickerMode; set { - _isInStickerMode = value; + _isInStickerMode = value && !IsRestrictedInstance; // ensure cannot enter when restricted if (_isInStickerMode) { CohtmlHud.Instance.SelectPropToSpawn( diff --git a/Stickers/Stickers/StickerSystem.StickerLifecycle.cs b/Stickers/Stickers/StickerSystem.StickerLifecycle.cs index 821aedc..df4ee96 100644 --- a/Stickers/Stickers/StickerSystem.StickerLifecycle.cs +++ b/Stickers/Stickers/StickerSystem.StickerLifecycle.cs @@ -51,7 +51,7 @@ public partial class StickerSystem private bool PlaceStickerSelf(Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true) { - if (!AttemptPlaceSticker(PlayerLocalId, position, forward, up, alignWithNormal, SelectedStickerSlot, RestrictedInstance)) + if (!AttemptPlaceSticker(PlayerLocalId, position, forward, up, alignWithNormal, SelectedStickerSlot)) return false; // failed // placed, now network @@ -59,8 +59,12 @@ public partial class StickerSystem return true; } - private bool AttemptPlaceSticker(string playerId, Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true, int stickerSlot = 0, bool RestrictedInstance = false, bool isPreview = false) + private bool AttemptPlaceSticker(string playerId, Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true, int stickerSlot = 0, bool isPreview = false) { + // if the world contained a gameobject with the [DisableStickers] name and restricted the instance disable stickers! + if (IsRestrictedInstance) + return false; + StickerData stickerData = GetOrCreateStickerData(playerId); if (Time.time - stickerData.LastPlacedTime < StickerCooldown) return false; @@ -75,10 +79,6 @@ public partial class StickerSystem if (hit.transform.gameObject.name.StartsWith("[NoSticker]")) return false; - // if the world contained a gameobject with the [DisableStickers] name and restricted the instance disable stickers! - if (RestrictedInstance == true) - return false; - if (isPreview) { stickerData.PlacePreview(hit, alignWithNormal ? -hit.normal : forward, up, stickerSlot); @@ -181,6 +181,7 @@ public partial class StickerSystem if (!IsInStickerMode) return; StickerData localStickerData = GetOrCreateStickerData(PlayerLocalId); + localStickerData.ClearPreview(); // clear prior frames sticker preview localStickerData.UpdatePreview(SelectedStickerSlot); } diff --git a/Stickers/format.json b/Stickers/format.json index 8eb9979..b25086c 100644 --- a/Stickers/format.json +++ b/Stickers/format.json @@ -1,11 +1,11 @@ { "_id": 232, "name": "Stickers", - "modversion": "1.0.6", - "gameversion": "2024r175", + "modversion": "1.0.8", + "gameversion": "2024r177", "loaderversion": "0.6.1", "modtype": "Mod", - "author": "NotAKidoS", + "author": "NotAKidoS, SketchFoxsky", "description": "Stickers! Allows you to place small images on any surface. Requires both users to have the mod installed. Synced over Mod Network.\n\nLimitations:\n- Image should be under 256KB in size.\n- Image dimensions should be a power of 2 (e.g. 512x512, 1024x1024).\n - If the image exceeds the size limit or is not a power of 2 the mod will automatically resize it.\n - The automatic resizing may result in loss of quality (or may just fail), so it is recommended to resize the image yourself before placing it in the `UserData/Stickers/` folder.\n\n-# More information can be found on the [README](https://github.com/NotAKidoS/NAK_CVR_Mods/blob/main/Stickers/README.md).", "searchtags": [ "stickers", @@ -16,8 +16,8 @@ "requirements": [ "None" ], - "downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r40/Stickers.dll", + "downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r41/Stickers.dll", "sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/Stickers/", - "changelog": "- Added Friends Only setting.\n- Added button to clear sticker thumbnail cache.\n- Added Identify button to Player Selection page.\n- Added `[NoSticker]` GameObject name check. \n- Adjusted inbound network buffers to be cleared on initial connection to an instance.\n- Adjusted selecting a new image for a sticker slot to clear stickers in-scene for that slot.\n- Stripped all unused classes a bunch of other methods from decalery.\n - Completely removed Skinned Mesh Renderer support as it required running on CPU.\n - Most uploaded content is not marked as readable anyways (plus it crashed consistantly).\n- Fixed nullref spam when clearing stickers when sticker was already marked as dead.\n- Fixed issue where saving melon preferences would error due to null sticker selection.", + "changelog": "- Added world restriction via `[DisableStickers]` GameObject (thx Sketch).\n- Added sticker placement preview.\n- Fixed stickers being hit by VR switch shader replacement.\n- Fixed Desktop Sticker placement bind firing when a text field was focused.", "embedcolor": "#f61963" } \ No newline at end of file