private static void WriterTimerElapsed(object sender, ElapsedEventArgs e) { object writerLock = Texture2DOverride.WriterLock; Monitor.Enter(writerLock); try { Texture2DOverride.StopWatchTextFiles(); try { if (!Directory.Exists(Texture2DOverride.TranslationImageIniFileDir)) { Directory.CreateDirectory(Texture2DOverride.TranslationImageIniFileDir); } if (!File.Exists(Texture2DOverride.TranslationImageIniFilePath)) { Texture2DOverride.LoadMainIniFile(); } if (!Directory.Exists(Texture2DOverride.TranslationImageDir)) { Directory.CreateDirectory(Texture2DOverride.TranslationImageDir); } foreach (Texture2DDumpData writerdatum in Texture2DOverride.writerdata) { Texture2DOverride.mainini.WriteValue(writerdatum.Section, "sPath", writerdatum.Path); if (writerdatum.Format != TextureFormat.DXT1 && writerdatum.Format != TextureFormat.DXT5) { continue; } Texture2DOverride.mainini.WriteValue(writerdatum.Section, "bFlipTexture", true); } } catch (Exception exception) { IniSettings.Error(string.Concat("DumpTexture2D:\n", exception.ToString())); } Texture2DOverride.writerdata.Clear(); Texture2DOverride.WatchTextFiles(); } finally { Monitor.Exit(writerLock); } }
private static void Load() { Texture2DCacheData texture2DCacheDatum; object dataLock = Texture2DOverride.DataLock; Monitor.Enter(dataLock); try { Texture2DOverride.StopWatchTextFiles(); Dictionary <int, Texture2DCacheData> nums = new Dictionary <int, Texture2DCacheData>(Texture2DOverride.loaded); Texture2DOverride.unused.Clear(); Texture2DOverride.loaded.Clear(); Texture2DOverride.LoadMainIniFile(); Texture2DOverride.inidata = Texture2DOverride.ParseIniData(Texture2DOverride.mainini); Texture2DOverride.uniqueimagesdata = Texture2DOverride.GetUniqueImageFiles(Texture2DOverride.TranslationImageDir); if (Texture2DOverride.GlobalTranslationImageIniFilePath != Texture2DOverride.TranslationImageDir) { Dictionary <string, Texture2DData> strs = Texture2DOverride.ParseIniData(new IniFile(Texture2DOverride.GlobalTranslationImageIniFilePath)); foreach (KeyValuePair <string, Texture2DData> keyValuePair in strs) { if (Texture2DOverride.inidata.ContainsKey(keyValuePair.Key)) { continue; } Texture2DOverride.inidata.Add(keyValuePair.Key, keyValuePair.Value); } strs.Clear(); strs = null; Dictionary <string, string> uniqueImageFiles = Texture2DOverride.GetUniqueImageFiles(Texture2DOverride.GlobalTranslationImageDir); foreach (KeyValuePair <string, string> uniqueImageFile in uniqueImageFiles) { if (Texture2DOverride.uniqueimagesdata.ContainsKey(uniqueImageFile.Key)) { continue; } Texture2DOverride.uniqueimagesdata.Add(uniqueImageFile.Key, uniqueImageFile.Value); } uniqueImageFiles.Clear(); uniqueImageFiles = null; } Texture2DOverride.WatchTextFiles(); foreach (KeyValuePair <int, Texture2DCacheData> num in nums) { Texture2DOverrideData overrideData = num.Value.OverrideData; Texture2DOverride.LoadTexture2D(num.Value.ObjectName, overrideData.OriginalTexture2D, out overrideData); if (!Texture2DOverride.loaded.TryGetValue(overrideData.InstanceID, out texture2DCacheDatum)) { continue; } texture2DCacheDatum.IncreaseAmount(num.Value.Count); } if (IniSettings.DebugMode || IniSettings.FindImage) { int count = Texture2DOverride.inidata.Count; IniSettings.Log(string.Concat("ImageSettingsLoaded: ", count.ToString())); } } finally { Monitor.Exit(dataLock); } }