internal Feedback(Account account) { _account = account; InitializeComponent(); }
/// <summary> /// Loads the user preferences for CZBindMaker if it exists. If not, get the path info and write the file. /// </summary> private void InitializeData( ) { #region //---[ BEGIN RESOLVE PATHS AND LOAD CONFIGS ]------------------------------------------- #region bool loadConfig = false; _configFilePath = ""; _bindFilePath = ""; _userFilePath = ""; _autoFilePath = ""; _clipsFilePath = ""; ConfigSearch cs = new ConfigSearch( ); if ( cs.KeyFound ) { AccountsCollection acc = cs.Accounts; if ( acc.Count > 1 ) { string[] acts = new string[acc.Count]; for ( int i = 0; i < acc.Count; i++ ) { acts[i] = ( (Account)acc[i] ).AccountName; } using ( AccountChooser ac = new AccountChooser( acts ) { SelectedAccountName = UpdateAccountName } ) { ac.ShowDialog( this ); } } else if ( cs.Accounts.Count == 1 ) { _tempAccountUsage = ( (Account)cs.Accounts[0] ).AccountName; } else { loadConfig = PromptForConfigLocation( ); } Account act = acc[_tempAccountUsage]; _account = act; Games g = Games.None; if ( act.GamesListed == ( Games.CS | Games.CZ | Games.CSS ) ) { using ( GameSelector gs = new GameSelector( act.GamesListed ) ) { gs.SelectGame += gs_SelectGame; gs.ShowDialog( this ); } if ( _option.ToLower( ) == "cs" ) { g = _game = Games.CS; } else if ( _option.ToLower( ) == "css" ) { g = _game = Games.CSS; } else if ( _option.ToLower( ) == "cz" ) { g = _game = Games.CZ; } } else if ( act.GamesListed == ( Games.CS | Games.CZ ) ) { using ( GameSelector gs = new GameSelector( act.GamesListed ) ) { gs.SelectGame += gs_SelectGame; gs.ShowDialog( this ); } if ( _option.ToLower( ) == "cs" ) { g = _game = Games.CS; } else if ( _option.ToLower( ) == "cz" ) { g = _game = Games.CZ; } } else if ( act.GamesListed == ( Games.CS | Games.CSS ) ) { using ( GameSelector gs = new GameSelector( act.GamesListed ) ) { gs.SelectGame += gs_SelectGame; gs.ShowDialog( this ); } if ( _option.ToLower( ) == "cs" ) { g = _game = Games.CS; } else if ( _option.ToLower( ) == "css" ) { g = _game = Games.CSS; } } else if ( act.GamesListed == ( Games.CSS | Games.CZ ) ) { using ( GameSelector gs = new GameSelector( act.GamesListed ) ) { gs.SelectGame += gs_SelectGame; gs.ShowDialog( this ); } if ( _option.ToLower( ) == "css" ) { g = _game = Games.CSS; } else if ( _option.ToLower( ) == "cz" ) { g = _game = Games.CZ; } } else if ( act.GamesListed == Games.CS ) { g = _game = Games.CS; } else if ( act.GamesListed == Games.CZ ) { g = _game = Games.CZ; } else if ( act.GamesListed == Games.CSS ) { g = _game = Games.CSS; } if ( g != Games.None ) { // make sure we have the compatibility file if game is css if ( g == Games.CSS && !File.Exists( act.GetConfigPath( g, ConfigType.Compatibility ) ) ) { Stream s = System.Reflection.Assembly.GetExecutingAssembly( ).GetManifestResourceStream( "CZBindMaker.compatibility.cfg" ); byte[] data = new byte[s.Length]; s.Read( data, 0, data.Length ); s.Close( ); FileStream fs = new FileStream( act.GetConfigPath( g, ConfigType.Compatibility ), FileMode.Create, FileAccess.Write ); fs.Write( data, 0, data.Length ); fs.Flush( ); fs.Close( ); } _configFilePath = act.GetConfigPath( g, ConfigType.Config ); _bindFilePath = act.GetConfigPath( g, ConfigType.Czbm ); _userFilePath = act.GetConfigPath( g, ConfigType.User ); _autoFilePath = act.GetConfigPath( g, ConfigType.Auto ); _clipsFilePath = act.GetConfigPath( g, ConfigType.Clips ); loadConfig = true; } if ( _game == Games.CSS ) DisableConfigForSource( ); else EnableConfig( ); if ( loadConfig ) LoadConfigFile( ); } else { MessageBox.Show( "Failed to find Game Directory!\n\nYou will need to browse to your game directory (cstrike or czero) \nand locate your config.cfg file yourself.\t", "Info: Could not find a game directory", MessageBoxButtons.OK, MessageBoxIcon.Information ); //IF NONE FOUND OPEN DIALOG AND GET USER SETTINGS if ( _configFileFinder.ShowDialog( this ) == DialogResult.OK ) { _configFilePath = _configFileFinder.FileName; _bindFilePath = Regex.Replace( _configFilePath, @"config.cfg", "czbind.cfg", RegexOptions.IgnoreCase ); _userFilePath = Regex.Replace( _configFilePath, @"config.cfg", "userconfig.cfg", RegexOptions.IgnoreCase ); _autoFilePath = Regex.Replace( _configFilePath, @"config.cfg", "autoexec.cfg", RegexOptions.IgnoreCase ); _clipsFilePath = Regex.Replace( _configFilePath, @"config.cfg", "clips.cfg", RegexOptions.IgnoreCase ); loadConfig = true; } // CASE: USER HIT CANCEL ON THE CONFIGURATION DIALOG else { _configFilePath = ""; _bindFilePath = ""; _userFilePath = ""; _autoFilePath = ""; loadConfig = false; //MessageBox.Show("You have to select your config file before you can save your custom binds!", "Can't save without a config file",MessageBoxButtons.OK,MessageBoxIcon.Information); } } #endregion //---[ END RESOLVE PATHS AND LOAD CONFIGS ]--------------------------------------------- //---[ BEGIN LOADING DYNAMIC DATA FROM HASH MAPS ]-------------------------------------- #region #region BINDS LIST _bindItems = new ArrayList( ); _bindMap = new BindMap( ); _bindOptionsListBox.Items.Clear( ); foreach ( string s in _bindMap.BuyKeys ) { _bindOptionsListBox.Items.Add( s ); } #endregion #region RADIO COMMANDS radioCommandsToolStripComboBox.Items.Clear( ); foreach ( string s in _bindMap.RadioKeys ) { radioCommandsToolStripComboBox.Items.Add( s ); } #endregion #region SAY/TEAM SAY sayTeamSayComboBox.Items.Clear( ); sayTeamSayComboBox.Items.Add( "- Choose -" ); foreach ( string s in _bindMap.SayKeys ) { sayTeamSayComboBox.Items.Add( s ); } sayTeamSayComboBox.SelectedIndex = 0; #endregion #region CONSOLE SIZE COMBOBOX _crosshairSize.SelectedIndex = 0; #endregion #endregion //---[ END LOADING DYNAMIC DATA FROM HASH MAPS ]---------------------------------------- UpdateTitle( ); #endregion }