示例#1
0
        public IEnumerable <ActiveExternalContentInfo> GetActiveExternalContent()
        {
            string downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.World, DirectoryName);

            if (!string.IsNullOrEmpty(downloadedContentAddress))
            {
                yield return(new ActiveExternalContentInfo
                {
                    Address = downloadedContentAddress,
                    DisplayName = WorldSettings.Name,
                    Type = ExternalContentType.World
                });
            }
            if (!BlocksTexturesManager.IsBuiltIn(WorldSettings.BlocksTextureName))
            {
                downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.BlocksTexture, WorldSettings.BlocksTextureName);
                if (!string.IsNullOrEmpty(downloadedContentAddress))
                {
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = BlocksTexturesManager.GetDisplayName(WorldSettings.BlocksTextureName),
                        Type = ExternalContentType.BlocksTexture
                    });
                }
            }
            SubsystemPlayers subsystemPlayers = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);

            foreach (PlayerData playersDatum in subsystemPlayers.PlayersData)
            {
                if (!CharacterSkinsManager.IsBuiltIn(playersDatum.CharacterSkinName))
                {
                    downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.CharacterSkin, playersDatum.CharacterSkinName);
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = CharacterSkinsManager.GetDisplayName(playersDatum.CharacterSkinName),
                        Type = ExternalContentType.CharacterSkin
                    });
                }
            }
            SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = base.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);

            foreach (FurnitureSet furnitureSet in subsystemFurnitureBlockBehavior.FurnitureSets)
            {
                if (furnitureSet.ImportedFrom != null)
                {
                    downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.FurniturePack, furnitureSet.ImportedFrom);
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = FurniturePacksManager.GetDisplayName(furnitureSet.ImportedFrom),
                        Type = ExternalContentType.FurniturePack
                    });
                }
            }
        }
示例#2
0
        public override void Update()
        {
            if (m_terrainGenerationButton.IsClicked && !m_isExistingWorld)
            {
                IList <int> enumValues = EnumUtils.GetEnumValues(typeof(TerrainGenerationMode));
                DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, 1), enumValues, 56f, (object e) => StringsManager.GetString("TerrainGenerationMode." + ((TerrainGenerationMode)e).ToString() + ".Name"), delegate(object e)
                {
                    if (m_worldSettings.GameMode != 0 && ((TerrainGenerationMode)e == TerrainGenerationMode.FlatContinent || (TerrainGenerationMode)e == TerrainGenerationMode.FlatIsland))
                    {
                        DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get(fName, 4), LanguageControl.Get(fName, 5), LanguageControl.Get("Usual", "ok"), null, null));
                    }
                    else
                    {
                        m_worldSettings.TerrainGenerationMode = (TerrainGenerationMode)e;
                        m_descriptionLabel.Text = StringsManager.GetString("TerrainGenerationMode." + m_worldSettings.TerrainGenerationMode.ToString() + ".Description");
                    }
                }));
            }
            if (m_islandSizeEW.IsSliding && !m_isExistingWorld)
            {
                m_worldSettings.IslandSize.X = m_islandSizes[MathUtils.Clamp((int)m_islandSizeEW.Value, 0, m_islandSizes.Length - 1)];
            }
            if (m_islandSizeNS.IsSliding && !m_isExistingWorld)
            {
                m_worldSettings.IslandSize.Y = m_islandSizes[MathUtils.Clamp((int)m_islandSizeNS.Value, 0, m_islandSizes.Length - 1)];
            }
            if (m_flatTerrainLevelSlider.IsSliding && !m_isExistingWorld)
            {
                m_worldSettings.TerrainLevel = MathUtils.Clamp((int)m_flatTerrainLevelSlider.Value / (int)m_flatTerrainLevelSlider.Granularity * (int)m_flatTerrainLevelSlider.Granularity, 2, 252);
                m_descriptionLabel.Text      = StringsManager.GetString("FlatTerrainLevel.Description");
            }
            if (m_flatTerrainShoreRoughnessSlider.IsSliding && !m_isExistingWorld)
            {
                m_worldSettings.ShoreRoughness = m_flatTerrainShoreRoughnessSlider.Value;
                m_descriptionLabel.Text        = StringsManager.GetString("FlatTerrainShoreRoughness.Description");
            }
            if (m_flatTerrainBlockButton.IsClicked && !m_isExistingWorld)
            {
                int[] items = new int[19]
                {
                    8,
                    2,
                    7,
                    3,
                    67,
                    66,
                    4,
                    5,
                    26,
                    73,
                    21,
                    46,
                    47,
                    15,
                    62,
                    68,
                    126,
                    71,
                    1
                };
                DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, 2), items, 72f, delegate(object index)
                {
                    XElement node2       = ContentManager.Get <XElement>("Widgets/SelectBlockItem");
                    ContainerWidget obj2 = (ContainerWidget)Widget.LoadWidget(null, node2, null);
                    obj2.Children.Find <BlockIconWidget>("SelectBlockItem.Block").Contents = (int)index;
                    obj2.Children.Find <LabelWidget>("SelectBlockItem.Text").Text          = BlocksManager.Blocks[(int)index].GetDisplayName(null, Terrain.MakeBlockValue((int)index));
                    return(obj2);
                }, delegate(object index)
                {
                    m_worldSettings.TerrainBlockIndex = (int)index;
                }));
            }
            if (m_flatTerrainMagmaOceanCheckbox.IsClicked)
            {
                m_worldSettings.TerrainOceanBlockIndex = ((m_worldSettings.TerrainOceanBlockIndex == 18) ? 92 : 18);
                m_descriptionLabel.Text = StringsManager.GetString("FlatTerrainMagmaOcean.Description");
            }
            if (m_seaLevelOffsetSlider.IsSliding && !m_isExistingWorld)
            {
                m_worldSettings.SeaLevelOffset = (int)m_seaLevelOffsetSlider.Value;
                m_descriptionLabel.Text        = StringsManager.GetString("SeaLevelOffset.Description");
            }
            if (m_temperatureOffsetSlider.IsSliding && !m_isExistingWorld)
            {
                m_worldSettings.TemperatureOffset = m_temperatureOffsetSlider.Value;
                m_descriptionLabel.Text           = StringsManager.GetString("TemperatureOffset.Description");
            }
            if (m_humidityOffsetSlider.IsSliding && !m_isExistingWorld)
            {
                m_worldSettings.HumidityOffset = m_humidityOffsetSlider.Value;
                m_descriptionLabel.Text        = StringsManager.GetString("HumidityOffset.Description");
            }
            if (m_biomeSizeSlider.IsSliding && !m_isExistingWorld)
            {
                m_worldSettings.BiomeSize = m_biomeSizes[MathUtils.Clamp((int)m_biomeSizeSlider.Value, 0, m_biomeSizes.Length - 1)];
                m_descriptionLabel.Text   = StringsManager.GetString("BiomeSize.Description");
            }
            if (m_blocksTextureButton.IsClicked)
            {
                BlocksTexturesManager.UpdateBlocksTexturesList();
                ListSelectionDialog dialog = new ListSelectionDialog(LanguageControl.Get(fName, 3), BlocksTexturesManager.BlockTexturesNames, 64f, delegate(object item)
                {
                    XElement node       = ContentManager.Get <XElement>("Widgets/BlocksTextureItem");
                    ContainerWidget obj = (ContainerWidget)Widget.LoadWidget(this, node, null);
                    Texture2D texture2  = m_blockTexturesCache.GetTexture((string)item);
                    obj.Children.Find <LabelWidget>("BlocksTextureItem.Text").Text           = BlocksTexturesManager.GetDisplayName((string)item);
                    obj.Children.Find <LabelWidget>("BlocksTextureItem.Details").Text        = $"{texture2.Width}x{texture2.Height}";
                    obj.Children.Find <RectangleWidget>("BlocksTextureItem.Icon").Subtexture = new Subtexture(texture2, Vector2.Zero, Vector2.One);
                    return(obj);
                }, delegate(object item)
                {
                    m_worldSettings.BlocksTextureName = (string)item;
                });
                DialogsManager.ShowDialog(null, dialog);
                m_descriptionLabel.Text = StringsManager.GetString("BlocksTexture.Description");
            }
            if (m_paletteButton.IsClicked)
            {
                DialogsManager.ShowDialog(null, new EditPaletteDialog(m_worldSettings.Palette));
            }
            if (m_supernaturalCreaturesButton.IsClicked)
            {
                m_worldSettings.AreSupernaturalCreaturesEnabled = !m_worldSettings.AreSupernaturalCreaturesEnabled;
                m_descriptionLabel.Text = StringsManager.GetString("SupernaturalCreatures." + m_worldSettings.AreSupernaturalCreaturesEnabled.ToString());
            }
            if (m_friendlyFireButton.IsClicked)
            {
                m_worldSettings.IsFriendlyFireEnabled = !m_worldSettings.IsFriendlyFireEnabled;
                m_descriptionLabel.Text = StringsManager.GetString("FriendlyFire." + m_worldSettings.IsFriendlyFireEnabled.ToString());
            }
            if (m_environmentBehaviorButton.IsClicked)
            {
                IList <int> enumValues2 = EnumUtils.GetEnumValues(typeof(EnvironmentBehaviorMode));
                m_worldSettings.EnvironmentBehaviorMode = (EnvironmentBehaviorMode)((enumValues2.IndexOf((int)m_worldSettings.EnvironmentBehaviorMode) + 1) % enumValues2.Count);
                m_descriptionLabel.Text = StringsManager.GetString("EnvironmentBehaviorMode." + m_worldSettings.EnvironmentBehaviorMode.ToString() + ".Description");
            }
            if (m_timeOfDayButton.IsClicked)
            {
                IList <int> enumValues3 = EnumUtils.GetEnumValues(typeof(TimeOfDayMode));
                m_worldSettings.TimeOfDayMode = (TimeOfDayMode)((enumValues3.IndexOf((int)m_worldSettings.TimeOfDayMode) + 1) % enumValues3.Count);
                m_descriptionLabel.Text       = StringsManager.GetString("TimeOfDayMode." + m_worldSettings.TimeOfDayMode.ToString() + ".Description");
            }
            if (m_weatherEffectsButton.IsClicked)
            {
                m_worldSettings.AreWeatherEffectsEnabled = !m_worldSettings.AreWeatherEffectsEnabled;
                m_descriptionLabel.Text = StringsManager.GetString("WeatherMode." + m_worldSettings.AreWeatherEffectsEnabled.ToString());
            }
            if (m_adventureRespawnButton.IsClicked)
            {
                m_worldSettings.IsAdventureRespawnAllowed = !m_worldSettings.IsAdventureRespawnAllowed;
                m_descriptionLabel.Text = StringsManager.GetString("AdventureRespawnMode." + m_worldSettings.IsAdventureRespawnAllowed.ToString());
            }
            if (m_adventureSurvivalMechanicsButton.IsClicked)
            {
                m_worldSettings.AreAdventureSurvivalMechanicsEnabled = !m_worldSettings.AreAdventureSurvivalMechanicsEnabled;
                m_descriptionLabel.Text = StringsManager.GetString("AdventureSurvivalMechanics." + m_worldSettings.AreAdventureSurvivalMechanicsEnabled.ToString());
            }
            m_creativeModePanel.IsVisible     = (m_worldSettings.GameMode == GameMode.Creative);
            m_newWorldOnlyPanel.IsVisible     = !m_isExistingWorld;
            m_continentTerrainPanel.IsVisible = (m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.Continent || m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.FlatContinent);
            m_islandTerrainPanel.IsVisible    = (m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.Island || m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.FlatIsland);
            m_flatTerrainPanel.IsVisible      = (m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.FlatContinent || m_worldSettings.TerrainGenerationMode == TerrainGenerationMode.FlatIsland);
            m_terrainGenerationButton.Text    = StringsManager.GetString("TerrainGenerationMode." + m_worldSettings.TerrainGenerationMode.ToString() + ".Name");
            m_islandSizeEW.Value                      = FindNearestIndex(m_islandSizes, m_worldSettings.IslandSize.X);
            m_islandSizeEW.Text                       = m_worldSettings.IslandSize.X.ToString();
            m_islandSizeNS.Value                      = FindNearestIndex(m_islandSizes, m_worldSettings.IslandSize.Y);
            m_islandSizeNS.Text                       = m_worldSettings.IslandSize.Y.ToString();
            m_flatTerrainLevelSlider.Value            = m_worldSettings.TerrainLevel;
            m_flatTerrainLevelSlider.Text             = m_worldSettings.TerrainLevel.ToString();
            m_flatTerrainShoreRoughnessSlider.Value   = m_worldSettings.ShoreRoughness;
            m_flatTerrainShoreRoughnessSlider.Text    = $"{m_worldSettings.ShoreRoughness * 100f:0}%";
            m_flatTerrainBlock.Contents               = m_worldSettings.TerrainBlockIndex;
            m_flatTerrainMagmaOceanCheckbox.IsChecked = (m_worldSettings.TerrainOceanBlockIndex == 92);
            string text = (BlocksManager.Blocks[m_worldSettings.TerrainBlockIndex] != null) ? BlocksManager.Blocks[m_worldSettings.TerrainBlockIndex].GetDisplayName(null, Terrain.MakeBlockValue(m_worldSettings.TerrainBlockIndex)) : string.Empty;

            m_flatTerrainBlockLabel.Text = ((text.Length > 10) ? (text.Substring(0, 10) + "...") : text);
            Texture2D texture = m_blockTexturesCache.GetTexture(m_worldSettings.BlocksTextureName);

            m_blocksTextureIcon.Subtexture          = new Subtexture(texture, Vector2.Zero, Vector2.One);
            m_blocksTextureLabel.Text               = BlocksTexturesManager.GetDisplayName(m_worldSettings.BlocksTextureName);
            m_blocksTextureDetails.Text             = $"{texture.Width}x{texture.Height}";
            m_seaLevelOffsetSlider.Value            = m_worldSettings.SeaLevelOffset;
            m_seaLevelOffsetSlider.Text             = FormatOffset(m_worldSettings.SeaLevelOffset);
            m_temperatureOffsetSlider.Value         = m_worldSettings.TemperatureOffset;
            m_temperatureOffsetSlider.Text          = FormatOffset(m_worldSettings.TemperatureOffset);
            m_humidityOffsetSlider.Value            = m_worldSettings.HumidityOffset;
            m_humidityOffsetSlider.Text             = FormatOffset(m_worldSettings.HumidityOffset);
            m_biomeSizeSlider.Value                 = FindNearestIndex(m_biomeSizes, m_worldSettings.BiomeSize);
            m_biomeSizeSlider.Text                  = m_worldSettings.BiomeSize.ToString() + "x";
            m_environmentBehaviorButton.Text        = LanguageControl.Get("EnvironmentBehaviorMode", m_worldSettings.EnvironmentBehaviorMode.ToString());
            m_timeOfDayButton.Text                  = LanguageControl.Get("TimeOfDayMode", m_worldSettings.TimeOfDayMode.ToString());
            m_weatherEffectsButton.Text             = (m_worldSettings.AreWeatherEffectsEnabled ? LanguageControl.Get("Usual", "enable") : LanguageControl.Get("Usual", "disable"));
            m_adventureRespawnButton.Text           = (m_worldSettings.IsAdventureRespawnAllowed ? LanguageControl.Get("Usual", "allowed") : LanguageControl.Get("Usual", "not allowed"));
            m_adventureSurvivalMechanicsButton.Text = (m_worldSettings.AreAdventureSurvivalMechanicsEnabled ? LanguageControl.Get("Usual", "enable") : LanguageControl.Get("Usual", "disable"));
            m_supernaturalCreaturesButton.Text      = (m_worldSettings.AreSupernaturalCreaturesEnabled ? LanguageControl.Get("Usual", "enable") : LanguageControl.Get("Usual", "disable"));
            m_friendlyFireButton.Text               = (m_worldSettings.IsFriendlyFireEnabled ? LanguageControl.Get("Usual", "allowed") : LanguageControl.Get("Usual", "not allowed"));
            if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked)
            {
                ScreensManager.SwitchScreen(ScreensManager.PreviousScreen);
            }
        }