Exemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            mGameList = new GameListItem[] {
                new GameListItem(GameType.None, "<Not found>", ""),
                new GameListItem(GameType.Doom3, "Doom 3", "doom3.exe"),
                new GameListItem(GameType.Prey, "Prey", "prey.exe"),
                new GameListItem(GameType.Quake4, "Quake 4", "quake4.exe")
            };

            if (mGameList == null)
            {
                throw new OutOfMemoryException();
            }

            var game = DetectGame();

            gameComboBox.DataSource    = mGameList;
            gameComboBox.SelectedValue = game;
            mGame = (GameListItem)gameComboBox.SelectedItem;

            if (game != GameType.None)
            {
                if (LoadFile(mGame.ExeName))
                {
                    mPatchOffset  = FindBytes(PATCH_BYTES);
                    mRevertOffset = FindBytes(REVERT_BYTES);

                    bool foundPatch  = (mPatchOffset > 0);
                    bool foundRevert = (mRevertOffset > 0);

                    if (foundPatch && foundRevert)
                    {
                        errorProvider.SetError(
                            gameComboBox, "File \"" + mGame.ExeName + "\" contains both data to patch and to revert.\n" +
                            "Not original file?");
                    }
                    else if (!foundPatch && !foundRevert)
                    {
                        errorProvider.SetError(
                            gameComboBox, "File \"" + mGame.ExeName + "\" contains no data to patch/revert.");
                    }
                    else
                    {
                        if (foundPatch)
                        {
                            patchButton.Enabled = true;
                        }

                        if (foundRevert)
                        {
                            revertButton.Enabled = true;
                        }
                    }
                }
            }
            else
            {
                errorProvider.SetError(gameComboBox,
                                       "Game not found. Please put the\nprogram into the game folder.");
            }
        }
Exemplo n.º 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            mGameList = new GameListItem[] {
                new GameListItem(GameType.None, "<Not found>", ""),
                new GameListItem(GameType.Doom3, "Doom 3", "doom3.exe"),
                new GameListItem(GameType.Prey, "Prey", "prey.exe"),
                new GameListItem(GameType.Quake4, "Quake 4", "quake4.exe")
            };

            if (mGameList == null)
                throw new OutOfMemoryException();

            var game = DetectGame();
            gameComboBox.DataSource = mGameList;
            gameComboBox.SelectedValue = game;
            mGame = (GameListItem)gameComboBox.SelectedItem;

            if (game != GameType.None)
            {
                if (LoadFile(mGame.ExeName))
                {
                    mPatchOffset = FindBytes(PATCH_BYTES);
                    mRevertOffset = FindBytes(REVERT_BYTES);

                    bool foundPatch = (mPatchOffset > 0);
                    bool foundRevert = (mRevertOffset > 0);

                    if (foundPatch && foundRevert)
                    {
                        errorProvider.SetError(
                            gameComboBox, "File \"" + mGame.ExeName + "\" contains both data to patch and to revert.\n" +
                            "Not original file?");
                    }
                    else if (!foundPatch && !foundRevert)
                    {
                        errorProvider.SetError(
                            gameComboBox, "File \"" + mGame.ExeName + "\" contains no data to patch/revert.");
                    }
                    else
                    {
                        if (foundPatch)
                            patchButton.Enabled = true;

                        if (foundRevert)
                            revertButton.Enabled = true;
                    }
                }
            }
            else
            {
                errorProvider.SetError(gameComboBox,
                    "Game not found. Please put the\nprogram into the game folder.");
            }
        }