private void cbSpellFilter_DrawItem(object sender, DrawItemEventArgs e) { if (Heroes3Master.Master != null && e.Index >= 0 && selectedFilterIndex >= 0) { Color clr; Bitmap schoolImage; if (e.Index == 0) { clr = Color.Lavender; schoolImage = new Bitmap(SecondarySkill.GetImage(Heroes3Master.Master, 25, 3), 32, 32); //25 is sorecery //schoolImage = SecondarySkill.GetImage(Heroes3Master.Master.H3Sprite, 25, 3); //25 is sorecery } else { clr = Spell.MagicSchoolColors[e.Index - 1]; schoolImage = new Bitmap(SecondarySkill.GetImage(Heroes3Master.Master, SecondarySkill.MagicSchoolSecondarySkillIndexes[e.Index - 1], 3), 32, 32); // schoolImage = SecondarySkill.GetImage(Heroes3Master.Master.H3Sprite, SecondarySkill.MagicSchoolSecondarySkillIndexes[e.Index - 1], 3); } e.Graphics.FillRectangle(new SolidBrush(clr), e.Bounds); e.Graphics.DrawImage(schoolImage, e.Bounds.X, e.Bounds.Y); e.Graphics.DrawString(cbSpellFilter.Items[e.Index].ToString(), e.Font, Brushes.Black, e.Bounds.X + 56, e.Bounds.Y + 9); } }
// private static Bitmap GetImageForPropertyType(ProfilePropertyType propertyType, int index, bool forceAllCreatures) { if (index >= 0) { if (propertyType == ProfilePropertyType.Creature) { int realIndex = CreatureManager.OnlyActiveCreatures[index].CreatureIndex; return(CreatureManager.GetImage(Heroes3Master.Master, realIndex)); } if (propertyType == ProfilePropertyType.SecondarySkill) { return(SecondarySkill.AllSkills[index / 3].GetImage(Heroes3Master.Master, 1 + index % 3)); } if (propertyType == ProfilePropertyType.Spell) { return(Spell.AllSpells[index].GetImage(Heroes3Master.Master)); } if (propertyType == ProfilePropertyType.SpecCreature || propertyType == ProfilePropertyType.SpecCreatureStatic) { return(CreatureManager.GetImage(Heroes3Master.Master, CreatureManager.IndexesOfFirstLevelCreatures[index])); } if (propertyType == ProfilePropertyType.SpecCreatureUpgrade) { if (!forceAllCreatures) { return(CreatureManager.GetImage(Heroes3Master.Master, CreatureManager.IndexesOfFirstLevelCreatures[index])); } int realIndex = CreatureManager.OnlyActiveCreatures[index].CreatureIndex; return(CreatureManager.GetImage(Heroes3Master.Master, realIndex)); } if (propertyType == ProfilePropertyType.SpecSpell) { return(Spell.GetSpellByIndex(Spell.SpecSpellIndexes[index]).GetImage(Heroes3Master.Master)); } if (propertyType == ProfilePropertyType.SpecSecondarySkill) { return(SecondarySkill.GetImage(Heroes3Master.Master, SecondarySkill.IndexesOfAllSpecSkills[index], 1)); } if (propertyType == ProfilePropertyType.SpecResource) { return(Resource.GetImage(Heroes3Master.Master, index)); } } return(null); }
private static Bitmap GetBackgroundImageForPropertyType(ProfilePropertyType propertyType, bool forceAllCreatures) { if (Heroes3Master.Master != null) { if (propertyType == ProfilePropertyType.Creature) { return(new Bitmap(CreatureManager.GetAllCreaturesBitmapParallel(Heroes3Master.Master))); } if (propertyType == ProfilePropertyType.SecondarySkill) { return(new Bitmap(SecondarySkill.GetSkillTree(Heroes3Master.Master))); } if (propertyType == ProfilePropertyType.Spell) { return(new Bitmap(Spell.GetAllSpells(Heroes3Master.Master))); } if (propertyType == ProfilePropertyType.SpecCreature || propertyType == ProfilePropertyType.SpecCreatureStatic) { return(CreatureManager.GetAllBasicCreatures(Heroes3Master.Master)); } if (propertyType == ProfilePropertyType.SpecCreatureUpgrade) { if (forceAllCreatures) { return(new Bitmap(CreatureManager.GetAllCreaturesBitmapParallel(Heroes3Master.Master))); } return(CreatureManager.GetAllBasicCreatures(Heroes3Master.Master)); } if (propertyType == ProfilePropertyType.SpecSecondarySkill) { return(SecondarySkill.GetSkillsForSpeciality(Heroes3Master.Master)); } if (propertyType == ProfilePropertyType.SpecSpell) { return(Spell.GetAvailableSpellsForSpeciality(Heroes3Master.Master)); } if (propertyType == ProfilePropertyType.SpecResource) { return(Resource.GetAllResources(Heroes3Master.Master)); } } return(null); }
private void TryLoadStaticImages() { if (BitmapCache.SpellsMagicSchools == null || BitmapCache.SpellsMagicSchoolsInactive == null) { BitmapCache.SpellsMagicSchools = new Bitmap[5]; BitmapCache.SpellsMagicSchoolsInactive = new Bitmap[4]; for (int i = 0; i < 4; i++) { BitmapCache.SpellsMagicSchools[i] = SecondarySkill.GetImage(Heroes3Master.Master, SecondarySkill.MagicSchoolSecondarySkillIndexes[i], 3); var inactive = new Bitmap(BitmapCache.SpellsMagicSchools[i]); using (var g = Graphics.FromImage(inactive)) { g.FillRectangle(new SolidBrush(Color.FromArgb(190, Color.Gray)), 0, 0, inactive.Width, inactive.Height); } BitmapCache.SpellsMagicSchoolsInactive[i] = inactive; } } }
public void RefreshData() { routingCache = new Dictionary <string, LodFile>(); BackupManager = new BackupManager(); Resource.Unload(); CreatureAnimationLoop.Unload(); BitmapCache.UnloadCachedDrawItems(); HeroesManager.LoadInfo(this); HeroClass.LoadInfo(this); CreatureManager.LoadInfo(this); Spell.LoadInfo(this); SecondarySkill.LoadInfo(this); StringsData.LoadInfo(this); Speciality.LoadInfo(this); Town.LoadInfo(this); HeroExeData.LoadInfo(this); BackupManager.LoadData(this); }
private void GenerateControls() { if (!controlsCreated) { cbAggression.Items.AddRange(Aggression); SuspendLayout(); var bmp = SecondarySkill.GetSkillTreeForHeroClass(Heroes3Master.Master); pbSkillTree.Width = bmp.Width; pbSkillTree.Height = bmp.Height; pbSkillTree.Image = bmp; int itemWidth = pbSkillTree.Width / 7; int itemHeight = pbSkillTree.Height / 4; var bmp2 = HeroesManager.GetPrimarySkillsPanel(Heroes3Master.Master); pbPrimarySkills.Image = bmp2; int totalCount = HeroClass.Stats.Length - 9; int offset = 2; int maxTab = Controls.Cast <Control>().Max(s => s.TabIndex) - 1; for (int i = offset; i < totalCount; i++) { var ctrl = new NumericUpDown(); ((ISupportInitialize)ctrl).BeginInit(); ctrl.Name = "nmStat" + i; ctrl.TextAlign = HorizontalAlignment.Center; ctrl.Maximum = 99; ctrl.TabIndex = i + maxTab; int row, col; if (i < offset + 12) { ctrl.Size = new Size(42, 20); row = (i - 2) / 4; col = (i - 2) % 4; int y = pbPrimarySkills.Top + pbPrimarySkills.Height + 3 + row * (20 + 5); ctrl.Location = new Point(pbPrimarySkills.Left + col * 42, y); if (row == 0) { ctrl.Font = new Font(ctrl.Font, FontStyle.Bold); } if (col == 0) { var lbl = Controls.Find("lbl0" + (row + 1), false).FirstOrDefault() as Label; if (lbl != null) { lbl.Top = y + (ctrl.Height - lbl.Height) / 2; } } } else { ctrl.Size = new Size(itemWidth, 24); row = (i - 14) / 7; col = (i - 14) % 7; ctrl.Width = itemWidth; ctrl.Location = new Point(pbSkillTree.Left + itemWidth * col, pbSkillTree.Top + (itemHeight) * (row + 1) - 19); } Controls.Add(ctrl); ((ISupportInitialize)ctrl).EndInit(); } pbSkillTree.SendToBack(); ResumeLayout(false); PerformLayout(); controlsCreated = true; } }