Example #1
0
        public override void Update()
        {
            m_characterSkinsCache.GetTexture(m_playerData.CharacterSkinName);
            m_playerModel.PlayerClass       = m_playerData.PlayerClass;
            m_playerModel.CharacterSkinName = m_playerData.CharacterSkinName;
            m_playerClassButton.Text        = m_playerData.PlayerClass.ToString();
            if (!m_nameTextBox.HasFocus)
            {
                m_nameTextBox.Text = m_playerData.Name;
            }
            m_characterSkinLabel.Text = CharacterSkinsManager.GetDisplayName(m_playerData.CharacterSkinName);
            m_controlsLabel.Text      = GetDeviceDisplayName(m_inputDevices.Where((WidgetInputDevice id) => (id & m_playerData.InputDevice) != 0).FirstOrDefault());
            ValuesDictionary valuesDictionary = DatabaseManager.FindValuesDictionaryForComponent(DatabaseManager.FindEntityValuesDictionary(m_playerData.GetEntityTemplateName(), throwIfNotFound: true), typeof(ComponentCreature));
            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]);
            }
            m_descriptionLabel.Text = dy;
            if (m_playerClassButton.IsClicked)
            {
                m_playerData.PlayerClass = ((m_playerData.PlayerClass == PlayerClass.Male) ? PlayerClass.Female : PlayerClass.Male);
                m_playerData.RandomizeCharacterSkin();
                if (m_playerData.IsDefaultName)
                {
                    m_playerData.ResetName();
                }
            }
            if (m_characterSkinButton.IsClicked)
            {
                CharacterSkinsManager.UpdateCharacterSkinsList();
                IEnumerable <string> items  = CharacterSkinsManager.CharacterSkinsNames.Where((string n) => CharacterSkinsManager.GetPlayerClass(n) == m_playerData.PlayerClass || !CharacterSkinsManager.GetPlayerClass(n).HasValue);
                ListSelectionDialog  dialog = new ListSelectionDialog(LanguageControl.Get(fName, 1), items, 64f, delegate(object item)
                {
                    XElement node       = ContentManager.Get <XElement>("Widgets/CharacterSkinItem");
                    ContainerWidget obj = (ContainerWidget)Widget.LoadWidget(this, node, null);
                    Texture2D texture   = m_characterSkinsCache.GetTexture((string)item);
                    obj.Children.Find <LabelWidget>("CharacterSkinItem.Text").Text    = CharacterSkinsManager.GetDisplayName((string)item);
                    obj.Children.Find <LabelWidget>("CharacterSkinItem.Details").Text = $"{texture.Width}x{texture.Height}";
                    PlayerModelWidget playerModelWidget    = obj.Children.Find <PlayerModelWidget>("CharacterSkinItem.Model");
                    playerModelWidget.PlayerClass          = m_playerData.PlayerClass;
                    playerModelWidget.CharacterSkinTexture = texture;
                    return(obj);
                }, delegate(object item)
                {
                    m_playerData.CharacterSkinName = (string)item;
                    if (m_playerData.IsDefaultName)
                    {
                        m_playerData.ResetName();
                    }
                });
                DialogsManager.ShowDialog(null, dialog);
            }
            if (m_controlsButton.IsClicked)
            {
                DialogsManager.ShowDialog(null, new ListSelectionDialog(LanguageControl.Get(fName, 2), m_inputDevices, 56f, (object d) => GetDeviceDisplayName((WidgetInputDevice)d), delegate(object d)
                {
                    WidgetInputDevice widgetInputDevice = (WidgetInputDevice)d;
                    m_playerData.InputDevice            = widgetInputDevice;
                    foreach (PlayerData playersDatum in m_playerData.SubsystemPlayers.PlayersData)
                    {
                        if (playersDatum != m_playerData && (playersDatum.InputDevice & widgetInputDevice) != 0)
                        {
                            playersDatum.InputDevice &= ~widgetInputDevice;
                        }
                    }
                }));
            }
            if (m_addButton.IsClicked && VerifyName())
            {
                m_playerData.SubsystemPlayers.AddPlayerData(m_playerData);
                ScreensManager.SwitchScreen("Players", m_playerData.SubsystemPlayers);
            }
            if (m_deleteButton.IsClicked)
            {
                DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "warning"), LanguageControl.Get(fName, 3), LanguageControl.Get("Usual", "ok"), LanguageControl.Get("Usual", "cancel"), delegate(MessageDialogButton b)
                {
                    if (b == MessageDialogButton.Button1)
                    {
                        m_playerData.SubsystemPlayers.RemovePlayerData(m_playerData);
                        ScreensManager.SwitchScreen("Players", m_playerData.SubsystemPlayers);
                    }
                }));
            }
            if (m_playButton.IsClicked && VerifyName())
            {
                m_playerData.SubsystemPlayers.AddPlayerData(m_playerData);
                ScreensManager.SwitchScreen("Game");
            }
            if (m_addAnotherButton.IsClicked && VerifyName())
            {
                m_playerData.SubsystemPlayers.AddPlayerData(m_playerData);
                ScreensManager.SwitchScreen("Player", Mode.Initial, m_playerData.SubsystemPlayers.Project);
            }
            if ((base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked) && VerifyName())
            {
                if (m_mode == Mode.Initial)
                {
                    GameManager.SaveProject(waitForCompletion: true, showErrorDialog: true);
                    GameManager.DisposeProject();
                    ScreensManager.SwitchScreen("MainMenu");
                }
                else if (m_mode == Mode.Add || m_mode == Mode.Edit)
                {
                    ScreensManager.SwitchScreen("Players", m_playerData.SubsystemPlayers);
                }
            }
            m_nameWasInvalid = false;
        }
Example #2
0
 public override void Update()
 {
     if (Children.Find <ButtonWidget>("More").IsClicked)
     {
         List <Tuple <string, Action> > list = new List <Tuple <string, Action> >();
         if (m_adventureRestartExists && GameManager.WorldInfo.WorldSettings.GameMode == GameMode.Adventure)
         {
             list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 82), delegate
             {
                 DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 83), LanguageControl.Get(fName, 84), LanguageControl.Get("Usual", "yes"), LanguageControl.Get("Usual", "no"), delegate(MessageDialogButton result)
                 {
                     if (result == MessageDialogButton.Button1)
                     {
                         ScreensManager.SwitchScreen("GameLoading", GameManager.WorldInfo, "AdventureRestart");
                     }
                 }));
             }));
         }
         if (GetRateableItems().FirstOrDefault() != null && UserManager.ActiveUser != null)
         {
             list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 85), delegate
             {
                 DialogsManager.ShowDialog(base.ParentWidget, new ListSelectionDialog(LanguageControl.Get(fName, 86), GetRateableItems(), 60f, (object o) => ((ActiveExternalContentInfo)o).DisplayName, delegate(object o)
                 {
                     ActiveExternalContentInfo activeExternalContentInfo = (ActiveExternalContentInfo)o;
                     DialogsManager.ShowDialog(base.ParentWidget, new RateCommunityContentDialog(activeExternalContentInfo.Address, activeExternalContentInfo.DisplayName, UserManager.ActiveUser.UniqueId));
                 }));
             }));
         }
         list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 87), delegate
         {
             ScreensManager.SwitchScreen("Players", m_componentPlayer.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true));
         }));
         list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 88), delegate
         {
             ScreensManager.SwitchScreen("Settings");
         }));
         list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 89), delegate
         {
             ScreensManager.SwitchScreen("Help");
         }));
         if ((base.Input.Devices & (WidgetInputDevice.Keyboard | WidgetInputDevice.Mouse)) != 0)
         {
             list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 90), delegate
             {
                 DialogsManager.ShowDialog(base.ParentWidget, new KeyboardHelpDialog());
             }));
         }
         if ((base.Input.Devices & WidgetInputDevice.Gamepads) != 0)
         {
             list.Add(new Tuple <string, Action>(LanguageControl.Get(fName, 91), delegate
             {
                 DialogsManager.ShowDialog(base.ParentWidget, new GamepadHelpDialog());
             }));
         }
         ListSelectionDialog dialog = new ListSelectionDialog(LanguageControl.Get(fName, 92), list, 60f, (object t) => ((Tuple <string, Action>) t).Item1, delegate(object t)
         {
             ((Tuple <string, Action>)t).Item2();
         });
         DialogsManager.ShowDialog(base.ParentWidget, dialog);
     }
     if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("Resume").IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
     if (Children.Find <ButtonWidget>("Quit").IsClicked)
     {
         DialogsManager.HideDialog(this);
         GameManager.SaveProject(waitForCompletion: true, showErrorDialog: true);
         GameManager.DisposeProject();
         ScreensManager.SwitchScreen("MainMenu");
     }
 }
Example #3
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);
            }
        }