public void Run() { TDCGExplorer.TDCGExplorer.IncBusy(); ArcsDatabase arcDB = TDCGExplorer.TDCGExplorer.ArcsDB; // TAHを列挙する. List <ArcsTahEntry> tahs = arcDB.GetTahs(); foreach (ArcsTahEntry tah in tahs) { Dictionary <string, ArcsTahEntry> tbnmap = new Dictionary <string, ArcsTahEntry>(); List <ArcsTahFilesEntry> files = arcDB.GetTahFilesPath(tah.id); foreach (ArcsTahFilesEntry file in files) { try { TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.Searching + ":" + tah.shortname); if (file.path.ToLower().StartsWith("script/items/") /*|| file.path.ToLower().StartsWith("script/backgrounds/" )*/) { // TBNファイルか? if (file.path.ToLower().EndsWith(".tbn") == true) { // N765BODY_A00.TBN // 1234567890123456 string directory = Path.GetDirectoryName(file.path).ToLower().Replace('\\', '/'); string fullname = Path.GetFileNameWithoutExtension(file.path).ToLower(); string basename = fullname.Substring(0, 10); string colbase = directory + "/" + basename + "00.tbn"; // <<1.08.1 // コード毎のtbnファイル名を全て集める. if (tbnfiles.ContainsKey(colbase) == false) { tbnfiles.Add(colbase, new List <string>()); } tbnfiles[colbase].Add(file.path); // 1.08.1>> if (tbnmap.ContainsKey(colbase) == true) { continue; // 既に該当tbnの情報を見つけている. } // baseとなるtbnそのものだった場合. if (file.path.ToLower() == colbase) { tbnmap.Add(colbase, tah); continue; } // カテゴリ先頭のtbnファイルを検索する. List <ArcsTahFilesEntry> tbns = arcDB.GetTahFilesEntry(TDCGExplorer.TAHUtil.CalcHash(colbase)); if (tbns.Count == 0) { // 該当するtbnの00番が見つからない. MissingEntryInformation entry = new MissingEntryInformation(); entry.id = tah.id; entry.path = String.Copy(tah.path); entry.basetbn = String.Copy(colbase); entry.zipfiles = null; // 該当tbnを含むzipを検索する. HashSet <string> zipname = new HashSet <string>(); List <ArcsTahFilesEntry> zipfiles = arcDB.GetZipTahFilesEntries(TDCGExplorer.TAHUtil.CalcHash(colbase)); foreach (ArcsTahFilesEntry zipfile in zipfiles) { if (zipfile.path.ToLower() != colbase) { continue; // ハッシュ衝突なら無視する. } ArcsZipTahEntry ziptah = arcDB.GetZipTah(zipfile.tahid); ArcsZipArcEntry zip = arcDB.GetZip(ziptah.zipid); zipname.Add(zip.GetDisplayPath()); } // 発見したZIPの数だけ報告する.0 if (zipname.Count == 0) { control.asyncDisplayFromArcs(entry); } else { entry.zipfiles = new List <string>(); foreach (string zip in zipname) { entry.zipfiles.Add(String.Copy(zip)); } control.asyncDisplayFromArcs(entry); } } tbnmap.Add(colbase, tah); } } } // おかしなファイル名でindex違反が起きるかもしれない. catch (Exception) { } } } // TBN辞書をセットして終了 control.tbnfiles = tbnfiles; TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.SearchComplete); TDCGExplorer.TDCGExplorer.DecBusy(); }
public void Run() { TDCGExplorer.TDCGExplorer.IncBusy(); ArcsDatabase arcDB = TDCGExplorer.TDCGExplorer.ArcsDB; // TAHを列挙する. List <ArcsTahEntry> tahs = arcDB.GetTahs(); foreach (ArcsTahEntry tah in tahs) { TDCGExplorer.TDCGExplorer.SetToolTips("検索中:" + tah.shortname); if (HasString(tah.path, keyword)) { FindEntryInformation entry = new FindEntryInformation(); entry.category = 0; // arcs entry.path = String.Copy(tah.path); entry.file = Path.GetFileName(tah.path); control.asyncDisplayFromArcs(entry); } } if (flagtahlevelsearch) { List <ArcsTahFilesEntry> files = arcDB.GetTahFilesPathHasString(keyword); foreach (ArcsTahFilesEntry file in files) { ArcsTahEntry tah = arcDB.GetTah(file.tahid); FindEntryInformation entry = new FindEntryInformation(); entry.category = 0; // arcs entry.path = String.Copy(tah.path); entry.file = String.Copy(file.GetDisplayPath()); control.asyncDisplayFromArcs(entry); } } if (flagzipsearch) { List <ArcsZipArcEntry> zips = arcDB.GetZips(); foreach (ArcsZipArcEntry zip in zips) { TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.Searching + ":" + zip.GetDisplayPath()); if (HasString(zip.GetDisplayPath(), keyword)) { FindEntryInformation entry = new FindEntryInformation(); entry.category = 1; //zips entry.path = String.Copy(Path.GetDirectoryName(zip.path) + "\\" + zip.GetDisplayPath()); entry.file = zip.GetDisplayPath(); control.asyncDisplayFromArcs(entry); } } // LIKE文で総当たりする. List <ArcsZipTahEntry> ziptahs = arcDB.GetZipTahsHasString(keyword); foreach (ArcsZipTahEntry tah in ziptahs) { ArcsZipArcEntry subzip = arcDB.GetZip(tah.zipid); FindEntryInformation entry = new FindEntryInformation(); entry.category = 1; //zips entry.path = String.Copy(Path.GetDirectoryName(subzip.path) + "\\" + subzip.GetDisplayPath()); entry.file = tah.shortname; control.asyncDisplayFromArcs(entry); } } if (flagzipsearch && flagtahlevelsearch) { List <ArcsTahFilesEntry> files = arcDB.GetTahFilesPathHasString(keyword); foreach (ArcsTahFilesEntry file in files) { ArcsZipTahEntry tah = arcDB.GetZipTah(file.tahid); ArcsZipArcEntry zip = arcDB.GetZip(tah.zipid); FindEntryInformation entry = new FindEntryInformation(); entry.category = 1; //zips entry.path = String.Copy(zip.path + "\\" + zip.GetDisplayPath()); entry.file = String.Copy(file.GetDisplayPath()); control.asyncDisplayFromArcs(entry); } } // TBN辞書をセットして終了 TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.SearchComplete); TDCGExplorer.TDCGExplorer.DecBusy(); }