public MultiSetter(List <Creature> creatureList, List <bool> appliedSettings, List <Creature>[] parents, List <string> tagList, List <string> speciesList)
        {
            InitializeComponent();
            Disposed += MultiSetter_Disposed;

            colors      = new int[6];
            tagControls = new List <MultiSetterTag>();

            this.creatureList            = creatureList;
            parentComboBoxMother.naLabel = " - Mother n/a";
            parentComboBoxFather.naLabel = " - Father n/a";
            if (parents == null)
            {
                // disable parents, probably multiple species selected
                checkBoxMother.Enabled       = false;
                checkBoxFather.Enabled       = false;
                parentComboBoxMother.Enabled = false;
                parentComboBoxFather.Enabled = false;
                uniqueSpecies = false;
            }
            else
            {
                parentComboBoxMother.ParentList = parents[0];
                parentComboBoxFather.ParentList = parents[1];
                uniqueSpecies = true;
            }
            checkBoxMother.Checked = false;
            checkBoxFather.Checked = false;
            creatureStatus         = CreatureStatus.Available;
            creatureSex            = Sex.Unknown;

            ParentsChanged = false;
            TagsChanged    = false;
            SpeciesChanged = false;

            pictureBox1.Image = CreatureColored.getColoredCreature(colors, uniqueSpecies ? creatureList[0].species : "",
                                                                   new[] { true, true, true, true, true, true });

            // tags
            int i = 0;

            foreach (string t in tagList)
            {
                MultiSetterTag mst = new MultiSetterTag(t)
                {
                    Location = new Point(3, 3 + i * 29 - panelTags.VerticalScroll.Value)
                };
                panelTags.Controls.Add(mst);
                tagControls.Add(mst);
                i++;
            }

            foreach (string s in speciesList)
            {
                cbbSpecies.Items.Add(s);
            }

            tt.SetToolTip(lbTagSettingInfo, "The left checkbox indicates if the setting of that tag is applied, " +
                          "the right checkbox indicates if the tag is added or removed from the selected creatures.");
        }
Esempio n. 2
0
 private void chooseColor(int region, Button sender)
 {
     if (creatureList[0] != null && !cp.isShown)
     {
         cp.SetColors(colors, region, "Region " + region);
         if (cp.ShowDialog() == DialogResult.OK)
         {
             // color was chosen
             setColorButton(sender, species.CreatureColors.creatureColor(colors[region]));
             pictureBox1.Image = CreatureColored.getColoredCreature(colors, uniqueSpecies ? creatureList[0].species : "",
                                                                    new[] { true, true, true, true, true, true });
         }
     }
 }
Esempio n. 3
0
 private void chooseColor(int region, Button sender)
 {
     if (creatureList[0] != null && !cp.isShown)
     {
         cp.SetColors(colors[region], "Region " + region);
         if (cp.ShowDialog() == DialogResult.OK)
         {
             // color was chosen
             colors[region] = cp.SelectedColorId;
             sender.SetBackColorAndAccordingForeColor(CreatureColors.CreatureColor(colors[region]));
             pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(colors, uniqueSpecies ? creatureList[0].Species : null,
                                                                                  new[] { true, true, true, true, true, true }));
         }
     }
 }
        /// <summary>
        /// Creates an image with infos about the creature.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="cc">CreatureCollection for server settings.</param>
        /// <returns></returns>
        public static Bitmap InfoGraphic(this Creature creature, CreatureCollection cc)
        {
            if (creature == null)
            {
                return(null);
            }
            int maxGraphLevel = cc?.maxChartLevel ?? 0;

            if (maxGraphLevel < 1)
            {
                maxGraphLevel = 50;
            }

            int width  = Properties.Settings.Default.InfoGraphicWidth; // 330
            int height = width * 6 / 11;                               //180

            int fontSize       = Math.Max(1, height / 18);             // 10
            int fontSizeSmall  = Math.Max(1, height * 2 / 45);         // 8
            int fontSizeHeader = Math.Max(1, height / 15);             // 12
            int frameThickness = Math.Max(1, height / 180);

            int statLineHeight = height * 5 / 59; // 15

            var fontName = Properties.Settings.Default.InfoGraphicFontName;

            if (string.IsNullOrWhiteSpace(fontName))
            {
                fontName = "Arial";
                Properties.Settings.Default.InfoGraphicFontName = fontName;
            }

            var bmp = new Bitmap(width, height);

            using (var g = Graphics.FromImage(bmp))
                using (var font = new Font(fontName, fontSize))
                    using (var fontSmall = new Font(fontName, fontSizeSmall))
                        using (var fontHeader = new Font(fontName, fontSizeHeader, FontStyle.Bold))
                            using (var fontBrush = new SolidBrush(Properties.Settings.Default.InfoGraphicForeColor))
                                using (var borderAroundColors = new Pen(Utils.ForeColor(Properties.Settings.Default.InfoGraphicBackColor), 1))
                                    using (var stringFormatRight = new StringFormat {
                                        Alignment = StringAlignment.Far
                                    })
                                    {
                                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                                        int currentYPosition = frameThickness * 3;

                                        using (var backgroundBrush = new SolidBrush(Properties.Settings.Default.InfoGraphicBackColor))
                                            g.FillRectangle(backgroundBrush, 0, 0, width, height);

                                        g.DrawString(creature.Species.DescriptiveNameAndMod, fontHeader, fontBrush, 3, currentYPosition);
                                        currentYPosition += height * 19 / 180; //19
                                        string creatureInfos = $"{Loc.S("Level")} {creature.LevelHatched} | {Utils.SexSymbol(creature.sex) + (creature.flags.HasFlag(CreatureFlags.Neutered) ? $" ({Loc.S(creature.sex == Sex.Female ? "Spayed" : "Neutered")})" : string.Empty)}";
                                        if (Properties.Settings.Default.InfoGraphicDisplayMutations)
                                        {
                                            creatureInfos += $" | {creature.Mutations} {Loc.S("Mutations")}";
                                        }
                                        if (Properties.Settings.Default.InfoGraphicDisplayGeneration)
                                        {
                                            creatureInfos += $" | {Loc.S("generation")} {creature.generation}";
                                        }
                                        g.DrawString(creatureInfos, font, fontBrush, width * 4 / 165, currentYPosition);
                                        currentYPosition += height * 17 / 180; //17

                                        using (var p = new Pen(Color.FromArgb(50, Properties.Settings.Default.InfoGraphicForeColor), 1))
                                            g.DrawLine(p, 0, currentYPosition, width, currentYPosition);
                                        currentYPosition += 2;

                                        // levels
                                        double meanLetterWidth = fontSize * 7d / 10;
                                        int    xStatName       = (int)meanLetterWidth;
                                        // x position of level number. torpor is the largest level number.
                                        bool showDomLevel        = Properties.Settings.Default.InfoGraphicWithDomLevels;
                                        int  xRightLevelValue    = (int)(xStatName + ((showDomLevel ? 6 : 5) + creature.levelsWild[2].ToString().Length) * meanLetterWidth);
                                        int  xRightLevelDomValue = xRightLevelValue;
                                        if (showDomLevel)
                                        {
                                            xRightLevelDomValue += (int)((creature.levelsDom.Max().ToString().Length) * meanLetterWidth);
                                        }
                                        int xRightBrValue = (int)(xRightLevelDomValue + (2 + MaxCharLength(creature.valuesBreeding)) * meanLetterWidth);
                                        int maxBoxLength  = xRightBrValue - xStatName;
                                        int statBoxHeight = Math.Max(2, height / 90);
                                        g.DrawString(Loc.S("Levels"), font, fontBrush, xRightLevelDomValue, currentYPosition, stringFormatRight);
                                        g.DrawString(Loc.S("Values"), font, fontBrush, xRightBrValue, currentYPosition, stringFormatRight);
                                        int statDisplayIndex = 0;
                                        for (int si = 0; si < Values.STATS_COUNT; si++)
                                        {
                                            int statIndex = Values.statsDisplayOrder[si];
                                            if (statIndex == (int)StatNames.Torpidity || !creature.Species.UsesStat(statIndex))
                                            {
                                                continue;
                                            }

                                            int y = currentYPosition + (height / 9) + (statDisplayIndex++) * statLineHeight;

                                            // box
                                            // empty box to show the max possible length
                                            using (var b = new SolidBrush(Color.DarkGray))
                                                g.FillRectangle(b, xStatName, y + statLineHeight - 1, maxBoxLength, statBoxHeight);
                                            double levelFractionOfMax = Math.Min(1, (double)creature.levelsWild[statIndex] / maxGraphLevel);
                                            if (levelFractionOfMax < 0)
                                            {
                                                levelFractionOfMax = 0;
                                            }
                                            int levelPercentageOfMax = (int)(100 * levelFractionOfMax);
                                            int statBoxLength        = Math.Max((int)(maxBoxLength * levelFractionOfMax), 1);
                                            var statColor            = Utils.GetColorFromPercent(levelPercentageOfMax);
                                            using (var b = new SolidBrush(statColor))
                                                g.FillRectangle(b, xStatName, y + statLineHeight - 1, statBoxLength, statBoxHeight);
                                            using (var b = new SolidBrush(Color.FromArgb(10, statColor)))
                                            {
                                                for (int r = 4; r > 0; r--)
                                                {
                                                    g.FillRectangle(b, xStatName - r, y + statLineHeight - 2 - r, statBoxLength + 2 * r, statBoxHeight + 2 * r);
                                                }
                                            }
                                            using (var p = new Pen(Utils.GetColorFromPercent(levelPercentageOfMax, -0.5), 1))
                                                g.DrawRectangle(p, xStatName, y + statLineHeight - 1, statBoxLength, statBoxHeight);

                                            // stat name
                                            g.DrawString($"{Utils.StatName(statIndex, true, creature.Species.statNames)}",
                                                         font, fontBrush, xStatName, y);
                                            // stat level number
                                            g.DrawString($"{creature.levelsWild[statIndex]}{(showDomLevel ? " +" : string.Empty)}",
                                                         font, fontBrush, xRightLevelValue, y, stringFormatRight);
                                            // dom level number
                                            if (showDomLevel)
                                            {
                                                g.DrawString($"{creature.levelsDom[statIndex]}",
                                                             font, fontBrush, xRightLevelDomValue, y, stringFormatRight);
                                            }
                                            // stat breeding value
                                            double displayedValue = showDomLevel ? creature.valuesDom[statIndex] : creature.valuesBreeding[statIndex];
                                            string statValueRepresentation;
                                            if (Utils.Precision(statIndex) == 3)
                                            {
                                                statValueRepresentation = (100 * displayedValue).ToString("0.0");
                                                g.DrawString("%", font, fontBrush, xRightBrValue, y);
                                            }
                                            else
                                            {
                                                statValueRepresentation = displayedValue.ToString("0.0");
                                            }
                                            g.DrawString(statValueRepresentation, font, fontBrush, xRightBrValue, y, stringFormatRight);
                                        }

                                        // colors
                                        var enabledColorRegions = creature.Species.EnabledColorRegions;

                                        int xColor             = (int)(xRightBrValue + meanLetterWidth * 3.5);
                                        int circleDiameter     = height * 4 / 45;
                                        int colorRowHeight     = circleDiameter + 2;
                                        int maxColorNameLength = (int)((width - xColor - circleDiameter) / meanLetterWidth); // max char length for the color region name
                                        if (maxColorNameLength < 0)
                                        {
                                            maxColorNameLength = 0;
                                        }

                                        bool creatureImageShown = false;
                                        bool displayMaxWild     = Properties.Settings.Default.InfoGraphicShowMaxWildLevel;
                                        int  extraMarginBottom  = displayMaxWild ? fontSizeSmall : 0;
                                        int  imageSize          = (int)Math.Min(width - xColor - circleDiameter - 8 * meanLetterWidth - frameThickness * 4,
                                                                                height - currentYPosition - frameThickness * 4 - extraMarginBottom);
                                        if (imageSize > 5)
                                        {
                                            using (var crBmp =
                                                       CreatureColored.GetColoredCreature(creature.colors, creature.Species, enabledColorRegions,
                                                                                          imageSize, onlyImage: true, creatureSex: creature.sex))
                                            {
                                                if (crBmp != null)
                                                {
                                                    g.DrawImage(crBmp, width - imageSize - frameThickness * 4,
                                                                height - imageSize - frameThickness * 4 - extraMarginBottom, imageSize, imageSize);
                                                    creatureImageShown = true;
                                                }
                                            }
                                        }

                                        if (creature.colors != null)
                                        {
                                            g.DrawString(Loc.S("Colors"), font, fontBrush, xColor, currentYPosition);
                                            int colorRow = 0;
                                            for (int ci = 0; ci < Species.ColorRegionCount; ci++)
                                            {
                                                if (!enabledColorRegions[ci])
                                                {
                                                    continue;
                                                }

                                                int y = currentYPosition + (height / 9) + (colorRow++) * colorRowHeight;

                                                Color c = CreatureColors.CreatureColor(creature.colors[ci]);
                                                //Color fc = Utils.ForeColor(c);

                                                using (var b = new SolidBrush(c))
                                                    g.FillEllipse(b, xColor, y, circleDiameter, circleDiameter);
                                                g.DrawEllipse(borderAroundColors, xColor, y, circleDiameter, circleDiameter);

                                                string colorRegionName = null;
                                                //string colorName = CreatureColors.CreatureColorName(creature.colors[ci]);

                                                if (!creatureImageShown)
                                                {
                                                    colorRegionName = creature.Species.colors[ci].name;
                                                    int totalColorLength = colorRegionName.Length + 11;
                                                    if (totalColorLength > maxColorNameLength)
                                                    {
                                                        // shorten color region name
                                                        int lengthForRegionName =
                                                            colorRegionName.Length - (totalColorLength - maxColorNameLength);
                                                        colorRegionName = lengthForRegionName < 2
                                    ? string.Empty
                                    : colorRegionName.Substring(0, lengthForRegionName - 1) + "…";
                                                    }

                                                    if (!string.IsNullOrEmpty(colorRegionName))
                                                    {
                                                        colorRegionName = " (" + colorRegionName + ")";
                                                    }
                                                }

                                                g.DrawString($"{creature.colors[ci]} - [{ci}]{colorRegionName}",
                                                             fontSmall, fontBrush, xColor + circleDiameter + 4, y);
                                            }
                                        }

                                        // imprinting
                                        if (showDomLevel)
                                        {
                                            g.DrawString($"Imp: {creature.imprintingBonus * 100:0.0} %", font, fontBrush, xColor + (int)((Loc.S("Colors").Length + 3) * meanLetterWidth), currentYPosition);
                                        }

                                        // max wild level on server
                                        if (cc != null && displayMaxWild)
                                        {
                                            g.DrawString($"{Loc.S("max wild level")}: {cc.maxWildLevel}",
                                                         fontSmall, fontBrush, width - 2 * frameThickness, height - fontSizeSmall - 4 * frameThickness, stringFormatRight);
                                        }

                                        // frame
                                        using (var p = new Pen(Properties.Settings.Default.InfoGraphicBorderColor, frameThickness))
                                            g.DrawRectangle(p, 0, 0, width - frameThickness, height - frameThickness);
                                    }

            return(bmp);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates an image with infos about the creature.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="cc">CreatureCollection for server settings.</param>
        /// <returns></returns>
        public static Bitmap InfoGraphic(this Creature creature, CreatureCollection cc)
        {
            if (creature == null)
            {
                return(null);
            }
            int maxGraphLevel = cc?.maxChartLevel ?? 0;

            if (maxGraphLevel < 1)
            {
                maxGraphLevel = 50;
            }

            const int width  = 330;
            const int height = 180;

            var bmp = new Bitmap(width, height);

            using (var g = Graphics.FromImage(bmp))
                using (var font = new Font("Arial", 10))
                    using (var fontSmall = new Font("Arial", 8))
                        using (var fontHeader = new Font("Arial", 12, FontStyle.Bold))
                            using (var fontBrush = new SolidBrush(Color.Black))
                                using (var penBlack = new Pen(Color.Black, 1))
                                    using (var stringFormatRight = new StringFormat()
                                    {
                                        Alignment = StringAlignment.Far
                                    })
                                    {
                                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                                        int currentYPosition = 3;

                                        using (var backgroundBrush = new SolidBrush(Color.AntiqueWhite))
                                            g.FillRectangle(backgroundBrush, 0, 0, width, height);

                                        g.DrawString(creature.Species.DescriptiveNameAndMod, fontHeader, fontBrush, 3, currentYPosition);
                                        currentYPosition += 19;
                                        g.DrawString($"Level {creature.LevelHatched} | {Utils.SexSymbol(creature.sex) + (creature.flags.HasFlag(CreatureFlags.Neutered) ? $" ({Loc.S(creature.sex == Sex.Female ? "Spayed" : "Neutered")})" : string.Empty)} | {creature.Mutations} mutations | generation {creature.generation}", font, fontBrush, 8, currentYPosition);
                                        currentYPosition += 17;

                                        using (var p = new Pen(Color.LightGray, 1))
                                            g.DrawLine(p, 0, currentYPosition, width, currentYPosition);
                                        currentYPosition += 2;

                                        // levels
                                        const int xStatName     = 8;
                                        int       xLevelValue   = xStatName + 30 + (creature.levelsWild[2].ToString().Length) * 7;
                                        int       xRightBrValue = xLevelValue + 14 + MaxBreedingValueLength(creature.valuesBreeding) * 7;
                                        int       maxBoxLength  = xRightBrValue - xStatName;
                                        const int statBoxHeight = 2;
                                        g.DrawString("Levels", font, fontBrush, xLevelValue, currentYPosition, stringFormatRight);
                                        g.DrawString("Values", font, fontBrush, xRightBrValue, currentYPosition, stringFormatRight);
                                        int statDisplayIndex = 0;
                                        for (int si = 0; si < Values.STATS_COUNT; si++)
                                        {
                                            int statIndex = Values.statsDisplayOrder[si];
                                            if (statIndex == (int)StatNames.Torpidity || !creature.Species.UsesStat(statIndex))
                                            {
                                                continue;
                                            }

                                            int y = currentYPosition + 20 + (statDisplayIndex++) * 15;

                                            // box
                                            // empty box to show the max possible length
                                            using (var b = new SolidBrush(Color.DarkGray))
                                                g.FillRectangle(b, xStatName, y + 14, maxBoxLength, statBoxHeight);
                                            double levelFractionOfMax = Math.Min(1, (double)creature.levelsWild[statIndex] / maxGraphLevel);
                                            if (levelFractionOfMax < 0)
                                            {
                                                levelFractionOfMax = 0;
                                            }
                                            int levelPercentageOfMax = (int)(100 * levelFractionOfMax);
                                            int statBoxLength        = Math.Max((int)(maxBoxLength * levelFractionOfMax), 1);
                                            var statColor            = Utils.GetColorFromPercent(levelPercentageOfMax);
                                            using (var b = new SolidBrush(statColor))
                                                g.FillRectangle(b, xStatName, y + 14, statBoxLength, statBoxHeight);
                                            using (var b = new SolidBrush(Color.FromArgb(10, statColor)))
                                            {
                                                for (int r = 4; r > 0; r--)
                                                {
                                                    g.FillRectangle(b, xStatName - r, y + 13 - r, statBoxLength + 2 * r, statBoxHeight + 2 * r);
                                                }
                                            }
                                            using (var p = new Pen(Utils.GetColorFromPercent(levelPercentageOfMax, -0.5), 1))
                                                g.DrawRectangle(p, xStatName, y + 14, statBoxLength, statBoxHeight);

                                            // stat name
                                            g.DrawString($"{Utils.StatName(statIndex, true, creature.Species.statNames)}",
                                                         font, fontBrush, xStatName, y);
                                            // stat level number
                                            g.DrawString($"{creature.levelsWild[statIndex]}",
                                                         font, fontBrush, xLevelValue, y, stringFormatRight);
                                            // stat breeding value
                                            string statValueRepresentation;
                                            if (Utils.Precision(statIndex) == 3)
                                            {
                                                statValueRepresentation = (100 * creature.valuesBreeding[statIndex]).ToString("0.0");
                                                g.DrawString("%", font, fontBrush, xRightBrValue, y);
                                            }
                                            else
                                            {
                                                statValueRepresentation = creature.valuesBreeding[statIndex].ToString("0.0");
                                            }
                                            g.DrawString(statValueRepresentation, font, fontBrush, xRightBrValue, y, stringFormatRight);
                                        }

                                        // colors
                                        var       enabledColorRegions = creature.Species.EnabledColorRegions;
                                        bool      creatureImageShown  = false;
                                        const int imageSize           = 125;
                                        using (var crBmp =
                                                   CreatureColored.GetColoredCreature(creature.colors, creature.Species, enabledColorRegions, imageSize, onlyImage: true, creatureSex: creature.sex))
                                        {
                                            if (crBmp != null)
                                            {
                                                g.DrawImage(crBmp, 200, 40, imageSize, imageSize);
                                                creatureImageShown = true;
                                            }
                                        }

                                        int       xColor             = xRightBrValue + 25;
                                        const int circleDiameter     = 16;
                                        const int rowHeight          = circleDiameter + 2;
                                        int       maxColorNameLength = (width - xColor - circleDiameter) / 6; // max char length for the color region name
                                        if (maxColorNameLength < 0)
                                        {
                                            maxColorNameLength = 0;
                                        }
                                        g.DrawString("Colors", font, fontBrush, xColor, currentYPosition);
                                        int colorRow = 0;
                                        for (int ci = 0; ci < Species.ColorRegionCount; ci++)
                                        {
                                            if (!enabledColorRegions[ci])
                                            {
                                                continue;
                                            }

                                            int y = currentYPosition + 20 + (colorRow++) * rowHeight;

                                            Color c = CreatureColors.CreatureColor(creature.colors[ci]);
                                            //Color fc = Utils.ForeColor(c);

                                            using (var b = new SolidBrush(c))
                                                g.FillEllipse(b, xColor, y, circleDiameter, circleDiameter);
                                            g.DrawEllipse(penBlack, xColor, y, circleDiameter, circleDiameter);

                                            string colorRegionName = null;
                                            //string colorName = CreatureColors.CreatureColorName(creature.colors[ci]);

                                            if (!creatureImageShown)
                                            {
                                                colorRegionName = creature.Species.colors[ci].name;
                                                int totalColorLenght = colorRegionName.Length + 11;
                                                if (totalColorLenght > maxColorNameLength)
                                                {
                                                    // shorten color region name
                                                    int lengthForRegionName = colorRegionName.Length - (totalColorLenght - maxColorNameLength);
                                                    colorRegionName = lengthForRegionName < 2
                                ? string.Empty
                                : colorRegionName.Substring(0, lengthForRegionName - 1) + "…";
                                                }

                                                if (!string.IsNullOrEmpty(colorRegionName))
                                                {
                                                    colorRegionName = " (" + colorRegionName + ")";
                                                }
                                            }

                                            g.DrawString($"{creature.colors[ci]} - [{ci}]{colorRegionName}",
                                                         fontSmall, fontBrush, xColor + circleDiameter + 4, y);
                                        }

                                        // max wild level on server
                                        if (cc != null)
                                        {
                                            g.DrawString($"max wild level: {cc.maxWildLevel}",
                                                         fontSmall, fontBrush, width - 4, height - 14, stringFormatRight);
                                        }

                                        // frame
                                        using (var p = new Pen(Color.DarkRed, 1))
                                            g.DrawRectangle(p, 0, 0, width - 1, height - 1);
                                    }

            return(bmp);
        }
Esempio n. 6
0
        public MultiSetter(List <Creature> creatureList, List <bool> appliedSettings, List <Creature>[] parents, List <string> tagList, List <string> speciesList, string[] ownerList, string[] serverList)
        {
            InitializeComponent();
            Disposed += MultiSetter_Disposed;

            SuspendLayout();
            colors      = new int[6];
            tagControls = new List <MultiSetterTag>();

            this.creatureList            = creatureList;
            parentComboBoxMother.naLabel = " - Mother n/a";
            parentComboBoxFather.naLabel = " - Father n/a";
            if (parents == null)
            {
                // disable parents, probably multiple species selected
                checkBoxMother.Enabled       = false;
                checkBoxFather.Enabled       = false;
                parentComboBoxMother.Enabled = false;
                parentComboBoxFather.Enabled = false;
                uniqueSpecies = false;
            }
            else
            {
                parentComboBoxMother.ParentList = parents[0];
                parentComboBoxFather.ParentList = parents[1];
                uniqueSpecies = true;
            }
            checkBoxMother.Checked = false;
            checkBoxFather.Checked = false;
            creatureStatus         = CreatureStatus.Available;
            creatureSex            = Sex.Unknown;

            ParentsChanged = false;
            TagsChanged    = false;
            SpeciesChanged = false;

            pictureBox1.Image = CreatureColored.getColoredCreature(colors, uniqueSpecies ? creatureList[0].species : "",
                                                                   new[] { true, true, true, true, true, true });

            // tags
            foreach (string t in tagList)
            {
                MultiSetterTag mst = new MultiSetterTag(t);
                flowLayoutPanelTags.SetFlowBreak(mst, true);
                flowLayoutPanelTags.Controls.Add(mst);
                tagControls.Add(mst);
                mst.TagCheckState = CheckState.Indeterminate;
                foreach (var c in creatureList)
                {
                    if (c.tags.Contains(t))
                    {
                        if (mst.TagCheckState == CheckState.Indeterminate)
                        {
                            mst.TagCheckState = CheckState.Checked;
                        }
                        else if (mst.TagCheckState == CheckState.Unchecked)
                        {
                            mst.TagCheckState = CheckState.Indeterminate;
                            break;
                        }
                    }
                    else
                    {
                        if (mst.TagCheckState == CheckState.Indeterminate)
                        {
                            mst.TagCheckState = CheckState.Unchecked;
                        }
                        else if (mst.TagCheckState == CheckState.Checked)
                        {
                            mst.TagCheckState = CheckState.Indeterminate;
                            break;
                        }
                    }
                }
                mst.Considered = false;
            }

            foreach (string s in speciesList)
            {
                cbbSpecies.Items.Add(s);
            }

            // owner combobox
            var l = new AutoCompleteStringCollection();

            l.AddRange(ownerList);
            cbbOwner.AutoCompleteCustomSource = l;
            foreach (string s in ownerList)
            {
                cbbOwner.Items.Add(s);
            }

            // server combobox
            l = new AutoCompleteStringCollection();
            l.AddRange(serverList);
            cbbServer.AutoCompleteCustomSource = l;
            foreach (string s in serverList)
            {
                cbbServer.Items.Add(s);
            }

            tt.SetToolTip(lbTagSettingInfo, "The left checkbox indicates if the setting of that tag is applied, " +
                          "the right checkbox indicates if the tag is added or removed from the selected creatures.");

            ResumeLayout();
        }
        /// <summary>
        /// Creates the pedigree with creature controls.
        /// </summary>
        private void CreatePedigree()
        {
            splitContainer1.Panel2.SuspendDrawing();
            SuspendLayout();
            // clear old pedigreeCreatures
            ClearControls(false);
            if (_selectedCreature == null)
            {
                NoCreatureSelected();
                ResumeLayout();
                splitContainer1.Panel2.ResumeDrawing();
                return;
            }

            pedigreeCreatureHeaders.SetCustomStatNames(_selectedCreature.Species?.statNames);
            statSelector1.SetStatNames(_selectedCreature.Species);

            lbPedigreeEmpty.Visible = false;

            // scroll offsets
            splitContainer1.Panel2.AutoScrollPosition = Point.Empty; // if not reset there are still offset issues sometimes, just reset the scrolling when creating a pedigree

            if (_pedigreeViewMode == PedigreeViewMode.Classic)
            {
                PedigreeCreation.CreateDetailedView(_selectedCreature, _lines, _pedigreeControls, _enabledColorRegions);
                _yBottomOfPedigree = 170;
            }
            else
            {
                _displayedGenerations = Math.Min(_compactGenerations, _selectedCreature.generation + 1);
                _yBottomOfPedigree    = PedigreeCreation.CreateCompactView(_selectedCreature, _lines, _pedigreeControls, _tt, _displayedGenerations, _highlightInheritanceStatIndex, _pedigreeViewMode == PedigreeViewMode.HView);

                var creatureColorsTop = _yBottomOfPedigree + LbCreatureName.Height;
                PbRegionColors.Top    = creatureColorsTop;
                PbKeyExplanations.Top = creatureColorsTop;
                LbCreatureName.Top    = creatureColorsTop - LbCreatureName.Height;
                LbCreatureName.Text   = _selectedCreature.name;

                if (PbKeyExplanations.Image == null)
                {
                    DrawKey(PbKeyExplanations, _selectedSpecies);
                }

                _pedigreeControls.Add(new PedigreeCreature(_selectedCreature, _enabledColorRegions)
                {
                    Location = new Point(PedigreeCreation.LeftBorder, _yBottomOfPedigree + PedigreeCreation.Margin)
                });
                _yBottomOfPedigree += 50;
            }

            // create descendants
            int row          = 0;
            var yDescendants = _yBottomOfPedigree + 3 * PedigreeCreation.Margin;

            foreach (Creature c in _creatureChildren)
            {
                PedigreeCreature pc = new PedigreeCreature(c, _enabledColorRegions)
                {
                    Location = new Point(PedigreeCreation.LeftBorder, yDescendants + 35 * row)
                };
                if (c.levelsWild != null && _selectedCreature.levelsWild != null)
                {
                    for (int s = 0; s < PedigreeCreature.DisplayedStatsCount; s++)
                    {
                        int si = PedigreeCreature.DisplayedStats[s];
                        if (_selectedCreature.valuesDom[si] > 0 && _selectedCreature.levelsWild[si] >= 0 &&
                            _selectedCreature.levelsWild[si] == c.levelsWild[si])
                        {
                            _lines[0].Add(new[]
                            {
                                PedigreeCreation.LeftBorder + PedigreeCreature.XOffsetFirstStat + PedigreeCreature.HorizontalStatDistance * s, yDescendants + 35 * row + 6,
                                PedigreeCreation.LeftBorder + PedigreeCreature.XOffsetFirstStat + PedigreeCreature.HorizontalStatDistance * s, yDescendants + 35 * row + 15, 0, 0
                            });
                        }
                    }
                }
                _pedigreeControls.Add(pc);
                row++;
            }

            // add controls
            foreach (var pc in _pedigreeControls)
            {
                splitContainer1.Panel2.Controls.Add(pc);
                var ipc = (IPedigreeCreature)pc;
                ipc.CreatureClicked      += CreatureClicked;
                ipc.CreatureEdit         += CreatureEdit;
                ipc.BestBreedingPartners += BestBreedingPartners;
            }

            PbRegionColors.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_selectedCreature.colors,
                                                                                    _selectedCreature.Species, _enabledColorRegions, 256, creatureSex: _selectedCreature.sex));
            PbRegionColors.Visible = true;

            ResumeLayout();
            splitContainer1.Panel2.ResumeDrawing();
        }
Esempio n. 8
0
        public MultiSetter(List <Creature> creatureList, List <Creature>[] parents, List <string> tagList, List <Species> speciesList, string[] ownerList, string[] tribeList, string[] serverList)
        {
            InitializeComponent();
            Disposed += MultiSetter_Disposed;

            SuspendLayout();
            _colors      = new byte[Species.ColorRegionCount];
            _tagControls = new List <MultiSetterTag>();

            this._creatureList           = creatureList;
            parentComboBoxMother.naLabel = " - Mother n/a";
            parentComboBoxFather.naLabel = " - Father n/a";
            if (parents == null)
            {
                // disable parents, probably multiple species selected
                checkBoxMother.Enabled       = false;
                checkBoxFather.Enabled       = false;
                parentComboBoxMother.Enabled = false;
                parentComboBoxFather.Enabled = false;
                _uniqueSpecies = false;
            }
            else
            {
                parentComboBoxMother.ParentList = parents[0];
                parentComboBoxFather.ParentList = parents[1];
                _uniqueSpecies = true;
            }
            checkBoxMother.Checked = false;
            checkBoxFather.Checked = false;
            _creatureStatus        = CreatureStatus.Available;
            _creatureSex           = Sex.Unknown;

            ParentsChanged = false;
            TagsChanged    = false;
            SpeciesChanged = false;

            pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_colors, _uniqueSpecies ? creatureList[0].Species : null,
                                                                                 new[] { true, true, true, true, true, true }));

            // tags
            foreach (string t in tagList)
            {
                MultiSetterTag mst = new MultiSetterTag(t);
                flowLayoutPanelTags.SetFlowBreak(mst, true);
                flowLayoutPanelTags.Controls.Add(mst);
                _tagControls.Add(mst);
                mst.TagCheckState = CheckState.Indeterminate;
                foreach (var c in creatureList)
                {
                    if (c.tags.Contains(t))
                    {
                        if (mst.TagCheckState == CheckState.Indeterminate)
                        {
                            mst.TagCheckState = CheckState.Checked;
                        }
                        else if (mst.TagCheckState == CheckState.Unchecked)
                        {
                            mst.TagCheckState = CheckState.Indeterminate;
                            break;
                        }
                    }
                    else
                    {
                        if (mst.TagCheckState == CheckState.Indeterminate)
                        {
                            mst.TagCheckState = CheckState.Unchecked;
                        }
                        else if (mst.TagCheckState == CheckState.Checked)
                        {
                            mst.TagCheckState = CheckState.Indeterminate;
                            break;
                        }
                    }
                }
            }

            cbbSpecies.Items.AddRange(speciesList.ToArray());

            // owner combobox
            var l = new AutoCompleteStringCollection();

            l.AddRange(ownerList);
            cbbOwner.AutoCompleteCustomSource = l;
            foreach (string s in ownerList)
            {
                cbbOwner.Items.Add(s);
            }

            // tribe combobox
            l = new AutoCompleteStringCollection();
            l.AddRange(tribeList);
            cbbTribe.AutoCompleteCustomSource = l;
            foreach (string s in tribeList)
            {
                cbbTribe.Items.Add(s);
            }

            // server combobox
            l = new AutoCompleteStringCollection();
            l.AddRange(serverList);
            cbbServer.AutoCompleteCustomSource = l;
            foreach (string s in serverList)
            {
                cbbServer.Items.Add(s);
            }

            SetLocalizations();
            ResumeLayout();
        }