Exemplo n.º 1
0
        public PlayerScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/PlayerScreen");

            LoadContents(this, node);
            m_playerModel                     = Children.Find <PlayerModelWidget>("Model");
            m_playerClassButton               = Children.Find <ButtonWidget>("PlayerClassButton");
            m_nameTextBox                     = Children.Find <TextBoxWidget>("Name");
            m_characterSkinLabel              = Children.Find <LabelWidget>("CharacterSkinLabel");
            m_characterSkinButton             = Children.Find <ButtonWidget>("CharacterSkinButton");
            m_controlsLabel                   = Children.Find <LabelWidget>("ControlsLabel");
            m_controlsButton                  = Children.Find <ButtonWidget>("ControlsButton");
            m_descriptionLabel                = Children.Find <LabelWidget>("DescriptionLabel");
            m_addButton                       = Children.Find <ButtonWidget>("AddButton");
            m_addAnotherButton                = Children.Find <ButtonWidget>("AddAnotherButton");
            m_deleteButton                    = Children.Find <ButtonWidget>("DeleteButton");
            m_playButton                      = Children.Find <ButtonWidget>("PlayButton");
            m_characterSkinsCache             = new CharacterSkinsCache();
            m_playerModel.CharacterSkinsCache = m_characterSkinsCache;
            m_nameTextBox.FocusLost          += delegate
            {
                if (VerifyName())
                {
                    m_playerData.Name = m_nameTextBox.Text.Trim();
                }
                else
                {
                    m_nameWasInvalid = true;
                }
            };
        }
Exemplo n.º 2
0
        public ClothingWidget(ComponentPlayer componentPlayer)
        {
            m_componentPlayer = componentPlayer;
            XElement node = ContentManager.Get <XElement>("Widgets/ClothingWidget");

            LoadContents(this, node);
            m_clothingStack            = Children.Find <StackPanelWidget>("ClothingStack");
            m_inventoryGrid            = Children.Find <GridPanelWidget>("InventoryGrid");
            m_vitalStatsButton         = Children.Find <ButtonWidget>("VitalStatsButton");
            m_sleepButton              = Children.Find <ButtonWidget>("SleepButton");
            m_innerClothingModelWidget = Children.Find <PlayerModelWidget>("InnerClothingModel");
            m_outerClothingModelWidget = Children.Find <PlayerModelWidget>("OuterClothingModel");
            for (int i = 0; i < 4; i++)
            {
                InventorySlotWidget inventorySlotWidget = new InventorySlotWidget();
                float y = float.PositiveInfinity;
                if (i == 0)
                {
                    y = 68f;
                }
                if (i == 3)
                {
                    y = 54f;
                }
                inventorySlotWidget.Size        = new Vector2(float.PositiveInfinity, y);
                inventorySlotWidget.BevelColor  = Color.Transparent;
                inventorySlotWidget.CenterColor = Color.Transparent;
                inventorySlotWidget.AssignInventorySlot(m_componentPlayer.ComponentClothing, i);
                inventorySlotWidget.HideEditOverlay        = true;
                inventorySlotWidget.HideInteractiveOverlay = true;
                inventorySlotWidget.HideFoodOverlay        = true;
                inventorySlotWidget.HideHighlightRectangle = true;
                inventorySlotWidget.HideBlockIcon          = true;
                inventorySlotWidget.HideHealthBar          = (m_componentPlayer.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true).WorldSettings.GameMode == GameMode.Creative);
                m_clothingStack.Children.Add(inventorySlotWidget);
            }
            int num = 10;

            for (int j = 0; j < m_inventoryGrid.RowsCount; j++)
            {
                for (int k = 0; k < m_inventoryGrid.ColumnsCount; k++)
                {
                    InventorySlotWidget inventorySlotWidget2 = new InventorySlotWidget();
                    inventorySlotWidget2.AssignInventorySlot(componentPlayer.ComponentMiner.Inventory, num++);
                    m_inventoryGrid.Children.Add(inventorySlotWidget2);
                    m_inventoryGrid.SetWidgetCell(inventorySlotWidget2, new Point2(k, j));
                }
            }
            m_innerClothingModelWidget.PlayerClass          = componentPlayer.PlayerData.PlayerClass;
            m_innerClothingModelWidget.CharacterSkinTexture = m_componentPlayer.ComponentClothing.InnerClothedTexture;
            m_outerClothingModelWidget.PlayerClass          = componentPlayer.PlayerData.PlayerClass;
            m_outerClothingModelWidget.OuterClothingTexture = m_componentPlayer.ComponentClothing.OuterClothedTexture;
        }
Exemplo n.º 3
0
        public PlayerWidget(PlayerData playerData, CharacterSkinsCache characterSkinsCache)
        {
            XElement node = ContentManager.Get <XElement>("Widgets/PlayerWidget");

            LoadContents(this, node);
            m_playerModel  = Children.Find <PlayerModelWidget>("PlayerModel");
            m_nameLabel    = Children.Find <LabelWidget>("Name");
            m_detailsLabel = Children.Find <LabelWidget>("Details");
            m_editButton   = Children.Find <ButtonWidget>("EditButton");
            m_playerModel.CharacterSkinsCache = characterSkinsCache;
            m_playerData = playerData;
        }
Exemplo n.º 4
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;
        }