Esempio n. 1
0
 private void DownloadNextMod()
 {
     if (currentFile_ is null)
     {
         launchGameButton.Enabled = false;
         currentFile_             = modFilesToUpload_.First;
         downloadProgressTracker_ = new DownloadProgressTracker(50, TimeSpan.FromMilliseconds(500));
     }
     else if (currentFile_.Value.LastFileOfMod != null || currentFile_.Value.LastFileOfModToUpdate != null)
     {
         if (!FinalizeModDownload(currentFile_.Value))
         {
             FinishModDownload();
             return;
         }
         currentFile_ = modFilesToUpload_.First;
     }
     else
     {
         currentFile_ = currentFile_.Next;
     }
     if (currentFile_ != null)
     {
         if (currentFile_.Value.IsOK)
         {
             DownloadNextMod();
         }
         else
         {
             DownloadFile(currentFile_.Value);
         }
     }
     else
     {
         updateLabelText.Text = Locale.Get("ModInstallationDone");
         FinishModDownload();
     }
 }
Esempio n. 2
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. 3
0
        private async void Initialize()
        {
            _progressBar1.Value = 0;
            Program.OfflineMode = false;
            long startingTicks = DateTime.Now.Ticks;
            long lastTicks     = startingTicks;

            void logDeltaTicks(string point)
            {
                long current = DateTime.Now.Ticks;

                YU.Log(point + ": " + (current - lastTicks) + " (" + (current - startingTicks) + ')');
                lastTicks = current;
            }

            try {
                if (!Directory.Exists(IMGPATH))
                {
                    Directory.CreateDirectory(IMGPATH);
                }
                if (!Directory.Exists(UPDPATH))
                {
                    Directory.CreateDirectory(UPDPATH);
                }
                //WebBrowserHelper.FixBrowserVersion();
                //ErrorAndKill("Cannot get Images:\r\n");
                string settingsJson = (await wc_.DownloadStringTaskAsync(Program.SETTINGS_URL));
                logDeltaTicks("settings");
                incProgress(5);
                try {
                    Program.LoncherSettings = new LauncherData(settingsJson);
                    try {
                        File.WriteAllText(SETTINGSPATH, settingsJson, Encoding.UTF8);
                    }
                    catch { }
                    incProgress(5);
                    try {
                        if (Program.LoncherSettings.RAW.Localization != null)
                        {
                            FileInfo locInfo = Program.LoncherSettings.RAW.Localization;
                            if (YU.stringHasText(locInfo.Url))
                            {
                                locInfo.Path = LOCPATH;
                                if (!FileChecker.CheckFileMD5("", locInfo))
                                {
                                    string loc = await wc_.DownloadStringTaskAsync(locInfo.Url);

                                    File.WriteAllText(LOCPATH, loc, Encoding.UTF8);
                                    Locale.LoadCustomLoc(loc.Replace("\r\n", "\n").Split('\n'));
                                }
                                Locale.LoadCustomLoc(File.ReadAllLines(LOCPATH, Encoding.UTF8));
                            }
                            else if (File.Exists(LOCPATH))
                            {
                                Locale.LoadCustomLoc(File.ReadAllLines(LOCPATH, Encoding.UTF8));
                            }
                        }
                        else if (File.Exists(LOCPATH))
                        {
                            Locale.LoadCustomLoc(File.ReadAllLines(LOCPATH, Encoding.UTF8));
                        }
                        incProgress(5);
                        logDeltaTicks("locales");
                    }
                    catch (Exception ex) {
                        YobaDialog.ShowDialog(Locale.Get("CannotGetLocaleFile") + ":\r\n" + ex.Message);
                    }
                    try {
                        downloadProgressTracker_     = new DownloadProgressTracker(50, TimeSpan.FromMilliseconds(500));
                        wc_.DownloadProgressChanged += new DownloadProgressChangedEventHandler(OnDownloadProgressChanged);
#if DEBUG
#else
                        if (YU.stringHasText(Program.LoncherSettings.LoncherHash))
                        {
                            string selfHash = FileChecker.GetFileMD5(Application.ExecutablePath);

                            if (!Program.LoncherSettings.LoncherHash.ToUpper().Equals(selfHash))
                            {
                                if (YU.stringHasText(Program.LoncherSettings.LoncherExe))
                                {
                                    string newLoncherPath = Application.ExecutablePath + ".new";
                                    string appname        = Application.ExecutablePath;
                                    appname = appname.Substring(appname.LastIndexOf('\\') + 1);
                                    await loadFile(Program.LoncherSettings.LoncherExe, newLoncherPath, Locale.Get("UpdatingLoncher"));

                                    string newHash = FileChecker.GetFileMD5(newLoncherPath);

                                    if (selfHash.Equals(Program.PreviousVersionHash))
                                    {
                                        YU.ErrorAndKill(Locale.Get("LoncherOutOfDate2"));
                                    }
                                    else if (newHash.Equals(Program.PreviousVersionHash))
                                    {
                                        YU.ErrorAndKill(Locale.Get("LoncherOutOfDate3"));
                                    }
                                    else
                                    {
                                        Process.Start(new ProcessStartInfo {
                                            Arguments = String.Format("/C choice /C Y /N /D Y /T 1 & Del \"{0}\" & Rename \"{1}\" \"{2}\" & \"{0}\" -oldhash {3}"
                                                                      , Application.ExecutablePath, newLoncherPath, appname, selfHash)
                                            ,
                                            FileName = "cmd"
                                            ,
                                            WindowStyle = ProcessWindowStyle.Hidden
                                        });
                                        Application.Exit();
                                    }
                                    return;
                                }
                                else
                                {
                                    YU.ErrorAndKill(Locale.Get("LoncherOutOfDate1"));
                                    return;
                                }
                            }
                        }
#endif
                    }
                    catch (Exception ex) {
                        YU.ErrorAndKill(Locale.Get("CannotUpdateLoncher") + ":\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                        return;
                    }
                    LauncherData.LauncherDataRaw launcherDataRaw = Program.LoncherSettings.RAW;
                    try {
                        if (await assertFile(launcherDataRaw.Icon, IMGPATH, ICON_FILE))
                        {
                            Bitmap bm = YU.readBitmap(ICON_FILE);
                            if (bm != null)
                            {
                                Program.LoncherSettings.Icon = Icon.FromHandle(bm.GetHicon());
                                this.Icon = Program.LoncherSettings.Icon;
                            }
                        }
                        if (Program.LoncherSettings.Icon == null)
                        {
                            Program.LoncherSettings.Icon = this.Icon;
                        }
                        if (await assertFile(launcherDataRaw.PreloaderBackground, IMGPATH, BG_FILE))
                        {
                            this.BackgroundImage = YU.readBitmap(BG_FILE);
                        }
                        bool gotRandomBG = false;
                        if (launcherDataRaw.RandomBackgrounds != null && launcherDataRaw.RandomBackgrounds.Count > 0)
                        {
                            int randomBGRoll = new Random().Next(0, 1000);
                            int totalRoll    = 0;
                            foreach (RandomBgImageInfo rbgi in launcherDataRaw.RandomBackgrounds)
                            {
                                if (await assertFile(rbgi.Background, IMGPATH))
                                {
                                    totalRoll += rbgi.Chance;
                                    if (totalRoll > randomBGRoll)
                                    {
                                        Program.LoncherSettings.Background = YU.readBitmap(IMGPATH + rbgi.Background.Path);
                                        gotRandomBG = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (!gotRandomBG && await assertFile(launcherDataRaw.Background, IMGPATH))
                        {
                            Program.LoncherSettings.Background = YU.readBitmap(IMGPATH + launcherDataRaw.Background.Path);
                        }

                        if (Program.LoncherSettings.UI.Count > 0)
                        {
                            string[] keys = Program.LoncherSettings.UI.Keys.ToArray();
                            foreach (string key in keys)
                            {
                                if (!(await assertFile(Program.LoncherSettings.UI[key].BgImage, IMGPATH)))
                                {
                                    Program.LoncherSettings.UI[key].BgImage = null;
                                }
                                if (!(await assertFile(Program.LoncherSettings.UI[key].BgImageClick, IMGPATH)))
                                {
                                    Program.LoncherSettings.UI[key].BgImageClick = null;
                                }
                                if (!(await assertFile(Program.LoncherSettings.UI[key].BgImageHover, IMGPATH)))
                                {
                                    Program.LoncherSettings.UI[key].BgImageHover = null;
                                }
                            }
                        }
                        if (Program.LoncherSettings.Buttons.Count > 0)
                        {
                            foreach (LinkButton lbtn in Program.LoncherSettings.Buttons)
                            {
                                if (!(await assertFile(lbtn.BgImage, IMGPATH)))
                                {
                                    lbtn.BgImage = null;
                                }
                                if (!(await assertFile(lbtn.BgImageClick, IMGPATH)))
                                {
                                    lbtn.BgImageClick = null;
                                }
                                if (!(await assertFile(lbtn.BgImageHover, IMGPATH)))
                                {
                                    lbtn.BgImageHover = null;
                                }
                            }
                        }

                        /*await assertFile(new FileInfo() {
                         *      Url = "https://drive.google.com/uc?export=download&confirm=-MpP&id=1fUW0NfP2EYUG6K2hOg6hgajRi59pCBBy"
                         *      , Path = "legends"
                         * }, IMGPATH);*/

                        logDeltaTicks("images");
                    }
                    catch (Exception ex) {
                        YU.ErrorAndKill(Locale.Get("CannotGetImages") + ":\r\n" + ex.Message);
                        return;
                    }
                    if (Program.LoncherSettings.Fonts != null)
                    {
                        List <string> keys = Program.LoncherSettings.Fonts.Keys.ToList();
                        if (keys.Count > 0)
                        {
                            try {
                                if (!Directory.Exists(FNTPATH))
                                {
                                    Directory.CreateDirectory(FNTPATH);
                                }
                                foreach (string key in keys)
                                {
                                    using (Font fontTester = new Font(key, 12, FontStyle.Regular, GraphicsUnit.Pixel)) {
                                        if (fontTester.Name == key)
                                        {
                                            Program.LoncherSettings.Fonts[key] = "win";
                                        }
                                        else if (File.Exists(FNTPATH + key))
                                        {
                                            Program.LoncherSettings.Fonts[key] = "local";
                                        }
                                        else
                                        {
                                            string status   = "none";
                                            string src      = Program.LoncherSettings.Fonts[key];
                                            string filename = FNTPATH + key;
                                            if (YU.stringHasText(src))
                                            {
                                                await loadFile(src, filename);

                                                if (File.Exists(filename))
                                                {
                                                    status = "local";
                                                }
                                            }
                                            Program.LoncherSettings.Fonts[key] = status;
                                        }
                                    }
                                }
                                logDeltaTicks("fonts");
                            }
                            catch (Exception ex) {
                                YU.ErrorAndKill(Locale.Get("CannotGetFonts") + ":\r\n" + ex.Message);
                                return;
                            }
                        }
                    }
                    try {
                        loadingLabel.Text = Locale.Get("PreparingToLaunch");
                        //await Program.LoncherSettings.InitChangelogOnline();
                        Program.LoncherSettings.Changelog = await getStaticTabData("Changelog", launcherDataRaw.Changelog, launcherDataRaw.QuoteToEscape, "[[[CHANGELOG]]]");

                        Program.LoncherSettings.FAQ = await getStaticTabData("FAQ", launcherDataRaw.FAQFile, launcherDataRaw.QuoteToEscape, "[[[FAQTEXT]]]");

                        incProgress(5);
                        logDeltaTicks("changelog and etc");
                        //loadingLabel.Text = Locale.Get("PreparingToLaunch");
                        try {
                            if (findGamePath())
                            {
                                try {
                                    updateGameVersion();
                                    if (oldMainForm_ != null)
                                    {
                                        oldMainForm_.Dispose();
                                    }
                                    int progressBarPerFile = 100 - _progressBar1.Value;
                                    if (progressBarPerFile < Program.LoncherSettings.Files.Count)
                                    {
                                        progressBarPerFile  = 88;
                                        _progressBar1.Value = 6;
                                    }
                                    progressBarPerFile = progressBarPerFile / Program.LoncherSettings.Files.Count;
                                    if (progressBarPerFile < 1)
                                    {
                                        progressBarPerFile = 1;
                                    }

                                    Program.GameFileCheckResult = await FileChecker.CheckFiles(
                                        Program.LoncherSettings.Files
                                        , new EventHandler <FileCheckedEventArgs>((object o, FileCheckedEventArgs a) => {
                                        _progressBar1.Value += progressBarPerFile;
                                        if (_progressBar1.Value > 100)
                                        {
                                            _progressBar1.Value = 40;
                                        }
                                    })
                                        );

                                    foreach (ModInfo mi in Program.LoncherSettings.Mods)
                                    {
                                        if (mi.ModConfigurationInfo != null)
                                        {
                                            await FileChecker.CheckFiles(
                                                mi.CurrentVersionFiles
                                                , new EventHandler <FileCheckedEventArgs>((object o, FileCheckedEventArgs a) => {
                                                _progressBar1.Value += progressBarPerFile;
                                                if (_progressBar1.Value > 100)
                                                {
                                                    _progressBar1.Value = 40;
                                                }
                                            })
                                                );
                                        }
                                    }
                                    logDeltaTicks("filecheck");
                                    showMainForm();
                                }
                                catch (Exception ex) {
                                    YU.ErrorAndKill(Locale.Get("CannotCheckFiles") + ":\r\n" + ex.Message);
                                }
                            }
                        }
                        catch (Exception ex) {
                            YU.ErrorAndKill(Locale.Get("CannotParseConfig") + ":\r\n" + ex.Message);
                        }
                    }
                    catch (Exception ex) {
                        YU.ErrorAndKill(Locale.Get("CannotLoadIcon") + ":\r\n" + ex.Message);
                    }
                }
                catch (Exception ex) {
                    YU.ErrorAndKill(Locale.Get("CannotParseSettings") + ":\r\n" + ex.Message);
                }
            }
            catch (Exception ex) {
                UIElement[] btns;
                UIElement   btnQuit = new UIElement();
                btnQuit.Caption = Locale.Get("Quit");
                btnQuit.Result  = DialogResult.Abort;
                UIElement btnRetry = new UIElement();
                btnRetry.Caption = Locale.Get("Retry");
                btnRetry.Result  = DialogResult.Retry;
                string msg;
                if (File.Exists(SETTINGSPATH))
                {
                    msg = Locale.Get("WebClientErrorOffline");
                    UIElement btnOffline = new UIElement();
                    btnOffline.Caption = Locale.Get("RunOffline");
                    btnOffline.Result  = DialogResult.Ignore;
                    btns = new UIElement[] { btnQuit, btnRetry, btnOffline };
                }
                else
                {
                    msg  = Locale.Get("WebClientError");
                    btns = new UIElement[] { btnQuit, btnRetry };
                }
                YobaDialog yobaDialog = new YobaDialog(msg, btns);
                yobaDialog.Icon = Program.LoncherSettings != null ? (Program.LoncherSettings.Icon ?? this.Icon) : this.Icon;
                DialogResult result = yobaDialog.ShowDialog(this);
                switch (result)
                {
                case DialogResult.Retry:
                    Initialize();
                    break;

                case DialogResult.Ignore:
                    InitializeOffline();
                    break;

                case DialogResult.Abort: {
                    Application.Exit();
                    return;
                }
                }
            }
        }