Пример #1
0
        public RecipaediaScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/RecipaediaScreen");

            LoadContents(this, node);
            m_blocksList         = Children.Find <ListPanelWidget>("BlocksList");
            m_categoryLabel      = Children.Find <LabelWidget>("Category");
            m_prevCategoryButton = Children.Find <ButtonWidget>("PreviousCategory");
            m_nextCategoryButton = Children.Find <ButtonWidget>("NextCategory");
            m_detailsButton      = Children.Find <ButtonWidget>("DetailsButton");
            m_recipesButton      = Children.Find <ButtonWidget>("RecipesButton");
            m_categories.Add(null);
            m_categories.AddRange(BlocksManager.Categories);
            m_blocksList.ItemWidgetFactory = delegate(object item)
            {
                int             value = (int)item;
                int             num   = Terrain.ExtractContents(value);
                Block           block = BlocksManager.Blocks[num];
                XElement        node2 = ContentManager.Get <XElement>("Widgets/RecipaediaItem");
                ContainerWidget obj   = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                obj.Children.Find <BlockIconWidget>("RecipaediaItem.Icon").Value = value;
                obj.Children.Find <LabelWidget>("RecipaediaItem.Text").Text      = block.GetDisplayName(null, value);
                obj.Children.Find <LabelWidget>("RecipaediaItem.Details").Text   = block.GetDescription(value);
                return(obj);
            };
            m_blocksList.ItemClicked += delegate(object item)
            {
                if (m_blocksList.SelectedItem == item && item is int)
                {
                    ScreensManager.SwitchScreen("RecipaediaDescription", item, m_blocksList.Items.Cast <int>().ToList());
                }
            };
        }
 public SingleplayerScreen()
 {
     WidgetsManager.LoadWidgetContents((Widget)this.ScreenWidget, (object)this, ContentManager.Get <XElement>("Screens/SingleplayerScreen"));
     this.m_worldsListWidget = this.ScreenWidget.Children.Find <ListPanelWidget>("WorldsList", true);
     this.m_worldsListWidget.ItemWidgetFactory += (Func <object, Widget>)(item =>
     {
         WorldInfo worldInfo             = (WorldInfo)item;
         ContainerWidget containerWidget = (ContainerWidget)WidgetsManager.LoadWidget((object)this, ContentManager.Get <XElement>("Widgets/SavedWorldItem"), null);
         LabelWidget labelWidget1        = containerWidget.Children.Find <LabelWidget>("WorldItem.Name", true);
         LabelWidget labelWidget2        = containerWidget.Children.Find <LabelWidget>("WorldItem.Size", true);
         LabelWidget labelWidget3        = containerWidget.Children.Find <LabelWidget>("WorldItem.Date", true);
         LabelWidget labelWidget4        = containerWidget.Children.Find <LabelWidget>("WorldItem.GameMode", true);
         LabelWidget labelWidget5        = containerWidget.Children.Find <LabelWidget>("WorldItem.EnvironmentBehaviorMode", true);
         LabelWidget labelWidget6        = containerWidget.Children.Find <LabelWidget>("WorldItem.Version", true);
         containerWidget.Tag = (object)worldInfo;
         labelWidget1.Text   = worldInfo.Name;
         labelWidget2.Text   = string.Format("{0:0.00MB}", new object[1]
         {
             (object)(float)((double)worldInfo.Size / 1024.0 / 1024.0)
         });
         labelWidget3.Text = string.Format("{0:dd MMM yyyy HH:mm}", new object[1]
         {
             (object)worldInfo.LastSaveTime
         });
         labelWidget4.Text = worldInfo.GameMode.ToString();
         labelWidget5.Text = worldInfo.EnvironmentBehaviorMode.ToString();
         labelWidget6.Text = !(worldInfo.SerializationVersion != VersionsManager.SerializationVersion) ? string.Empty : (string.IsNullOrEmpty(worldInfo.SerializationVersion) ? "(unknown)" : "(" + worldInfo.SerializationVersion + ")");
         return((Widget)containerWidget);
     });
 }
Пример #3
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);
                }
            }
        }
Пример #4
0
        public ViewGameLogDialog()
        {
            XElement node = ContentManager.Get <XElement>("Dialogs/ViewGameLogDialog");

            LoadContents(this, node);
            m_listPanel              = Children.Find <ListPanelWidget>("ViewGameLogDialog.ListPanel");
            m_copyButton             = Children.Find <ButtonWidget>("ViewGameLogDialog.CopyButton");
            m_filterButton           = Children.Find <ButtonWidget>("ViewGameLogDialog.FilterButton");
            m_closeButton            = Children.Find <ButtonWidget>("ViewGameLogDialog.CloseButton");
            m_listPanel.ItemClicked += delegate(object item)
            {
                if (m_listPanel.SelectedItem == item)
                {
                    DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog("Log Item", item.ToString(), LanguageControl.Get("Usual", "ok"), null, null));
                }
            };
            PopulateList();
        }
Пример #5
0
        public EditCommandBlockDialog(CommandData data)
        {
            XElement node = ContentManager.Get <XElement>("Dialogs/EditCommandBlockDialog");

            WidgetsManager.LoadWidgetContents(this, this, node);
            textBox      = Children.Find <TextBoxWidget>("EditCommandBlockDialog.TextBox");
            list         = Children.Find <ListPanelWidget>("EditCommandBlockDialog.List");
            okButton     = Children.Find <ButtonWidget>("EditCommandBlockDIalog.OkButton");
            cancelButton = Children.Find <ButtonWidget>("EditCommandBlockDIalog.CancelButton");

            commandData          = data;
            command              = data.Command;
            textBox.Text         = command;
            textBox.TextChanged += TextChanged;

            list.ItemClicked += ListSelected;

            engine = GameManager.Project.FindSubsystem <SubsystemCommandEngine>(true);
        }
Пример #6
0
        public CommunityContentScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/CommunityContentScreen");

            LoadContents(this, node);
            m_listPanel                   = Children.Find <ListPanelWidget>("List");
            m_orderLabel                  = Children.Find <LabelWidget>("Order");
            m_changeOrderButton           = Children.Find <ButtonWidget>("ChangeOrder");
            m_filterLabel                 = Children.Find <LabelWidget>("Filter");
            m_changeFilterButton          = Children.Find <ButtonWidget>("ChangeFilter");
            m_downloadButton              = Children.Find <ButtonWidget>("Download");
            m_deleteButton                = Children.Find <ButtonWidget>("Delete");
            m_moreOptionsButton           = Children.Find <ButtonWidget>("MoreOptions");
            m_listPanel.ItemWidgetFactory = delegate(object item)
            {
                CommunityContentEntry communityContentEntry = item as CommunityContentEntry;
                if (communityContentEntry != null)
                {
                    XElement        node2 = ContentManager.Get <XElement>("Widgets/CommunityContentItem");
                    ContainerWidget obj   = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                    obj.Children.Find <RectangleWidget>("CommunityContentItem.Icon").Subtexture   = ExternalContentManager.GetEntryTypeIcon(communityContentEntry.Type);
                    obj.Children.Find <LabelWidget>("CommunityContentItem.Text").Text             = communityContentEntry.Name;
                    obj.Children.Find <LabelWidget>("CommunityContentItem.Details").Text          = $"{ExternalContentManager.GetEntryTypeDescription(communityContentEntry.Type)} {DataSizeFormatter.Format(communityContentEntry.Size)}";
                    obj.Children.Find <StarRatingWidget>("CommunityContentItem.Rating").Rating    = communityContentEntry.RatingsAverage;
                    obj.Children.Find <StarRatingWidget>("CommunityContentItem.Rating").IsVisible = (communityContentEntry.RatingsAverage > 0f);
                    obj.Children.Find <LabelWidget>("CommunityContentItem.ExtraText").Text        = communityContentEntry.ExtraText;
                    return(obj);
                }
                XElement        node3           = ContentManager.Get <XElement>("Widgets/CommunityContentItemMore");
                ContainerWidget containerWidget = (ContainerWidget)Widget.LoadWidget(this, node3, null);
                m_moreLink     = containerWidget.Children.Find <LinkWidget>("CommunityContentItemMore.Link");
                m_moreLink.Tag = (item as string);
                return(containerWidget);
            };
            m_listPanel.SelectionChanged += delegate
            {
                if (m_listPanel.SelectedItem != null && !(m_listPanel.SelectedItem is CommunityContentEntry))
                {
                    m_listPanel.SelectedItem = null;
                }
            };
        }
Пример #7
0
        public FurnitureInventoryPanel(CreativeInventoryWidget creativeInventoryWidget)
        {
            m_creativeInventoryWidget       = creativeInventoryWidget;
            ComponentFurnitureInventory     = creativeInventoryWidget.Entity.FindComponent <ComponentFurnitureInventory>(throwOnError: true);
            m_componentPlayer               = creativeInventoryWidget.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
            SubsystemFurnitureBlockBehavior = ComponentFurnitureInventory.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);
            SubsystemTerrain = ComponentFurnitureInventory.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            XElement node = ContentManager.Get <XElement>("Widgets/FurnitureInventoryPanel");

            LoadContents(this, node);
            m_furnitureSetList = Children.Find <ListPanelWidget>("FurnitureSetList");
            m_inventoryGrid    = Children.Find <GridPanelWidget>("InventoryGrid");
            m_addButton        = Children.Find <ButtonWidget>("AddButton");
            m_moreButton       = Children.Find <ButtonWidget>("MoreButton");
            for (int i = 0; i < m_inventoryGrid.RowsCount; i++)
            {
                for (int j = 0; j < m_inventoryGrid.ColumnsCount; j++)
                {
                    InventorySlotWidget widget = new InventorySlotWidget();
                    m_inventoryGrid.Children.Add(widget);
                    m_inventoryGrid.SetWidgetCell(widget, new Point2(j, i));
                }
            }
            ListPanelWidget furnitureSetList = m_furnitureSetList;

            furnitureSetList.ItemWidgetFactory   = (Func <object, Widget>)Delegate.Combine(furnitureSetList.ItemWidgetFactory, (Func <object, Widget>)((object item) => new FurnitureSetItemWidget(this, (FurnitureSet)item)));
            m_furnitureSetList.SelectionChanged += delegate
            {
                if (!m_ignoreSelectionChanged && ComponentFurnitureInventory.FurnitureSet != m_furnitureSetList.SelectedItem as FurnitureSet)
                {
                    ComponentFurnitureInventory.PageIndex    = 0;
                    ComponentFurnitureInventory.FurnitureSet = (m_furnitureSetList.SelectedItem as FurnitureSet);
                    if (ComponentFurnitureInventory.FurnitureSet == null)
                    {
                        m_furnitureSetList.SelectedIndex = 0;
                    }
                    AssignInventorySlots();
                }
            };
            m_populateNeeded = true;
        }
Пример #8
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);
        }
Пример #9
0
        public PlayScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/PlayScreen");

            LoadContents(this, node);
            m_worldsListWidget = Children.Find <ListPanelWidget>("WorldsList");
            ListPanelWidget worldsListWidget = m_worldsListWidget;

            worldsListWidget.ItemWidgetFactory = (Func <object, Widget>) Delegate.Combine(worldsListWidget.ItemWidgetFactory, (Func <object, Widget>) delegate(object item)
            {
                WorldInfo worldInfo             = (WorldInfo)item;
                XElement node2                  = ContentManager.Get <XElement>("Widgets/SavedWorldItem");
                ContainerWidget containerWidget = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                LabelWidget labelWidget         = containerWidget.Children.Find <LabelWidget>("WorldItem.Name");
                LabelWidget labelWidget2        = containerWidget.Children.Find <LabelWidget>("WorldItem.Details");
                containerWidget.Tag             = worldInfo;
                labelWidget.Text                = worldInfo.WorldSettings.Name;
                labelWidget2.Text               = string.Format("{0} | {1:dd MMM yyyy HH:mm} | {2} | {3} | {4}", DataSizeFormatter.Format(worldInfo.Size),
                                                                worldInfo.LastSaveTime.ToLocalTime(),
                                                                (worldInfo.PlayerInfos.Count > 1) ? string.Format(LanguageControl.GetContentWidgets(fName, 9), worldInfo.PlayerInfos.Count): string.Format(LanguageControl.GetContentWidgets(fName, 10), 1),
                                                                LanguageControl.Get("GameMode", worldInfo.WorldSettings.GameMode.ToString()),
                                                                LanguageControl.Get("EnvironmentBehaviorMode", worldInfo.WorldSettings.EnvironmentBehaviorMode.ToString()));
                if (worldInfo.SerializationVersion != VersionsManager.SerializationVersion)
                {
                    labelWidget2.Text = labelWidget2.Text + " | " + (string.IsNullOrEmpty(worldInfo.SerializationVersion) ? LanguageControl.GetContentWidgets("Usual", "Unknown") : ("(" + worldInfo.SerializationVersion + ")"));
                }
                return(containerWidget);
            });
            m_worldsListWidget.ScrollPosition = 0f;
            m_worldsListWidget.ScrollSpeed    = 0f;
            m_worldsListWidget.ItemClicked   += delegate(object item)
            {
                if (item != null && m_worldsListWidget.SelectedItem == item)
                {
                    Play(item);
                }
            };
        }
Пример #10
0
        public ExternalContentScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/ExternalContentScreen");

            LoadContents(this, node);
            m_directoryLabel                  = Children.Find <LabelWidget>("TopBar.Label");
            m_directoryList                   = Children.Find <ListPanelWidget>("DirectoryList");
            m_providerNameLabel               = Children.Find <LabelWidget>("ProviderName");
            m_changeProviderButton            = Children.Find <ButtonWidget>("ChangeProvider");
            m_loginLogoutButton               = Children.Find <ButtonWidget>("LoginLogout");
            m_upDirectoryButton               = Children.Find <ButtonWidget>("UpDirectory");
            m_actionButton                    = Children.Find <ButtonWidget>("Action");
            m_copyLinkButton                  = Children.Find <ButtonWidget>("CopyLink");
            m_directoryList.ItemWidgetFactory = delegate(object item)
            {
                ExternalContentEntry externalContentEntry2 = (ExternalContentEntry)item;
                XElement             node2           = ContentManager.Get <XElement>("Widgets/ExternalContentItem");
                ContainerWidget      containerWidget = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                string fileName = Storage.GetFileName(externalContentEntry2.Path);
                string text     = m_downloadedFiles.ContainsKey(externalContentEntry2.Path) ? LanguageControl.Get(fName, 11) : string.Empty;
                string text2    = (externalContentEntry2.Type != ExternalContentType.Directory) ? $"{ExternalContentManager.GetEntryTypeDescription(externalContentEntry2.Type)} | {DataSizeFormatter.Format(externalContentEntry2.Size)} | {externalContentEntry2.Time:dd-MMM-yyyy HH:mm}{text}" : ExternalContentManager.GetEntryTypeDescription(externalContentEntry2.Type);
                containerWidget.Children.Find <RectangleWidget>("ExternalContentItem.Icon").Subtexture = ExternalContentManager.GetEntryTypeIcon(externalContentEntry2.Type);
                containerWidget.Children.Find <LabelWidget>("ExternalContentItem.Text").Text           = fileName;
                containerWidget.Children.Find <LabelWidget>("ExternalContentItem.Details").Text        = text2;
                return(containerWidget);
            };
            m_directoryList.ItemClicked += delegate(object item)
            {
                if (m_directoryList.SelectedItem == item)
                {
                    ExternalContentEntry externalContentEntry = item as ExternalContentEntry;
                    if (externalContentEntry != null && externalContentEntry.Type == ExternalContentType.Directory)
                    {
                        SetPath(externalContentEntry.Path);
                    }
                }
            };
        }
Пример #11
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);
            }
        }
Пример #12
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);
            }
        }