コード例 #1
0
        public clsXMLUpdate.eCheckResponse UpdateCheck(bool silent, ref IMessager iLoadFrm)
        {
            this.mFrm = iLoadFrm;
            this.ShowMessage(silent, ref iLoadFrm);
            this.SetMessage("Checking For Updates...", "");
            clsXMLUpdate.eCheckResponse eCheckResponse;
            if (!this.RequestXMLVersionInfo())
            {
                eCheckResponse = clsXMLUpdate.eCheckResponse.NoUpdates;
            }
            else
            {
                int updateId = -1;
                int num      = this.Updates.Length - 1;
                for (int index = 0; index <= num; index++)
                {
                    clsXMLUpdate.clsXMLItem update = this.Updates[index];
                    if (update.Version > 0f)
                    {
                        switch (update.nType)
                        {
                        case clsXMLUpdate.eUpdateType.AppUpdate:
                            if (update.Version > 1.962f)
                            {
                                updateId = index;
                                goto IL_E3;
                            }
                            break;

                        case clsXMLUpdate.eUpdateType.DBUpdate:
                            if (update.Version > DatabaseAPI.Database.Version)
                            {
                                updateId = index;
                                goto IL_E3;
                            }
                            break;
                        }
                    }
                }
IL_E3:
                if (updateId < 0)
                {
                    this.HideMessage();
                    eCheckResponse = clsXMLUpdate.eCheckResponse.NoUpdates;
                }
                else
                {
                    bool flag = true;
                    clsXMLUpdate.clsXMLItem update2 = this.Updates[updateId];
                    if (update2.DisplayName == "")
                    {
                        flag = false;
                    }
                    if (update2.LocalDest == "")
                    {
                        flag = false;
                    }
                    if (update2.Size < 1)
                    {
                        flag = false;
                    }
                    if (update2.SourceURI == "")
                    {
                        flag = false;
                    }
                    this.HideMessage();
                    if (flag)
                    {
                        string str5 = "An update for the ";
                        switch (this.Updates[updateId].nType)
                        {
                        case clsXMLUpdate.eUpdateType.AppUpdate:
                            str5 += "application";
                            break;

                        case clsXMLUpdate.eUpdateType.DBUpdate:
                            str5 += "database";
                            break;
                        }
                        str5 += " is available.\r\n";
                        clsXMLUpdate.clsXMLItem update3 = this.Updates[updateId];
                        str5 = str5 + "Update: " + update3.DisplayName + "\r\n";
                        str5 = string.Concat(new string[]
                        {
                            str5,
                            "Version: ",
                            Conversions.ToString(update3.Version),
                            " (",
                            Strings.Format(update3.VersionDate, "Short Date"),
                            ")\r\n"
                        });
                        if (!update3.Manual)
                        {
                            str5 = str5 + "Size: " + Strings.Format((double)update3.Size / 1024.0, "###,##0") + " KB\r\n";
                        }
                        str5 = str5 + "Notes: " + update3.Notes + "\r\n";
                        if (update3.Restart & !update3.Manual)
                        {
                            str5 += "\r\nUpdate will require the application to restart.\r\n";
                        }
                        if (update3.Manual)
                        {
                            str5 += "\r\nThis update requires you download and re-install fully. You will be directed to the download page.\r\n\r\nDownload this update now?";
                        }
                        else
                        {
                            str5 += "\r\nDownload and install this update now?";
                        }
                        if (Interaction.MsgBox(str5, MsgBoxStyle.YesNo | MsgBoxStyle.Information, "Automatic Update") == MsgBoxResult.Yes)
                        {
                            if (update3.Manual)
                            {
                                clsXMLUpdate.LaunchBrowser(update3.SourceURI);
                                return(clsXMLUpdate.eCheckResponse.Updates);
                            }
                            this.ShowMessage(silent, ref iLoadFrm);
                            if (this.RequestWithProgress(ref updateId))
                            {
                                this.HideMessage();
                                if (!update3.Restart)
                                {
                                    if (this.ApplyUpdate(ref updateId))
                                    {
                                        this.ShowMessage(silent, ref iLoadFrm);
                                        this.SetMessage("Loading updated data...", "");
                                        frmLoading iFrm = null;
                                        MainModule.MidsController.LoadData(ref iFrm);
                                        this.HideMessage();
                                        Interaction.MsgBox("Update applied!", MsgBoxStyle.Information, "Done.");
                                        return(clsXMLUpdate.eCheckResponse.Updates);
                                    }
                                    Interaction.MsgBox("Update not applied! Something didn't work out.", MsgBoxStyle.Information, "Oops.");
                                    return(clsXMLUpdate.eCheckResponse.FailedWithMessage);
                                }
                                else
                                {
                                    this.RestartNeeded = true;
                                    str5 = "Update package has been downloaded!\r\nYou need to close all other instances of Mids' Hero Designer, and then allow it to re-start for the automatic update to be applied.";
                                    if (!silent)
                                    {
                                        Interaction.MsgBox(str5, MsgBoxStyle.Information, "Update Downloaded");
                                        return(clsXMLUpdate.eCheckResponse.Updates);
                                    }
                                    if (Interaction.MsgBox(str5 + "\r\nQuit now?", MsgBoxStyle.YesNo | MsgBoxStyle.Information, "Update Downloaded") == MsgBoxResult.Yes)
                                    {
                                        clsXMLUpdate.LaunchSelfUpdate();
                                        ProjectData.EndApp();
                                    }
                                }
                            }
                            this.HideMessage();
                            return(clsXMLUpdate.eCheckResponse.FailedWithMessage);
                        }
                    }
                    eCheckResponse = clsXMLUpdate.eCheckResponse.NoUpdates;
                }
            }
            return(eCheckResponse);
        }
コード例 #2
0
            public static void LoadData(ref frmLoading iFrm)
            {
                DatabaseAPI.LoadDatabaseVersion();
                IsAppInitialized = true;
                iFrm?.SetMessage("Loading Data...");
                iFrm?.SetMessage("Loading Attribute Modifiers...");
                DatabaseAPI.Database.AttribMods = new Modifiers();
                if (!DatabaseAPI.Database.AttribMods.Load())
                {
                }

                iFrm?.SetMessage("Loading Powerset Database...");
                if (!DatabaseAPI.LoadLevelsDatabase())
                {
                    Interaction.MsgBox(
                        "Failed to load Leveling data file! The program is unable to proceed.\r\n" +
                        "We suggest you redownload the application from https://github.com/Crytilis/mids-reborn-hero-designer/releases",
                        MsgBoxStyle.Critical, "Error");
                    ProjectData.EndApp();
                }

                if (!DatabaseAPI.LoadMainDatabase())
                {
                    Interaction.MsgBox("There was an error reading the database. Aborting.", MsgBoxStyle.Critical, "Dang");
                    ProjectData.EndApp();
                }

                if (!DatabaseAPI.LoadMaths())
                {
                    ProjectData.EndApp();
                }
                iFrm?.SetMessage("Loading Enhancement Database...");
                if (!DatabaseAPI.LoadEnhancementClasses())
                {
                    ProjectData.EndApp();
                }
                I9Gfx.LoadClasses();
                DatabaseAPI.LoadEnhancementDb();
                I9Gfx.LoadEnhancements();
                I9Gfx.LoadSets();
                DatabaseAPI.LoadOrigins();
                I9Gfx.LoadBorders();
                DatabaseAPI.LoadSetTypeStrings();
                iFrm?.SetMessage("Loading Recipe Database...");
                DatabaseAPI.LoadSalvage();
                DatabaseAPI.LoadRecipes();
                iFrm?.SetMessage("Loading Graphics...");
                I9Gfx.LoadSetTypes();
                I9Gfx.LoadEnhTypes();
                I9Gfx.LoadOriginImages();
                I9Gfx.LoadArchetypeImages();
                I9Gfx.LoadPowersetImages();
                MidsContext.Config.Export.LoadCodes(Files.SelectDataFileLoad(Files.MxdbFileBbCodeUpdate));
                if (iFrm != null)
                {
                    iFrm.Opacity = 1.0;
                    DatabaseAPI.MatchAllIDs(iFrm);
                    iFrm?.SetMessage("Matching Set Bonus IDs...");
                    DatabaseAPI.AssignSetBonusIndexes();
                    iFrm?.SetMessage("Matching Recipe IDs...");
                }

                DatabaseAPI.AssignRecipeIDs();
                GC.Collect();
            }
コード例 #3
0
 public static void LoadData(ref frmLoading iFrm)
 {
     DatabaseAPI.LoadDatabaseVersion();
     MainModule.MidsController._appInitialized = true;
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Data...");
     }
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Attribute Modifiers...");
     }
     DatabaseAPI.Database.AttribMods = new Modifiers();
     DatabaseAPI.Database.AttribMods.Load();
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Powerset Database...");
     }
     if (!DatabaseAPI.LoadLevelsDatabase())
     {
         Interaction.MsgBox("Failed to load Levelling data file! The program is unable to proceed.\r\nSuggest you redownload the application from http://www.cohplanner.com/", MsgBoxStyle.Critical, "Error");
         ProjectData.EndApp();
     }
     if (!DatabaseAPI.LoadMainDatabase())
     {
         if (Interaction.MsgBox("There was an error reading the database. Attempt to download replacement?", MsgBoxStyle.YesNo | MsgBoxStyle.Information, "Dang") == MsgBoxResult.Yes)
         {
             DateTime date = new DateTime(1, 1, 1);
             DatabaseAPI.Database.Date = date;
             clsXMLUpdate clsXmlUpdate = new clsXMLUpdate("http://repo.cohtitan.com/mids_updates/");
             IMessager    iLoadFrm     = null;
             clsXmlUpdate.UpdateCheck(false, ref iLoadFrm);
         }
         else
         {
             ProjectData.EndApp();
         }
     }
     if (!DatabaseAPI.LoadMaths())
     {
         ProjectData.EndApp();
     }
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Enhancement Database...");
     }
     if (!DatabaseAPI.LoadEnhancementClasses())
     {
         ProjectData.EndApp();
     }
     I9Gfx.LoadClasses();
     DatabaseAPI.LoadEnhancementDb();
     I9Gfx.LoadEnhancements();
     I9Gfx.LoadSets();
     DatabaseAPI.LoadOrigins();
     I9Gfx.LoadBorders();
     DatabaseAPI.LoadSetTypeStrings();
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Recipe Database...");
     }
     DatabaseAPI.LoadSalvage();
     DatabaseAPI.LoadRecipes();
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Graphics...");
     }
     I9Gfx.LoadSetTypes();
     I9Gfx.LoadEnhTypes();
     I9Gfx.LoadOriginImages();
     I9Gfx.LoadArchetypeImages();
     I9Gfx.LoadPowersetImages();
     MidsContext.Config.Export.LoadCodes(Files.SelectDataFileLoad("BBCode.mhd"));
     iFrm.Opacity = 1.0;
     DatabaseAPI.MatchAllIDs(iFrm);
     if (iFrm != null)
     {
         iFrm.SetMessage("Matching Set Bonus IDs...");
     }
     DatabaseAPI.AssignSetBonusIndexes();
     if (iFrm != null)
     {
         iFrm.SetMessage("Matching Recipe IDs...");
     }
     DatabaseAPI.AssignRecipeIDs();
     GC.Collect();
 }