//generates or updates .plg files public static void SavePluginSettings(TMPluginSave plugin) { if (pluginExists(plugin.getName())) { if (!Directory.Exists(loc)) { Directory.CreateDirectory(loc); } string FileName = plugin.getName() + ".plg"; string path = loc + FileName; Console.Write(" - Saving Settings for TMPlugin " + plugin.getName() + "..."); try { using (FileStream m_FileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) { BinaryFileWriter writer = new BinaryFileWriter(m_FileStream, true); plugin.SavePlugin(writer); writer.Close(); m_FileStream.Close(); } Console.WriteLine("done."); } catch (Exception e) { SkillSettings.DoTell(" TMPlugin " + plugin + " could not be saved. Error: " + e); } } else { SkillSettings.DoTell(" TMPlugin " + plugin + " not registered to system. Save cannot continue."); } }
public static bool LoadPluginSettings(TMPluginSave plugin) { if (pluginExists(plugin.getName())) { if (!Directory.Exists(loc)) { SkillSettings.DoTell(" -TMSS- Plugin Data directory does not exist. Plugin load cancelled."); return(false); } string FileName = plugin.getName() + ".plg"; string path = loc + FileName; Console.Write("Loading TMPlugin " + plugin.getName() + "..."); try { using (FileStream m_FileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { BinaryReader m_BinaryReader = new BinaryReader(m_FileStream); BinaryFileReader reader = new BinaryFileReader(m_BinaryReader); plugin.LoadPlugin(reader); reader.Close(); m_FileStream.Close(); } } catch (Exception e) { Console.WriteLine("failed. Exception: " + e); return(false); } return(true); } else { SkillSettings.DoTell(" Plugin " + plugin.getName() + " not registered with system. Plugin load cancelled."); return(false); } }
public static bool LoadPluginSettings(TMPluginSave plugin) { if (pluginExists(plugin.getName())) { if (!Directory.Exists(loc)) { SkillSettings.DoTell(" -TMSS- Plugin Data directory does not exist. Plugin load cancelled."); return false; } string FileName = plugin.getName() + ".plg"; string path = loc + FileName; Console.Write("Loading TMPlugin " + plugin.getName() + "..."); try { using (FileStream m_FileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { BinaryReader m_BinaryReader = new BinaryReader(m_FileStream); BinaryFileReader reader = new BinaryFileReader(m_BinaryReader); plugin.LoadPlugin(reader); reader.Close(); m_FileStream.Close(); } } catch (Exception e) { Console.WriteLine("failed. Exception: " + e); return false; } return true; } else { SkillSettings.DoTell(" Plugin " + plugin.getName() + " not registered with system. Plugin load cancelled."); return false; } }
//generates or updates .plg files public static void SavePluginSettings(TMPluginSave plugin) { if (pluginExists(plugin.getName())) { if (!Directory.Exists(loc)) Directory.CreateDirectory(loc); string FileName = plugin.getName() + ".plg"; string path = loc + FileName; Console.Write(" - Saving Settings for TMPlugin " + plugin.getName() + "..."); try { using (FileStream m_FileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) { BinaryFileWriter writer = new BinaryFileWriter(m_FileStream, true); plugin.SavePlugin(writer); writer.Close(); m_FileStream.Close(); } Console.WriteLine("done."); } catch (Exception e) { SkillSettings.DoTell(" TMPlugin " + plugin + " could not be saved. Error: " + e); } } else SkillSettings.DoTell(" TMPlugin " + plugin + " not registered to system. Save cannot continue."); }