예제 #1
0
        public void ToggleModEnabled(CustomDGVCheckBoxCell cb)
        {
            ModIncompatibilityWarning warningLevel = GameManager.CheckForModIncompatibilities(cb.ModMeta);
            string fileName = Path.GetFileName(cb.ModMeta.modPath);

            if (cb.ModMeta.isStandalone && !cb.ModMeta.isEnabled)
            {
                foreach (DataGridViewRow row in modList.Rows)
                {
                    var ocb = (CustomDGVCheckBoxCell)row.Cells[1];
                    if (ocb.ModMeta != cb.ModMeta && ocb.ModMeta.isStandalone)
                    {
                        ocb.ModMeta.isStandalone = false;
                        CustomDGVCheckBoxCell.ToggleProgrammatically = true;
                        ocb.Value             = false;
                        ocb.ModMeta.isEnabled = false;
                        CustomDGVCheckBoxCell.ToggleProgrammatically = false;
                    }
                }
            }

            if (cb.ModMeta.isEnabled == false)
            {
                if (warningLevel.warningLevel == 1)
                {
                    MessageBox.Show(string.Format("The mod {0} might not work with the following mods:{1}{2}", fileName, Environment.NewLine, warningLevel.sameClassMods));
                }
                else if (warningLevel.warningLevel == 2)
                {
                    string msg = string.Format("The mod {0} is incompatible with the following mods:{1}{2}{1}Don't expect them both to work together, but you can still launch the game.", fileName, Environment.NewLine, warningLevel.sameFunctionMods);
                    if (warningLevel.sameClassMods.Length > 0)
                    {
                        msg += string.Format("It also might not work with these mods:{0}{1}", Environment.NewLine, warningLevel.sameClassMods);
                    }
                    MessageBox.Show(msg);
                }
            }

            CustomDGVCheckBoxCell.ToggleProgrammatically = true;
            cb.ModMeta.isEnabled = !cb.ModMeta.isEnabled;
            cb.Value             = cb.ModMeta.isEnabled;
            CustomDGVCheckBoxCell.ToggleProgrammatically = false;
        }
예제 #2
0
        public void FillOutMods()
        {
            modList.Rows.Clear();

            if (GameManager.exePath == null || GameManager.exePath == "")
            {
                return;
            }

            GameManager.LoadModMetas();

            int i = 0;

            foreach (ModMetadata md in GameManager.modMetas)
            {
                var icon = md.isStandalone ? Properties.Resources.standaloneIcon_x16 : (md.isPatch ? Properties.Resources.patchIcon_x16 : Properties.Resources.modIcon_x16);

                var new_row = new DataGridViewRow();

                new_row.Cells.Add(new DataGridViewImageCell()
                {
                    ToolTipText = md.isStandalone ? "Standalone Mod" : (md.isPatch ? "Patch" : "Mod"),
                    Value       = icon
                });

                var new_cb_cell = new CustomDGVCheckBoxCell()
                {
                    Value = md.isEnabled, FalseValue = false, TrueValue = true, ModMeta = md,
                };
                new_cb_cell.OnValueChanged += (b) => { ToggleModEnabled(new_cb_cell); };
                new_row.Cells.Add(new_cb_cell);

                new_row.Cells.Add(new DataGridViewTextBoxCell()
                {
                    ToolTipText = md.modPath,
                    Value       = Path.GetFileName(md.modPath)
                });

                modList.Rows.Add(new_row);
                i++;
            }
        }