Ejemplo n.º 1
0
        public QuickEdit(PatcherLib.Datatypes.Context context, IDictionary <Guid, ISerializableFile> files, IDictionary <SectionType, IList <QuickEditEntry> > sections)
        {
            Context    = context;
            this.files = new Dictionary <Guid, ISerializableFile>(files);
            lookup     = new Dictionary <SectionType, IList <QuickEditEntry> >(sections);

            List <IList <string> > sections2      = new List <IList <string> >(sections.Count);
            List <IList <string> > entryNames     = new List <IList <string> >(sections.Count);
            List <SectionType>     sectionTypes   = new List <SectionType>(sections.Count);
            List <int>             sectionLengths = new List <int>(sections.Count);
            List <string>          sectionNames   = new List <string>();

            HiddenEntries = new bool[sections.Count].AsReadOnly();

            foreach (KeyValuePair <SectionType, IList <QuickEditEntry> > kvp in sections)
            {
                CharMap = CharMap ?? files[kvp.Value[0].Guid].CharMap;

                IList <QuickEditEntry> entries   = kvp.Value;
                QuickEditEntry         mainEntry = entries.FindAll(e => e.Main)[0];

                //ISerializableFile mainFile = files[mainEntry.Guid];
                ISerializableFile mainFile = null;
                files.TryGetValue(mainEntry.Guid, out mainFile);
                if (mainFile == null)
                {
                    continue;
                }

                int           entryCount = mainEntry.Length;
                List <string> names      = new List <string>(entryCount);
                List <string> values     = new List <string>(entryCount);
                for (int i = mainEntry.Offset; i < (mainEntry.Offset + entryCount); i++)
                {
                    names.Add(mainFile.EntryNames[mainEntry.Section][i]);
                    values.Add(mainFile[mainEntry.Section, i]);
                }
                entryNames.Add(names.AsReadOnly());
                sections2.Add(values.ToArray());
                sectionLengths.Add(entryCount);
                sectionTypes.Add(kvp.Key);
                sectionNames.Add(FormatName(kvp.Key.ToString()));
            }

            this.sections       = sections2.AsReadOnly();
            EntryNames          = entryNames.AsReadOnly();
            NumberOfSections    = sections.Count;
            this.sectionTypes   = sectionTypes.AsReadOnly();
            this.SectionNames   = sectionNames.AsReadOnly();
            this.SectionLengths = sectionLengths.AsReadOnly();
        }
Ejemplo n.º 2
0
        public QuickEdit(IDictionary <Guid, ISerializableFile> files, IDictionary <SectionType, IList <QuickEditEntry> > sections)
        {
            this.files = new Dictionary <Guid, ISerializableFile>(files);
            lookup     = new Dictionary <SectionType, IList <QuickEditEntry> >(sections);

            List <IList <string> > sections2      = new List <IList <string> >(sections.Count);
            List <IList <string> > entryNames     = new List <IList <string> >(sections.Count);
            List <SectionType>     sectionTypes   = new List <SectionType>(sections.Count);
            List <int>             sectionLengths = new List <int>(sections.Count);
            List <string>          sectionNames   = new List <string>();

            foreach (KeyValuePair <SectionType, IList <QuickEditEntry> > kvp in sections)
            {
                CharMap = CharMap ?? files[kvp.Value[0].Guid].CharMap;

                IList <QuickEditEntry> entries   = kvp.Value;
                QuickEditEntry         mainEntry = entries.FindAll(e => e.Main)[0];
                ISerializableFile      mainFile  = files[mainEntry.Guid];
                int           entryCount         = mainEntry.Length;
                List <string> names  = new List <string>(entryCount);
                List <string> values = new List <string>(entryCount);
                for (int i = mainEntry.Offset; i < (mainEntry.Offset + entryCount); i++)
                {
                    names.Add(mainFile.EntryNames[mainEntry.Section][i]);
                    values.Add(mainFile[mainEntry.Section, i]);
                }
                entryNames.Add(names.AsReadOnly());
                sections2.Add(values.ToArray());
                sectionLengths.Add(entryCount);
                sectionTypes.Add(kvp.Key);
                sectionNames.Add(kvp.Key.ToString());
            }

            this.sections       = sections2.AsReadOnly();
            EntryNames          = entryNames.AsReadOnly();
            NumberOfSections    = sections.Count;
            this.sectionTypes   = sectionTypes.AsReadOnly();
            this.SectionNames   = sectionNames.AsReadOnly();
            this.SectionLengths = sectionLengths.AsReadOnly();
        }