30. May '08, 15:57

AoC Patcher Source

This is defenitly not the best code but it does what it should ;p

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;

namespace AoC_GUI_Patcher
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            // Welcome Text
            WriteMSG("        _______ _____   _______ ______ __ _______",false);
            WriteMSG(".-----.|       |     |_|   _   |   __ \__|__     |",false);
            WriteMSG("|__ --||   -   |       |       |      < |     __|",false);
            WriteMSG("|_____||_______|_______|___|___|___|__|__|_______|",false);
            WriteMSG("-=======[ AOC XML PATCHER by  SOLARiZ.de ]=======-",false);
            WriteMSG("        [  MARCO GÖTZE  | MG SOLARIZ.DE  ]", false);
            WriteMSG("     ", false);
            //richTextBox1.Text = "Age of Conan custom GUI Version PatchernProgrammed by Marco 'sOLARiZ' GoetzenPlease visit my Website: www.solariz.denn";<span id="more-655"></span>

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            GetAOCPath();
            //get_current_version("");
            linkLabel1.Text = "Version 1.3";
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

        public void GetAOCPath()
        {
            // Getting AOCPAth form registry
            string AoCPath = "";
            WriteMSG("- Trying to read your AOC Path from Registry",false);
            RegistryKey regkey;/* new Microsoft.Win32 Registry Key */
            // 32Bit
            if (AoCPath == "")
            {
                try
                {
                    regkey = Registry.LocalMachine.OpenSubKey(@"SoftwareFuncomAge of Conan");
                    AoCPath = (string)regkey.GetValue("LastInstalledClient");
                    WriteMSG("* 32Bit RegKey found", true);
                }
                catch
                {
                    WriteMSG("* 32Bit RegKey not Found", true);
                }
            }
            // 64Bit
            if (AoCPath == "")
            {
                try
                {
                    regkey = Registry.LocalMachine.OpenSubKey(@"SoftwareWow6432NodeFuncomAge of Conan");
                    AoCPath = (string)regkey.GetValue("LastInstalledClient");
                    WriteMSG("* 64Bit RegKey found", true);
                }
                catch
                {
                    WriteMSG("* 64Bit RegKey not Found", true);
                }
            }
            // Alternative AoCCombatLog
            if (AoCPath == "")
            {
                try
                {
                    regkey = Registry.CurrentUser.OpenSubKey(@"SoftwareAoCCombatLog");
                    AoCPath = (string)regkey.GetValue("AoCPath");
                    WriteMSG("* CombatLog RegKey found", true);
                }
                catch
                {
                    WriteMSG("* CombatLog RegKey not Found", true);
                }
            }
            if (AoCPath != "")
            {
                textBox1.Text = AoCPath;
                WriteMSG("- AoCPath entry found: " + textBox1.Text,false);
                button4.Enabled = true;
            }
            else
            {
                WriteMSG("! WARNING:ntCan't get the AOC Path from your Windows registryntyou have to enter the path manualy!",false);
            }//end else
        }

        public string get_current_version(string SourceFile)
        {
            // aktuelle Versionsnummer holen
            string XMLChangeString = "
                                string line = streamReader.ReadLine();
                                int pos = line.IndexOf(XMLChangeString, 0, StringComparison.CurrentCultureIgnoreCase);
                                if (pos >= 0)
                                {
                                    found = found + 1;
                                    doReplace = 1;
                                    // // Bestimmen der Versions Nummer
                                    temp_filename = filePath.Replace(ConanPathCustomized, "");
                                    xmlver = get_current_version(temp_filename);
                                    line = Regex.Replace(line, XMLRegex, ": " + xmlver);
                                    WriteMSG(xmlver + ": t" + temp_filename, false);
                                }
                                temp_buffer = temp_buffer + line;
                                if (temp_buffer != "") temp_buffer = temp_buffer + "rn";
                            }// end while
                            streamReader.Close();
                            // Neues File erstellen
                            if (doReplace != 0)
                            {

                                doReplace = 0;
                                try
                                {
                                    StreamWriter tw = new StreamWriter(filePath);
                                    tw.WriteLine(temp_buffer);
                                    //tw.Write(temp_buffer);
                                    tw.Close();
                                    patched = patched + 1;
                                }
                                catch
                                {
                                    WriteMSG("! ERROR: Cant write to file:n" + filePath, false);
                                }// end catch
                            }// end if
                            //richTextBox1.Text = temp_buffer;
                            //break;
                        }// End for Each filePAth
                        WriteMSG("Ready!t(Patched " + patched + " of " + found + " Files)", false);
                        WriteMSG("nNow its time to crush your enemies, see them driven before you and hear the lamentations of the women !", false);
                    }
                    catch
                    {
                        string text = "! Error occured, AOC Directory not found !";
                        WriteMSG(text,false);
                    }//end catch
                }
                catch
                { // Wird aufgerufen wenn die datei zur rev. bestimmung nicht gefunden wurde.
                    string text = "! Error occured, AOC Directory not found !n(Cant open " + ConanPathDefault + "\Modules.xml)n";
                }// end catch
            }
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            GetAOCPath();
        }

        private void button2_Hover_1(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "Read Conan Path from Registy";
        }

        private void textBox1_TextChanged_1(object sender, EventArgs e)
        {
            if (textBox1.Text != "Enter Path of your AOC Installation") button4.Enabled = true;
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            get_current_version("");
        }

        private void button1_Hover_1(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "Read current Ver. No. from Modules.xml";
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            try
            {
                // launch default browser
                System.Diagnostics.Process.Start("http://www.solariz.de/aoc/20-aoc/76-aocpatcher");
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }

    }
}

Related Posts

Tags:

 

Der Artikel hat dir gefallen oder war hilfreich ?

Wenn dir dieser Artikel gefallen hat kannst Du nun einen Kommentar verfassen oder einen trackback senden. Über eine Share/Bookmark Verlinkung oder Empfehlung würde ich mich freuen. Als Alternative zum Lesen im Blog steht auch noch ein RSS Icon RSS Full-Feed zur Verfügung sowie die Möglichkeit Blog Postings via E-Mail zu abonnieren.


Leave a Reply

XHTML: allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <p> <q cite=""> <strike> <strong>

AVATARS: To set a Picture / Avatar please check out Gravatar.

Spam protection by WP Captcha-Free