private void DrawBottomButtons()
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("ADVANCED SETTINGS", this.buttonStyle, GUILayout.Width(180)))
            {
                if (!this.GetComponent <CompatibilityOverrideAdvSettingsGui>())
                {
                    this.gameObject.AddComponent <CompatibilityOverrideAdvSettingsGui>();
                    return;
                }
                else
                {
                    Destroy(this.GetComponent <CompatibilityOverrideAdvSettingsGui>());
                }
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("RESET", this.buttonStyle, GUILayout.Width(180)))
            {
                for (int i = 0; i < versions.Count(); i++)
                {
                    enabledCompatVersions[i] = false;
                }

                foreach (Addon addon in AddonLibrary.Addons.Where(x => !x.IsCompatible))
                {
                    if (GuiHelper.CompatibilityState(OverrideType.ignore, addon))
                    {
                        Configuration.RemoveFromIgnore(addon);
                    }
                    if (GuiHelper.CompatibilityState(OverrideType.name, addon))
                    {
                        Configuration.RemoveOverrideName(addon);
                    }
                }
                if (Configuration.CompatibleVersions.Count != 0)
                {
                    Configuration.CompatibleVersions.Clear();
                }
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("HELP", this.buttonStyle, GUILayout.Width(180)))
            {
                if (!this.GetComponent <CompatibilityOverrideHelpGui>())
                {
                    this.gameObject.AddComponent <CompatibilityOverrideHelpGui>();
                    return;
                }
                else
                {
                    Destroy(this.GetComponent <CompatibilityOverrideHelpGui>());
                }
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("CLOSE", this.buttonStyle, GUILayout.Width(180)))
            {
                Configuration.SaveCfg();
                Destroy(this);
            }
            GUILayout.EndHorizontal();
        }
        private void DrawButtonArrowRight(string VersionNumber)
        {
            GUIStyle coloredButtonStyle = GuiHelper.CompatibilityState(OverrideType.version, null, VersionNumber) ? buttonStyleGreen : buttonStyle;
            string   buttonLabel        = "\u25B6"; //unicode for a triangle, pointing to the right

            if (GUILayout.Button(buttonLabel, coloredButtonStyle, GUILayout.Width(25), GUILayout.Height(25)))
            {
                if (!GuiHelper.CompatibilityState(OverrideType.version, null, VersionNumber))
                {
                    GuiHelper.UpdateCompatibilityState(OverrideType.version, null, VersionNumber);
                }
            }
        }
 private void DrawDefaultValues()
 {
     for (int i = 0; i < versions.Count(); i++)
     {
         GUIStyle coloredLabel = GuiHelper.CompatibilityState(OverrideType.version, null, versions[i]) ? this.labelStyleCyan : this.labelStyleYellow;
         GUILayout.BeginHorizontal();
         GUILayout.Space(51);
         GUILayout.Label("(PRESET) Enable Override for:", coloredLabel, GUILayout.MinWidth(230.0f));
         GUILayout.Space(10);
         GUILayout.Label(versions[i], coloredLabel, GUILayout.MinWidth(65));
         GUILayout.Space(18);
         DrawButtonArrowRight(versions[i]);
         GUILayout.FlexibleSpace();
         GUILayout.EndHorizontal();
     }
 }
        private void DrawButtonArrowLeft(Addon addon)
        {
            if (GuiHelper.CompatibilityState(OverrideType.locked, addon) || (GuiHelper.CompatibilityState(OverrideType.version, addon) && !GuiHelper.CompatibilityState(OverrideType.ignore, addon)))
            {
                GUILayout.Space(33); //fill the space which would usually taken by the button at this position
                return;
            }

            GUIStyle coloredButtonStyle = GuiHelper.CompatibilityState(OverrideType.name, addon) ? buttonStyleGreen : buttonStyle;
            string   buttonLabel        = "\u25C0"; //unicode for a triangle, pointing to the left

            if (GUILayout.Button(buttonLabel, coloredButtonStyle, GUILayout.Width(25), GUILayout.Height(25)))
            {
                if (!GuiHelper.CompatibilityState(OverrideType.name, addon))
                {
                    GuiHelper.UpdateCompatibilityState(OverrideType.name, addon);
                }
            }
        }
        private void DrawButtonArrowRight(Addon addon)
        {
            if (GuiHelper.CompatibilityState(OverrideType.locked, addon) || GuiHelper.CompatibilityState(OverrideType.name, addon))
            {
                GUILayout.Space(25); //fill the space which would usually taken by the button at this position
                return;
            }

            GUIStyle coloredButtonStyle = GuiHelper.CompatibilityState(OverrideType.version, addon) ? buttonStyleGreen : buttonStyle;
            string   buttonLabel        = "\u25B6"; //unicode for a triangle, pointing to the right

            if (GUILayout.Button(buttonLabel, coloredButtonStyle, GUILayout.Width(25), GUILayout.Height(25)))
            {
                if (!GuiHelper.CompatibilityState(OverrideType.version, addon))
                {
                    GuiHelper.UpdateCompatibilityState(OverrideType.version, null, addon.LocalInfo.KspVersionMaxIsNull && addon.LocalInfo.KspVersionMinIsNull ? addon.LocalInfo.KspVersion.ToString() : addon.LocalInfo.KspVersionMax.ToString());
                }
            }
        }
        private void DrawIncompatibleMods()
        {
            if (Configuration.OverrideIsDisabledGlobal)
            {
                DrawDisabled();
                return;
            }
            List <Addon> listIncompatibleMods = AddonLibrary.Addons.Where(a => !a.IsCompatible).OrderBy(a => a.Name).ToList();
            int          m = listIncompatibleMods.Count();

            if (m == 0)
            {
                DrawNoIncompatibleAddons();
                return;
            }
            if (Configuration.ShowDefaultValues)
            {
                DrawDefaultValues();
            }
            for (int i = 0; i < m; i++)
            {
                Addon       addon         = listIncompatibleMods[i];
                GUIStyle    coloredLabel  = (GuiHelper.CompatibilityState(OverrideType.version, addon) || GuiHelper.CompatibilityState(OverrideType.name, addon)) ? this.labelStyleCyan : GuiHelper.CompatibilityState(OverrideType.ignore, addon) ? this.labelStyleIgnore : this.labelStyleYellow; //highlighting ignored mods
                VersionInfo versionNumber = addon.LocalInfo.KspVersionMaxIsNull && addon.LocalInfo.KspVersionMinIsNull ? addon.LocalInfo.KspVersion : addon.LocalInfo.KspVersionMax;

                GUILayout.BeginHorizontal();
                DrawButtonArrowLeft(addon);
                GUILayout.Space(18);
                GUILayout.Label(addon.Name, coloredLabel, GUILayout.MinWidth(230.0f));
                GUILayout.Space(10);
                GUILayout.Label($"{versionNumber}", coloredLabel, GUILayout.MinWidth(65));
                GUILayout.Space(18);
                DrawButtonArrowRight(addon);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
        }
Exemplo n.º 7
0
        private void DrawIgnoreList()
        {
            List <Addon> overrideMods = AddonLibrary.Addons.Where(x => x.IsForcedCompatibleByVersion || GuiHelper.CompatibilityState(OverrideType.ignore, x)).OrderBy(x => x.Name).ToList();
            int          m            = overrideMods.Count;

            for (int i = 0; i < m; i++)
            {
                var      addon            = overrideMods[i];
                bool     toggleState      = GuiHelper.CompatibilityState(OverrideType.ignore, addon);
                GUIStyle labelStyleIgnore = GuiHelper.CompatibilityState(OverrideType.ignore, addon) ? this.labelStyleYellow : this.labelStyleCyan;

                GUILayout.BeginHorizontal();
                GUILayout.Label(addon.Name, labelStyleIgnore);
                GUILayout.FlexibleSpace();

                toggleState = GUILayout.Toggle(toggleState, "", this.toggleStyle);
                if (toggleState != GuiHelper.CompatibilityState(OverrideType.ignore, addon))
                {
                    GuiHelper.UpdateCompatibilityState(OverrideType.ignore, addon);
                }
                GUILayout.Space(25);
                GUILayout.EndHorizontal();
            }
        }