public void ReadGameDirectory(string path) { DataPath = path; IsInitialized = false; System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); System.Threading.Thread workerThread = null; loadWaitWorker = new BackgroundWorker { WorkerReportsProgress = true }; loadWaitWorker.DoWork += ((s, e) => { try { System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; workerThread = System.Threading.Thread.CurrentThread; loadWaitWorker.ReportProgress(-1, "Reading game directory..."); ReadHeaderIdentify(); PrepareDirectoryUnpack(); loadWaitWorker.ReportProgress(-1, "Generating character map..."); EtrianString.GameVersion = Version; loadWaitWorker.ReportProgress(-1, "Initializing font renderers..."); ushort characterCount = (ushort)((SmallFontInfoOffset - MainFontInfoOffset) / 2); MainFontRenderer = new FontRenderer(this, Path.Combine(path, MainFontFilename + ".ntft"), MainFontInfoOffset, characterCount); SmallFontRenderer = new FontRenderer(this, Path.Combine(path, SmallFontFilename + ".ntft"), SmallFontInfoOffset, characterCount); MessageFiles = ReadDataTablesByExtension(new string[] { ".mbb", ".tbb" }, messageDirs); dataTableFiles = ReadDataTablesByExtension(new string[] { ".tbb" }, dataDirs); archives = ReadArchiveFiles(archiveDirs); EnsureMessageTableIntegrity(); GenerateDictionariesLists(); changedMessageFiles = new List <TableFile>(); ParsedData = ParseDataTables(); changedParsedData = new List <BaseParser>(); MapDataFiles = ReadMapDataFiles(mapDataDirs); MapTileData = ParseMapData(); changedMapTileData = new List <BaseTile>(); TextureFilePaths = FindTextureFiles(textureDataDirs); CleanStringDictionaries(); GenerateOtherDictionaries(); loadWaitWorker.ReportProgress(-1, "Finished loading."); IsInitialized = true; } catch (System.Threading.ThreadAbortException) { } catch (GameDataManagerException gameException) { GUIHelpers.ShowErrorMessage( "Application Error", "An error occured while loading the game data.", "Please ensure you've selected a valid game data directory.", gameException.Message, gameException.ToString(), (IntPtr)Program.MainForm.Invoke(new Func <IntPtr>(() => { return(Program.MainForm.Handle); }))); } #if !DEBUG catch (Exception exception) { GUIHelpers.ShowErrorMessage( "Application Error", "The application performed an illegal operation.", "Please contact a developer with the details of this message.", exception.Message, exception.ToString(), (IntPtr)Program.MainForm.Invoke(new Func <IntPtr>(() => { return(Program.MainForm.Handle); }))); } #endif }); loadWaitWorker.ProgressChanged += ((s, e) => { string message = (e.UserState as string); if (loadWaitDialog.Cancel) { workerThread.Abort(); Program.Logger.LogMessage("Loading aborted."); Program.MainForm.StatusText = "Ready"; return; } loadWaitDialog.Details = message; Program.Logger.LogMessage(true, message); }); loadWaitWorker.RunWorkerCompleted += ((s, e) => { loadWaitDialog.Close(); stopwatch.Stop(); Program.Logger.LogMessage("Game directory read in {0:0.000} sec...", stopwatch.Elapsed.TotalSeconds); }); loadWaitWorker.RunWorkerAsync(); loadWaitDialog = new ProgressDialog() { Title = "Loading", InstructionText = "Loading game data.", Text = "Please wait while the game data is being loaded...", ParentForm = Program.MainForm }; loadWaitDialog.Show(Program.MainForm); }