Esempio n. 1
0
        public SettingsDialog(MainForm mainForm) : base(new Size(480, 460), new UIElement[] {
            new UIElement() {
                Caption  = Locale.Get("Cancel")
                , Result = DialogResult.Cancel
            }
            , new UIElement() {
                Caption  = Locale.Get("Apply")
                , Result = DialogResult.OK
            }
        })
        {
            mainForm_ = mainForm;
            Text      = Locale.Get("SettingsTitle");

            SuspendLayout();

            folderBrowserDialog = new CommonOpenFileDialog()
            {
                IsFolderPicker = true
            };

            ToolTip theToolTip = new ToolTip();

            theToolTip.AutoPopDelay = 10000;
            theToolTip.InitialDelay = 200;
            theToolTip.ReshowDelay  = 100;

            Label gamePathLabel = new Label();

            gamePathLabel.Text     = Locale.Get("SettingsGamePath");
            gamePathLabel.Font     = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Pixel, 204);
            gamePathLabel.Location = new Point(18, 22);
            gamePathLabel.Size     = new Size(444, 40);

            gamePath             = new TextBox();
            gamePath.Text        = Program.GamePath;
            gamePath.Font        = new Font("Lucida Sans Unicode", 12F, FontStyle.Regular, GraphicsUnit.Pixel, 204);
            gamePath.Location    = new Point(2, 4);
            gamePath.Size        = new Size(359, 20);
            gamePath.BackColor   = Color.FromArgb(32, 33, 34);
            gamePath.BorderStyle = BorderStyle.None;
            gamePath.ForeColor   = Color.White;
            YU.assertLucida(gamePath);

            YobaButton browseButton = new YobaButton();

            browseButton.Location = new Point(385, 44);
            browseButton.Name     = "browseButton";
            browseButton.Size     = new Size(75, 27);
            browseButton.Text     = Locale.Get("Browse");
            browseButton.UseVisualStyleBackColor = false;
            browseButton.Click += new System.EventHandler(browseButton_Click);

            Panel fieldBackground = new Panel();

            fieldBackground.BackColor   = Color.FromArgb(32, 33, 34);
            fieldBackground.BorderStyle = BorderStyle.FixedSingle;
            fieldBackground.Controls.Add(gamePath);
            fieldBackground.Location = new Point(20, 44);
            fieldBackground.Name     = "fieldBackground";
            fieldBackground.Size     = new Size(361, 27);

            launchViaGalaxy           = new CheckBox();
            launchViaGalaxy.Text      = Locale.Get("SettingsGogGalaxy");
            launchViaGalaxy.Font      = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Pixel, 204);
            launchViaGalaxy.Location  = new Point(20, 86);
            launchViaGalaxy.Size      = new Size(440, 24);
            launchViaGalaxy.Checked   = LauncherConfig.LaunchFromGalaxy;
            launchViaGalaxy.BackColor = Color.Transparent;
            launchViaGalaxy.Enabled   = LauncherConfig.GalaxyDir != null;

            offlineMode           = new CheckBox();
            offlineMode.Text      = Locale.Get("SettingsOfflineMode");
            offlineMode.Font      = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Pixel, 204);
            offlineMode.Location  = new Point(20, 119);
            offlineMode.Size      = new Size(440, 24);
            offlineMode.Checked   = LauncherConfig.StartOffline;
            offlineMode.BackColor = Color.Transparent;

            theToolTip.SetToolTip(offlineMode, Locale.Get("SettingsOfflineModeTooltip"));

            closeLauncherOnLaunch           = new CheckBox();
            closeLauncherOnLaunch.Text      = Locale.Get("SettingsCloseOnLaunch");
            closeLauncherOnLaunch.Font      = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Pixel, 204);
            closeLauncherOnLaunch.Location  = new Point(20, 152);
            closeLauncherOnLaunch.Size      = new Size(440, 24);
            closeLauncherOnLaunch.Checked   = LauncherConfig.CloseOnLaunch;
            closeLauncherOnLaunch.BackColor = Color.Transparent;

            Label openingPanelLabel = new Label();

            openingPanelLabel.Text     = Locale.Get("SettingsOpeningPanel");
            openingPanelLabel.Font     = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Pixel, 204);
            openingPanelLabel.Location = new Point(18, 187);
            openingPanelLabel.Size     = new Size(444, 40);

            openingPanelCB            = new YobaComboBox();
            openingPanelCB.Location   = new Point(20, 208);
            openingPanelCB.Name       = "openingPanel";
            openingPanelCB.Size       = new Size(440, 22);
            openingPanelCB.DataSource = new string[] {
                Locale.Get("SettingsOpeningPanelChangelog")
                , Locale.Get("SettingsOpeningPanelStatus")
                , Locale.Get("SettingsOpeningPanelLinks")
                //, Locale.Get("SettingsOpeningPanelMods")
            };

            /*openingPanelCB = new YobaButton();
             * openingPanelCB.Location = new Point(20, 141);
             * openingPanelCB.Name = "openingPanel";
             *
             * YobaButton opt1 = new YobaComboBox();
             * opt1.Location = new Point(20, 141);
             * Size = new Size(440, 28);
             *
             * Panel cbDD = new Panel();
             * cbDD.BackColor = Color.FromArgb(40, 40, 41);
             * cbDD.BorderStyle = BorderStyle.FixedSingle;
             * cbDD.Controls.Add(gamePath);
             * cbDD.Location = new Point(20, 141 + openingPanelCB.Height);
             * cbDD.Name = "cbDD";
             * cbDD.Size = new Size(361, openingPanelCB.Height * 3);
             */
            YobaButton makeBackupBtn = new YobaButton();

            makeBackupBtn.MouseClick += MakeBackupBtn_MouseClick;
            makeBackupBtn.Location    = new Point(20, 246);
            makeBackupBtn.Size        = new Size(240, 24);
            makeBackupBtn.Text        = Locale.Get("SettingsMakeBackup");

            YobaButton createShortcutBtn = new YobaButton();

            createShortcutBtn.MouseClick += CreateShortcutBtn_MouseClick;
            createShortcutBtn.Location    = new Point(20, 286);
            createShortcutBtn.Size        = new Size(240, 24);
            createShortcutBtn.Text        = Locale.Get("SettingsCreateShortcut");

            /*YobaButton uninstallRussifierBtn = new YobaButton();
             * createShortcutBtn.MouseClick += CreateShortcutBtn_MouseClick;
             * createShortcutBtn.Location = new Point(20, 366);
             * createShortcutBtn.Size = new Size(240, 24);
             * createShortcutBtn.Text = Locale.Get("SettingsUninstallMainProduct");
             *
             * YobaButton uninstallLoncherBtn = new YobaButton();
             * createShortcutBtn.MouseClick += CreateShortcutBtn_MouseClick;
             * createShortcutBtn.Location = new Point(20, 406);
             * createShortcutBtn.Size = new Size(240, 24);
             * createShortcutBtn.Text = Locale.Get("SettingsUninstallRussifier");*/

            gamePath.TabIndex              = 1;
            browseButton.TabIndex          = 2;
            launchViaGalaxy.TabIndex       = 3;
            offlineMode.TabIndex           = 4;
            closeLauncherOnLaunch.TabIndex = 5;

            openingPanelCB.TabIndex    = 10;
            makeBackupBtn.TabIndex     = 15;
            createShortcutBtn.TabIndex = 16;

            Controls.Add(fieldBackground);
            Controls.Add(browseButton);
            Controls.Add(launchViaGalaxy);
            Controls.Add(offlineMode);
            Controls.Add(closeLauncherOnLaunch);
            Controls.Add(openingPanelCB);
            Controls.Add(makeBackupBtn);
            Controls.Add(createShortcutBtn);

            Controls.Add(openingPanelLabel);
            Controls.Add(gamePathLabel);

            Load += new EventHandler((object o, EventArgs a) => {
                openingPanelCB.SelectedIndex = (int)LauncherConfig.StartPage;
            });
            ResumeLayout();
        }
Esempio n. 2
0
        private void onBtnClick(object s, EventArgs args)
        {
            YobaButton _this = (YobaButton)s;

            ((YobaDialog)_this.Parent).DialogResult = _this.DialogResult;
        }
Esempio n. 3
0
        public MainForm()
        {
            ThePath = Program.GamePath;

            InitializeComponent();

            int winstyle = NativeWinAPI.GetWindowLong(basePanel.Handle, NativeWinAPI.GWL_EXSTYLE);

            NativeWinAPI.SetWindowLong(basePanel.Handle, NativeWinAPI.GWL_EXSTYLE, winstyle | NativeWinAPI.WS_EX_COMPOSITED);

            SuspendLayout();

            wc_ = new WebClient {
                Encoding = Encoding.UTF8
            };
            wc_.DownloadProgressChanged += new DownloadProgressChangedEventHandler(OnDownloadProgressChanged);
            wc_.DownloadFileCompleted   += new AsyncCompletedEventHandler(OnDownloadCompleted);
            downloadProgressTracker_     = new DownloadProgressTracker(50, TimeSpan.FromMilliseconds(500));

            int missingFilesCount = Program.GameFileCheckResult.InvalidFiles.Count;

            if (missingFilesCount > 0)
            {
                filesToUpload_ = Program.GameFileCheckResult.InvalidFiles;
                bool allowRun = true;
                foreach (FileInfo fi in filesToUpload_)
                {
                    if (fi.Importance < 2 && (!fi.IsPresent || (!fi.IsOK && fi.Importance < 1)))
                    {
                        allowRun = false;
                    }
                    else
                    {
                        missingFilesCount--;
                    }
                }
                SetReady(allowRun);
            }
            else
            {
                SetReady(true);
            }
            updateLabelText.Text = ReadyToGo_ ? Locale.Get("AllFilesIntact") : String.Format(Locale.Get("FilesMissing"), missingFilesCount);

            changelogMenuBtn.Text = Locale.Get("ChangelogBtn");
            linksButton.Text      = Locale.Get("LinksBtn");
            settingsButton.Text   = Locale.Get("SettingsBtn");
            faqButton.Text        = Locale.Get("FAQBtn");
            statusButton.Text     = Locale.Get("StatusBtn");
            modsButton.Text       = Locale.Get("ModsBtn");
            Text = Locale.Get("MainFormTitle");

            theToolTip.SetToolTip(closeButton, Locale.Get("Close"));
            theToolTip.SetToolTip(minimizeButton, Locale.Get("Minimize"));
            theToolTip.SetToolTip(changelogMenuBtn, Locale.Get("ChangelogTooltip"));
            theToolTip.SetToolTip(statusButton, Locale.Get("StatusTooltip"));
            theToolTip.SetToolTip(linksButton, Locale.Get("LinksTooltip"));
            theToolTip.SetToolTip(settingsButton, Locale.Get("SettingsTooltip"));
            theToolTip.SetToolTip(faqButton, Locale.Get("FAQTooltip"));
            theToolTip.SetToolTip(modsButton, Locale.Get("ModsTooltip"));

            uiPanels_ = new Panel[] { changelogPanel, statusPanel, linksPanel, modsPanel, faqPanel };

            foreach (Panel p in uiPanels_)
            {
                p.Location = new Point(0, 0);
                p.Size     = new Size(610, 330);
            }

            allowUrlsInEmbeddedBrowser.Add(statusBrowser, false);
            allowUrlsInEmbeddedBrowser.Add(modsBrowser, false);
            allowUrlsInEmbeddedBrowser.Add(faqBrowser, false);
            allowUrlsInEmbeddedBrowser.Add(changelogBrowser, false);

            UpdateInfoWebViews();

            statusBrowser.Size     = new Size(610, 330);
            statusBrowser.Location = new Point(0, 0);
            modsBrowser.Size       = new Size(610, 330);
            modsBrowser.Location   = new Point(0, 0);

            statusBrowser.ObjectForScripting  = StatusController.Instance;
            StatusController.Instance.Form    = this;
            StatusController.Instance.FileMap = new Dictionary <string, FileInfo>();
            modsBrowser.ObjectForScripting    = ModsController.Instance;
            ModsController.Instance.Form      = this;

            UpdateStatusWebView();
            UpdateModsWebView();

            if (Program.LoncherSettings.UI.ContainsKey("UpdateLabel"))
            {
                UIElement updateLabelInfo = Program.LoncherSettings.UI["UpdateLabel"];
                if (updateLabelInfo != null)
                {
                    updateLabelText.BackColor = YU.colorFromString(updateLabelInfo.BgColor, Color.Transparent);
                    updateLabelText.ForeColor = YU.colorFromString(updateLabelInfo.Color, Color.White);
                    YU.setFont(updateLabelText, updateLabelInfo.Font, updateLabelInfo.FontSize);
                }
            }
            string[] menuScreenKeys = new string[] {
                "BasePanel", "StatusPanel", "LinksPanel", "ModsPanel", "ChangelogPanel", "FAQPanel"
            };
            string[] menuBtnKeys = new string[] {
                "LaunchButton", "SettingsButton", "StatusButton", "LinksButton", "ChangelogButton", "ModsButton", "FAQButton", "CloseButton", "MinimizeButton", "HelpButton"
            };
            string[] menuBtnControlKeys = new string[] {
                "launchGameButton", "settingsButton", "statusButton", "linksButton", "changelogMenuBtn", "modsButton", "faqButton", "closeButton", "minimizeButton", "helpButton"
            };
            for (int i = 0; i < menuBtnKeys.Length; i++)
            {
                string menuBtnKey = menuBtnKeys[i];
                if (Program.LoncherSettings.UI.ContainsKey(menuBtnKey))
                {
                    UIElement launchButtonInfo = Program.LoncherSettings.UI[menuBtnKey];
                    if (launchButtonInfo != null)
                    {
                        Control[] ctrls = Controls.Find(menuBtnControlKeys[i], true);
                        if (ctrls.Length > 0)
                        {
                            ((YobaButtonAbs)ctrls[0]).ApplyUIStyles(launchButtonInfo);
                        }
                    }
                }
            }
            foreach (string menuScreenKey in menuScreenKeys)
            {
                if (Program.LoncherSettings.UI.ContainsKey(menuScreenKey))
                {
                    UIElement uiInfo = Program.LoncherSettings.UI[menuScreenKey];
                    if (uiInfo != null)
                    {
                        Control[] ctrls = Controls.Find(menuScreenKey, true);
                        if (ctrls.Length > 0)
                        {
                            Panel panel = (Panel)ctrls[0];
                            if (uiInfo.Position != null)
                            {
                                panel.Location = new Point(uiInfo.Position.X, uiInfo.Position.Y);
                            }
                            if (uiInfo.Size != null)
                            {
                                panel.Size = new Size(uiInfo.Size.X, uiInfo.Size.Y);
                            }
                            if (YU.stringHasText(uiInfo.Color))
                            {
                                panel.ForeColor = YU.colorFromString(uiInfo.Color, Color.White);
                            }
                            if (YU.stringHasText(uiInfo.BgColor))
                            {
                                panel.BackColor = YU.colorFromString(uiInfo.BgColor, Color.DimGray);
                            }
                            if (uiInfo.BgImage != null && YU.stringHasText(uiInfo.BgImage.Path))
                            {
                                if (YU.stringHasText(uiInfo.BgImage.Layout))
                                {
                                    try {
                                        Enum.Parse(typeof(ImageLayout), uiInfo.BgImage.Layout);
                                    }
                                    catch {
                                        panel.BackgroundImageLayout = ImageLayout.Stretch;
                                    }
                                }
                                else
                                {
                                    panel.BackgroundImageLayout = ImageLayout.Stretch;
                                }
                                panel.BackgroundImage = YU.readBitmap(PreloaderForm.IMGPATH + uiInfo.BgImage.Path);
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < Program.LoncherSettings.Buttons.Count; i++)
            {
                LinkButton lbtn = Program.LoncherSettings.Buttons[i];
                if (lbtn != null)
                {
                    YobaButton linkButton = new YobaButton(lbtn.Url);
                    linkButton.Name     = "linkBtn" + (i + 1);
                    linkButton.TabIndex = 10 + i;
                    linkButton.UseVisualStyleBackColor = true;
                    linkButton.ApplyUIStyles(lbtn);
                    if (YU.stringHasText(lbtn.Caption))
                    {
                        linkButton.Text = "";
                        theToolTip.SetToolTip(linkButton, lbtn.Caption);
                    }
                    linkButton.Click += new EventHandler((object o, EventArgs a) => {
                        string url = ((YobaButton)o).Url;
                        if (YU.stringHasText(url))
                        {
                            Process.Start(url);
                        }
                    });
                    linksPanel.Controls.Add(linkButton);
                }
            }

            BackgroundImageLayout = ImageLayout.Stretch;
            BackgroundImage       = Program.LoncherSettings.Background;

            switch (LauncherConfig.StartPage)
            {
            case StartPageEnum.Changelog:
                changelogPanel.Visible = true;
                break;

            case StartPageEnum.Mods:
                modsPanel.Visible = true;
                break;

            case StartPageEnum.Status:
                statusPanel.Visible = true;
                break;

            case StartPageEnum.Links:
                linksPanel.Visible = true;
                break;

            case StartPageEnum.FAQ:
                faqPanel.Visible = true;
                break;
            }

            List <ModInfo>        outdatedMods            = new List <ModInfo>();
            LinkedList <FileInfo> outdatedModFiles        = new LinkedList <FileInfo>();
            LinkedList <FileInfo> outdatedAlteredModFiles = new LinkedList <FileInfo>();

            foreach (ModInfo mi in Program.LoncherSettings.Mods)
            {
                if (mi.CurrentVersionFiles != null)
                {
                    if ((mi.ModConfigurationInfo != null) && mi.ModConfigurationInfo.Active)
                    {
                        bool hasit = false;
                        foreach (FileInfo mif in mi.CurrentVersionFiles)
                        {
                            if (!mif.IsOK)
                            {
                                outdatedModFiles.AddLast(mif);
                                if (!hasit)
                                {
                                    outdatedMods.Add(mi);
                                    hasit = true;
                                }
                                if (mi.ModConfigurationInfo.Altered)
                                {
                                    outdatedAlteredModFiles.AddLast(mif);
                                }
                            }
                        }
                        if (hasit)
                        {
                            outdatedModFiles.Last.Value.LastFileOfModToUpdate = mi;
                        }
                    }
                }
            }
            if (outdatedMods.Count > 0)
            {
                string         outdatedmods        = "";
                string         alteredmods         = "";
                List <ModInfo> alteredOutdatedMods = new List <ModInfo>();
                ulong          outdatedmodssize    = 0;
                bool           comma    = false;
                bool           altcomma = false;
                foreach (ModInfo mi in outdatedMods)
                {
                    if (!comma)
                    {
                        comma = true;
                    }
                    else
                    {
                        outdatedmods += ", ";
                    }
                    outdatedmods += mi.CurrentVersionData.Name ?? mi.Name;
                    if (mi.ModConfigurationInfo.Altered)
                    {
                        if (!altcomma)
                        {
                            altcomma = true;
                        }
                        else
                        {
                            alteredmods += ", ";
                        }
                        alteredOutdatedMods.Add(mi);
                        alteredmods += mi.CurrentVersionData.Name ?? mi.Name;
                    }
                }
                foreach (FileInfo mif in outdatedModFiles)
                {
                    outdatedmodssize += mif.Size;
                }
                if (DialogResult.Yes == YobaDialog.ShowDialog(String.Format(Locale.Get("YouHaveOutdatedMods"), outdatedmods, YU.formatFileSize(outdatedmodssize)), YobaDialog.YesNoBtns))
                {
                    modFilesToUpload_ = outdatedModFiles;
                    foreach (ModInfo mi in outdatedMods)
                    {
                        mi.DlInProgress = true;
                    }
                    UpdateModsWebView();
                    if (!UpdateInProgress_)
                    {
                        DownloadNextMod();
                    }
                }
                else
                {
                    if (alteredOutdatedMods.Count > 0)
                    {
                        ulong alteredmodssize = 0;
                        foreach (FileInfo mif in outdatedAlteredModFiles)
                        {
                            alteredmodssize += mif.Size;
                        }
                        if (DialogResult.Yes == YobaDialog.ShowDialog(String.Format(Locale.Get("YouHaveAlteredMods"), alteredmods, YU.formatFileSize(alteredmodssize)), YobaDialog.YesNoBtns))
                        {
                            modFilesToUpload_ = outdatedAlteredModFiles;
                            foreach (ModInfo mi in alteredOutdatedMods)
                            {
                                mi.DlInProgress = true;
                            }
                            UpdateModsWebView();
                            if (!UpdateInProgress_)
                            {
                                DownloadNextMod();
                            }
                        }
                    }
                }
            }
            PerformLayout();
        }
Esempio n. 4
0
 private void initButtons(UIElement[] buttons)
 {
     SuspendLayout();
     if (buttons == null)
     {
         YobaButton button = new YobaButton();
         button.Location     = new Point((int)((double)Size.Width / 2 - (double)button.Width / 2), Size.Height - 46);
         button.Name         = "okButton";
         button.Text         = Locale.Get("OK");
         button.TabIndex     = 1;
         button.DialogResult = DialogResult.OK;
         Controls.Add(button);
         //button.Click += new EventHandler(onBtnClick);
     }
     else
     {
         int          minwidth  = 38;
         int          maxheight = 1;
         byte         btnnum    = 0;
         YobaButton[] ybuttons  = new YobaButton[buttons.Length];
         foreach (UIElement btnInfo in buttons)
         {
             YobaButton button = new YobaButton();
             button.Name      = "button" + btnnum;
             ybuttons[btnnum] = button;
             button.TabIndex  = 1 + btnnum;
             if (btnInfo.Size != null)
             {
                 button.Size = new Size(btnInfo.Size.X, btnInfo.Size.Y);
             }
             if (btnInfo.Caption != null)
             {
                 button.Text = btnInfo.Caption;
             }
             button.DialogResult = btnInfo.Result;
             minwidth           += 18 + button.Size.Width;
             maxheight           = Math.Max(maxheight, button.Size.Height);
             Controls.Add(button);
             btnnum++;
         }
         Size = MinimumSize = MaximumSize = new Size(Math.Max(minwidth, Size.Width), maxheight > 28 ? Size.Height + maxheight - 28 : Size.Height);
         if (ybuttons.Length == 1)
         {
             YobaButton btn = ybuttons[0];
             btn.Location = new Point((int)((double)Size.Width / 2 - (double)btn.Width / 2), Size.Height - maxheight - 18);
         }
         else
         {
             int space   = (Size.Width - minwidth) / (btnnum - 1);
             int bottomY = Size.Height - maxheight - 18;
             int offsetX = 28;
             foreach (YobaButton btn in ybuttons)
             {
                 btn.Location = new Point(offsetX, bottomY);
                 offsetX     += 18 + btn.Size.Width + space;
             }
         }
     }
     if (messageLabel.Text.Length > 0)
     {
         messageLabel.Size = new Size(Size.Width - 56, Size.Height - 84);
     }
     else
     {
         Controls.Remove(messageLabel);
     }
     closeButton.UpdateLocation();            //Location = new Point(Size.Width - 30, -3);
     draggingPanel.Size = new Size(Size.Width - 32, 24);
     ResumeLayout(false);
 }