Esempio n. 1
0
 internal void Show(MyNews news)
 {
     m_news.Clear();
     m_news.AddRange(news.Entry);
     m_currentEntryIndex = 0; // showing the newest entry by default
     RefreshShownEntry();
 }
Esempio n. 2
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_downloadedNews = (MyNews)m_newsSerializer.Deserialize(stream);

                    if (!MyFinalBuildConstants.IS_STABLE)
                    {
                        m_downloadedNews.Entry.RemoveAll(entry => entry.Dev);
                    }

                    StringBuilder text = new StringBuilder();
                    for (int i = 0; i < m_downloadedNews.Entry.Count; i++)
                    {
                        var newsItem = m_downloadedNews.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_downloadedNews.Entry[i] = new MyNewsEntry()
                        {
                            Title = newsItem.Title,
                            Version = newsItem.Version,
                            Date = newsItem.Date,
                            Text = text.ToString(),
                        };
                    }

                    if (MyFakes.TEST_NEWS)
                    {
                        var entry = m_downloadedNews.Entry[m_downloadedNews.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_downloadedNews.Entry.Add(entry);
                    }
                    m_downloadedNewsOK = true;
                }
            }
            catch (Exception e)
            {
                MyLog.Default.WriteLine("Error while downloading news: " + e.ToString());
            }
            finally
            {
                m_downloadedNewsFinished = true;
            }
        }
 private void SetNews(MyNews news)
 {
     m_newsControl.Show(news);
 }