コード例 #1
0
        void DownloadNewsAsync()
        {
            try
            {
                var newsDownloadClient = new WebClient();
                newsDownloadClient.Proxy = null;
                var downloadedNews = newsDownloadClient.DownloadString(new Uri(MyPerGameSettings.ChangeLogUrl));

                using (StringReader stream = new StringReader(downloadedNews))
                {
                    m_news = (MyNews)m_newsSerializer.Deserialize(stream);
                    
                    if (!MyFinalBuildConstants.IS_DEBUG)
                    {
                        m_news.Entry.RemoveAll(entry => !entry.Public);
                    }

                    StringBuilder text = new StringBuilder();
                    for (int i = 0; i < m_news.Entry.Count; i++)
                    {
                        var newsItem = m_news.Entry[i];

                        string itemText = newsItem.Text.Trim(m_trimArray);
                        string[] lines = itemText.Split(m_splitArray);

                        text.Clear();
                        foreach (string lineItem in lines)
                        {
                            string line = lineItem.Trim();
                            text.AppendLine(line);
                        }

                        m_news.Entry[i] = new MyNewsEntry()
                        {
                            Title = newsItem.Title,
                            Version = newsItem.Version,
                            Date = newsItem.Date,
                            Text = text.ToString(),
                        };
                    }

                    if (MyFakes.TEST_NEWS)
                    {
                        var entry = m_news.Entry[m_news.Entry.Count - 1];
                        entry.Title = "Test";
                        entry.Text = "ASDF\nASDF\n[www.spaceengineersgame.com Space engineers web]\n[[File:Textures\\GUI\\MouseCursor.dds|64x64px]]\n";
                        m_news.Entry.Add(entry);
                    }
                    m_downloadedNewsOK = true;
                }
            }
            catch (Exception e)
            {
                MyLog.Default.WriteLine("Error while downloading news: " + e.ToString());
            }
            finally
            {
                m_downloadedNewsFinished = true;
            }
        }
コード例 #2
0
 internal void Show(MyNews news)
 {
     m_news.Clear();
     m_news.AddRange(news.Entry);
     m_currentEntryIndex = 0; // showing the newest entry by default
     RefreshShownEntry();
 }
コード例 #3
0
 private void SetNews(MyNews news)
 {
     m_newsControl.Show(news);
 }