Example #1
0
        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." );
        }
Example #2
0
 internal static void Undo( GlobalConfigChange change )
 {
     if ( change != changes.Peek() ) throw new GlobalConfigIntegrityException();
     changes.Pop();
 }
Example #3
0
 internal static void Apply( GlobalConfigChange change )
 {
     changes.Push( change );
 }