コード例 #1
0
		public GamePathSelectForm() {
			InitializeComponent();

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

			int style = NativeWinAPI.GetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE);
			style |= NativeWinAPI.WS_EX_COMPOSITED;
			NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, style);

			YU.assertLucida(textBox1);

			button1.Text = Locale.Get("Browse");
			button2.Text = Locale.Get("Proceed");
			label1.Text = Locale.Get("EnterThePath");
			Text = Locale.Get("GamePathSelectionTitle");

			closeButton.UpdateLocation();
		}
コード例 #2
0
        private void startInit(string message)
        {
            InitializeComponent();
            _originalWinStyle = NativeWinAPI.GetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE);
            NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, _originalWinStyle | NativeWinAPI.WS_EX_COMPOSITED);

            Icon = Program.LoncherSettings != null ? (Program.LoncherSettings.Icon ?? Resource1.yIcon) : Resource1.yIcon;
            messageLabel.Text = message;
            if (message.Length > 200)
            {
                int height = Size.Height + (Size.Height - 90) * ((message.Length - message.Length % 200) / 200);
                int width  = Size.Width;
                if (height > 400)
                {
                    height = 400;
                    width  = 640;
                }
                Size = new Size(width, height);
            }
            MinimumSize = Size;
            MaximumSize = Size;
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: Hy60koshk/YobaLoncher
        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();
        }
コード例 #4
0
 public void ResetWinStyle()
 {
     NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, _originalWinStyle);
 }