Ejemplo n.º 1
0
 internal FFTText( Context context, IDictionary<Guid, ISerializableFile> files, IList<Glyph> customGlyphs, QuickEdit quickEdit )
 {
     this.customGlyphs = customGlyphs;
     Filetype = context;
     List<IFile> filesList = new List<IFile>( files.Count + 1 );
     files.ForEach( kvp => filesList.Add( kvp.Value ) );
     filesList.Sort( ( a, b ) => a.DisplayName.CompareTo( b.DisplayName ) );
     if (quickEdit != null)
     {
         filesList.Insert(0, quickEdit);
     }
     Files = filesList.AsReadOnly();
     CharMap = filesList[0].CharMap;
 }
Ejemplo n.º 2
0
        public static FFTText GetFilesXml( XmlNode doc, BackgroundWorker worker )
        {
            Context context = (Context)Enum.Parse( typeof( Context ), doc.SelectSingleNode( "/FFTText/@context" ).InnerText );
            XmlNode layoutDoc = context == Context.US_PSP ? Resources.PSP : Resources.PSX;
            GenericCharMap charmap = ( context == Context.US_PSP ) ? (GenericCharMap)TextUtilities.PSPMap : (GenericCharMap)TextUtilities.PSXMap;

            Dictionary<Guid, ISerializableFile> result = new Dictionary<Guid, ISerializableFile>();
            foreach ( XmlNode fileNode in doc.SelectNodes( "//File" ) )
            {
                string guidText = fileNode.SelectSingleNode( "Guid" ).InnerText;
                Guid guid = new Guid( guidText );
                if ( worker.CancellationPending )
                    return null;
                FileInfo fi = GetFileInfo( context, layoutDoc.SelectSingleNode( string.Format( "//Files/*[Guid='{0}']", guidText ) ) );
                if ( worker.CancellationPending )
                    return null;
                result.Add(
                    guid,
                    AbstractFile.ConstructFile( fi.FileType, charmap, fi, GetStrings( fileNode.SelectSingleNode( "Sections" ) ) ) );
                if ( worker.CancellationPending )
                    return null;
            }

            var quickEdit = new QuickEdit( result, GetQuickEditLookup( layoutDoc.SelectSingleNode( "//QuickEdit" ), worker ) );
            if ( quickEdit == null || worker.CancellationPending )
            {
                return null;
            }

            return new FFTText( context, result, quickEdit );

        }
Ejemplo n.º 3
0
        private static FFTText GetText( Stream iso, Context context, XmlNode doc, BytesFromIso reader, GenericCharMap charmap, BackgroundWorker worker )
        {
            IDictionary<Guid, ISerializableFile> files = GetFiles( iso, context, doc, reader, charmap, worker );
            if ( files == null || worker.CancellationPending )
                return null;

            var quickEdit = new QuickEdit( files, GetQuickEditLookup( doc.SelectSingleNode( "//QuickEdit" ), worker ) );
            if ( quickEdit == null || worker.CancellationPending )
                return null;

            return new FFTText( context, files, quickEdit );
        }
Ejemplo n.º 4
0
 internal FFTText( Context context, IDictionary<Guid, ISerializableFile> files, QuickEdit quickEdit )
 {
     Filetype = context;
     List<IFile> filesList = new List<IFile>( files.Count + 1 );
     files.ForEach( kvp => filesList.Add( kvp.Value ) );
     filesList.Sort( ( a, b ) => a.DisplayName.CompareTo( b.DisplayName ) );
     filesList.Add( quickEdit );
     Files = filesList.AsReadOnly();
     CharMap = filesList[0].CharMap;
 }
Ejemplo n.º 5
0
        public static FFTText GetFilesXml( XmlNode doc, BackgroundWorker worker, Set<Guid> guidsToLoadFromIso, Stream iso )
        {
            Context context = (Context)Enum.Parse( typeof( Context ), doc.SelectSingleNode( "/FFTText/@context" ).InnerText );
            XmlNode layoutDoc = context == Context.US_PSP ? Resources.PSP : Resources.PSX;
            GenericCharMap charmap = (context == Context.US_PSP) ? (GenericCharMap)TextUtilities.PSPMap : (GenericCharMap)TextUtilities.PSXMap;

            Dictionary<Guid, ISerializableFile> result = new Dictionary<Guid, ISerializableFile>();
            foreach (XmlNode fileNode in doc.SelectNodes( "//File" ))
            {
                string guidText = fileNode.SelectSingleNode( "Guid" ).InnerText;
                Guid guid = new Guid( guidText );
                if (worker.CancellationPending)
                    return null;
                FileInfo fi = GetFileInfo( context, layoutDoc.SelectSingleNode( string.Format( "//Files/*[Guid='{0}']", guidText ) ) );
                string fileComment = GetFileComment( doc.SelectSingleNode( string.Format( "//FFTText/*[Guid='{0}']", guidText ) ) );
                if (worker.CancellationPending)
                    return null;
                XmlNode sectionsNode = fileNode.SelectSingleNode( "Sections" );
                result.Add(
                    guid,
                    AbstractFile.ConstructFile( fi.FileType, charmap, fi, GetStrings( sectionsNode ), fileComment, GetSectionComments( sectionsNode ) ) );
                if (worker.CancellationPending)
                    return null;
            }

            if (guidsToLoadFromIso != null && guidsToLoadFromIso.Count > 0 && iso != null)
            {
                FFTText tempText = null;
                if (context == Context.US_PSP)
                {
                    tempText = GetPspText( iso, worker );
                }
                else if (context == Context.US_PSX)
                {
                    tempText = GetPsxText( iso, worker );
                }

                Set<IFile> isoFiles =
                    new Set<IFile>(
                        tempText.Files.FindAll( f => f is ISerializableFile ).FindAll( g => guidsToLoadFromIso.Contains( (g as ISerializableFile).Layout.Guid ) ) );
                isoFiles.ForEach( f => result.Add( (f as ISerializableFile).Layout.Guid, f as ISerializableFile ) );
            }

            //result.Values.ForEach( f => RemoveUnnecessaryColors( f ) );

            XmlNode quickEditNode = layoutDoc.SelectSingleNode( "//QuickEdit" );
            Set<Guid> guids = GetGuidsNeededForQuickEdit( quickEditNode );
            QuickEdit quickEdit = null;
            if (guids.TrueForAll( g => result.ContainsKey( g ) ))
            {
                quickEdit = new QuickEdit( context, result, GetQuickEditLookup( layoutDoc.SelectSingleNode( "//QuickEdit" ), worker ) );
                if (quickEdit == null || worker.CancellationPending)
                {
                    return null;
                }
            }

            return new FFTText( context, result, null, quickEdit );
        }