Esempio n. 1
0
        public void FullRefresh()
        {
            if (ModManager != null)
            {
                Directory.CreateDirectory(ModManager.DownloadPath);
                Directory.CreateDirectory(ModManager.InstallPath);

                ModManager.SyncModsFromDisk();
                ModManager.SyncConfigFromDisk();
                ModManager.UpdateReadOnlyStatus();
                ModManager.SortMods();
                if (!autoUpdater.IsBusy)
                {
                    autoUpdater.RunWorkerAsync();
                }
            }

            AMLUtils.InvokeUI(() =>
            {
                if (TableManager != null)
                {
                    TableManager.Refresh();
                }
                AMLPalette.RefreshTheme(this);
                RefreshModInfoLabel();
            });
        }
Esempio n. 2
0
        private void InitialPathPrompt_Load(object sender, EventArgs e)
        {
            mainLabel.Text = DisplayText;
            if (this.Owner is Form1 parentForm)
            {
                this.Text = parentForm.Text;
            }
            AMLPalette.RefreshTheme(this);
            this.AdjustFormPosition();
            if (!AllowBrowse)
            {
                browseButton.Hide();
                gamePathBox.Size = new Size(this.ClientSize.Width - 24, gamePathBox.ClientSize.Height);
            }

            int debugLabelEndX = this.browseButton.Location.X + this.browseButton.Width - 5;

            this.debugLabel.ForeColor = AMLPalette.WarningColor;
            this.debugLabel.Width     = debugLabelEndX - (this.cancelButton.Location.X + this.cancelButton.Width);
            this.debugLabel.Location  = new Point(debugLabelEndX - this.debugLabel.Width, this.cancelButton.Location.Y);

            if (!string.IsNullOrEmpty(PrefilledText))
            {
                gamePathBox.Text = PrefilledText;
                PerformPathSubstitutions();
            }
        }
        private void accentComboBox_UpdateColor(object sender, EventArgs e)
        {
            Color backupColor = Color.FromArgb(AMLPalette.AccentColor.ToArgb());

            try
            {
                if (AMLPalette.PresetMap.ContainsKey(accentComboBox.Text))
                {
                    AMLPalette.AccentColor = AMLPalette.PresetMap[accentComboBox.Text];
                }
                else
                {
                    AMLPalette.AccentColor = AMLUtils.ColorFromHTML(accentComboBox.Text);
                }

                AMLPalette.RefreshTheme(BaseForm);
                BaseForm.ModManager.SyncConfigToDisk();
                AMLPalette.RefreshTheme(this);
            }
            catch
            {
                this.ShowBasicButton("Invalid color!", "OK", null, null);
                AMLPalette.AccentColor = backupColor;
            }
            UpdateColorBoxText();
        }
 private void ProfileSelector_Load(object sender, EventArgs e)
 {
     if (this.Owner is Form1 parentForm)
     {
         OurParentForm = this.Owner as Form1;
         this.Text     = OurParentForm.Text;
         RefreshBox();
     }
     this.RefreshTheme();
     AMLPalette.RefreshTheme(this);
     this.AdjustFormPosition();
 }
 private void themeBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!_readyToUpdateTheme)
     {
         return;
     }
     Enum.TryParse(themeComboBox.SelectedValue.ToString(), out ModLoaderTheme nextTheme);
     AMLPalette.CurrentTheme = nextTheme;
     AMLPalette.RefreshTheme(BaseForm);
     BaseForm.ModManager.SyncConfigToDisk();
     AMLPalette.RefreshTheme(this);
 }
Esempio n. 6
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();
        }
Esempio n. 7
0
        public void SyncIndependentConfigFromDisk()
        {
            IndependentConfig independentConfig = null;

            try
            {
                independentConfig = JsonConvert.DeserializeObject <IndependentConfig>(File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AstroModLoader", "config.json")));
            }
            catch
            {
                independentConfig = null;
            }

            if (independentConfig != null)
            {
                if (!string.IsNullOrEmpty(independentConfig.AccentColor))
                {
                    try
                    {
                        AMLPalette.AccentColor = AMLUtils.ColorFromHTML(independentConfig.AccentColor);
                    }
                    catch { }
                }
                AMLPalette.CurrentTheme = independentConfig.Theme;
                AMLPalette.RefreshTheme(BaseForm);

                Platform = independentConfig.Platform;
                if (FirstRecordedIndependentConfigPlatform == PlatformType.Unknown)
                {
                    FirstRecordedIndependentConfigPlatform = independentConfig.Platform;
                }
                if (!string.IsNullOrEmpty(independentConfig.CustomBasePath))
                {
                    CustomBasePath = independentConfig.CustomBasePath;
                }
                if (!string.IsNullOrEmpty(independentConfig.PlayFabCustomID))
                {
                    PlayFabAPI.CustomID = independentConfig.PlayFabCustomID;
                }
                if (!string.IsNullOrEmpty(independentConfig.PlayFabToken))
                {
                    PlayFabAPI.Token = independentConfig.PlayFabToken;
                }
            }
        }
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            if (this.Owner is Form1)
            {
                BaseForm = (Form1)this.Owner;
                AMLPalette.RefreshTheme(BaseForm);
                this.UpdateLabels();
                UpdateColorBoxText();
            }
            themeComboBox.DataSource    = Enum.GetValues(typeof(ModLoaderTheme));
            themeComboBox.SelectedIndex = (int)AMLPalette.CurrentTheme;
            accentComboBox.Items.AddRange(AMLPalette.PresetMap.Keys.ToArray());
            AMLPalette.RefreshTheme(this);

            this.AdjustFormPosition();

            gamePathBox.SelectionStart     = 0;
            accentComboBox.SelectionLength = 0;
            _readyToUpdateTheme            = true;
        }
        private void ProgressBarPopup_Load(object sender, EventArgs e)
        {
            if (this.Owner is Form1 f1)
            {
                BaseForm = (Form1)this.Owner;
            }
            this.Text = BaseForm.Text;

            AMLPalette.RefreshTheme(this);
            this.AdjustFormPosition();

            waitingTimer.Enabled                         = true;
            backgroundWorker1                            = new BackgroundWorker();
            backgroundWorker1.DoWork                    += backgroundWorker1_DoWork;
            backgroundWorker1.ProgressChanged           += backgroundWorker1_ProgressChanged;
            backgroundWorker1.RunWorkerCompleted        += backgroundWorker1_RunWorkerCompleted;
            backgroundWorker1.WorkerReportsProgress      = true;
            backgroundWorker1.WorkerSupportsCancellation = true;
            backgroundWorker1.RunWorkerAsync();
        }
        private void BasicButtonPopup_Load(object sender, EventArgs e)
        {
            mainLabel.Text = DisplayText;

            using (Graphics g = CreateGraphics())
            {
                SizeF sz = g.MeasureString(mainLabel.Text, mainLabel.Font);
                this.Width       = (int)(Math.Ceiling(sz.Width) * 1.4f);
                mainLabel.Height = (int)Math.Ceiling(sz.Height) * 2;
                this.Height      = mainLabel.Location.Y + mainLabel.Height + button1.Height * 3;
            }

            if (this.Owner is Form1 parentForm)
            {
                this.Text = parentForm.Text;
            }
            this.AdjustFormPosition();
            AMLPalette.RefreshTheme(this);

            mainLabel.Select();
        }
Esempio n. 11
0
        private void aboutButton_Click(object sender, EventArgs e)
        {
            AboutText = "AstroModLoader v" + Application.ProductVersion + "\n" +
                        "By AstroTechies\n" +
                        "\nThanks to the folks in the Astroneer Modding Discord community for their contributions\n" +
                        "\nThanks to you for making this little modding venture what it is\n";

            var formPopup = new AboutPopup();

            formPopup.StartPosition = FormStartPosition.CenterParent;

            formPopup.Controls.Add(new Label()
            {
                AutoSize  = false,
                TextAlign = ContentAlignment.MiddleCenter,
                Dock      = DockStyle.Fill,
                Text      = AboutText,
                Font      = new Font(this.Font.FontFamily, 10)
            });

            AMLPalette.RefreshTheme(formPopup);
            formPopup.ShowDialog(this);
        }