Esempio n. 1
0
 public Plugin(byte[] data, string name)
 {
     Name = name;
     var br = new BinaryReader(new MemoryStream(data));
     try
     {
         this.LoadPluginData(br, false, null);
         this.FileName = Path.GetFileNameWithoutExtension(name);
         define = this.DetectVersion();
     }
     finally
     {
         br.Close();
     }
 }
Esempio n. 2
0
        static DomainDefinition()
        {
            var iniFile = Path.Combine(Folders.SettingsDirectory, "Domains.ini");
            foreach (var section in IniFile.GetSectionNames(iniFile))
            {
                var values = IniFile.GetPropertyValues(iniFile, section);
                var define = new DomainDefinition(section);
                define.DisplayName = GetValue(values, "Display", section);
                define.Master = GetValue(values, "Master", section+".esm");
                define.RegistryKey = GetValue(values, "Registry", "Bethesda Softworks\\" + section);
                define.FilteredESM = GetValue(values, "FilteredESM", "").Split(';');
                define.AllESMRecords = GetValue(values, "AllESMRecords", "").Split(';');
                define.HEDRType = GetValue(values, "HEDRType", "TES4");
                define.HEDRVersion = float.Parse(GetValue(values, "HEDRVersion", "1.0"));
                define.HEDRVersionMin = float.Parse(GetValue(values, "HEDRVersionMin", define.HEDRVersion.ToString()));
                define.HEDRVersionMax = float.Parse(GetValue(values, "HEDRVersionMax", define.HEDRVersion.ToString()));
                define.HEDROffset = int.Parse(GetValue(values, "HEDROffset", "4"));
                define.HEDRRecSize = int.Parse(GetValue(values, "HEDRRecSize", "2"));
                define.RecSize = int.Parse(GetValue(values, "RecSize", "16"));

                try
                {
                    define.GameDirectory = GetGameDirectoryFromRegistry(define.RegistryKey);
                    if (!string.IsNullOrEmpty(define.GameDirectory))
                    {
                        define.GameDataDirectory = Path.Combine(define.GameDirectory, "Data");
                        if (!Directory.Exists(define.GameDataDirectory))
                            define.GameDataDirectory = Path.Combine(define.GameDirectory, "Data files");
                    }
                }
                catch
                {
                    define.GameDirectory = null;
                    define.GameDataDirectory = null;
                }

                Domains[section] = define;
            }
        }
Esempio n. 3
0
 public static DomainDefinition Load(string p)
 {
     DomainDefinition define;
     if (!Domains.TryGetValue(p, out define))
     {
         define = new DomainDefinition(p);
         Domains[p] = define;
     }
     if (!define.Loaded)
     {
         define.Records = RecordStructure.Load(define.xmlPath);
         define.Loaded = true;
         if (DomainLoaded != null)
             DomainLoaded(define, EventArgs.Empty);
     }
     return define;
 }
Esempio n. 4
0
        public Plugin(string filePath, bool headerOnly, Func<string, bool> includeFilter )
        {
            Name = Path.GetFileName(filePath);
            PluginPath = Path.GetDirectoryName(filePath);
            var fi = new FileInfo(filePath);
            using (var br = new BinaryReader(fi.OpenRead()))
            {
                define = this.DetectVersion(br, filePath);
                br.BaseStream.Position = 0;
                this.LoadPluginData(br, headerOnly, includeFilter);
            }

            this.FileName = Path.GetFileNameWithoutExtension(filePath);
            if (!headerOnly)
            {
                this.StringsFolder = Path.Combine(Path.GetDirectoryName(filePath), "Strings");
            }

            this.ReloadStrings();
        }
Esempio n. 5
0
 public Plugin(DomainDefinition define)
 {
     this.Name = "New plugin.esp";
     this.define = define;
 }
Esempio n. 6
0
 private Plugin(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     // detect version
     define = this.DetectVersion();
 }