Esempio n. 1
0
        public GameData(MeType type, ConfIni configIni, bool force = false, bool installerMode = false)
        {
            gameType   = type;
            _configIni = configIni;

            string key  = "ME" + (int)gameType;
            string path = configIni.Read(key, "GameDataPath");

            if (path != null && path != "" && !force)
            {
                _path = path.TrimEnd(Path.DirectorySeparatorChar);
                if (File.Exists(GameExePath))
                {
                    return;
                }
                else
                {
                    _path = null;
                }
            }

            string registryKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BioWare\Mass Effect";
            string entry       = "Path";

            if (type == MeType.ME2_TYPE)
            {
                registryKey += " 2";
            }
            else if (type == MeType.ME3_TYPE)
            {
                registryKey += " 3";
                entry        = "Install Dir";
            }

            path = (string)Registry.GetValue(registryKey, entry, null);
            if (path != null && !force)
            {
                _path = path.TrimEnd(Path.DirectorySeparatorChar);
                if (File.Exists(GameExePath))
                {
                    configIni.Write(key, _path, "GameDataPath");
                    return;
                }
                else
                {
                    _path = null;
                }
            }
            if (_path != null)
            {
                _configIni.Write(key, _path, "GameDataPath");
            }
        }
Esempio n. 2
0
        public bool Run(bool runAsAdmin)
        {
            installerIni = new ConfIni(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "installer.ini"));
            string gameIdStr = installerIni.Read("GameId", "Main");

            if (gameIdStr.ToLowerInvariant() == "me1")
            {
                gameId = 1;
            }
            else if (gameIdStr.ToLowerInvariant() == "me2")
            {
                gameId = 2;
            }
            else if (gameIdStr.ToLowerInvariant() == "me3")
            {
                gameId = 3;
            }
            else
            {
                MessageBox.Show("Game ID not recognized in installer.ini, exiting...", "Installer");
                return(false);
            }
            Text += " ME" + gameId;
            if (runAsAdmin)
            {
                Text += " (run as Administrator)";
            }
            configIni = new ConfIni();

            labelStatusPrepare.Text  = "";
            labelStatusScan.Text     = "";
            labelStatusTextures.Text = "";
            labelStatusStore.Text    = "";
            labelStatusMipMaps.Text  = "";
            labelStatusLOD.Text      = "";
            labelFinalStatus.Text    = "Before beginning, press the CHECK button.";

            if (gameId != 3)
            {
                checkBoxPreEnablePack.Visible = false;
                labelME3DLCPack.Visible       = false;
                checkBoxPackDLC.Visible       = false;
                labelStatusPackDLC.Visible    = false;

                labelMERepackZlib.Visible     = false;
                checkBoxRepackZlib.Visible    = false;
                labelStatusRepackZlib.Visible = false;
                buttonUnpackDLC.Visible       = false;
            }
            if (gameId == 3)
            {
                checkBoxPreEnableRepack.Visible = false;
                labelMERepackZlib.Visible       = false;
                labelME3DLCPack.Visible         = false;
                checkBoxRepackZlib.Visible      = false;
                labelStatusRepackZlib.Visible   = false;

                labelME3DLCPack.Visible    = false;
                checkBoxPackDLC.Visible    = false;
                labelStatusPackDLC.Visible = false;
            }

            checkBoxOptionVanilla.Checked = false;
            checkBoxOptionFaster.Checked  = false;
            buttonUnpackDLC.Enabled       = false;

            clearPreCheckStatus();

            buttonSTART.Enabled = false;

            return(true);
        }
        public GameData(MeType type, ConfIni configIni, bool force = false)
        {
            gameType   = type;
            _configIni = configIni;

            string key  = "ME" + (int)gameType;
            string path = configIni.Read(key, "GameDataPath");

            if (path != null && path != "" && !force)
            {
                _path = path.TrimEnd(Path.DirectorySeparatorChar);
                if (File.Exists(GameExePath))
                {
                    return;
                }
                else
                {
                    _path = null;
                }
            }

            string softwareKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\";
            string key64       = @"Wow6432Node\";
            string gameKey     = @"BioWare\Mass Effect";
            string entry       = "Path";

            if (type == MeType.ME2_TYPE)
            {
                gameKey += @" 2";
            }
            else if (type == MeType.ME3_TYPE)
            {
                gameKey += @" 3";
                entry    = "Install Dir";
            }

            path = (string)Registry.GetValue(softwareKey + gameKey, entry, null);
            if (path == null)
            {
                path = (string)Registry.GetValue(softwareKey + key64 + gameKey, entry, null);
            }
            if (path != null && !force)
            {
                _path = path.TrimEnd(Path.DirectorySeparatorChar);
                if (File.Exists(GameExePath))
                {
                    configIni.Write(key, _path, "GameDataPath");
                    return;
                }
                else
                {
                    _path = null;
                }
            }

            OpenFileDialog selectExe = new OpenFileDialog();

            selectExe.Title = "Please select the Mass Effect " + (int)gameType + " executable file";
            if (_path != null)
            {
                selectExe.FileName = _path;
            }
            switch (gameType)
            {
            case MeType.ME1_TYPE:
                selectExe.Filter   = "ME1 exe file|MassEffect.exe";
                selectExe.FileName = "MassEffect.exe";
                break;

            case MeType.ME2_TYPE:
                selectExe.Filter   = "ME2 exe file|MassEffect2.exe";
                selectExe.FileName = "MassEffect2.exe";
                break;

            case MeType.ME3_TYPE:
                selectExe.Filter   = "ME3 exe file|MassEffect3.exe";
                selectExe.FileName = "MassEffect3.exe";
                break;
            }
            if (selectExe.ShowDialog() == DialogResult.OK)
            {
                if (gameType == MeType.ME3_TYPE)
                {
                    _path = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(selectExe.FileName)));
                }
                else
                {
                    _path = Path.GetDirectoryName(Path.GetDirectoryName(selectExe.FileName));
                }
            }
            if (_path != null)
            {
                _configIni.Write(key, _path, "GameDataPath");
            }
        }