private static int TryUpdateSpec(HeroExeData hero, DefFile un32, DefFile un44) { if (OriginalSpecs == null) { return(-1); } int index = FindOriginalSpecIndexFromSpeciality(hero.Spec); if (index >= 0) { un44.RetargetSprite(def44, 0, hero.Index, index); un32.RetargetSprite(def32, 0, hero.Index, index); var hs = HeroesManager.AllHeroes[hero.Index]; hs.Speciality = SpecialityBuilder.OriginalSpecText(index); return(index); } else { index = FindSameIconIndexForSpeciality(hero.Spec); if (index >= 0) { un44.RetargetSprite(def44, 0, hero.Index, index); un32.RetargetSprite(def32, 0, hero.Index, index); } else { CreateNewSpecImage(); } var hs = HeroesManager.AllHeroes[hero.Index]; hs.Speciality = GenerateCustomSpecText(hero); } return(index); }
public void LoadMaster(string executablPath) { var master = Heroes3Master.LoadInfo(executablPath); selectedLodFile = master.GetByName("h3bitmap.lod"); SpecialityBuilder.LoadFromMaster(master); heroMainDataControl.LoadCastles(); heroMainDataControl.LoadHeroes(); heroClassDataControl.LoadHeroClasses(); creatureDataControl.LoadCastles(); spellDataControl.LoadSpells(); var lodFileNames = master.ResourceFiles.Select(s => s.Name).ToArray(); cbLodFiles.Items.AddRange(lodFileNames); cbLodFiles.SelectedIndex = Array.IndexOf <string>(lodFileNames, selectedLodFile.Name); tabsMain.TabPages.Add(tabHeroes); tabsMain.TabPages.Add(tabHeroClass); tabsMain.TabPages.Add(tabCreatures); tabsMain.TabPages.Add(tabSpells); tabsMain.TabPages.Add(tabResources); }
private void HeroPropertyForm_ItemSelected(int selIndex, int arg1, int arg2, int arg3) { ProfilePropertyType type = heroPropertyForm.PropertyType; var hpcHeroProfile = heroMainDataControl.HeroProfileControl; var hero = hpcHeroProfile.Hero; if (type == ProfilePropertyType.Creature) { int realIndex = CreatureManager.OnlyActiveCreatures[selIndex].CreatureIndex; hero.HasChanged = true; switch (heroPropertyForm.CurrentIndex) { case 0: hero.Unit1Index = realIndex; break; case 1: hero.Unit2Index = realIndex; break; case 2: hero.Unit3Index = realIndex; break; } hpcHeroProfile.LoadHero(hpcHeroProfile.HeroIndex, Heroes3Master.Master); } else if (type == ProfilePropertyType.SecondarySkill) { int skill = selIndex / 3; int level = 1 + selIndex % 3; hero.HasChanged = true; if (heroPropertyForm.CurrentIndex == 0) { hero.FirstSkillIndex = skill; hero.FirstSkillLevel = level; } else { hero.SecondSkillIndex = skill; hero.SecondSkillLevel = level; } hpcHeroProfile.LoadHero(hpcHeroProfile.HeroIndex, Heroes3Master.Master); } else if (type == ProfilePropertyType.Spell) { hero.HasChanged = true; hero.SpellBook = 1; hero.SpellIndex = selIndex; hpcHeroProfile.LoadHero(hpcHeroProfile.HeroIndex, Heroes3Master.Master); } else { var specType = Speciality.FromProfileProperty(type); if (specType != SpecialityType.Invalid) { Speciality.UpdateSpecialityData(specType, hero.Index, selIndex, arg1, arg2, arg3); hero.HasChanged = true; var hs = HeroesManager.AllHeroes[hero.Index]; SpecialityBuilder.TryUpdateSpecialityImageAndText(Heroes3Master.Master, hero); heroMainDataControl.Speciality = hs.Speciality; HeroesManager.AnyChanges = true; hpcHeroProfile.LoadHero(hpcHeroProfile.HeroIndex, Heroes3Master.Master); } //hpcHeroProfile } }