예제 #1
0
        private async Task ForceUpdateCells()
        {
            await Task.Run(() =>
            {
                if (ModManager.IsReadOnly)
                {
                    return;
                }

                if (!updateCellsSemaphore.WaitOne(5000))
                {
                    return;
                }
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    if (row.Tag is Mod taggedMod)
                    {
                        if (taggedMod.CannotCurrentlyUpdate)
                        {
                            continue;
                        }
                        taggedMod.Enabled = (bool)row.Cells[0].Value;
                        if (TableHandler.ShouldContainOptionalColumn())
                        {
                            taggedMod.IsOptional = (bool)row.Cells[5].Value;
                        }
                        if (row.Cells[2].Value is string strVal)
                        {
                            Version changingVer = null;
                            if (strVal.Contains("Latest"))
                            {
                                taggedMod.ForceLatest = true;
                                changingVer           = taggedMod.AvailableVersions[0];
                            }
                            else
                            {
                                taggedMod.ForceLatest = false;
                                changingVer           = new Version(strVal);
                            }

                            SwitchVersionSync(taggedMod, changingVer);
                        }
                    }
                }
                ModManager.FullUpdate();
                updateCellsSemaphore.Release();
            }).ContinueWith(res =>
            {
                AMLUtils.InvokeUI(TableManager.Refresh);
            });
        }
예제 #2
0
        public Form1()
        {
            InitializeComponent();
            modInfo.Text = "";
            AMLUtils.InitializeInvoke(this);

            this.Text = "AstroModLoader v" + Application.ProductVersion;

            // Enable double buffering to look nicer
            if (!SystemInformation.TerminalServerSession)
            {
                Type         ourGridType = dataGridView1.GetType();
                PropertyInfo pi          = ourGridType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
                pi.SetValue(dataGridView1, true, null);
                this.DoubleBuffered = true;
            }
            dataGridView1.Select();

            if (Program.CommandLineOptions.ServerMode)
            {
                syncButton.Hide();
            }

            ModManager   = new ModHandler(this);
            TableManager = new TableHandler(dataGridView1, ModManager);

            dataGridView1.CellValueChanged    += DataGridView1_CellValueChanged;
            dataGridView1.CellContentClick    += DataGridView1_CellContentClick;
            dataGridView1.DataBindingComplete += DataGridView1_DataBindingComplete;
            dataGridView1.CellEndEdit         += DataGridView1_CellEndEdit;
            dataGridView1.SelectionChanged    += new EventHandler(DataGridView1_SelectionChanged);
            footerPanel.Paint += Footer_Paint;
            AMLPalette.RefreshTheme(this);

            AllowDrop  = true;
            DragEnter += new DragEventHandler(Form1_DragEnter);
            DragDrop  += new DragEventHandler(Form1_DragDrop);
            dataGridView1.DragEnter += new DragEventHandler(Form1_DragEnter);
            dataGridView1.DragDrop  += new DragEventHandler(Form1_DragDrop);

            PeriodicCheckTimer.Enabled     = true;
            CheckAllDirty.Enabled          = true;
            ForceAutoUpdateRefresh.Enabled = true;

            autoUpdater                     = new BackgroundWorker();
            autoUpdater.DoWork             += new DoWorkEventHandler(AutoUpdater_DoWork);
            autoUpdater.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Simple_Refresh_RunWorkerCompleted);
            autoUpdater.RunWorkerAsync();
        }
예제 #3
0
        public void IntegrateMods()
        {
            if (IsReadOnly || GamePath == null || InstallPath == null)
            {
                return;
            }

            List <string> optionalMods = new List <string>();

            foreach (Mod mod in Mods)
            {
                if (mod.Enabled && mod.IsOptional)
                {
                    optionalMods.Add(mod.CurrentModData.ModID);
                }
            }

            if (TableHandler.ShouldContainOptionalColumn())
            {
                OurIntegrator.OptionalModIDs = optionalMods;
            }
            OurIntegrator.IntegrateMods(InstallPath, Path.Combine(GamePath, "Astro", "Content", "Paks"));
        }
예제 #4
0
 public bool ShouldSerializeIsOptional()
 {
     return(IsOptional || TableHandler.ShouldContainOptionalColumn());
 }