private void fillComboBox(ComboBox cb, Characteristic characteristic)
        {
            cb.Items.Clear();
            PortraitType portraitType = portrait.GetPortraitType();

            if (portraitType != null)
            {
                int frameCount = loader.GetActivePortraitData().GetFrameCount(portraitType, characteristic);
                if (frameCount > 0)
                {
                    logger.Debug(string.Format("Item count for {0} {1} : {2}", portraitType, characteristic, frameCount));
                    cb.Enabled = true;
                    fillComboBox(cb, frameCount);
                    if (frameCount == 1)
                    {
                        cb.Enabled = false;                         // Disable if only 1 frame, as there's no selection to do, for instance head (p2)
                    }
                }
                else
                {
                    logger.Warn(string.Format("Could not find frame count for {0} and {1}, disabling dropdown.", portraitType, characteristic));
                    cb.Enabled = false;
                }
            }
        }
Exemple #2
0
        private void DrawTile(Portrait portrait, Graphics g, Sprite sprite, Layer layer, int tileIndex)
        {
            Bitmap tile;

            if (layer.IsHair)
            {
                List <Hair> hairCoulours = portrait.GetPortraitType().HairColours;
                int         hairIndex    = Portrait.GetIndex(portrait.GetLetter(Characteristic.HAIR_COLOR), hairCoulours.Count);
                tile = DrawHair(sprite.Tiles[tileIndex], hairCoulours[hairIndex]);
            }
            else if (layer.IsEye)
            {
                List <Colour> eyeCoulours = portrait.GetPortraitType().EyeColours;
                int           eyeIndex    = Portrait.GetIndex(portrait.GetLetter(Characteristic.EYE_COLOR), eyeCoulours.Count);
                tile = DrawEye(sprite.Tiles[tileIndex], eyeCoulours[eyeIndex]);
            }
            else
            {
                tile = sprite.Tiles[tileIndex];
            }

            g.DrawImage(tile, 12 + layer.Offset.X, 12 + 152 - tile.Size.Height - layer.Offset.Y);
        }
Exemple #3
0
        /// <summary>
        /// Draws a character portrait.
        /// </summary>
        /// <param name="portraitType">PortaitType to use for drawing.</param>
        /// <param name="portrait">Portrait input to draw.</param>
        /// <param name="activeContents">Content to load sprites from</param>
        /// <returns>Frameless portrait drawn with the given parameters.</returns>
        public Bitmap DrawPortrait(Portrait portrait, List <Content> activeContents, Dictionary <string, Sprite> sprites)
        {
            logger.Info(string.Format("Drawing Portrait {0}", portrait));

            Bitmap   portraitImage = new Bitmap(176, 176);
            Graphics g             = Graphics.FromImage(portraitImage);

            foreach (Layer layer in portrait.GetPortraitType().Layers)
            {
                DrawLayer(layer, g, portrait, activeContents, sprites);
            }

            DrawBorder(portrait, g, activeContents, sprites);

            g.Dispose();
            return(portraitImage);
        }