private void OnGameInfoUpdate(object source, GameInfoUpdateEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         logMessage(e.Message);
         if (e.Result == GameInfoUpdateResult.Updated)
         {
             updateCurrentWorldAnalyzer();
         }
     });
 }
示例#2
0
        protected static void OnGameInfoUpdate(GameInfoUpdateEventArgs e)
        {
            EventHandler <GameInfoUpdateEventArgs> handler = GameInfoUpdate;

            handler?.Invoke(typeof(GameInfo), e);
        }
示例#3
0
        public static void CheckForNewGameInfo()
        {
            GameInfoUpdateEventArgs args = new GameInfoUpdateEventArgs();

            try
            {
                WebClient client = new WebClient();
                client.DownloadFile("https://raw.githubusercontent.com/Razzmatazzz/RemnantSaveManager/master/Resources/GameInfo.xml", "TempGameInfo.xml");

                XmlTextReader reader = new XmlTextReader("TempGameInfo.xml");
                reader.WhitespaceHandling = WhitespaceHandling.None;
                int remoteversion = 0;
                int localversion  = 0;
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name.Equals("GameInfo"))
                        {
                            remoteversion = int.Parse(reader.GetAttribute("version"));
                            break;
                        }
                    }
                }
                args.RemoteVersion = remoteversion;
                reader.Close();
                if (File.Exists("GameInfo.xml"))
                {
                    reader = new XmlTextReader("GameInfo.xml");
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.Name.Equals("GameInfo"))
                            {
                                localversion = int.Parse(reader.GetAttribute("version"));
                                break;
                            }
                        }
                    }
                    reader.Close();
                    args.LocalVersion = localversion;

                    if (remoteversion > localversion)
                    {
                        File.Delete("GameInfo.xml");
                        File.Move("TempGameInfo.xml", "GameInfo.xml");
                        RefreshGameInfo();
                        args.Result  = GameInfoUpdateResult.Updated;
                        args.Message = "Game info updated from v" + localversion + " to v" + remoteversion + ".";
                    }
                    else
                    {
                        File.Delete("TempGameInfo.xml");
                    }
                }
                else
                {
                    File.Move("TempGameInfo.xml", "GameInfo.xml");
                    RefreshGameInfo();
                    args.Result  = GameInfoUpdateResult.Updated;
                    args.Message = "No local game info found; updated to v" + remoteversion + ".";
                }
            } catch (Exception ex)
            {
                args.Result  = GameInfoUpdateResult.Failed;
                args.Message = "Error checking for new game info: " + ex.Message;
            }

            OnGameInfoUpdate(args);
        }