Skip to content

Commit

Permalink
Various menu toggles to allow turning off some of the new features in…
Browse files Browse the repository at this point in the history
…troduced in 0.5.6. Also adjusts the audio occlusion filter strengths.
  • Loading branch information
CCraigen committed Oct 16, 2022
1 parent 7cedfbc commit bb068b6
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 45 deletions.
48 changes: 40 additions & 8 deletions GameMod/MPDirectionalWarning.cs
Expand Up @@ -13,34 +13,66 @@ public static class MPDirectionalWarning
{
public static Vector3 homingDir = Vector3.zero;

public static void SetDirection(Player p, Transform t)
{
if (Menus.mms_directional_warnings)
{
homingDir = Vector3.MoveTowards(p.c_player_ship.transform.localPosition, t.localPosition, 0.7f);
}
}

public static void PlayCueWarning(SFXCue sfx_type, float vol_mod = 1f, float pitch_mod = 0f, float delay = 0f, bool reverb = false)
{
//Debug.Log("CCC playing homing cue at position " + homingDir + ", ship position is " + GameManager.m_player_ship.transform.localPosition);
SFXCueManager.PlayCuePos(sfx_type, homingDir, vol_mod, pitch_mod, false, delay, 1f);
if (Menus.mms_directional_warnings)
{
SFXCueManager.PlayCuePos(sfx_type, homingDir, vol_mod, pitch_mod, false, delay, 1f);
}
else
{
SFXCueManager.PlayCue2D(sfx_type, vol_mod, pitch_mod, delay, reverb);
}
}
}

[HarmonyPatch(typeof(Projectile), "SteerTowardsTarget")]
internal class MPDirectionalWarning_Projectile_SteerTowardsTarget
{
static void Postfix(Player ___m_cur_target_player, Transform ___c_transform)
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codes)
{

if (___m_cur_target_player != null && ___m_cur_target_player.isLocalPlayer)
foreach (var code in codes)
{
MPDirectionalWarning.homingDir = Vector3.MoveTowards(___m_cur_target_player.c_player_ship.transform.localPosition, ___c_transform.localPosition, 0.7f);
yield return code;

if (code.opcode == OpCodes.Stsfld && code.operand == AccessTools.Field(typeof(Projectile), "PlayerLockOnMinDistanceSq"))
{
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(Projectile), "m_cur_target_player"));
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(Projectile), "c_transform"));
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(MPDirectionalWarning), "SetDirection"));
}
}
}
}

[HarmonyPatch(typeof(Projectile), "MoveTowardsTarget")]
internal class MPDirectionalWarning_Projectile_MoveTowardsTarget
{
static void Postfix(Player ___m_cur_target_player, Transform ___c_transform)
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codes)
{
if (___m_cur_target_player != null && ___m_cur_target_player.isLocalPlayer)
foreach (var code in codes)
{
MPDirectionalWarning.homingDir = Vector3.MoveTowards(___m_cur_target_player.c_player_ship.transform.localPosition, ___c_transform.localPosition, 0.7f);
yield return code;

if (code.opcode == OpCodes.Stsfld && code.operand == AccessTools.Field(typeof(Projectile), "PlayerLockOnMinDistanceSq"))
{
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(Projectile), "m_cur_target_player"));
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(Projectile), "c_transform"));
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(MPDirectionalWarning), "SetDirection"));
}
}
}
}
Expand Down
37 changes: 19 additions & 18 deletions GameMod/MPLoadouts.cs
Expand Up @@ -676,26 +676,27 @@ internal class MPLoadouts_PlayerShip_Update
{
public static void LoadoutSelect(PlayerShip ps)
{
if (!PlayerShip.m_typing_in_chat)
if (Menus.mms_loadout_hotkeys && !PlayerShip.m_typing_in_chat && NetworkMatch.m_force_loadout == 0 && (float)ps.m_dying_timer < 2.5f)
{
if (NetworkMatch.m_force_loadout == 0 && (float)ps.m_dying_timer < 2.5f)
if (Controls.JustPressed(CCInput.WEAPON_1x2))
{
if (Controls.JustPressed(CCInput.WEAPON_1x2))
{
MPLoadouts.SendCustomLoadoutToServer(0);
}
else if (Controls.JustPressed(CCInput.WEAPON_3x4))
{
MPLoadouts.SendCustomLoadoutToServer(1);
}
else if (Controls.JustPressed(CCInput.WEAPON_5x6))
{
MPLoadouts.SendCustomLoadoutToServer(2);
}
else if (Controls.JustPressed(CCInput.WEAPON_7x8))
{
MPLoadouts.SendCustomLoadoutToServer(3);
}
MPLoadouts.SendCustomLoadoutToServer(0);
MenuManager.PlayCycleSound();
}
else if (Controls.JustPressed(CCInput.WEAPON_3x4))
{
MPLoadouts.SendCustomLoadoutToServer(1);
MenuManager.PlayCycleSound();
}
else if (Controls.JustPressed(CCInput.WEAPON_5x6))
{
MPLoadouts.SendCustomLoadoutToServer(2);
MenuManager.PlayCycleSound();
}
else if (Controls.JustPressed(CCInput.WEAPON_7x8))
{
MPLoadouts.SendCustomLoadoutToServer(3);
MenuManager.PlayCycleSound();
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions GameMod/MPSetup.cs
Expand Up @@ -251,6 +251,8 @@ static void Postfix(string filename)
HUDVelocity.MenuManagerEnabled = ModPrefs.GetBool("MP_PM_SHOWHUDVELOCITY", HUDVelocity.MenuManagerEnabled);
Menus.mms_show_framerate = ModPrefs.GetBool("MP_PM_SHOWFRAMERATE", Menus.mms_show_framerate);
Menus.mms_audio_occlusion_strength = ModPrefs.GetInt("MP_PM_AUDIO_OCCLUSION_STRENGTH", Menus.mms_audio_occlusion_strength);
Menus.mms_directional_warnings = ModPrefs.GetBool("MP_PM_DIRECTIONAL_WARNINGS", Menus.mms_directional_warnings);
Menus.mms_loadout_hotkeys = ModPrefs.GetBool("MP_PM_LOADOUT_HOTKEYS", Menus.mms_loadout_hotkeys);

MPLoadouts.Loadouts[0].weapons[0] = (WeaponType)ModPrefs.GetInt("MP_PM_LOADOUT_BOMBER1_W1", (int)MPLoadouts.Loadouts[0].weapons[0]);
MPLoadouts.Loadouts[0].missiles[0] = (MissileType)ModPrefs.GetInt("MP_PM_LOADOUT_BOMBER1_M1", (int)MPLoadouts.Loadouts[0].missiles[0]);
Expand Down Expand Up @@ -330,6 +332,8 @@ private static void Prefix(string filename)
ModPrefs.SetBool("MP_PM_SHOWHUDVELOCITY", HUDVelocity.MenuManagerEnabled);
ModPrefs.SetBool("MP_PM_SHOWFRAMERATE", Menus.mms_show_framerate);
ModPrefs.SetInt("MP_PM_AUDIO_OCCLUSION_STRENGTH", Menus.mms_audio_occlusion_strength);
ModPrefs.SetBool("MP_PM_DIRECTIONAL_WARNINGS", Menus.mms_directional_warnings);
ModPrefs.SetBool("MP_PM_LOADOUT_HOTKEYS", Menus.mms_loadout_hotkeys);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER1_W1", (int)MPLoadouts.Loadouts[0].weapons[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER1_M1", (int)MPLoadouts.Loadouts[0].missiles[0]);
ModPrefs.SetInt("MP_PM_LOADOUT_BOMBER1_M2", (int)MPLoadouts.Loadouts[0].missiles[1]);
Expand Down
10 changes: 5 additions & 5 deletions GameMod/MPSoundOcclusion.cs
Expand Up @@ -8,11 +8,11 @@ namespace GameMod
{
public static class MPSoundOcclusion
{
// N/A LOW MED STRONG
public static float[] MAXDISTS = { 0f, 100f, 95f, 85f };
public static float[] BOOSTS = { 0f, 0.15f, 0.20f, 0.25f };
public static float[] LOWFREQS = { 0f, 800f, 500f , 500f };
public static float[] CUTOFFS = { 0f, 9500f, 10000f, 10500f };
// N/A LOW MED STRONG
public static float[] MAXDISTS = { 0f, 110f, 100f, 95f }; // xtra strong 85f
public static float[] BOOSTS = { 0f, 0.10f, 0.15f, 0.20f }; // xtra strong 0.25f
public static float[] LOWFREQS = { 0f, 950f, 800f, 500f }; // xtra strong 500f
public static float[] CUTOFFS = { 0f, 9000f, 9500f, 10000f }; // xtra strong 10500f
// actual cutoff starting point is currently targetted at ~7khz since we are clamping to 15 units minimum distance below

// Change this at your peril, gotta recalculate the curves if you do
Expand Down
57 changes: 43 additions & 14 deletions GameMod/Menus.cs
Expand Up @@ -71,6 +71,18 @@ public static string GetMMSAudioOcclusionStrength()
}
}

public static bool mms_directional_warnings { get; set; } = true;
public static string GetMMSDirectionalWarnings()
{
return MenuManager.GetToggleSetting(Convert.ToInt32(mms_directional_warnings));
}

public static bool mms_loadout_hotkeys { get; set; } = true;
public static string GetMMSLoadoutHotkeys()
{
return MenuManager.GetToggleSetting(Convert.ToInt32(mms_loadout_hotkeys));
}

public static string GetMMSAlwaysCloaked()
{
return MenuManager.GetToggleSetting(Convert.ToInt32(mms_always_cloaked));
Expand Down Expand Up @@ -628,21 +640,23 @@ static bool Prefix(UIElement __instance)
{
case 0:
__instance.SelectAndDrawStringOptionItem(Loc.LS("TEXT CHAT"), position, 0, MenuManager.GetMPTextChat(), string.Empty, 1.5f, false);
position.y += 62f;
position.y += 52f;
__instance.SelectAndDrawStringOptionItem(Loc.LS("AUTO-RESPAWN TIMER"), position, 2, MenuManager.GetToggleSetting(MenuManager.opt_mp_auto_respawn), string.Empty, 1.5f, false);
position.y += 62f;
position.y += 52f;
__instance.SelectAndDrawStringOptionItem(Loc.LS("STICKY DEATH SUMMARY"), position, 3, Menus.mms_sticky_death_summary ? "YES" : "NO", "KEEP DEATH SUMMARY ON THE SCREEN AFTER LETTING GO OF THE TOGGLE");
position.y += 62f;
position.y += 52f;
__instance.SelectAndDrawSliderItem(Loc.LS("DAMAGE BLUR INTENSITY"), position, 4, ((float)Menus.mms_damageeffect_drunk_blur_mult) / 100f);
position.y += 62f;
position.y += 52f;
__instance.SelectAndDrawSliderItem(Loc.LS("DAMAGE COLOR INTENSITY"), position, 5, ((float)Menus.mms_damageeffect_alpha_mult) / 100f);
position.y += 62f;
position.y += 52f;
__instance.SelectAndDrawStringOptionItem(Loc.LS("SHIP EXPLOSION EFFECTS"), position, 6, Menus.mms_reduced_ship_explosions ? Loc.LS("REDUCED") : Loc.LS("FULL"), Loc.LS("REDUCED VISUAL CLUTTER DURING DEATH ROLL"));
position.y += 62f;
position.y += 52f;
__instance.SelectAndDrawStringOptionItem(Loc.LS("INDIVIDUAL PLAYER COLORS"), position, 7, MPColoredPlayerNames.isActive ? "ON" : "OFF", Loc.LS("MAKES NAMES MORE RECOGNIZABLE AND DISTINCT BY MAKING THEM BIGGER AND COLORING THEM BY PLAYER [ANARCHY ONLY]"));
position.y += 62f;
position.y += 52f;
__instance.SelectAndDrawStringOptionItem(Loc.LS("PROFANITY FILTER"), position, 8, DisableProfanityFilter.profanity_filter ? "ON" : "OFF", Loc.LS(""));
position.y += 62f;
position.y += 52f;
__instance.SelectAndDrawStringOptionItem(Loc.LS("ENABLE LOADOUT SELECTION HOTKEYS"), position, 9, Menus.GetMMSLoadoutHotkeys(), Loc.LS("WEAPON SELECTION HOTKEYS WILL QUICK-SWAP BETWEEN LOADOUTS"));
position.y += 68f;
__instance.SelectAndDrawItem(Loc.LS("QUICK CHAT"), position, 1, false, 1f, 0.75f);
break;
case 1:
Expand Down Expand Up @@ -893,6 +907,10 @@ static bool Prefix(ref float ___m_menu_state_timer)
DisableProfanityFilter.profanity_filter = !DisableProfanityFilter.profanity_filter;
MenuManager.PlaySelectSound(1f);
break;
case 9:
Menus.mms_loadout_hotkeys = !Menus.mms_loadout_hotkeys;
MenuManager.PlaySelectSound(1f);
break;
}
break;
case 1:
Expand Down Expand Up @@ -1024,10 +1042,12 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
[HarmonyPatch(typeof(UIElement), "DrawSoundMenu")]
class Menus_UIElement_DrawSoundMenu
{
private static void DrawSoundReload(UIElement uie, ref Vector2 position)
private static void DrawAdditionalSoundOptions(UIElement uie, ref Vector2 position)
{
position.y += 62f;
uie.SelectAndDrawStringOptionItem(Loc.LS("AUDIO OCCLUSION STRENGTH"), position, 6, Menus.GetMMSAudioOcclusionStrength());
uie.SelectAndDrawStringOptionItem(Loc.LS("AUDIO OCCLUSION STRENGTH"), position, 6, Menus.GetMMSAudioOcclusionStrength(), Loc.LS("SOUND EFFECTS OUT OF LINE-OF-SIGHT WILL BE FILTERED DEPENDING ON DISTANCE"));
position.y += 62f;
uie.SelectAndDrawStringOptionItem(Loc.LS("DIRECTIONAL HOMING WARNINGS"), position, 7, Menus.GetMMSDirectionalWarnings(), Loc.LS("PLAYS HOMING WARNINGS FROM THE DIRECTION OF THE INCOMING PROJECTILE"));
position.y += 62f;
uie.SelectAndDrawItem("REINITIALIZE AUDIO DEVICE", position, 5, false);
}
Expand All @@ -1038,6 +1058,10 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
int state = 0;
foreach (var code in codes)
{
if (code.opcode == OpCodes.Ldc_R4 && (float)code.operand == 93f)
{
code.operand = 186f; // offsets the menu up a bit for the extra options
}
if (code.opcode == OpCodes.Ldstr && (string)code.operand == "SPEAKER MODE")
state = 1;

Expand All @@ -1047,7 +1071,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
yield return code;
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldloca_S, 0);
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Menus_UIElement_DrawSoundMenu), "DrawSoundReload"));
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Menus_UIElement_DrawSoundMenu), "DrawAdditionalSoundOptions"));
continue;
}
yield return code;
Expand Down Expand Up @@ -1077,6 +1101,11 @@ private static void AdditionalSoundOptions(int menu_selection)
}
MenuManager.PlaySelectSound(1f);
break;
case 7:
Menus.mms_directional_warnings = !Menus.mms_directional_warnings;
MenuManager.PlaySelectSound(1f);
break;

}
}

Expand All @@ -1096,8 +1125,8 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
}
}

// Fix next/previous resolution buttons.
[HarmonyPatch(typeof(MenuManager), "SelectNextResolution")]
// Fix next/previous resolution buttons.
[HarmonyPatch(typeof(MenuManager), "SelectNextResolution")]
class FixSelectNextResolution {
static bool Prefix() {
var resolutions = Screen.resolutions.Where(r => r.width >= 800 && r.height >= 540).Select(r => new Resolution { width = r.width, height = r.height }).Distinct().ToList();
Expand Down Expand Up @@ -1434,7 +1463,7 @@ static bool Prefix(UIElement __instance)
else
{
position.y = -153f;
__instance.DrawLabelSmall(position, Loc.LS("SELECT TWO LOADOUTS (REFLEX SIDEARM INCLUDED)"), 400f, 20f, 1f);
__instance.DrawLabelSmall(position, Loc.LS("SELECT YOUR LOADOUT WEAPONS (REFLEX SIDEARM INCLUDED IN ALL LOADOUTS)"), 400f, 20f, 1f);
position.x = -310f;
position.y = -90f;

Expand Down

0 comments on commit bb068b6

Please sign in to comment.