public void InitializeSpeciesImages(List <Species> species)
        {
            var creatureColors      = new byte[] { 44, 42, 57, 10, 26, 78 }; // uniform color pattern that is used for all species in the selector
            var creatureColorsPolar = new byte[] { 18, 18, 18, 18, 18, 18 }; // uniform color pattern that is used for all polar species in the selector
            var lImgList            = new ImageList();

            _iconIndices = new List <string>();
            bool imageFolderExist = !string.IsNullOrEmpty(CreatureColored.ImageFolder) && Directory.Exists(CreatureColored.ImageFolder);

            //var speciesWOImage = new List<string>();// to determine which species have no image yet
            foreach (Species s in species)
            {
                if (!imageFolderExist)
                {
                    continue;
                }

                var(imgExists, imagePath, speciesListName) = CreatureColored.SpeciesImageExists(s,
                                                                                                s.name.Contains("Polar") ? creatureColorsPolar : creatureColors);
                //if (!imgExists && !speciesWOImage.Contains(s.name)) speciesWOImage.Add(s.name);
                if (!imgExists || _iconIndices.Contains(speciesListName))
                {
                    continue;
                }

                try
                {
                    lImgList.Images.Add(Image.FromFile(imagePath));
                    _iconIndices.Add(speciesListName);
                }
                catch (OutOfMemoryException)
                {
                    // usually this exception occurs if the image file is corrupted
                    if (FileService.TryDeleteFile(imagePath))
                    {
                        (imgExists, imagePath, speciesListName) = CreatureColored.SpeciesImageExists(s,
                                                                                                     s.name.Contains("Polar") ? creatureColorsPolar : creatureColors);
                        if (imgExists)
                        {
                            try
                            {
                                lImgList.Images.Add(Image.FromFile(imagePath));
                                _iconIndices.Add(speciesListName);
                            }
                            catch
                            {
                                // ignore image if it failed a second time
                            }
                        }
                    }
                }
            }
            //Clipboard.SetText(speciesWOImage.Any() ? string.Join("\n", speciesWOImage) : string.Empty);

            lImgList.ImageSize                = new Size(64, 64);
            lvLastSpecies.LargeImageList      = lImgList;
            lvSpeciesInLibrary.LargeImageList = lImgList;
            UpdateLastSpecies();
            UpdateLibraryList();
        }
Esempio n. 2
0
 private void RegionColorChooser1_RegionColorChosen()
 {
     creature.colors   = regionColorChooser1.colorIDs;
     pictureBox1.Image = CreatureColored.getColoredCreature(creature.colors, creature.species, colorRegionUseds);
     renewLargeImage   = true;
     Changed(creature, false);
 }
Esempio n. 3
0
        public MultiSetter(Creature creatureSettings, List <bool> appliedSettings, List <Creature>[] parents)
        {
            InitializeComponent();
            tt.SetToolTip(buttonStatus, "Status: " + c.status.ToString());
            tt.SetToolTip(buttonSex, "Sex: " + c.gender.ToString());
            if (appliedSettings.Count != 13)
            {
                DialogResult = DialogResult.Cancel; // invalid parameters
            }
            this.appliedSettings = appliedSettings;
            this.c = creatureSettings;
            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;
            }
            else
            {
                parentComboBoxMother.ParentList = parents[0];
                parentComboBoxFather.ParentList = parents[1];
                uniqueSpecies = true;
            }
            checkBoxMother.Checked = false;
            checkBoxFather.Checked = false;

            pictureBox1.Image = CreatureColored.getColoredCreature(c.colors, (uniqueSpecies ? c.species : ""), new bool[] { true, true, true, true, true, true });
        }
Esempio n. 4
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     if (renewLargeImage)
     {
         largeImage      = CreatureColored.getColoredCreature(creature.colors, creature.species, colorRegionUseds, 256);
         renewLargeImage = false;
     }
 }
 /// <summary>
 /// Updates the displayed colors of the creature.
 /// </summary>
 private void UpdateRegionColorImage()
 {
     ParentInheritance?.UpdateColors(RegionColors);
     ColorsChanged?.Invoke(this);
     if (PbColorRegion != null)
     {
         PbColorRegion.Image = CreatureColored.GetColoredCreature(RegionColors, _selectedSpecies, regionColorChooser1.ColorRegionsUseds, 256, onlyImage: true, creatureSex: CreatureSex);
     }
 }
Esempio n. 6
0
        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.Alive;
            creatureSex            = Sex.Unknown;

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

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

            // tags
            MultiSetterTag mst;
            int            i = 0;

            foreach (string t in tagList)
            {
                mst          = new MultiSetterTag(t);
                mst.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.");
        }
        private void UpdateRegionColorImage()
        {
            if (PbColorRegion == null)
            {
                return;
            }

            PbColorRegion.Image = CreatureColored.GetColoredCreature(RegionColors, _selectedSpecies, regionColorChooser1.ColorRegionsUseds, 256, onlyImage: true, creatureSex: CreatureSex);
        }
Esempio n. 8
0
        public void setCreature(Creature creature)
        {
            this.creature  = creature;
            groupBox1.Text = (!onlyLevels && creature.status != CreatureStatus.Available ? "(" + Utils.statusSymbol(creature.status) + ") " : "") + creature.name + " (" + creature.levelHatched + (totalLevelUnknown ? "+" : "") + ")";
            if (!onlyLevels && creature.status == CreatureStatus.Dead)
            {
                groupBox1.ForeColor = SystemColors.GrayText;
                tt.SetToolTip(groupBox1, "Creature has passed away");
            }
            else if (!onlyLevels && creature.status == CreatureStatus.Unavailable)
            {
                groupBox1.ForeColor = SystemColors.GrayText;
                tt.SetToolTip(groupBox1, "Creature is currently not available");
            }

            for (int s = 0; s < 7; s++)
            {
                if (creature.levelsWild[s] < 0)
                {
                    labels[s].Text      = "?";
                    labels[s].BackColor = Color.WhiteSmoke;
                    labels[s].ForeColor = Color.LightGray;
                }
                else
                {
                    labels[s].Text      = creature.levelsWild[s].ToString();
                    labels[s].BackColor = Utils.getColorFromPercent((int)(creature.levelsWild[s] * 2.5), (creature.topBreedingStats[s] ? 0.2 : 0.7));
                    labels[s].ForeColor = SystemColors.ControlText;
                    tt.SetToolTip(labels[s], Utils.statName(s) + ": " + (creature.valuesBreeding[s] * (Utils.precision(s) == 3 ? 100 : 1)).ToString() + (Utils.precision(s) == 3 ? "%" : ""));
                }
                labels[s].Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, (creature.topBreedingStats[s] ? System.Drawing.FontStyle.Bold : System.Drawing.FontStyle.Regular), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            }
            if (onlyLevels)
            {
                labelSex.Visible    = false;
                pictureBox1.Visible = false;
                plainTextcurrentValuesToolStripMenuItem.Visible = false;
                aRKChatcurrentValuesToolStripMenuItem.Visible   = false;
            }
            else
            {
                labelSex.Visible   = true;
                labelSex.Text      = Utils.sexSymbol(creature.gender);
                labelSex.BackColor = creature.neutered ? SystemColors.GrayText : Utils.sexColor(creature.gender);
                // creature Colors
                pictureBox1.Image   = CreatureColored.getColoredCreature(creature.colors, "", enabledColorRegions, 24, 22, true);
                labelSex.Visible    = true;
                pictureBox1.Visible = true;
                plainTextcurrentValuesToolStripMenuItem.Visible = true;
                aRKChatcurrentValuesToolStripMenuItem.Visible   = true;
            }
            labelMutations.BackColor = Color.FromArgb(225, 192, 255);
            labelMutations.Text      = creature.mutationCounter.ToString();
            labelMutations.Visible   = creature.mutationCounter > 0;
            contextMenuAvailable     = true;
        }
        private void RegionColorChooser1_RegionColorChosen()
        {
            if (_creature == null)
            {
                return;
            }

            pictureBox1.Image = CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, colorRegionUseds, creatureSex: _creature.sex);
            _creature.colors  = regionColorChooser1.ColorIDs;
            Changed?.Invoke(_creature, false, false);
        }
Esempio n. 10
0
        public void updateLabel()
        {
            if (creature != null)
            {
                labelGender.Text = Utils.sexSymbol(creature.gender);
                groupBox1.Text   = creature.name + " (Lvl " + creature.level + "/" + (creature.levelHatched + maxDomLevel) + ")";
                if (creature.Mother != null || creature.Father != null)
                {
                    labelParents.Text = "";
                    if (creature.Mother != null)
                    {
                        labelParents.Text = "Mo: " + creature.Mother.name;
                    }
                    if (creature.Father != null && creature.Mother != null)
                    {
                        labelParents.Text += "; ";
                    }
                    if (creature.Father != null)
                    {
                        labelParents.Text += "Fa: " + creature.Father.name;
                    }
                }
                else if (creature.isBred)
                {
                    labelParents.Text = "bred, click 'edit' to add parents";
                }
                else
                {
                    labelParents.Text = "found wild " + creature.levelFound + (creature.tamingEff >= 0 ? ", tamed with TE: " + (creature.tamingEff * 100).ToString("N1") + "%" : ", TE unknown.");
                }
                for (int s = 0; s < 8; s++)
                {
                    updateStat(s);
                }
                labelNotes.Text     = creature.note;
                labelSpecies.Text   = creature.species;
                pictureBox1.Image   = CreatureColored.getColoredCreature(creature.colors, creature.species, colorRegionUseds);
                pictureBox1.Visible = true;

                for (int c = 0; c < 6; c++)
                {
                    if (colorRegionUseds[c])
                    {
                        setColorButton(colorButtons[c], Utils.creatureColor(creature.colors[c]));
                        tt.SetToolTip(colorButtons[c], colorRegions[c].name);
                        colorButtons[c].Visible = true;
                    }
                    else
                    {
                        colorButtons[c].Visible = false;
                    }
                }
            }
        }
Esempio n. 11
0
        private void RegionColorChooser1_RegionColorChosen()
        {
            if (_creature == null)
            {
                return;
            }

            _creature.colors = regionColorChooser1.ColorIds;
            pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, _colorRegionUseds, creatureSex: _creature.sex));
            Changed?.Invoke(_creature, false, false);
        }
Esempio n. 12
0
 private void chooseColor(int region, Button sender)
 {
     if (c != null && !cp.isShown)
     {
         cp.SetColors(c.colors, region, "Region " + region.ToString());
         if (cp.ShowDialog() == DialogResult.OK)
         {
             // color was chosen
             setColorButton(sender, Utils.creatureColor(c.colors[region]));
             pictureBox1.Image = CreatureColored.getColoredCreature(c.colors, (uniqueSpecies ? c.species : ""), new bool[] { true, true, true, true, true, true });
         }
     }
 }
Esempio n. 13
0
 private void chooseColor(int region, Button sender)
 {
     if (creature != null && !cp.isShown)
     {
         cp.SetColors(creature.colors, region);
         if (cp.ShowDialog() == DialogResult.OK)
         {
             // color was chosen
             setColorButton(sender, Utils.creatureColor(creature.colors[region]));
             pictureBox1.Image = CreatureColored.getColoredCreature(creature.colors, creature.species, enabledColorRegions);
             renewLargeImage   = true;
         }
     }
 }
Esempio n. 14
0
        public MultiSetter(List <Creature> creatureList, List <bool> appliedSettings, List <Creature>[] parents, List <string> tagList)
        {
            InitializeComponent();

            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.Alive;
            creatureSex            = Sex.Unknown;

            ParentsChanged = false;
            TagsChanged    = false;

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

            // tags
            MultiSetterTag mst;
            int            i = 0;

            foreach (string t in tagList)
            {
                mst          = new MultiSetterTag(t);
                mst.Location = new Point(3, 3 + i * 29 - panelTags.VerticalScroll.Value);
                panelTags.Controls.Add(mst);
                tagControls.Add(mst);
                i++;
            }
        }
Esempio n. 15
0
        public void UpdateLabel()
        {
            LbMotherAndWildInfo.Text = "";
            if (_creature != null)
            {
                groupBox1.Text = $"{_creature.name} (Lvl {_creature.Level}/{_creature.LevelHatched + _cc.maxDomLevel})";

                void SetParentLabel(Label l, string lbText = null, bool clickable = false)
                {
                    l.Text   = lbText;
                    l.Cursor = clickable ? Cursors.Hand : null;
                    _tt.SetToolTip(l, clickable ? lbText : null);
                }

                if (_creature.Mother != null || _creature.Father != null)
                {
                    SetParentLabel(LbMotherAndWildInfo, _creature.Mother != null ? $"{Loc.S("Mother")}: {_creature.Mother.name}" : null, _creature.Mother != null);
                    SetParentLabel(LbFather, _creature.Father != null ? $"{Loc.S("Father")}: {_creature.Father.name}" : null, _creature.Father != null);
                }
                else if (_creature.isBred)
                {
                    SetParentLabel(LbMotherAndWildInfo, "bred, click 'edit' to add parents");
                    SetParentLabel(LbFather);
                }
                else
                {
                    SetParentLabel(LbMotherAndWildInfo, "found wild " + _creature.levelFound + (_creature.tamingEff >= 0 ? ", tamed with TE: " + (_creature.tamingEff * 100).ToString("N1") + "%" : ", TE unknown."));
                    SetParentLabel(LbFather);
                }
                statsDisplay1.SetCreatureValues(_creature);
                labelNotes.Text = _creature.note;
                _tt.SetToolTip(labelNotes, _creature.note);
                labelSpecies.Text = _creature.Species.name;
                pictureBox1.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, _colorRegionUseds, creatureSex: _creature.sex));
                _tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(_creature.Species, _creature.colors)
                               + "\n\nClick to copy creature infos as image to the clipboard");
                pictureBox1.Visible = true;
            }
        }
Esempio n. 16
0
 public void UpdateLabel()
 {
     labelParents.Text = "";
     if (creature != null)
     {
         groupBox1.Text = $"{creature.name} (Lvl {creature.Level}/{creature.LevelHatched + cc.maxDomLevel})";
         if (creature.Mother != null || creature.Father != null)
         {
             if (creature.Mother != null)
             {
                 labelParents.Text = "Mo: " + creature.Mother.name;
             }
             if (creature.Father != null && creature.Mother != null)
             {
                 labelParents.Text += "; ";
             }
             if (creature.Father != null)
             {
                 labelParents.Text += "Fa: " + creature.Father.name;
             }
         }
         else if (creature.isBred)
         {
             labelParents.Text = "bred, click 'edit' to add parents";
         }
         else
         {
             labelParents.Text = "found wild " + creature.levelFound + (creature.tamingEff >= 0 ? ", tamed with TE: " + (creature.tamingEff * 100).ToString("N1") + "%" : ", TE unknown.");
         }
         statsDisplay1.SetCreatureValues(creature);
         labelNotes.Text   = creature.note;
         labelSpecies.Text = creature.Species.name;
         pictureBox1.Image = CreatureColored.getColoredCreature(creature.colors, creature.Species, colorRegionUseds);
         tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(creature.Species, creature.colors)
                       + "\n\nClick to copy creature infos as image to the clipboard");
         pictureBox1.Visible = true;
     }
 }
Esempio n. 17
0
        /// <summary>
        /// call this function to create the pedigreeCreature-Elements
        /// </summary>
        public void createPedigree()
        {
            // clear old pedigreeCreatures
            ClearControls();
            if (creature != null)
            {
                SuspendLayout();

                bool isGlowSpecies = Values.V.IsGlowSpecies(creature.Species?.name);
                pedigreeCreature1.IsGlowSpecies = isGlowSpecies;

                int leftBorder           = 40;
                int pedigreeElementWidth = 325;
                int margin = 10;

                lbPedigreeEmpty.Visible = false;

                // create ancestors
                createParentsChild(creature, leftBorder + pedigreeElementWidth + margin, 60, true, true);
                if (creature.Mother != null)
                {
                    if (createParentsChild(creature.Mother, leftBorder, 20))
                    {
                        lines[1].Add(new[] { leftBorder + pedigreeElementWidth, 79, leftBorder + pedigreeElementWidth + margin, 79 });
                    }
                }
                if (creature.Father != null)
                {
                    if (createParentsChild(creature.Father, leftBorder + 2 * (pedigreeElementWidth + margin), 20))
                    {
                        lines[1].Add(new[] { leftBorder + 2 * pedigreeElementWidth + 2 * margin, 79, leftBorder + 2 * pedigreeElementWidth + margin, 159 });
                    }
                }

                // create descendants
                int row = 0;
                // scrolloffsets
                int xS = AutoScrollPosition.X;
                int yS = AutoScrollPosition.Y;
                foreach (Creature c in children)
                {
                    PedigreeCreature pc = new PedigreeCreature(c, enabledColorRegions)
                    {
                        Location = new Point(leftBorder + xS, 200 + 35 * row + yS)
                    };
                    for (int s = 0; s < PedigreeCreature.displayedStats.Length; s++)
                    {
                        int si = PedigreeCreature.displayedStats[s];
                        if (creature.valuesDom[si] > 0 && creature.levelsWild[si] >= 0 && creature.levelsWild[si] == c.levelsWild[si])
                        {
                            lines[0].Add(new[] { leftBorder + 38 + 29 * s, 200 + 35 * row + 6, leftBorder + 38 + 29 * s, 200 + 35 * row + 15, 0, 0 });
                        }
                    }
                    pc.CreatureClicked      += CreatureClicked;
                    pc.CreatureEdit         += CreatureEdit;
                    pc.BestBreedingPartners += BestBreedingPartners;
                    pc.exportToClipboard    += exportToClipboard;
                    splitContainer1.Panel2.Controls.Add(pc);
                    pcs.Add(pc);
                    row++;
                }

                pictureBox.Image = CreatureColored.getColoredCreature(creature.colors, creature.Species, enabledColorRegions, 256);

                Invalidate();
                ResumeLayout();
            }
            else
            {
                noCreatureSelected();
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Creates the pedigree with creature controls.
        /// </summary>
        private void CreatePedigree()
        {
            // clear old pedigreeCreatures
            ClearControls();
            if (_selectedCreature == null)
            {
                NoCreatureSelected();
                return;
            }

            SuspendLayout();

            pedigreeCreature1.SetCustomStatNames(_selectedCreature?.Species?.statNames);

            const int leftBorder           = 40;
            const int pedigreeElementWidth = 325;
            const int margin = 10;

            lbPedigreeEmpty.Visible = false;

            // create ancestors
            CreateParentsChild(_selectedCreature, leftBorder + pedigreeElementWidth + margin, 60, true, true);
            if (_selectedCreature.Mother != null)
            {
                if (CreateParentsChild(_selectedCreature.Mother, leftBorder, 20))
                {
                    _lines[1].Add(new[] { leftBorder + pedigreeElementWidth, 79, leftBorder + pedigreeElementWidth + margin, 79 });
                }
            }
            if (_selectedCreature.Father != null)
            {
                if (CreateParentsChild(_selectedCreature.Father, leftBorder + 2 * (pedigreeElementWidth + margin), 20))
                {
                    _lines[1].Add(new[] { leftBorder + 2 * pedigreeElementWidth + 2 * margin, 79, leftBorder + 2 * pedigreeElementWidth + margin, 159 });
                }
            }

            // create descendants
            int row = 0;
            // scrolloffsets
            int xS = AutoScrollPosition.X;
            int yS = AutoScrollPosition.Y;

            foreach (Creature c in _creatureChildren)
            {
                PedigreeCreature pc = new PedigreeCreature(c, _enabledColorRegions)
                {
                    Location = new Point(leftBorder + xS, 200 + 35 * row + yS)
                };
                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[] { leftBorder + 38 + 29 * s, 200 + 35 * row + 6, leftBorder + 38 + 29 * s, 200 + 35 * row + 15, 0, 0 });
                    }
                }
                pc.CreatureClicked      += CreatureClicked;
                pc.CreatureEdit         += CreatureEdit;
                pc.BestBreedingPartners += BestBreedingPartners;
                pc.ExportToClipboard    += ExportToClipboard;
                splitContainer1.Panel2.Controls.Add(pc);
                _pcs.Add(pc);
                row++;
            }

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

            Invalidate();
            ResumeLayout();
        }
Esempio n. 19
0
        /// <summary>
        /// call this function to create the pedigreeCreature-Elements
        /// </summary>
        public void createPedigree()
        {
            // clear old pedigreeCreatures
            ClearControls();
            if (creature != null)
            {
                this.SuspendLayout();

                int leftBorder = 200;

                lbPedigreeEmpty.Visible = false;

                // create ancestors
                createParentsChild(creature, leftBorder + 325, 60, true, true);
                if (creature.Mother != null)
                {
                    if (createParentsChild(creature.Mother, leftBorder + 10, 20, false))
                    {
                        lines[1].Add(new int[] { leftBorder + 306, 79, leftBorder + 325, 79 });
                    }
                }
                if (creature.Father != null)
                {
                    if (createParentsChild(creature.Father, leftBorder + 640, 20, false))
                    {
                        lines[1].Add(new int[] { leftBorder + 640, 79, leftBorder + 621, 159 });
                    }
                }

                // create descendants
                int row = 0;
                // scrolloffsets
                int xS = AutoScrollPosition.X;
                int yS = AutoScrollPosition.Y;
                foreach (Creature c in children)
                {
                    PedigreeCreature pc = new PedigreeCreature(c, enabledColorRegions);
                    pc.Location = new Point(leftBorder + 10 + xS, 200 + 35 * row + yS);
                    for (int s = 0; s < 7; s++)
                    {
                        if (creature.levelsWild[s] >= 0 && creature.levelsWild[s] == c.levelsWild[s])
                        {
                            lines[0].Add(new int[] { leftBorder + 10 + 38 + 28 * s, 200 + 35 * row + 6, leftBorder + 10 + 38 + 28 * s, 200 + 35 * row + 15, 0, 0 });
                        }
                    }
                    pc.CreatureClicked      += new PedigreeCreature.CreatureChangedEventHandler(CreatureClicked);
                    pc.CreatureEdit         += new PedigreeCreature.CreatureEditEventHandler(CreatureEdit);
                    pc.BestBreedingPartners += new PedigreeCreature.CreaturePartnerEventHandler(BestBreedingPartners);
                    pc.exportToClipboard    += new PedigreeCreature.ExportToClipboardEventHandler(exportToClipboard);
                    Controls.Add(pc);
                    pcs.Add(pc);
                    row++;
                }

                pictureBox.Image = CreatureColored.getColoredCreature(creature.colors, creature.species, enabledColorRegions, 256);

                this.Invalidate();
                this.ResumeLayout();
            }
            else
            {
                noCreatureSelected();
            }
        }
 /// <summary>
 /// Updates the displayed colors of the creature.
 /// </summary>
 private void UpdateRegionColorImage()
 {
     ParentInheritance?.UpdateColors(RegionColors);
     ColorsChanged?.Invoke(this);
     PbColorRegion?.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(RegionColors, _selectedSpecies, regionColorChooser1.ColorRegionsUseds, 256, onlyImage: true, creatureSex: CreatureSex));
 }
Esempio n. 21
0
        private static (List <SpeciesListEntry>, ImageList, List <string>) LoadSpeciesImagesAndCreateSpeciesList(List <Species> species, Dictionary <string, string> aliases)
        {
            Dictionary <string, Species> speciesNameToSpecies = new Dictionary <string, Species>();

            var creatureColors = new int[]
            { 44, 42, 57, 10, 26, 78 };   // uniform color pattern that is used for all species in the selector
            var creatureColorsPolar = new int[]
            { 18, 18, 18, 18, 18, 18 };   // uniform color pattern that is used for all polar species in the selector
            ImageList lImgList         = new ImageList();
            var       iconIndices      = new List <string>();
            bool      imageFolderExist = Directory.Exists(FileService.GetPath(FileService.ImageFolderName));

            //var speciesWOImage = new List<string>();// to determine which species have no image yet
            foreach (Species ss in species)
            {
                if (!speciesNameToSpecies.ContainsKey(ss.DescriptiveNameAndMod))
                {
                    speciesNameToSpecies.Add(ss.DescriptiveNameAndMod, ss);
                }

                if (!imageFolderExist)
                {
                    continue;
                }

                var(imgExists, imagePath, speciesListName) = CreatureColored.SpeciesImageExists(ss,
                                                                                                ss.name.Contains("Polar") ? creatureColorsPolar : creatureColors);
                if (!imgExists || iconIndices.Contains(speciesListName))
                {
                    continue;
                }

                try
                {
                    lImgList.Images.Add(Image.FromFile(imagePath));
                    iconIndices.Add(speciesListName);
                }
                catch (OutOfMemoryException)
                {
                    // usually this exception occurs if the image file is corrupted
                    if (FileService.TryDeleteFile(imagePath))
                    {
                        (imgExists, imagePath, speciesListName) = CreatureColored.SpeciesImageExists(ss,
                                                                                                     ss.name.Contains("Polar") ? creatureColorsPolar : creatureColors);
                        if (imgExists)
                        {
                            try
                            {
                                lImgList.Images.Add(Image.FromFile(imagePath));
                            }
                            catch
                            {
                                // ignore image if it failed a second time
                            }

                            iconIndices.Add(speciesListName);
                        }
                    }
                }

                //if (!imgExists && !speciesWOImage.Contains(ss.name)) speciesWOImage.Add(ss.name);
            }
            //Clipboard.SetText(string.Join("\n", speciesWOImage));

            var entryList = new List <SpeciesListEntry>();

            foreach (var s in species)
            {
                entryList.Add(new SpeciesListEntry
                {
                    DisplayName = s.name,
                    SearchName  = s.name,
                    ModName     = s.Mod?.title ?? string.Empty,
                    Species     = s
                });
            }

            foreach (var a in aliases)
            {
                if (speciesNameToSpecies.ContainsKey(a.Value))
                {
                    entryList.Add(new SpeciesListEntry
                    {
                        DisplayName = a.Key + " (→" + speciesNameToSpecies[a.Value].name + ")",
                        SearchName  = a.Key,
                        Species     = speciesNameToSpecies[a.Value],
                        ModName     = speciesNameToSpecies[a.Value].Mod?.title ?? string.Empty,
                    });
                }
            }

            entryList = entryList.OrderBy(s => s.DisplayName).ToList();
            return(entryList, lImgList, iconIndices);
        }