diff --git a/drop_item.wav b/drop_item.wav deleted file mode 100644 index 0945bda..0000000 Binary files a/drop_item.wav and /dev/null differ diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 2f3f438..8260d34 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -222,21 +222,19 @@ namespace stardew_access }); #endregion - #region Custom Sounds - /*CueDefinition myCueDefinition = new CueDefinition(); - - // Adding the name for the cue, which will be - // the name of the audio to play when using sound functions. - myCueDefinition.name = "myNewSound"; - // If this sound is played multiple times in quick succession, - // only one sound instance will play at a time. - myCueDefinition.instanceLimit = 1; - myCueDefinition.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest; - // Get the audio file and add it to a SoundEffect. - SoundEffect sound_effect; - string filePathCombined = Path.Combine(this.Helper.DirectoryPath, "mySound.wav"); - System.IO.FileStream stream = new System.IO.FileStream(filePathCombined, System.IO.FileMode.Open) - sound_effect = SoundEffect.FromStream(stream);*/ + #region Custom Drop Item Sound + CueDefinition sa_drop_item = new CueDefinition(); + sa_drop_item.name = "sa_drop_item"; + sa_drop_item.instanceLimit = 1; + sa_drop_item.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest; + SoundEffect audio; + string filePathCombined = Path.Combine(this.Helper.DirectoryPath, "drop_item.wav"); + using (FileStream stream = new(filePathCombined, FileMode.Open)) + { + audio = SoundEffect.FromStream(stream); + } + sa_drop_item.SetSound(audio, Game1.audioEngine.GetCategoryIndex("Sound"), false); + Game1.soundBank.AddCue(sa_drop_item); #endregion helper.Events.Input.ButtonPressed += this.OnButtonPressed; diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs index c9bde3d..9695a33 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches.cs @@ -7,7 +7,11 @@ namespace stardew_access.Patches { internal class GameMenuPatches { + internal static string hoveredItemQueryKey = ""; internal static string geodeMenuQueryKey = ""; + internal static string itemGrabMenuQueryKey = ""; + internal static string craftingPageQueryKey = ""; + internal static string inventoryPageQueryKey = ""; internal static void GeodeMenuPatch(GeodeMenu __instance) { @@ -52,6 +56,7 @@ namespace stardew_access.Patches { geodeMenuQueryKey = toSpeak; ScreenReader.say(toSpeak, true); + Game1.playSound("sa_drop_item"); } return; } @@ -82,7 +87,8 @@ namespace stardew_access.Patches #endregion #region Narrate hovered item - narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y); + if(narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y)) + geodeMenuQueryKey = ""; #endregion } catch (Exception e) @@ -110,18 +116,34 @@ namespace stardew_access.Patches #region Narrate buttons in the menu if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) { - ScreenReader.sayWithMenuChecker("Ok Button", true); + string toSpeak = "Ok Button"; + if(itemGrabMenuQueryKey != toSpeak) + { + itemGrabMenuQueryKey = toSpeak; + ScreenReader.say(toSpeak, true); + } return; } if (__instance.trashCan != null && __instance.trashCan.containsPoint(x, y)) { - ScreenReader.sayWithMenuChecker("Trash Can", true); + string toSpeak = "Trash Can"; + if (itemGrabMenuQueryKey != toSpeak) + { + itemGrabMenuQueryKey = toSpeak; + ScreenReader.say(toSpeak, true); + } return; } if (__instance.dropItemInvisibleButton != null && __instance.dropItemInvisibleButton.containsPoint(x, y)) { - ScreenReader.sayWithMenuChecker("Drop Item", true); + string toSpeak = "Drop Item"; + if (itemGrabMenuQueryKey != toSpeak) + { + itemGrabMenuQueryKey = toSpeak; + ScreenReader.say(toSpeak, true); + Game1.playSound("sa_drop_item"); + } return; } #endregion @@ -204,7 +226,8 @@ namespace stardew_access.Patches } #region Narrate hovered item - narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true); + if(narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true)) + inventoryPageQueryKey = ""; #endregion } catch (Exception e) @@ -389,9 +412,9 @@ namespace stardew_access.Patches toSpeak = "Empty Slot"; } - if (geodeMenuQueryKey != $"{toSpeak}:{i}") + if (hoveredItemQueryKey != $"{toSpeak}:{i}") { - geodeMenuQueryKey = $"{toSpeak}:{i}"; + hoveredItemQueryKey = $"{toSpeak}:{i}"; ScreenReader.say(toSpeak, true); } return true; diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index 7ca6822..61bfeea 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -264,6 +264,8 @@ namespace stardew_access.Patches { GameMenuPatches.geodeMenuQueryKey = ""; } + + } catch (Exception e) { diff --git a/stardew-access/stardew-access.csproj b/stardew-access/stardew-access.csproj index b988097..cd68d76 100644 --- a/stardew-access/stardew-access.csproj +++ b/stardew-access/stardew-access.csproj @@ -1,7 +1,7 @@  - net452 + net5.0 stardew_access enable enable @@ -12,13 +12,8 @@ - + - - - - -