示例#1
0
        private void comboBox_Characters_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Customization.FirstRun || String.IsNullOrEmpty(comboBox_Characters.SelectedItem.ToString()))
            {
                return;
            }

            try
            {
                // Initialize
                Customization.Initialize(comboBox_Characters.SelectedItem.ToString());

                // Add world select gui
                comboBoxWorld.DataSource    = Util.GetCharacterWorlds(Customization.SelectedCharacter);
                comboBoxWorld.SelectedIndex = 0;

                // Put appearance in gui
                textBox_Name.Text             = Customization.SelectedCharacter.Data.Name;
                textBoxX.Text                 = Customization.SelectedCharacter.Data.WorldsData[long.Parse(comboBoxWorld.SelectedItem.ToString())].LogoutPoint.X.ToString();
                textBoxY.Text                 = Customization.SelectedCharacter.Data.WorldsData[long.Parse(comboBoxWorld.SelectedItem.ToString())].LogoutPoint.Y.ToString();
                textBoxZ.Text                 = Customization.SelectedCharacter.Data.WorldsData[long.Parse(comboBoxWorld.SelectedItem.ToString())].LogoutPoint.Z.ToString();
                comboBox_Beard.SelectedIndex  = comboBox_Beard.FindStringExact(ValheimEngine.BeardsUI[Util.FindInArrayString(ValheimEngine.BeardsInternal, Customization.SelectedCharacter.Data.Beard)]);
                comboBox_Hair.SelectedIndex   = comboBox_Hair.FindStringExact(ValheimEngine.HairsUI[Util.FindInArrayString(ValheimEngine.HairsInternal, Customization.SelectedCharacter.Data.Hair)]);
                comboBox_Gender.SelectedIndex = comboBox_Gender.FindStringExact(Customization.GenderInternaltoUI(Customization.SelectedCharacter.Data.Gender));
                textBox_HairColor.BackColor   = Util.Vec3ToColor(Customization.SelectedCharacter.Data.HairColor);
                textBox_SkinTone.BackColor    = Util.Vec3ToColor(Customization.SelectedCharacter.Data.SkinColor);

                // Enable gui elements
                textBox_Name.Enabled      = true;
                comboBoxWorld.Enabled     = true;
                textBoxX.Enabled          = true;
                textBoxY.Enabled          = true;
                textBoxZ.Enabled          = true;
                comboBox_Beard.Enabled    = true;
                comboBox_Hair.Enabled     = true;
                comboBox_Gender.Enabled   = true;
                button_SkinTone.Enabled   = true;
                button_HairColor.Enabled  = true;
                textBox_HairColor.Enabled = true;
                textBox_SkinTone.Enabled  = true;
                button_Apply.Enabled      = true;
            }
            catch
            {
                MessageBox.Show("There was an error while trying to get character data.", "ERROR", MessageBoxButtons.OK);
            }
        }
        private void comboBox_Characters_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Customization.FirstRun)
            {
                return;
            }

            try
            {
                // Initialize
                Customization.Initialize(comboBox_Characters.SelectedItem.ToString());

                // Check character appearance
                if (Customization.CheckCustomization())
                {
                    // Read character appearance (beard, hair and color)
                    Customization.ReadCustomization();

                    // Put appearance in gui
                    comboBox_Beard.SelectedIndex = comboBox_Beard.FindStringExact(Customization.SelectedCharacterBeard);
                    comboBox_Hair.SelectedIndex  = comboBox_Hair.FindStringExact(Customization.SelectedCharacterHair);

                    // Enable gui elements
                    comboBox_Beard.Enabled     = true;
                    comboBox_Hair.Enabled      = true;
                    comboBox_HairColor.Enabled = true;
                    button_Apply.Enabled       = true;
                }
                else
                {
                    return;
                }
            }
            catch
            {
                MessageBox.Show("There was an error while trying to get character data.", "ERROR", MessageBoxButtons.OK);
            }
        }
        private void comboBox_Characters_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Customization.FirstRun)
            {
                return;
            }

            try
            {
                // Save character name and file for future operations
                Customization.Initialize(comboBox_Characters.SelectedItem.ToString());

                // Read current character data
                String name = Customization.ReadCharacterName();
                if (String.IsNullOrEmpty(name))
                {
                    MessageBox.Show("Pattern not found. Character can not be customized.", "ERROR", MessageBoxButtons.OK);
                    button_RepairCharacter.Enabled = true;
                    return;
                }

                String beard = Customization.ReadCharacterBeard();
                String hair  = Customization.ReadCharacterHair();
                if (String.IsNullOrEmpty(hair) && String.IsNullOrEmpty(beard))
                {
                    MessageBox.Show("Please use the \"Repair character\" button.", "ERROR", MessageBoxButtons.OK);
                    button_RepairCharacter.Enabled = true;
                    return;
                }

                String color = Customization.ReadCharacterColor();
                if (String.IsNullOrEmpty(color))
                {
                    MessageBox.Show("Pattern not found. Character can not be customized.", "ERROR", MessageBoxButtons.OK);
                    return;
                }

                button_RepairCharacter.Enabled = false;


                if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(beard) || String.IsNullOrEmpty(hair))
                {
                    textBox_Name.Enabled       = false;
                    comboBox_Beard.Enabled     = false;
                    comboBox_Hair.Enabled      = false;
                    comboBox_HairColor.Enabled = false;
                    button_Apply.Enabled       = false;
                    return;
                }

                textBox_Name.Text                = name;
                comboBox_Beard.SelectedIndex     = comboBox_Beard.FindStringExact(beard);
                comboBox_Hair.SelectedIndex      = comboBox_Hair.FindStringExact(hair);
                comboBox_HairColor.SelectedIndex = comboBox_HairColor.FindStringExact(color);

                //textBox_Name.Enabled = true;
                comboBox_Beard.Enabled     = true;
                comboBox_Hair.Enabled      = true;
                comboBox_HairColor.Enabled = true;
                button_Apply.Enabled       = true;
            }
            catch
            {
                MessageBox.Show("There was an error while trying to get character data.", "ERROR", MessageBoxButtons.OK);
            }
        }