public void LoadData(Heroes3Master master) { Master = master; OriginalData = new List <FatRecord>(); foreach (var name in FileEntriesToBackups) { string backupName = GetBackupFileName(name); FatRecord temp = master.ResolveWith(backupName, false); FatRecord original = master.ResolveWith(name); if (temp == null || temp.Parent != original.Parent) { List <string> list; if (!master.NameToFileMap.TryGetValue(backupName.ToLower(), out list)) { list = new List <string>(); master.NameToFileMap[backupName.ToLower()] = list; } list.Add(original.Parent.Name.ToLower()); temp = original.Clone(backupName); temp.Parent.AddNewRecord(temp); } OriginalData.Add(temp); } }
public static void LoadInfo(Heroes3Master master) { Unload(); string[] names = Encoding.Default.GetString(master.ResolveWith(TXT_FNAME).GetRawData()).Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); AllTownsWithNeutral = new Town[10]; var rec = master.ResolveWith(IMG_FNAME).GetDefFile(); for (int i = 0; i < AllTownsWithNeutral.Length - 1; i++) { var bmp = rec.GetSprite(0, 2 + i * 2); AllTownsWithNeutral[i] = new Town { Index = i, Name = names[i], Image = new Bitmap(bmp, new Size(36, 24)), LargeImage = bmp }; } AllTownsWithNeutral[9] = new Town { Index = 9, Name = "Neutral", LargeImage = rec.GetSprite(38) }; AllTownsWithNeutral[9].Image = new Bitmap(AllTownsWithNeutral[9].LargeImage, new Size(36, 24)); TownNamesWithNeutral = AllTownsWithNeutral.Select(s => s.Name).ToArray(); }
public static void LoadFromMaster(Heroes3Master master) { FatRecord un32, un44; un32 = master.ResolveWith(BackupManager.GetBackupFileName(Speciality.IMG_FNAME_SMALL)) ?? master.ResolveWith(Speciality.IMG_FNAME_SMALL); un44 = master.ResolveWith(BackupManager.GetBackupFileName(Speciality.IMG_FNAME)) ?? master.ResolveWith(Speciality.IMG_FNAME); h_specs = master.ResolveWith(BackupManager.GetBackupFileName(HeroesManager.H_SPECS)) ?? master.ResolveWith(HeroesManager.H_SPECS); spec_rows = Encoding.Default.GetString(h_specs.GetRawData()).Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); LoadOriginalSpecs(Properties.Resources.allspecs, 0); LoadDefsUncompressed(un32.GetRawData(), un44.GetRawData()); }
public static Bitmap GetSkillTreeForHeroClass(Heroes3Master master) { if (_skillTree != null) { return(_skillTree); } if (_defFile == null) { _defFile = master.ResolveWith(IMG_FNAME).GetDefFile(); } var bmp = new Bitmap(44 * 7, (44 + 20) * 4); using (var g = Graphics.FromImage(bmp)) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 7; j++) { g.DrawImage(_defFile.GetByAbsoluteNumber(3 + (i * 7 + j) * 3), j * 44, 64 * i); } } } _skillTree = bmp; return(_skillTree); }
public static Bitmap GetSkillTree(Heroes3Master master) { if (_skillTree2 != null) { return(_skillTree2); } if (_defFile == null) { _defFile = master.ResolveWith(IMG_FNAME).GetDefFile(); } int rowCount = 3 * AllSkills.Count / ALL_COLNUMBER; var bmp = new Bitmap((44 + 1) * ALL_COLNUMBER, (44 + 1) * rowCount, System.Drawing.Imaging.PixelFormat.Format24bppRgb); var imageData = bmp.LockBits24(); Parallel.For(0, AllSkills.Count * 3, i => { int row = i / ALL_COLNUMBER; int col = i % ALL_COLNUMBER; var img = _defFile.GetByAbsoluteNumber2(3 + row * ALL_COLNUMBER + col); imageData.DrawImage24(col * (44 + 1), row * (44 + 1), 132, img); }); bmp.UnlockBits(imageData); _skillTree2 = bmp; return(_skillTree2); }
public static Bitmap GetAvailableSpellsForSpeciality(Heroes3Master master) { if (BitmapCache.SpellsForSpeciality != null) { return(BitmapCache.SpellsForSpeciality); } if (defFile == null) { defFile = master.ResolveWith(IMG_FNAME).GetDefFile(); } var bmp = new Bitmap((58 + 1) * 6, (64 + 1) * 5); var imageData = bmp.LockBits24(); Parallel.For(0, SpecSpellIndexes.Length, i => { int row = i / 6; int col = i % 6; var img = defFile.GetByAbsoluteNumber2(AllSpells[SpecSpellIndexes[i]].Index); if (img != null) { imageData.DrawImage24(col * (58 + 1), row * (64 + 1), 176, img); } }); bmp.UnlockBits(imageData); BitmapCache.SpellsForSpeciality = bmp; return(BitmapCache.SpellsForSpeciality); }
public Bitmap GetFrame(Heroes3Master master) { if (frames == null || CurrentFrame >= frames.Length) { return(null); } if (frames[CurrentFrame] == null) { var bmp = creatureAnimation.GetSprite(SPRITES_INDEX, CurrentFrame); int castleIndex = GetBackgroundIndex(CreatureIndex); if (backgrounds == null) { backgrounds = new Bitmap[master.CastlesCount + 1]; } if (backgrounds[castleIndex] == null) { backgrounds[castleIndex] = master.ResolveWith(backgroundNames[castleIndex]).GetBitmap(); } Point pt; Size size; ComputeSpriteParameters(creatureAnimation.headers[SPRITES_INDEX], out pt, out size); // var sw = Stopwatch.StartNew(); frames[CurrentFrame] = DrawTransparent(backgrounds[castleIndex], bmp, pt, size); //fullTime += sw.ElapsedMs(); using (var g = Graphics.FromImage(frames[CurrentFrame])) g.DrawRectangle(Pens.Black, 0, 0, 100 - 1, 130 - 1); } return(frames[CurrentFrame]); }
public static Bitmap GetSkillsForSpeciality(Heroes3Master master) { if (_specImage != null) { return(_specImage); } if (_defFile == null) { _defFile = master.ResolveWith(IMG_FNAME).GetDefFile(); } int rowNum = IndexesOfAllSpecSkills.Length / SPEC_COLNUMBER + (IndexesOfAllSpecSkills.Length % SPEC_COLNUMBER == 0 ? 0 : 1); var bmp = new Bitmap((44 + 1) * SPEC_COLNUMBER, (44 + 1) * rowNum, System.Drawing.Imaging.PixelFormat.Format24bppRgb); var imageData = bmp.LockBits24(); Parallel.For(0, IndexesOfAllSpecSkills.Length, i => { int row = i / SPEC_COLNUMBER; int col = i % SPEC_COLNUMBER; var img = _defFile.GetByAbsoluteNumber2(3 + IndexesOfAllSpecSkills[i] * 3); imageData.DrawImage24(col * (44 + 1), row * (44 + 1), 132, img); }); bmp.UnlockBits(imageData); _specImage = bmp; return(_specImage); }
public Bitmap GetImage(Heroes3Master master) { if (defFile == null) { defFile = master.ResolveWith(IMG_FNAME).GetDefFile(); } return(defFile.GetByAbsoluteNumber(Index)); }
public static void SaveLocalChanges(Heroes3Master master) { var sb = new StringBuilder(); sb.AppendLine(rows[0]); sb.AppendLine(rows[1]); for (int i = 0; i < AllHeroClasses.Count; i++) { sb.AppendLine(AllHeroClasses[i].GetRow()); } master.ResolveWith(TXT_FNAME).ApplyChanges(Encoding.Default.GetBytes(sb.ToString())); }
public static Bitmap GetBackground(Heroes3Master master) { if (BitmapCache.HeroesBackground != null) { return(BitmapCache.HeroesBackground); } var bmp = new Bitmap(288, 331); using (var g = Graphics.FromImage(bmp)) { var f = master.ResolveWith(H_BACKGROUND).GetBitmap(); if (f != null) { g.DrawImage(f, new Point(-14, -15)); } g.DrawImage(f, 5, 261, new RectangleF(18, 18, 62, 68), GraphicsUnit.Pixel); g.DrawImage(f, 5 + 62, 261, new RectangleF(18, 18, 62, 68), GraphicsUnit.Pixel); g.DrawImage(f, 5 + 62 + 62, 261, new RectangleF(18, 18, 62, 68), GraphicsUnit.Pixel); g.DrawImage(f, 192, 261, new RectangleF(196, 19, 93, 65), GraphicsUnit.Pixel); g.DrawImage(f, 0, 327, new RectangleF(14, 85, 288, 4), GraphicsUnit.Pixel); var ps = master.ResolveWith(H_PRIMARYSKILLS).GetDefFile(); if (ps != null) { g.DrawImage(ps.GetSprite(0), new Point(18, 97)); g.DrawImage(ps.GetSprite(1), new Point(88, 97)); g.DrawImage(ps.GetSprite(2), new Point(158, 97)); g.DrawImage(ps.GetSprite(5), new Point(228, 97)); g.DrawImage(ps.GetSprite(3), new Point(167, 167)); } } BitmapCache.HeroesBackground = bmp; return(BitmapCache.HeroesBackground); }
public static void LoadInfo(Heroes3Master master) { AnyChanges = false; var rec = master.ResolveWith(TXT_FNAME); string text = Encoding.Default.GetString(rec.GetRawData()); rows = text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); AllHeroClasses = new List <HeroClass>(rows.Length); for (int i = 0; i < rows.Length - 2; i++) { AllHeroClasses.Add(new HeroClass(i, rows[i + 2])); } }
public static void SaveLocalChanges(Heroes3Master master) { var rec = master.ResolveWith(TXT_FNAME); if (rec != null) { var sb = new StringBuilder(); int i; int index = 0; for (i = 0; i < 5; i++) { sb.AppendLine(allRows[i]); } for (; i < allRows.Length; i++) { string row = allRows[i]; if (row.StartsWith("Creature Abilities")) { break; } if (string.IsNullOrEmpty(row) || row.StartsWith("\t\t\t") || row.StartsWith("Combat Spells") || row.StartsWith("Adventure Spells") || row.StartsWith("Name")) { sb.AppendLine(row); continue; } var spellCells = AllSpells[index].cells; for (int j = 0; j < spellCells.Length - 1; j++) { sb.Append(spellCells[j]); sb.Append('\t'); } sb.AppendLine(spellCells[spellCells.Length - 1]); index++; } for (; i < allRows.Length; i++) { sb.AppendLine(allRows[i]); } rec.ApplyChanges(Encoding.Default.GetBytes(sb.ToString())); } }
public static Bitmap GetPrimarySkillsPanel(Heroes3Master master) { var bmp = new Bitmap(4 * 42, 42); using (var g = Graphics.FromImage(bmp)) { var ps = master.ResolveWith(H_PRIMARYSKILLS).GetDefFile(); if (ps != null) { g.DrawImage(ps.GetSprite(0), new Point(0, 0)); g.DrawImage(ps.GetSprite(1), new Point(42, 0)); g.DrawImage(ps.GetSprite(2), new Point(84, 0)); g.DrawImage(ps.GetSprite(5), new Point(126, 0)); } } return(bmp); }
public static void LoadInfo(Heroes3Master master) { Unload(); var rec = master.ResolveWith(TXT_FNAME); string text = Encoding.Default.GetString(rec.GetRawData()); var rows = text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); AllSkills = new List <SecondarySkill>(rows.Length - 2); for (int i = 2; i < rows.Length; i++) { string name = rows[i].Split('\t')[0]; AllSkills.Add(new SecondarySkill { Index = i - 2, Name = name }); } }
public static Bitmap GetAllSpells(Heroes3Master master) { if (BitmapCache.SpellsAll != null) { return(BitmapCache.SpellsAll); } if (defFile == null) { defFile = master.ResolveWith(IMG_FNAME).GetDefFile(); } int total = defFile.headers[0].SpritesCount; var baseSprite = defFile.headers[0].spriteHeaders[0]; int imgWidth = baseSprite.SpriteWidth; int imgHeight = baseSprite.SpriteHeight; int stride = baseSprite.Stride24; int colCount = ALL_SPELLS_COLUMN_NUMBER; int rowCount = (total / colCount) + (total % colCount == 0 ? 0 : 1); var bmp = new Bitmap((imgWidth + 1) * colCount, (imgHeight + 1) * rowCount); var imageData = bmp.LockBits24(); Parallel.For(0, total, i => { int row = i / colCount; int col = i % colCount; var img = defFile.GetByAbsoluteNumber2(i); if (img != null) { imageData.DrawImage24(col * (imgWidth + 1), row * (imgHeight + 1), stride, img); } }); bmp.UnlockBits(imageData); BitmapCache.SpellsAll = bmp; return(BitmapCache.SpellsAll); }
public static void SaveLocalChanges(Heroes3Master master) { var lod1 = master.Resolve(TXT_BIOGRAPHIES_FNAME); var lod2 = master.Resolve(H_SPECS); var lod3 = master.Resolve(H_HEROES); StringBuilder bios, spec, traits; bios = new StringBuilder(); spec = new StringBuilder(); traits = new StringBuilder(); spec.AppendLine(spec_rows[0] + "\r\n" + spec_rows[1]); traits.AppendLine(hero_rows[0] + "\r\n" + hero_rows[1]); for (int i = 0; i < HeroesOrder.Length; i++) { bios.AppendLine(AllHeroes[i].Biography); spec.AppendLine(AllHeroes[i].Speciality); traits.Append(AllHeroes[i].Name); traits.Append('\t'); traits.Append(AllHeroes[i].LowStack1); traits.Append('\t'); traits.Append(AllHeroes[i].HighStack1); traits.Append('\t'); traits.Append("cr1"); traits.Append('\t'); traits.Append(AllHeroes[i].LowStack2); traits.Append('\t'); traits.Append(AllHeroes[i].HighStack2); traits.Append('\t'); traits.Append("cr2"); traits.Append('\t'); traits.Append(AllHeroes[i].LowStack3); traits.Append('\t'); traits.Append(AllHeroes[i].HighStack3); traits.Append('\t'); traits.AppendLine("cr3"); if (AllHeroes[i].Large != null) { var rec = master.ResolveWith(HeroesOrder[AllHeroes[i].ImageIndex]); rec.ApplyChanges(PcxFile.FromBitmap(AllHeroes[i].Large).GetBytes); } if (AllHeroes[i].Small != null) { var rec = master.ResolveWith(HeroesOrder[AllHeroes[i].ImageIndex].Replace("HPL", "HPS")); rec.ApplyChanges(PcxFile.FromBitmap(AllHeroes[i].Small).GetBytes); } } for (int i = HeroesOrder.Length; i < bio_rows.Length; i++) { bios.AppendLine(bio_rows[i]); if (i + 2 < spec_rows.Length) { spec.AppendLine(spec_rows[2 + i]); } if (i + 2 < hero_rows.Length) { traits.AppendLine(hero_rows[2 + i]); } } lod1[TXT_BIOGRAPHIES_FNAME].ApplyChanges(Encoding.Default.GetBytes(bios.ToString())); lod2[H_SPECS].ApplyChanges(Encoding.Default.GetBytes(spec.ToString())); lod3[H_HEROES].ApplyChanges(Encoding.Default.GetBytes(traits.ToString())); }
//331 288 public void LoadHero(int heroIndex, Heroes3Master master) { HeroIndex = heroIndex; Hero = null; if (heroIndex > -1 && heroIndex < HeroesManager.HeroesOrder.Length && master != null) { var hs = HeroesManager.AllHeroes[heroIndex]; var bckgImage = HeroesManager.GetBackground(master); var canvas = new Bitmap(bckgImage); var g = Graphics.FromImage(canvas); /* g.InterpolationMode = InterpolationMode.High; * g.SmoothingMode = SmoothingMode.HighQuality; * g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; * g.CompositingQuality = CompositingQuality.HighQuality;*/ g.DrawImage(bckgImage, Point.Empty); var portrait = master.ResolveWith(HeroesManager.HeroesOrder[hs.ImageIndex]).GetBitmap(); g.DrawImage(portrait, new Point(4, 3)); var heroData = HeroExeData.Data[heroIndex]; var z = Speciality.GetImage(master, heroData.Index); g.DrawImage(z, new Point(4, 166)); Hero = heroData; if (heroData.Skill1 != null) { g.DrawImage(heroData.Skill1.GetImage(master, heroData.FirstSkillLevel), new Point(5, 213)); } if (heroData.Skill2 != null) { g.DrawImage(heroData.Skill2.GetImage(master, heroData.SecondSkillLevel), new Point(148, 213)); } var img1 = CreatureManager.GetImage(master, heroData.Unit1Index); g.DrawImage(img1, new Point(5, 262)); var img2 = CreatureManager.GetImage(master, heroData.Unit2Index); g.DrawImage(img2, new Point(68, 262)); var img3 = CreatureManager.GetImage(master, heroData.Unit3Index); g.DrawImage(img3, new Point(129, 262)); if (heroData.Spell != null) { g.DrawImage(heroData.Spell.GetImage(master), 192, 262); } DrawData(g, heroData); //heroData.Class.Stats /* * g.DrawImage(ps.GetSprite(0), new Point(18, 97)); * g.DrawImage(ps.GetSprite(1), new Point(88, 97)); * g.DrawImage(ps.GetSprite(2), new Point(158, 97)); * g.DrawImage(ps.GetSprite(5), new Point(228, 97)); */ g.Dispose(); PictureBox.Image = canvas; CalculateRatio(); } }
public static Bitmap GetImage(Heroes3Master master, int index) { return(master.ResolveWith(IMG_FNAME).GetDefFile().GetByAbsoluteNumber(index)); }