Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions FFVI_Mod/Core/AudioLoopManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public class AudioLoopManager
private const float TILE_SIZE = 16f;
private const float MAP_EXIT_TOLERANCE = 12.0f;
private const float WALL_TONE_INTERVAL = 0.1f;
private const float BEACON_INTERVAL = 2.0f;
private const float SCENE_LOAD_SUPPRESSION = 1.0f;
private const float INITIAL_LOOP_DELAY = 0.3f;

Expand Down Expand Up @@ -224,7 +223,7 @@ private IEnumerator BeaconLoop()
yield return null;
continue;
}
nextBeaconTime = Time.time + BEACON_INTERVAL;
nextBeaconTime = Time.time + (0.1f + (PreferencesManager.BeaconDelay / 25f));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 25f divisor and 0.1f floor are a bit opaque here. Could you extract this into a local variable with a short comment explaining the range?

Suggested change
nextBeaconTime = Time.time + (0.1f + (PreferencesManager.BeaconDelay / 25f));
nextBeaconTime = Time.time + (0.1f + (PreferencesManager.BeaconDelay / 25f)); // Slider 0-100 maps to 100ms-4100ms

Or pull the expression into a named variable — either works.


if (Time.time < beaconSuppressedUntil)
continue;
Expand Down Expand Up @@ -252,11 +251,6 @@ private IEnumerator BeaconLoop()
float pan = Mathf.Clamp(deltaX / 100f, -1f, 1f) * 0.5f + 0.5f;

bool isSouth = entityPos.y < playerPos.y - 8f;

float timeSinceLast = Time.time - lastBeaconPlayedAt;
if (timeSinceLast < BEACON_INTERVAL * 0.8f)
continue;

SoundPlayer.PlayBeacon(isSouth, pan, volumeScale);
lastBeaconPlayedAt = Time.time;
}
Expand Down
28 changes: 24 additions & 4 deletions FFVI_Mod/Core/ModMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public ToggleItem(string name, Func<bool> getter, Action toggle)
public override void Toggle() => toggle();
}

private class VolumeItem : MenuItem
private class SliderItem : MenuItem
{
private readonly Func<int> getter;
private readonly Action<int> setter;
protected readonly Func<int> getter;
protected readonly Action<int> setter;

public VolumeItem(string name, Func<int> getter, Action<int> setter)
public SliderItem(string name, Func<int> getter, Action<int> setter)
{
nameKey = name;
this.getter = getter;
Expand All @@ -71,12 +71,29 @@ public override void Adjust(int delta)
setter(newValue);
}

public override void Toggle()
{
//Only makes sense for volume controls, so leave as no-op.

}

}

private class VolumeItem: SliderItem
{

public VolumeItem(string name, Func<int> getter, Action<int> setter)
: base(name, getter, setter)
{
}

public override void Toggle()
{
// Toggle between 0 and 50 for quick mute/unmute
int current = getter();
setter(current == 0 ? 50 : 0);
}

}

private class EnumItem : MenuItem
Expand Down Expand Up @@ -183,6 +200,9 @@ public static void Initialize()
new ToggleItem("Audio Beacons",
() => FFVI_ScreenReaderMod.AudioBeaconsEnabled,
() => FFVI_ScreenReaderMod.Instance?.ToggleAudioBeacons()),
new SliderItem("Beacon delay",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things here:

  1. Title case: All other menu items use title case ("Audio Beacons", "Beacon Volume"), so this should be "Beacon Delay".
  2. Indentation: The leading spaces and continuation lines are off compared to surrounding entries. Should match:
Suggested change
new SliderItem("Beacon delay",
new SliderItem("Beacon Delay",
() => PreferencesManager.BeaconDelay,
PreferencesManager.SetBeaconDelay),

() => PreferencesManager.BeaconDelay,
PreferencesManager.SetBeaconDelay),
new VolumeItem("Beacon Volume",
() => PreferencesManager.BeaconVolume,
PreferencesManager.SetBeaconVolume),
Expand Down
12 changes: 12 additions & 0 deletions FFVI_Mod/Core/PreferencesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static class PreferencesManager
private static MelonPreferences_Entry<bool> prefWallBumps;
private static MelonPreferences_Entry<bool> prefFootsteps;
private static MelonPreferences_Entry<bool> prefAudioBeacons;
private static MelonPreferences_Entry<int> prefBeaconDelay;
private static MelonPreferences_Entry<bool> prefExpCounter;

// Volume preferences (0-100, default 50)
Expand All @@ -45,6 +46,7 @@ public static void Initialize()
prefWallBumps = prefsCategory.CreateEntry<bool>("WallBumps", false, "Wall Bumps", "Play bump sound when walking into walls");
prefFootsteps = prefsCategory.CreateEntry<bool>("Footsteps", false, "Footsteps", "Play click sound on each tile movement");
prefAudioBeacons = prefsCategory.CreateEntry<bool>("AudioBeacons", false, "Audio Beacons", "Play periodic pings toward the selected entity");
prefBeaconDelay = prefsCategory.CreateEntry<int>("BeaconDelay", 50, "Beacon delay", "How long to wait between audio beacons (0-100, higher values mean greater delay between pings)");
prefExpCounter = prefsCategory.CreateEntry<bool>("ExpCounter", false, "EXP Counter Sound", "Play rapid beeping while EXP bar animates on battle results");

prefWallBumpVolume = prefsCategory.CreateEntry<int>("WallBumpVolume", 50, "Wall Bump Volume", "Volume for wall bump sounds (0-100)");
Expand All @@ -65,6 +67,8 @@ public static void Initialize()
public static bool WallBumpsDefault => prefWallBumps?.Value ?? false;
public static bool FootstepsDefault => prefFootsteps?.Value ?? false;
public static bool AudioBeaconsDefault => prefAudioBeacons?.Value ?? false;
public static int BeaconDelay => prefBeaconDelay?.Value ?? 50;

public static bool ExpCounterDefault => prefExpCounter?.Value ?? false;

#endregion
Expand Down Expand Up @@ -117,6 +121,14 @@ public static void SetBeaconVolume(int value)
prefsCategory?.SaveToFile(false);
}
}
public static void SetBeaconDelay(int value)
{
if (prefBeaconDelay != null)
{
prefBeaconDelay.Value = Math.Clamp(value, 0, 100);
prefsCategory?.SaveToFile(false);
}
}

public static void SetExpCounterVolume(int value)
{
Expand Down