Exemple #1
0
        public PortraitGenerator(List <string> RL, Dictionary <string, string> N, Dictionary <string, byte[]> FD)
        {
            InitializeComponent();

            Emotion_Spec = new Control[] { LBL_Emotions, CB_Emotion, CHK_Blush, CHK_SweatDrop };
            Corrin_Spec  = new Control[] { LBL_CharType, CB_Corrin, LBL_Eyes, CB_Eyes, LBL_HairStyle, CB_HairStyle, LBL_FacialFeature, CB_FacialFeature, LBL_Accessory, CB_Accessory };

            ResourceList = RL;
            Names        = N;
            FaceData     = FD;

            DefaultHairs = new Dictionary <string, int>();
            string[] HCs = Resources.HCs.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string HC in HCs)
            {
                var H = HC.Split(new[] { '\t' });
                DefaultHairs[H[0]] = int.Parse(H[1], NumberStyles.AllowHexSpecifier);
            }
            CB_HairColor.Items.Add("Custom");
            CB_HairColor.Items.AddRange(DefaultHairs.Keys.Select(s => s).ToArray());

            CB_PortraitStyle.Items.AddRange(new[] { "Standard", "Closeup", "Critical" });

            for (int i = 0; i < Characters.Length; i++)
            {
                Characters[i] = new List <cbItem>();
                foreach (string Resource in ResourceList)
                {
                    if (Resource.Contains("_" + Prefixes[i] + "_"))
                    {
                        string Character = Resource.Substring(0, Resource.IndexOf("_" + Prefixes[i] + "_"));
                        cbItem ncbi      = new cbItem
                        {
                            Value = Character,
                            Text  = Names.ContainsKey(Character) ? Names[Character] : Character
                        };
                        if (!ncbi.Text.Contains("マイユニ") && ncbi.Text != "Kana")
                        {
                            if (Characters[i].All(cbi => cbi.Text != ncbi.Text) && Characters[i].All(cbi => cbi.Value != ncbi.Value))
                            {
                                Characters[i].Add(ncbi);
                            }
                        }
                    }
                }
                Characters[i].Add(new cbItem {
                    Text = "Corrin", Value = "username"
                });
                Characters[i].Add(new cbItem {
                    Text = "Kana (M)", Value = "カンナ男"
                });
                Characters[i].Add(new cbItem {
                    Text = "Kana (F)", Value = "カンナ女"
                });
                Characters[i] = Characters[i].OrderBy(cbi => cbi.Text).ToList();
            }
            CB_Character.DisplayMember = "Text";
            CB_Character.ValueMember   = "Value";

            CB_Corrin.Items.AddRange(new[] { "Male 1", "Male 2", "Female 1", "Female 2" });
            CB_Eyes.Items.AddRange(new[] { "Style A", "Style B", "Style C", "Style D", "Style E", "Style F", "Style G" });
            CB_HairStyle.Items.AddRange(Enumerable.Range(0, 12).Select(i => i.ToString("00")).ToArray());
            CB_FacialFeature.Items.AddRange(new[] { "None", "Scratches", "Vertical Scratches", "Horizontal Scratches", "Tattoo 1", "Tattoo 2", "Tattoo 3", "Eye Mole", "Mouth Mole", "Plaster 1", "Plaster 2", "White Eyepatch", "Black Eyepatch" });
            CB_Accessory.Items.AddRange(new[] { "None", "Silver Piece", "Butterfly", "Black Ribbon", "White Ribbon", "White Rose" });

            CB_PortraitStyle.SelectedIndex = 2;

            CB_Character.SelectedIndex = CB_HairColor.SelectedIndex = CB_Corrin.SelectedIndex = CB_Eyes.SelectedIndex = CB_HairStyle.SelectedIndex = CB_FacialFeature.SelectedIndex = CB_Accessory.SelectedIndex = 0;
            CB_Accessory.Enabled       = LBL_Accessory.Enabled = CB_Corrin.SelectedIndex > 1;

            loaded = true;
            UpdateImage();
        }
        /**
         * Constructor for portrait generation of dialogue characters.
         * @param RL Resource list.
         * @param N Names of the characters in dialogue.
         * @param FD Face data of the characters in dialogue.
         */
        public PortraitGenerator(List <string> RL, Dictionary <string, string> N, Dictionary <string, byte[]> FD)
        {
            InitializeComponent();

            // list of all character emotion assets
            Emotion_Spec = new Control[] { LBL_Emotions, CB_Emotion, CHK_Blush, CHK_SweatDrop };
            Corrin_Spec  = new Control[] { LBL_CharType, CB_Corrin, LBL_Eyes, CB_Eyes, LBL_HairStyle, CB_HairStyle, LBL_FacialFeature, CB_FacialFeature, LBL_Accessory, CB_Accessory };

            // set local variables
            ResourceList = RL;
            Names        = N;
            FaceData     = FD;

            // gets all possible hair colours of characters
            DefaultHairs = new Dictionary <string, int>();
            string[] HCs = Resources.HCs.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string HC in HCs)
            {
                var H = HC.Split(new[] { '\t' });
                DefaultHairs[H[0]] = int.Parse(H[1], NumberStyles.AllowHexSpecifier);
            }
            CB_HairColor.Items.Add("Custom");   // adds custom hair colour option
            CB_HairColor.Items.AddRange(DefaultHairs.Keys.Select(s => s).ToArray());

            CB_PortraitStyle.Items.AddRange(new[] { "Standard", "Closeup", "Critical" });   // adds various portrait range options

            // sets the character that is currently in dialogue
            for (int i = 0; i < Characters.Length; i++) // for each character in the dialogue
            {
                Characters[i] = new List <cbItem>();    // initialize the character as a new cbItem
                foreach (string Resource in ResourceList)
                {
                    if (Resource.Contains("_" + Prefixes[i] + "_"))                                          // finds character name for the current character
                    {
                        string Character = Resource.Substring(0, Resource.IndexOf("_" + Prefixes[i] + "_")); // gets the character name
                        cbItem ncbi      = new cbItem                                                        // create a new cbItem containing the character name
                        {
                            Value = Character,
                            Text  = Names.ContainsKey(Character) ? Names[Character] : Character
                        };
                        // if the character name is not "マイユニ" or "Kana"
                        if (!ncbi.Text.Contains("マイユニ") && ncbi.Text != "Kana")
                        {
                            // and if the character name found does not exist in the character list already, add it to the list
                            if (Characters[i].All(cbi => cbi.Text != ncbi.Text) && Characters[i].All(cbi => cbi.Value != ncbi.Value))
                            {
                                Characters[i].Add(ncbi);
                            }
                        }
                    }
                }
                Characters[i].Add(new cbItem {
                    Text = "Corrin", Value = "username"
                });                                                                         // add "Corrin" to the list
                Characters[i].Add(new cbItem {
                    Text = "Kana (M)", Value = "カンナ男"
                });                                                                     // add "Kana (M)" to the list
                Characters[i].Add(new cbItem {
                    Text = "Kana (F)", Value = "カンナ女"
                });                                                                     // add "Kana (F)" to the list
                Characters[i] = Characters[i].OrderBy(cbi => cbi.Text).ToList();
            }
            // set member values of the character
            CB_Character.DisplayMember = "Text";
            CB_Character.ValueMember   = "Value";

            // add options for the character's appearance
            CB_Corrin.Items.AddRange(new[] { "Male 1", "Male 2", "Female 1", "Female 2" });                                                                                                                                                           // add options for character gender
            CB_Eyes.Items.AddRange(new[] { "Style A", "Style B", "Style C", "Style D", "Style E", "Style F", "Style G" });                                                                                                                            // add options for eyes
            CB_HairStyle.Items.AddRange(Enumerable.Range(0, 12).Select(i => i.ToString("00")).ToArray());                                                                                                                                             // add options for hairstyles
            CB_FacialFeature.Items.AddRange(new[] { "None", "Scratches", "Vertical Scratches", "Horizontal Scratches", "Tattoo 1", "Tattoo 2", "Tattoo 3", "Eye Mole", "Mouth Mole", "Plaster 1", "Plaster 2", "White Eyepatch", "Black Eyepatch" }); // add options for facial features
            CB_Accessory.Items.AddRange(new[] { "None", "Silver Piece", "Butterfly", "Black Ribbon", "White Ribbon", "White Rose" });                                                                                                                 // add options for accessories

            CB_PortraitStyle.SelectedIndex = 2;                                                                                                                                                                                                       // set default portrait style to style 2

            CB_Character.SelectedIndex = CB_HairColor.SelectedIndex = CB_Corrin.SelectedIndex = CB_Eyes.SelectedIndex = CB_HairStyle.SelectedIndex = CB_FacialFeature.SelectedIndex = CB_Accessory.SelectedIndex = 0;                                 // set default indices of all character appearance options to 0
            CB_Accessory.Enabled       = LBL_Accessory.Enabled = CB_Corrin.SelectedIndex > 1;                                                                                                                                                         // enable accessories if the gender is female

            loaded = true;                                                                                                                                                                                                                            // set indicator that portrait generation is completed
            UpdateImage();                                                                                                                                                                                                                            // refresh image with portraits on screen
        }