Beispiel #1
0
        private void frmChecker_ProgressChanged( object sender, ProgressChangedEventArgs e )
        {
            if( e.ProgressPercentage == (int)ProgressData.CritterTypeName )
            {
                string text = (string)e.UserState;
                if( text != null )
                {
                    CritterType crType = CritterTypes.Find( cr => cr.Name == text );
                    if( crType == null )
                    {
                        crType = new CritterType( text );
                        CritterTypes.Add( crType );
                    }

                    if( !lstCritters.Items.Contains( text ) )
                    {
                        lstCritters.Items.Add( text );
                        lstCritters.Update();
                    }
                }
            }
            else if( e.ProgressPercentage == (int)ProgressData.CritterAnimation )
            {
                object[] data = (object[])e.UserState;

                string baseName = (string)data[0];
                string animName = (string)data[1];
                CritterAnimation anim = (CritterAnimation)data[2];

                CritterType crType = CritterTypes.Find( cr => cr.Name == baseName );
                crType.Animations.RemoveAll( a => a.Name == anim.Name );
                crType.Animations.Add( anim );

            }
            else if( e.ProgressPercentage == (int)ProgressData.CritterPreview )
            {
                object[] data = (object[])e.UserState;

                string baseName = (string)data[0];
                Bitmap preview = (Bitmap)data[1];

                CritterType crType = CritterTypes.Find( cr => cr.Name == baseName );
                crType.Preview = preview;
            }
            else if( e.ProgressPercentage == (int)ProgressData.ErrorMessage )
            {
                string text = (string)e.UserState;
                if( text != null && text.Length > 0 )
                {
                    MessageBox.Show( text, BaseText, MessageBoxButtons.OK, MessageBoxIcon.Error );
                }
            }
            else if( e.ProgressPercentage == (int)ProgressData.Finish )
            {
                frmCheckerConfig config = (frmCheckerConfig)e.UserState;

                Text = BaseText + " : " + config.Target;
                LoadedMode = config.LoadMode;
                LoadedTarget = config.Target;
                LoadedFast = config.FastCheck;

                menuFileExport.Enabled = menuOptionsTarget.Enabled = true;

                if( config.ShowCompletion != null )
                {
                    if( lstCritters.Items.Contains( config.ShowCompletion ) )
                    {
                        lstCritters.SelectedItem = config.ShowCompletion;
                        button1_Click( null, null );
                    }
                    else
                    {
                        MessageBox.Show( "Cannot find '" + config.ShowCompletion + "' critter" );
                        lstCritters.SelectedIndex = 0;
                    }
                }
                else
                    lstCritters.SelectedIndex = 0;

                EnableControls( true );
            }
            else if( e.ProgressPercentage >= 0 )
            {
                if( !statusProgress.Visible )
                    statusProgress.Visible = true;

                statusProgress.Value = e.ProgressPercentage;
                statusProgress.ToolTipText = e.ProgressPercentage + "%";
                statusLabel.Text = "[" + e.ProgressPercentage + "%]";

                string text = (string)e.UserState;
                if( text != null )
                    statusLabel.Text += " " + text;

                status.Update();
            }
            else
            {
                MessageBox.Show( "Unknown progress type : " + e.ProgressPercentage );
            }
        }
Beispiel #2
0
        public void Load(LoadModeType loadMode)
        {
            RijndaelManaged Password = new RijndaelManaged();
            Password.Key = PasswordKey;

            byte[] iv = new byte[16];
            byte[] salt = new byte[4];

            OpCore lookup = null;
            if (Core != null)
                lookup = Core.Context.Lookup;

            try
            {
                using (TaggedStream file = new TaggedStream(ProfilePath, Protocol, ProcessSplash)) // tagged with splash
                {
                    // first 16 bytes IV, next 4 bytes is salt
                    file.Read(iv, 0, 16);
                    file.Read(salt, 0, 4);
                    Password.IV = iv;

                    using (CryptoStream crypto = new CryptoStream(file, Password.CreateDecryptor(), CryptoStreamMode.Read))
                    {
                        PacketStream stream = new PacketStream(crypto, Protocol, FileAccess.Read);

                        G2Header root = null;
                        while (stream.ReadPacket(ref root))
                        {
                            if (loadMode == LoadModeType.Settings)
                            {
                                if (root.Name == IdentityPacket.OperationSettings)
                                    Settings = SettingsPacket.Decode(root);

                                if (root.Name == IdentityPacket.UserInfo && Core != null &&
                                    (Core.Sim == null || !Core.Sim.Internet.FreshStart))
                                    Core.IndexInfo(UserInfo.Decode(root));

                                // save icon to identity file because only root node saves icon/splash to link file
                                // to minimize link file size, but allow user to set custom icon/splash if there are not overrides
                                if (root.Name == IdentityPacket.Icon)
                                    OpIcon = IconPacket.Decode(root).OpIcon;
                            }

                            if (lookup != null && (loadMode == LoadModeType.AllCaches || loadMode == LoadModeType.LookupCache))
                            {
                                if (root.Name == IdentityPacket.LookupCachedIP)
                                    lookup.Network.Cache.AddSavedContact(CachedIP.Decode(root));

                                if (root.Name == IdentityPacket.LookupCachedWeb)
                                    lookup.Network.Cache.AddWebCache(WebCache.Decode(root));
                            }

                            if (loadMode == LoadModeType.AllCaches)
                            {
                                if (root.Name == IdentityPacket.OpCachedIP)
                                    Core.Network.Cache.AddSavedContact(CachedIP.Decode(root));

                                if (root.Name == IdentityPacket.OpCachedWeb)
                                    Core.Network.Cache.AddWebCache(WebCache.Decode(root));
                            }
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
 void CloseDatafile( ref object datafile, LoadModeType loadMode )
 {
     switch( loadMode )
     {
         case LoadModeType.Zip:
             ZipStorer zip = (ZipStorer)datafile;
             zip.Close();
             break;
         case LoadModeType.Dat:
             DAT dat = (DAT)datafile;
             dat.Close();
             break;
     }
 }
Beispiel #4
0
        /// <summary>
        /// Prepares form to open a new target.
        /// </summary>
        /// <param name="loadMode">Target type.</param>
        /// <param name="target">Target name.</param>
        /// <returns>Configuration for frmChecker</returns>
        private frmCheckerConfig frmCheckerPrepare( LoadModeType loadMode, string target )
        {
            frmCheckerConfig config = new frmCheckerConfig( loadMode, target );
            foreach( frmAnimation animWin in AnimationWindows )
            {
                animWin.Close();
            }
            AnimationWindows.Clear();
            CritterTypes.Clear();

            menuFileOpen.Enabled =
            menuFileExport.Enabled =
            menuOptionsTarget.Enabled =
                false;
            lstCritters.SelectedIndex = PrevSelectedCritterIndex = -1;
            lstCritters.Items.Clear();
            EnableControls( false );
            RefreshFalloutFOnline( new CritterType( "" ), true );
            statusLabel.Text = "Opening " + target + "...";

            frmCheckerCompleted = false;

            return (config);
        }
Beispiel #5
0
            public frmCheckerConfig( LoadModeType loadMode, string target )
            {
                LoadMode = loadMode;
                Target = target;
                FastCheck = Settings.GetBool( "FastCheckFRM" );

                ShowCompletion = null;
            }
Beispiel #6
0
        bool OpenDatafile( ref object datafile, string targetName, LoadModeType loadMode )
        {
            switch( loadMode )
            {
                case LoadModeType.Directory:
                    if( !Directory.Exists( targetName ) )
                        return (false);
                    datafile = targetName;
                    break;

                case LoadModeType.Zip:
                    ZipStorer zip = ZipStorer.Open( targetName, FileAccess.Read );
                    if( zip == null )
                        return (false);
                    datafile = zip;
                    break;

                case LoadModeType.Dat:
                    DatReaderError status;
                    DAT dat = DATReader.ReadDat( targetName, out status );
                    if( status.Error != DatError.Success )
                        return (false);
                    datafile = dat;
                    break;
            }

            return (true);
        }
Beispiel #7
0
        FalloutFRM LoadFRM( object datafile, object file, LoadModeType loadMode )
        {
            byte[] bytes = null;
            switch( loadMode )
            {
                case LoadModeType.Directory:
                    string filename = (string)datafile + Path.DirectorySeparatorChar + (string)file;
                    if( File.Exists( filename ) )
                        bytes = File.ReadAllBytes( filename );
                    break;

                case LoadModeType.Zip:
                    MemoryStream stream = new MemoryStream();
                    ZipStorer zip = (ZipStorer)datafile;
                    ZipStorer.ZipFileEntry zipEntry = (ZipStorer.ZipFileEntry)file;
                    zip.ExtractFile( zipEntry, stream );
                    bytes = stream.ToArray();
                    break;

                case LoadModeType.Dat:
                    DATFile datFile = (DATFile)file;
                    try
                    {
                        bytes = datFile.GetData();
                    }
                    catch
                    {
                        // sit and cry
                    }
                    break;

                default:
                    throw new NotSupportedException();
            }

            if( bytes != null && bytes.Length > 0 )
                return (FalloutFRMLoader.LoadFRM( bytes, TransparencyFRM ));

            return (null);
        }
Beispiel #8
0
        Bitmap[] LoadFRM( object datafile, CritterType crType, string animName, LoadModeType loadMode )
        {
            CritterAnimation crAnim = crType[animName];

            object[] files = new object[crAnim.Full ? 1 : 6];

            for( uint d = 0; d <= 5; d++ )
            {
                if( crAnim.Dir[d] == CritterAnimationDir.None )
                    continue;

                switch( loadMode )
                {
                    case LoadModeType.Directory:
                        string directory = (string)datafile;
                        files[d] = crType.Name + animName + ".FR" + (crAnim.Dir[d] == CritterAnimationDir.Full ? "M" : d.ToString());
                        break;

                    case LoadModeType.Zip:
                        files[d] = crAnim.ZipData[d];
                        break;

                    case LoadModeType.Dat:
                        DAT dat = (DAT)datafile;
                        files[d] = dat.FileList[crAnim.DatData[d]];
                        break;
                }

                if( crAnim.Full )
                    break;
            }

            Bitmap[] result = new Bitmap[6];

            if( files.Length == 1 && files[0] != null )
            {
                FalloutFRM frm = LoadFRM( datafile, files[0], loadMode );

                if( frm != null )
                {
                    for( int d = 0; d <= 5; d++ )
                    {
                        result[d] = frm.GetAnimFrameByDir( d, 1 );
                    }
                }
            }
            else
            {
                for( int d = 0; d <= 5; d++ )
                {
                    if( files[d] == null )
                        continue;

                    FalloutFRM frm = LoadFRM( datafile, files[d], loadMode );
                    if( frm == null )
                        continue;

                    foreach( Bitmap bmp in frm.Frames )
                    {
                        if( bmp != null )
                        {
                            result[d] = bmp;
                            break;
                        }
                    }
                }
            }

            return (result);
        }
Beispiel #9
0
        public void Load(LoadModeType loadMode)
        {
            RijndaelManaged Password = new RijndaelManaged();

            Password.Key = PasswordKey;

            byte[] iv   = new byte[16];
            byte[] salt = new byte[4];

            OpCore lookup = null;

            if (Core != null)
            {
                lookup = Core.Context.Lookup;
            }

            try
            {
                using (TaggedStream file = new TaggedStream(ProfilePath, Protocol, ProcessSplash)) // tagged with splash
                {
                    // first 16 bytes IV, next 4 bytes is salt
                    file.Read(iv, 0, 16);
                    file.Read(salt, 0, 4);
                    Password.IV = iv;

                    using (CryptoStream crypto = new CryptoStream(file, Password.CreateDecryptor(), CryptoStreamMode.Read))
                    {
                        PacketStream stream = new PacketStream(crypto, Protocol, FileAccess.Read);

                        G2Header root = null;
                        while (stream.ReadPacket(ref root))
                        {
                            if (loadMode == LoadModeType.Settings)
                            {
                                if (root.Name == IdentityPacket.OperationSettings)
                                {
                                    Settings = SettingsPacket.Decode(root);
                                }

                                if (root.Name == IdentityPacket.UserInfo && Core != null &&
                                    (Core.Sim == null || !Core.Sim.Internet.FreshStart))
                                {
                                    Core.IndexInfo(UserInfo.Decode(root));
                                }

                                // save icon to identity file because only root node saves icon/splash to link file
                                // to minimize link file size, but allow user to set custom icon/splash if there are not overrides
                                if (root.Name == IdentityPacket.Icon)
                                {
                                    OpIcon = IconPacket.Decode(root).OpIcon;
                                }
                            }

                            if (lookup != null && (loadMode == LoadModeType.AllCaches || loadMode == LoadModeType.LookupCache))
                            {
                                if (root.Name == IdentityPacket.LookupCachedIP)
                                {
                                    lookup.Network.Cache.AddSavedContact(CachedIP.Decode(root));
                                }

                                if (root.Name == IdentityPacket.LookupCachedWeb)
                                {
                                    lookup.Network.Cache.AddWebCache(WebCache.Decode(root));
                                }
                            }

                            if (loadMode == LoadModeType.AllCaches)
                            {
                                if (root.Name == IdentityPacket.OpCachedIP)
                                {
                                    Core.Network.Cache.AddSavedContact(CachedIP.Decode(root));
                                }

                                if (root.Name == IdentityPacket.OpCachedWeb)
                                {
                                    Core.Network.Cache.AddWebCache(WebCache.Decode(root));
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }