Пример #1
0
        public void PopulateList(string cursor)
        {
            string text = string.Empty;

            if (SettingsManager.CommunityContentMode == CommunityContentMode.Strict)
            {
                text = "1";
            }
            if (SettingsManager.CommunityContentMode == CommunityContentMode.Normal)
            {
                text = "0";
            }
            string text2    = (m_filter is string) ? ((string)m_filter) : string.Empty;
            string text3    = (m_filter is ExternalContentType) ? LanguageControl.Get(fName, m_filter.ToString()) : string.Empty;
            string text4    = LanguageControl.Get(fName, m_order.ToString());
            string cacheKey = text2 + "\n" + text3 + "\n" + text4 + "\n" + text;

            m_moreLink = null;
            if (string.IsNullOrEmpty(cursor))
            {
                m_listPanel.ClearItems();
                m_listPanel.ScrollPosition = 0f;
                if (m_contentExpiryTime != 0.0 && Time.RealTime < m_contentExpiryTime && m_itemsCache.TryGetValue(cacheKey, out IEnumerable <object> value))
                {
                    foreach (object item in value)
                    {
                        m_listPanel.AddItem(item);
                    }
                    return;
                }
            }
            CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 2), autoHideOnCancel: false);

            DialogsManager.ShowDialog(null, busyDialog);
            CommunityContentManager.List(cursor, text2, text3, text, text4, busyDialog.Progress, delegate(List <CommunityContentEntry> list, string nextCursor)
            {
                DialogsManager.HideDialog(busyDialog);
                m_contentExpiryTime = Time.RealTime + 300.0;
                while (m_listPanel.Items.Count > 0 && !(m_listPanel.Items[m_listPanel.Items.Count - 1] is CommunityContentEntry))
                {
                    m_listPanel.RemoveItemAt(m_listPanel.Items.Count - 1);
                }
                foreach (CommunityContentEntry item2 in list)
                {
                    m_listPanel.AddItem(item2);
                }
                if (list.Count > 0 && !string.IsNullOrEmpty(nextCursor))
                {
                    m_listPanel.AddItem(nextCursor);
                }
                m_itemsCache[cacheKey] = new List <object>(m_listPanel.Items);
            }, delegate(Exception error)
            {
                DialogsManager.HideDialog(busyDialog);
                DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
            });
        }
Пример #2
0
        public override void Enter(object[] parameters)
        {
            BusyDialog dialog = new BusyDialog(LanguageControl.GetContentWidgets(fName, 5), null);

            DialogsManager.ShowDialog(null, dialog);
            Task.Run(delegate
            {
                WorldInfo selectedItem = (WorldInfo)m_worldsListWidget.SelectedItem;
                WorldsManager.UpdateWorldsList();
                List <WorldInfo> worldInfos = new List <WorldInfo>(WorldsManager.WorldInfos);
                worldInfos.Sort((WorldInfo w1, WorldInfo w2) => DateTime.Compare(w2.LastSaveTime, w1.LastSaveTime));
                Dispatcher.Dispatch(delegate
                {
                    m_worldsListWidget.ClearItems();
                    foreach (WorldInfo item in worldInfos)
                    {
                        m_worldsListWidget.AddItem(item);
                    }
                    if (selectedItem != null)
                    {
                        m_worldsListWidget.SelectedItem = worldInfos.FirstOrDefault((WorldInfo wi) => wi.DirectoryName == selectedItem.DirectoryName);
                    }
                    DialogsManager.HideDialog(dialog);
                });
            });
        }
Пример #3
0
        void ShowList(IEnumerable <string> strs)
        {
            var children = list.Items;
            int index    = 0;

            foreach (string s in strs)
            {
                if (index < children.Count)
                {
                    ((LabelWidget)children[index]).Text = s;
                }
                else
                {
                    list.AddItem(new LabelWidget
                    {
                        Text = s,
                        HorizontalAlignment = WidgetAlignment.Center,
                        VerticalAlignment   = WidgetAlignment.Center
                    });
                }
                index++;
            }

            int count = children.Count;

            if (index < count)
            {
                for (int i = index; i < count; i++)
                {
                    list.RemoveItemAt(i);
                }
            }
        }
Пример #4
0
 public void UpdateList()
 {
     m_directoryList.ClearItems();
     if (m_externalContentProvider != null && m_externalContentProvider.IsLoggedIn)
     {
         CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 9), autoHideOnCancel: false);
         DialogsManager.ShowDialog(null, busyDialog);
         m_externalContentProvider.List(m_path, busyDialog.Progress, delegate(ExternalContentEntry entry)
         {
             DialogsManager.HideDialog(busyDialog);
             List <ExternalContentEntry> list = new List <ExternalContentEntry>(entry.ChildEntries.Where((ExternalContentEntry e) => EntryFilter(e)).Take(1000));
             m_directoryList.ClearItems();
             list.Sort(delegate(ExternalContentEntry e1, ExternalContentEntry e2)
             {
                 if (e1.Type == ExternalContentType.Directory && e2.Type != ExternalContentType.Directory)
                 {
                     return(-1);
                 }
                 return((e1.Type != ExternalContentType.Directory && e2.Type == ExternalContentType.Directory) ? 1 : string.Compare(e1.Path, e2.Path));
             });
             foreach (ExternalContentEntry item in list)
             {
                 m_directoryList.AddItem(item);
             }
         }, delegate(Exception error)
         {
             DialogsManager.HideDialog(busyDialog);
             DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
         });
     }
 }
Пример #5
0
 public void Populate()
 {
     ComponentFurnitureInventory.FillSlots();
     try
     {
         m_ignoreSelectionChanged = true;
         m_furnitureSetList.ClearItems();
         m_furnitureSetList.AddItem(null);
         foreach (FurnitureSet furnitureSet in SubsystemFurnitureBlockBehavior.FurnitureSets)
         {
             m_furnitureSetList.AddItem(furnitureSet);
         }
     }
     finally
     {
         m_ignoreSelectionChanged = false;
     }
     m_furnitureSetList.SelectedItem = ComponentFurnitureInventory.FurnitureSet;
     AssignInventorySlots();
 }
Пример #6
0
        public void PopulateList()
        {
            m_listPanel.ItemWidgetFactory = delegate(object item)
            {
                string text  = (item != null) ? item.ToString() : string.Empty;
                Color  color = Color.Gray;
                if (text.Contains("ERROR:"))
                {
                    color = Color.Red;
                }
                else if (text.Contains("WARNING:"))
                {
                    color = Color.DarkYellow;
                }
                else if (text.Contains("INFO:"))
                {
                    color = Color.LightGray;
                }
                return(new LabelWidget
                {
                    Text = text,
                    Font = BitmapFont.DebugFont,
                    HorizontalAlignment = WidgetAlignment.Near,
                    VerticalAlignment = WidgetAlignment.Center,
                    Color = color
                });
            };
            List <string> recentLogLines = GameLogSink.GetRecentLogLines(131072);

            m_listPanel.ClearItems();
            if (recentLogLines.Count > 1000)
            {
                recentLogLines.RemoveRange(0, recentLogLines.Count - 1000);
            }
            foreach (string item in recentLogLines)
            {
                if (m_filter == LogType.Warning)
                {
                    if (!item.Contains("WARNING:") && !item.Contains("ERROR:"))
                    {
                        continue;
                    }
                }
                else if (m_filter == LogType.Error && !item.Contains("ERROR:"))
                {
                    continue;
                }
                m_listPanel.AddItem(item);
            }
            m_listPanel.ScrollPosition = (float)m_listPanel.Items.Count * m_listPanel.ItemSize;
        }
Пример #7
0
        public HelpScreen()
        {
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("Screens/HelpScreen"));
            m_topicsList       = Children.Find <ListPanelWidget>("TopicsList", true);
            m_recipaediaButton = Children.Find <ButtonWidget>("RecipaediaButton", true);
            m_bestiaryButton   = Children.Find <ButtonWidget>("BestiaryButton", true);

            m_topicsList.ItemWidgetFactory = delegate(object item)
            {
                var      helpTopic3 = (HelpTopic)item;
                XElement node2      = ContentManager.Get <XElement>("Widgets/HelpTopicItem");
                var      obj        = (ContainerWidget)WidgetsManager.LoadWidget(this, node2, null);
                obj.Children.Find <LabelWidget>("HelpTopicItem.Title", true).Text = helpTopic3.Title;
                return(obj);
            };
            m_topicsList.ItemClicked += delegate(object item)
            {
                if (item is HelpTopic helpTopic2)
                {
                    ShowTopic(helpTopic2);
                }
            };
            for (var i = ContentManager.CombineXml(ContentManager.Get <XElement>("Help"), ModsManager.GetEntries(".hlp"), "Title", "Name", "Topic").Elements().GetEnumerator(); i.MoveNext();)
            {
                var element  = i.Current;
                var strArray = XmlUtils.GetAttributeValue(element, "DisabledPlatforms", string.Empty).Split(',');
                if (strArray.FirstOrDefault(Match) == null)
                {
                    var attributeValue1 = XmlUtils.GetAttributeValue(element, "Name", string.Empty);
                    var attributeValue2 = XmlUtils.GetAttributeValue <string>(element, "Title");
                    var str1            = string.Empty;
                    strArray = element.Value.Split('\n');
                    for (int i1 = 0; i1 < strArray.Length; i1++)
                    {
                        str1 = str1 + strArray[i1].Trim() + " ";
                    }
                    var helpTopic = new HelpTopic {
                        Name = attributeValue1, Title = attributeValue2, Text = str1.Replace("\r", "").Replace("’", "'").Replace("\\n", "\n")
                    };
                    if (!string.IsNullOrEmpty(helpTopic.Name))
                    {
                        m_topics.Add(helpTopic.Name, helpTopic);
                    }
                    m_topicsList.AddItem(helpTopic);
                }
            }
        }
Пример #8
0
        public void PopulateBlocksList()
        {
            m_listCategoryIndex = m_categoryIndex;
            string text = m_categories[m_categoryIndex];

            m_blocksList.ScrollPosition = 0f;
            m_blocksList.ClearItems();
            foreach (Block item in BlocksManager.Blocks.OrderBy((Block b) => b.DisplayOrder))
            {
                foreach (int creativeValue in item.GetCreativeValues())
                {
                    if (text == null || item.GetCategory(creativeValue) == text)
                    {
                        m_blocksList.AddItem(creativeValue);
                    }
                }
            }
        }
Пример #9
0
        public ListSelectionDialog(string title, IEnumerable items, float itemSize, Func <object, Widget> itemWidgetFactory, Action <object> selectionHandler)
        {
            m_selectionHandler = selectionHandler;
            XElement node = ContentManager.Get <XElement>("Dialogs/ListSelectionDialog");

            LoadContents(this, node);
            m_titleLabelWidget           = Children.Find <LabelWidget>("ListSelectionDialog.Title");
            m_listWidget                 = Children.Find <ListPanelWidget>("ListSelectionDialog.List");
            m_contentWidget              = Children.Find <CanvasWidget>("ListSelectionDialog.Content");
            m_titleLabelWidget.Text      = title;
            m_titleLabelWidget.IsVisible = !string.IsNullOrEmpty(title);
            m_listWidget.ItemSize        = itemSize;
            if (itemWidgetFactory != null)
            {
                m_listWidget.ItemWidgetFactory = itemWidgetFactory;
            }
            foreach (object item in items)
            {
                m_listWidget.AddItem(item);
            }
            int   num = m_listWidget.Items.Count;
            float num2;

            while (true)
            {
                if (num >= 0)
                {
                    num2 = MathUtils.Min((float)num + 0.5f, m_listWidget.Items.Count);
                    if (num2 * itemSize <= m_contentWidget.Size.Y)
                    {
                        break;
                    }
                    num--;
                    continue;
                }
                return;
            }
            m_contentWidget.Size = new Vector2(m_contentWidget.Size.X, num2 * itemSize);
        }
Пример #10
0
        public BestiaryScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/BestiaryScreen");

            LoadContents(this, node);
            m_creaturesList = Children.Find <ListPanelWidget>("CreaturesList");
            m_creaturesList.ItemWidgetFactory = delegate(object item)
            {
                BestiaryCreatureInfo bestiaryCreatureInfo2 = (BestiaryCreatureInfo)item;
                XElement             node2       = ContentManager.Get <XElement>("Widgets/BestiaryItem");
                ContainerWidget      obj         = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                ModelWidget          modelWidget = obj.Children.Find <ModelWidget>("BestiaryItem.Model");
                SetupBestiaryModelWidget(bestiaryCreatureInfo2, modelWidget, (m_creaturesList.Items.IndexOf(item) % 2 == 0) ? new Vector3(-1f, 0f, -1f) : new Vector3(1f, 0f, -1f), autoRotate: false, autoAspect: false);
                obj.Children.Find <LabelWidget>("BestiaryItem.Text").Text    = bestiaryCreatureInfo2.DisplayName;
                obj.Children.Find <LabelWidget>("BestiaryItem.Details").Text = bestiaryCreatureInfo2.Description;
                return(obj);
            };
            m_creaturesList.ItemClicked += delegate(object item)
            {
                ScreensManager.SwitchScreen("BestiaryDescription", item, m_creaturesList.Items.Cast <BestiaryCreatureInfo>().ToList());
            };
            List <BestiaryCreatureInfo> list = new List <BestiaryCreatureInfo>();

            foreach (ValuesDictionary entitiesValuesDictionary in DatabaseManager.EntitiesValuesDictionaries)
            {
                ValuesDictionary valuesDictionary = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentCreature));
                if (valuesDictionary != null)
                {
                    string value = valuesDictionary.GetValue <string>("DisplayName");
                    if (value.StartsWith("[") && value.EndsWith("]"))
                    {
                        string[] lp = value.Substring(1, value.Length - 2).Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                        value = LanguageControl.GetDatabase("DisplayName", lp[1]);
                    }
                    if (!string.IsNullOrEmpty(value))
                    {
                        int order = -1;
                        ValuesDictionary value2 = entitiesValuesDictionary.GetValue <ValuesDictionary>("CreatureEggData", null);
                        ValuesDictionary value3 = entitiesValuesDictionary.GetValue <ValuesDictionary>("Player", null);
                        if (value2 != null || value3 != null)
                        {
                            if (value2 != null)
                            {
                                int value4 = value2.GetValue <int>("EggTypeIndex");
                                if (value4 < 0)
                                {
                                    continue;
                                }
                                order = value4;
                            }
                            ValuesDictionary valuesDictionary2 = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentCreatureModel));
                            ValuesDictionary valuesDictionary3 = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentBody));
                            ValuesDictionary valuesDictionary4 = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentHealth));
                            ValuesDictionary valuesDictionary5 = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentMiner));
                            ValuesDictionary valuesDictionary6 = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentLocomotion));
                            ValuesDictionary valuesDictionary7 = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentHerdBehavior));
                            ValuesDictionary valuesDictionary8 = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentMount));
                            ValuesDictionary valuesDictionary9 = DatabaseManager.FindValuesDictionaryForComponent(entitiesValuesDictionary, typeof(ComponentLoot));
                            string           dy = valuesDictionary.GetValue <string>("Description");
                            if (dy.StartsWith("[") && dy.EndsWith("]"))
                            {
                                string[] lp = dy.Substring(1, dy.Length - 2).Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                                dy = LanguageControl.GetDatabase("Description", lp[1]);
                            }
                            BestiaryCreatureInfo bestiaryCreatureInfo = new BestiaryCreatureInfo
                            {
                                Order            = order,
                                DisplayName      = value,
                                Description      = dy,
                                ModelName        = valuesDictionary2.GetValue <string>("ModelName"),
                                TextureOverride  = valuesDictionary2.GetValue <string>("TextureOverride"),
                                Mass             = valuesDictionary3.GetValue <float>("Mass"),
                                AttackResilience = valuesDictionary4.GetValue <float>("AttackResilience"),
                                AttackPower      = (valuesDictionary5?.GetValue <float>("AttackPower") ?? 0f),
                                MovementSpeed    = MathUtils.Max(valuesDictionary6.GetValue <float>("WalkSpeed"), valuesDictionary6.GetValue <float>("FlySpeed"), valuesDictionary6.GetValue <float>("SwimSpeed")),
                                JumpHeight       = MathUtils.Sqr(valuesDictionary6.GetValue <float>("JumpSpeed")) / 20f,
                                IsHerding        = (valuesDictionary7 != null),
                                CanBeRidden      = (valuesDictionary8 != null),
                                HasSpawnerEgg    = (value2?.GetValue <bool>("ShowEgg") ?? false),
                                Loot             = ((valuesDictionary9 != null) ? ComponentLoot.ParseLootList(valuesDictionary9.GetValue <ValuesDictionary>("Loot")) : new List <ComponentLoot.Loot>())
                            };
                            if (value3 != null && entitiesValuesDictionary.DatabaseObject.Name.ToLower().Contains("female"))
                            {
                                bestiaryCreatureInfo.AttackPower      *= 0.8f;
                                bestiaryCreatureInfo.AttackResilience *= 0.8f;
                                bestiaryCreatureInfo.MovementSpeed    *= 1.03f;
                                bestiaryCreatureInfo.JumpHeight       *= MathUtils.Sqr(1.03f);
                            }
                            list.Add(bestiaryCreatureInfo);
                        }
                    }
                }
            }
            foreach (BestiaryCreatureInfo item in list.OrderBy((BestiaryCreatureInfo ci) => ci.Order))
            {
                m_creaturesList.AddItem(item);
            }
        }
Пример #11
0
        public HelpScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/HelpScreen");

            LoadContents(this, node);
            m_topicsList                   = Children.Find <ListPanelWidget>("TopicsList");
            m_recipaediaButton             = Children.Find <ButtonWidget>("RecipaediaButton");
            m_bestiaryButton               = Children.Find <ButtonWidget>("BestiaryButton");
            m_topicsList.ItemWidgetFactory = delegate(object item)
            {
                HelpTopic       helpTopic3 = (HelpTopic)item;
                XElement        node2      = ContentManager.Get <XElement>("Widgets/HelpTopicItem");
                ContainerWidget obj        = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                obj.Children.Find <LabelWidget>("HelpTopicItem.Title").Text = helpTopic3.Title;
                return(obj);
            };
            m_topicsList.ItemClicked += delegate(object item)
            {
                HelpTopic helpTopic2 = item as HelpTopic;
                if (helpTopic2 != null)
                {
                    ShowTopic(helpTopic2);
                }
            };
            foreach (KeyValuePair <string, Dictionary <string, string> > item in LanguageControl.items2["Help"])
            {
                if (item.Value.ContainsKey("DisabledPlatforms"))
                {
                    item.Value.TryGetValue("DisabledPlatforms", out string displa);
                    if (displa.Split(new string[] { "," }, StringSplitOptions.None).FirstOrDefault((string s) => s.Trim().ToLower() == VersionsManager.Platform.ToString().ToLower()) == null)
                    {
                        continue;
                    }
                }
                item.Value.TryGetValue("Title", out string Title);
                item.Value.TryGetValue("Name", out string Name);
                item.Value.TryGetValue("value", out string value);
                if (string.IsNullOrEmpty(Title))
                {
                    Title = string.Empty;
                }
                if (string.IsNullOrEmpty(Name))
                {
                    Name = string.Empty;
                }
                if (string.IsNullOrEmpty(value))
                {
                    value = string.Empty;
                }

                string   attributeValue  = Name;
                string   attributeValue2 = Title;
                string   text            = string.Empty;
                string[] array           = value.Split(new string[] { "\n" }, StringSplitOptions.None);
                foreach (string text2 in array)
                {
                    text = text + text2.Trim() + " ";
                }
                text = text.Replace("\r", "");
                text = text.Replace("’", "'");
                text = text.Replace("\\n", "\n");
                HelpTopic helpTopic = new HelpTopic
                {
                    Name  = attributeValue,
                    Title = attributeValue2,
                    Text  = text
                };
                if (!string.IsNullOrEmpty(helpTopic.Name))
                {
                    m_topics.Add(helpTopic.Name, helpTopic);
                }
                m_topicsList.AddItem(helpTopic);
            }
        }