Skip to content

Commit

Permalink
Option to hide damage numbers, fix pilot profile not working for some…
Browse files Browse the repository at this point in the history
… create multiplayer game settings.
  • Loading branch information
roncli committed Oct 30, 2022
1 parent cf7e57f commit cff1a45
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion GameMod/MPObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ static void Postfix(Player player, Vector2 offset)
offset.x = w - health;
UIManager.DrawQuadUIInner(offset, health, h, c1, 1f, 11, 1f);
}
if (MPObserver.Enabled || MPObserver.DamageNumbersEnabled)
if (MPObserver.Enabled || (MPObserver.DamageNumbersEnabled && Menus.mms_client_damage_numbers))
{
if (MPObserverDamage.playerDamages.ContainsKey(player) && MPObserverDamage.playerDamages[player].Sum(x => x.dmg) > 0f)
{
Expand Down
33 changes: 25 additions & 8 deletions GameMod/MPSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,25 @@ public static void DeleteAll()

public static int GetInt(string key, int defaultValue)
{
if (m_prefs_hashtable.ContainsKey(key))
{
return (int)m_prefs_hashtable[key];
try {
if (m_prefs_hashtable.ContainsKey(key)) {
return (int)m_prefs_hashtable[key];
}
} catch (Exception) {
Debug.Log($"MPSetup: Could not convert key {key} value {m_prefs_hashtable[key]} to an int, resetting to default {defaultValue}.");
}
m_prefs_hashtable.Add(key, defaultValue);
return defaultValue;
}

public static bool GetBool(string key, bool defaultValue)
{
if (m_prefs_hashtable.ContainsKey(key))
{
return (bool)m_prefs_hashtable[key];
try {
if (m_prefs_hashtable.ContainsKey(key)) {
return (bool)m_prefs_hashtable[key];
}
} catch (Exception) {
Debug.Log($"MPSetup: Could not convert key {key} value {m_prefs_hashtable[key]} to a bool, resetting to default {defaultValue}.");
}
m_prefs_hashtable.Add(key, defaultValue);
return defaultValue;
Expand Down Expand Up @@ -222,8 +228,13 @@ static void Postfix(string filename)
ExtMenuManager.mms_ext_lap_limit = ModPrefs.GetInt("MP_PM_LAP_LIMIT", ExtMenuManager.mms_ext_lap_limit);
Console.KeyEnabled = ModPrefs.GetBool("O_CONSOLE_KEY", Console.KeyEnabled);
Console.CustomUIColor = ModPrefs.GetInt("O_CUSTOM_UI_COLOR", Console.CustomUIColor);
Menus.mms_damage_numbers = MenuManager.LocalGetBool("MP_DAMAGE_NUMBERS", Menus.mms_damage_numbers);
MPThunderboltPassthrough.isAllowed = MenuManager.LocalGetBool("MP_THUNDERBOLT_PASSTHROUGH", MPThunderboltPassthrough.isAllowed);
Menus.mms_damage_numbers = ModPrefs.GetBool("MP_DAMAGE_NUMBERS", Menus.mms_damage_numbers);
Menus.mms_client_damage_numbers = ModPrefs.GetBool("MP_CLIENT_DAMAGE_NUMBERS", Menus.mms_client_damage_numbers);
MPThunderboltPassthrough.isAllowed = ModPrefs.GetBool("MP_THUNDERBOLT_PASSTHROUGH", MPThunderboltPassthrough.isAllowed);
Menus.mms_always_cloaked = ModPrefs.GetBool("MP_ALWAYS_CLOAKED", Menus.mms_always_cloaked);
Menus.mms_classic_spawns = ModPrefs.GetBool("MP_CLASSIC_SPAWNS", Menus.mms_classic_spawns);
Menus.mms_assist_scoring = ModPrefs.GetBool("MP_ASSIST_SCORING", Menus.mms_assist_scoring);
Menus.mms_allow_smash = ModPrefs.GetBool("MP_ALLOW_SMASH", Menus.mms_allow_smash);

JoystickRotationFix.alt_turn_ramp_mode = ModPrefs.GetBool("SCALE_UP_ROTATION", JoystickRotationFix.alt_turn_ramp_mode);
MPColoredPlayerNames.isActive = ModPrefs.GetBool("MP_COLORED_NAMES", MPColoredPlayerNames.isActive);
Expand Down Expand Up @@ -350,7 +361,13 @@ private static void Prefix(string filename)
ModPrefs.SetInt("MP_PM_LOADOUT_GUNNER2_W2", (int)MPLoadouts.Loadouts[3].weapons[1]);
ModPrefs.SetInt("MP_PM_LOADOUT_GUNNER2_M1", (int)MPLoadouts.Loadouts[3].missiles[0]);
ModPrefs.SetBool("MP_DAMAGE_NUMBERS", Menus.mms_damage_numbers);
ModPrefs.SetBool("MP_CLIENT_DAMAGE_NUMBERS", Menus.mms_client_damage_numbers);
ModPrefs.SetBool("MP_THUNDERBOLT_PASSTHROUGH", MPThunderboltPassthrough.isAllowed);
ModPrefs.SetBool("MP_ALWAYS_CLOAKED", Menus.mms_always_cloaked);
ModPrefs.SetBool("MP_CLASSIC_SPAWNS", Menus.mms_classic_spawns);
ModPrefs.SetBool("MP_ASSIST_SCORING", Menus.mms_assist_scoring);
ModPrefs.SetBool("MP_ALLOW_SMASH", Menus.mms_allow_smash);

ModPrefs.Flush(filename + "mod");
}

Expand Down
9 changes: 8 additions & 1 deletion GameMod/Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ public static bool mms_scale_respawn_time
public static bool mms_always_cloaked { get; set; }
public static bool mms_allow_smash { get; set; }
public static bool mms_damage_numbers { get; set; }
public static bool mms_client_damage_numbers { get; set; } = true;
public static bool mms_assist_scoring { get; set; } = true;
public static bool mms_team_color_default { get; set; } = true;
public static int mms_team_color_self = 5;
public static int mms_team_color_enemy = 6;

public static bool mms_team_health = true;
public static bool mms_team_health { get; set; } = true;
public static MpTeam? mms_team_selection { get; set; } = null;

public static string GetMMSRearViewPIP()
Expand Down Expand Up @@ -700,6 +701,8 @@ static bool Prefix(UIElement __instance)
__instance.SelectAndDrawStringOptionItem(Loc.LS("ENEMY TEAM"), position, 3, Menus.GetMMSTeamColorEnemy(), "", 1.5f, Menus.mms_team_color_default);
position.y += 64f;
__instance.SelectAndDrawStringOptionItem(Loc.LS("SHOW TEAM HEALTH"), position, 4, Menus.mms_team_health ? "ON" : "OFF", "SETS WHETHER THE HEALTH OF TEAMMATES SHOULD GET DISPLAYED", 1.5f, false);
position.y += 64;
__instance.SelectAndDrawStringOptionItem(Loc.LS("SHOW DAMAGE NUMBERS"), position, 5, Menus.mms_client_damage_numbers ? "ON" : "OFF", "SETS WHETHER DAMAGE NUMBERS ARE SHOWN IN GAMES WITH THEM ENABLED", 1.5f, false);
break;
case 2:
__instance.SelectAndDrawStringOptionItem(Loc.LS("LAG COMPENSATION"), position, 1, Menus.GetMMSLagCompensation(), "ENABLE LAG COMPENSATION FOR MULTIPLAYER GAMES", 1.5f, false);
Expand Down Expand Up @@ -978,6 +981,10 @@ static bool Prefix(ref float ___m_menu_state_timer)
Menus.mms_team_health = !Menus.mms_team_health;
MenuManager.PlaySelectSound(1f);
break;
case 5:
Menus.mms_client_damage_numbers = !Menus.mms_client_damage_numbers;
MenuManager.PlaySelectSound(1f);
break;
}
break;
case 2:
Expand Down

0 comments on commit cff1a45

Please sign in to comment.