Example #1
0
        IniFile MyIni = new IniFile("Settings.ini"); //creates / loads the settings file
        public Path(int currGame, FormStartPosition pos)
        {
            this.StartPosition = pos;
            intGame = currGame;
            Boolean worked = false;
            if (MyIni.KeyExists("Path" + intGame)) //Path contains the pathes of the GTA folders.
            {
                var GamePath = MyIni.Read("Path" + intGame);
                if (Directory.Exists(GamePath))
                {
                    if (Directory.GetFiles(GamePath, gameEXE(intGame), SearchOption.TopDirectoryOnly).Count() > 0 || Directory.GetFiles(GamePath, "gta-sa.exe", SearchOption.TopDirectoryOnly).Count() == 1)
                    {
                        worked = true;
                        Explorer explorerForm = new Explorer(intGame, GamePath);
                        explorerForm.Closed += (s, args) => Application.Exit();
                        explorerForm.Show(); //Opens the explorer form, if the path was found and exists. Parameters: int of the current game and path of the current game.
                    }
                }
            }
            if (!(worked))
            {
                this.Show();
            }
            //Following lines search in the registry for game pathes
            InitializeComponent();
            label1.Text = label1.Text + " " + gameString(currGame) + OpenRW.Resources._internal.ResourceManager.GetString("lblATR") + "!";
            RegistryKey rk = Registry.LocalMachine;
            RegistryKey sk1 = rk.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 12100"); // III Steam
            RegistryKey sk2 = rk.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 12110"); // Vice City Steam
            RegistryKey sk3 = rk.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 12120"); // San Andreas Steam

            if (intGame == 0)
            {
                if (sk1 != null)
                {
                    if (sk1.GetValueNames().Contains("InstallLocation") && sk1.GetValue("InstallLocation").ToString() != "")
                    {
                        textBox1.Text = sk1.GetValue("InstallLocation").ToString();
                    }
                }
            }
            else if (intGame == 1)
            {
                if (sk2 != null)
                {
                    if (sk2.GetValueNames().Contains("InstallLocation") && sk2.GetValue("InstallLocation").ToString() != "")
                    {
                        textBox1.Text = sk2.GetValue("InstallLocation").ToString();
                    }
                }
            }
            else if (intGame == 2)
            {
                if (sk3 != null)
                {
                    if (sk3.GetValueNames().Contains("InstallLocation") && sk3.GetValue("InstallLocation").ToString() != "")
                    {
                        textBox1.Text = sk3.GetValue("InstallLocation").ToString();
                    }
                }
            }




        }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            //Saves the path to the ini file, if.. aah common you can read those error messages on your own...
            if (Directory.Exists(textBox1.Text))
            {
                if (Directory.GetFiles(textBox1.Text, gameEXE(intGame), SearchOption.TopDirectoryOnly).Count() == 1 || Directory.GetFiles(textBox1.Text, "gta-sa.exe", SearchOption.TopDirectoryOnly).Count() == 1)
                {
                    MyIni.Write("Path" + intGame, textBox1.Text);

                    this.Hide();
                    Explorer explorerForm = new Explorer(intGame, textBox1.Text);
                    explorerForm.Closed += (s, args) => Application.Exit();
                    explorerForm.Show();

                }
                else
                {
                    MessageBox.Show(Resources._internal.ResourceManager.GetString("noFiTXT") + gameEXE(intGame) + "!", gameEXE(intGame) + Resources._internal.ResourceManager.GetString("noFiDES"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show(Resources._internal.ResourceManager.GetString("noFoTXT"), Resources._internal.ResourceManager.GetString("noFoDES"),
                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }