internal bool LoadMpq(string filename) { ResetMpqDatabase(); // reset everything that was loaded with previous map Current.map = DHRC.OpenArchive(filename, 11); // heroes splashScreen.ShowText("loading units..."); DHMpqDatabase.LoadUnits(); splashScreen.ProgressAdd(8); // items splashScreen.ShowText("loading items..."); DHMpqDatabase.LoadItems(); splashScreen.ProgressAdd(8); // abilites splashScreen.ShowText("loading abilities..."); DHMpqDatabase.LoadAbilities(splashScreen); // upgrades splashScreen.ShowText("loading upgrades..."); DHMpqDatabase.LoadUpgrades(splashScreen); DHLOOKUP.RefreshHotEntries(); // jass try { splashScreen.ShowText("compiling jass..."); DHJass.ReadCustom(DHRC.GetFile(Script.Custom).GetStream(), false); splashScreen.ProgressAdd(14); cbForm.PrepareControls(); splashScreen.ShowText("executing jass..."); DHJass.Config(); DHJass.Go(); splashScreen.ProgressAdd(15); } catch (Exception e) { MessageBox.Show("Failed to load the jass script. This heavely reduces the functionality of DotaHIT, but you will still be able to use simple features like DataDump." + Environment.NewLine + "Error Message: " + e.Message); return(false); } return(true); }
internal void LoadWar3Mpq() { if (Current.map != null) { hlForm.Reset(); DHMpqDatabase.UnitSlkDatabase.Clear(); ilForm.Reset(); DHMpqDatabase.ItemSlkDatabase.Clear(); hlForm.Minimize(true); ilForm.Minimize(true); } ClearMpqDatabase(); string w3path = DHCFG.Items["Path"].GetStringValue("War3"); if (string.IsNullOrEmpty(w3path)) { w3path = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Blizzard Entertainment\Warcraft III", "InstallPath", null) as string; } string war3_not_located = "Unable to locate Warcraft III installation path. For this tool to work correctly, it is required that you have all Warcraft III .mpq files in one directory." + "Would you like to specify that directory? Example: 'C:\\Games\\WarCraft III'"; string error_no_mpqs = "The specified directory for WarCraft III files does not contain any .mpq files, which will cause maps not to load correctly." + "\nWould you like to specify another directory? Example: 'C:\\Games\\WarCraft III'"; while (String.IsNullOrEmpty(w3path) || !Directory.Exists(w3path)) { switch (MessageBox.Show(war3_not_located, UIStrings.Warning, MessageBoxButtons.YesNo)) { case DialogResult.Yes: if (browseForFolder()) { w3path = folderBrowserDialogWrapper.SelectedPath; } break; case DialogResult.No: return; } } string[] files; while ((files = Directory.GetFiles(Path.GetFullPath(w3path), "*.mpq")).Length == 0) { switch (MessageBox.Show(error_no_mpqs, UIStrings.Warning, MessageBoxButtons.YesNo)) { case DialogResult.Yes: if (browseForFolder()) { w3path = folderBrowserDialogWrapper.SelectedPath; } break; case DialogResult.No: return; } } DHCFG.Items["Path"]["War3"] = w3path; // save the correct war3 path foreach (string file in files) { int index = MpqArchive.List.IndexOf(Path.GetFileName(file.ToLower())); if (index != -1) { DHRC.OpenArchive(file, (uint)index); } else { DHRC.OpenArchive(file, 10); } } ///////// editor data ////////// DHMpqDatabase.LoadEditorData(); //////// jass ////////////////// MemoryStream jassStream; DHJassExecutor.ShowMissingFunctions = true; jassStream = DHRC.GetFile(Script.Common).GetStream(); DHJass.ReadWar3Ex(jassStream, true); jassStream = DHRC.GetFile(Script.Blizzard).GetStream(); DHJass.ReadWar3(jassStream, false); DHJass.CompleteWar3Init(); Current.sessionHasWar3DB = true; }