示例#1
0
文件: Boot.cs 项目: And-G/Magellan
        public static void ExportProvince( string source, string target, ExportMode mode, bool allowTOT )
        {
            Console.WriteLine( "Opening source file \"{0}\"...", Path.GetFileName( source ) );

            EU2.Edit.File file = new EU2.Edit.File();
            try {
                file.ReadFrom( source );
            }
            catch ( EU2.Edit.InvalidFileFormatException ) {
                Console.WriteLine( "The specified source file is not an EU2Map file, or is corrupt." );
                return;
            }

            if ( file.Provinces == null ) {
                Console.WriteLine( "Error: The file does not contain province info." );
                return;
            }

            // -- Write the file
            Console.WriteLine( "Exporting to \"{0}\"...", Path.GetFileName( target ) );
            FileStream stream = null;
            try {
                stream = new FileStream( target, FileMode.Create, FileAccess.Write, FileShare.None );
                using ( GlobalConfigChange gcc = new GlobalConfigChange() ) {
                    gcc.AllowTOTAndHREInProvinceList = allowTOT;
                    if ( mode == ExportMode.XML ) {
                        file.Provinces.WriteTo( new System.Xml.XmlTextWriter( stream, System.Text.Encoding.UTF8 ) );
                    }
                    else {
                        file.Provinces.WriteTo( stream );
                    }
                }
            }
            finally {
                if ( stream != null ) stream.Close();
            }

            Console.WriteLine( "Export successful." );
        }
示例#2
0
 internal static void Undo( GlobalConfigChange change )
 {
     if ( change != changes.Peek() ) throw new GlobalConfigIntegrityException();
     changes.Pop();
 }
示例#3
0
 internal static void Apply( GlobalConfigChange change )
 {
     changes.Push( change );
 }