janxious / BTMLColorLOSMod

3 stars 3 forks source link

Toggle to invert line colors #12

Closed janxious closed 6 years ago

janxious commented 6 years ago

should help with color blind and other imparied viewing situations in certain map and line color combos.

Dumping code from @gponick in here until I can deal with it

public static PlayerAction ToggleInverseColor;

        [HarmonyPatch(typeof(BattleTech.UI.UIManager), "Update")]
        public static class UIManager_Patch
        {
            public static bool Prefix(UIManager __instance)
            {
                if (ToggleInverseColor.WasReleased)
                {
                    Logger.Debug($"Toggling inverse:");
                    //BTMLColorLOSMod.ModSettings.IndirectLineOfFireArcColor = new Color(1 - BTMLColorLOSMod.ModSettings.IndirectLineOfFireArcColor.r, 1 - BTMLColorLOSMod.ModSettings.IndirectLineOfFireArcColor.g, 1 - BTMLColorLOSMod.ModSettings.IndirectLineOfFireArcColor.b, BTMLColorLOSMod.ModSettings.IndirectLineOfFireArcColor.a);
                    BTMLColorLOSMod.ModSettings.IDFI++;
                    BTMLColorLOSMod.ModSettings.IDFI %= 4;
                    BTMLColorLOSMod.ModSettings.IndirectLineOfFireArcColor = BTMLColorLOSMod.ModSettings.IDLOFAC[BTMLColorLOSMod.ModSettings.IDFI];

                    Logger.Debug($"It's now inverted");
                }
                return true;
            }
        }
 internal class DynamicActionsAdapter : Adapter<DynamicActions>
        {
            internal DynamicActionsAdapter(DynamicActions instance) : base(instance)
            {
            }

            internal PlayerAction CreatePlayerAction(string name)
            {
                return traverse.Method("CreatePlayerAction", name).GetValue<PlayerAction>(name); ;
            }
        }
       public Color IndirectLineOfFireArcColor = Color.magenta;
        public Color[] IDLOFAC = new Color[4];
        public int IDFI = 1;

        public float[] indirectLineOfFireArcColor
        {
            set
            {
                IndirectLineOfFireArcColor = SettingsColorHelper.ColorFromValues(value[0], value[1], value[2], value[3]);
                IDLOFAC = new Color[4] { IndirectLineOfFireArcColor,
                    SettingsColorHelper.ColorFromValues(1-value[0], 1-value[1], 1-value[2], value[3]),
                    Color.green,
                    Color.magenta
                };
            }
        }
janxious commented 6 years ago

Done in #13