Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace AddAModOnAgeOfEmpireII
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- this.Text = "This Programme is made By Katsuie*";
- panel_type_drs.Visible = false;
- }
- /// <span class="code-SummaryComment"><summary></span>
- /// Executes a shell command synchronously.
- /// <span class="code-SummaryComment"></summary></span>
- /// <span class="code-SummaryComment"><param name="command">string command</param></span>
- /// <span class="code-SummaryComment"><returns>string, as output of the command.</returns></span>
- public void ExecuteCommandSync(object command)
- {
- //try
- //{
- // create the ProcessStartInfo using "cmd" as the program to be run,
- // and "/c " as the parameters.
- // Incidentally, /c tells cmd that we want it to execute the command that follows,
- // and then exit.
- System.Diagnostics.ProcessStartInfo procStartInfo =
- new System.Diagnostics.ProcessStartInfo("drsbuild.exe", "" + command);
- // The following commands are needed to redirect the standard output.
- // This means that it will be redirected to the Process.StandardOutput StreamReader.
- procStartInfo.RedirectStandardOutput = true;
- procStartInfo.UseShellExecute = false;
- // Do not create the black window.
- procStartInfo.CreateNoWindow = true;
- // Now we create a process, assign its ProcessStartInfo and start it
- System.Diagnostics.Process proc = new System.Diagnostics.Process();
- proc.StartInfo = procStartInfo;
- proc.Start();
- // Get the output into a string
- string result = proc.StandardOutput.ReadToEnd();
- // Display the command output.
- Console.WriteLine(result);
- //}
- //catch (Exception objException)
- //{
- // // Log the exception
- //}
- }
- /// <span class="code-SummaryComment"><summary></span>
- /// Execute the command Asynchronously.
- /// <span class="code-SummaryComment"></summary></span>
- /// <span class="code-SummaryComment"><param name="command">string command.</param></span>
- public void ExecuteCommandAsync(string command)
- {
- try
- {
- //Asynchronously start the Thread to process the Execute command request.
- Thread objThread = new Thread(new ParameterizedThreadStart(ExecuteCommandSync));
- //Make the thread as background thread.
- objThread.IsBackground = true;
- //Set the Priority of the thread.
- objThread.Priority = ThreadPriority.AboveNormal;
- //Start the thread.
- objThread.Start(command);
- }
- catch (ThreadStartException objException)
- {
- // Log the exception
- }
- catch (ThreadAbortException objException)
- {
- // Log the exception
- }
- catch (Exception objException)
- {
- // Log the exception
- }
- }
- public string folderPath;
- public string AddQuotesIfRequired(string path)
- {
- return !string.IsNullOrEmpty(path) ?
- path.Contains(" ") ? "\"" + path + "\"" : path
- : string.Empty;
- }
- //add_mod("terrainHD", "terrain", "*.slp");
- public bool flag;
- public void message()
- {
- if (folderPath == null)
- {
- MessageBox.Show("Choise Age of Rmpire II path !!! Click Browser");
- flag = false;
- }
- }
- private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
- {
- // Get the subdirectories for the specified directory.
- DirectoryInfo dir = new DirectoryInfo(sourceDirName);
- if (!dir.Exists)
- {
- throw new DirectoryNotFoundException(
- "Source directory does not exist or could not be found: "
- + sourceDirName);
- }
- DirectoryInfo[] dirs = dir.GetDirectories();
- // If the destination directory doesn't exist, create it.
- if (!Directory.Exists(destDirName))
- {
- Directory.CreateDirectory(destDirName);
- }
- // Get the files in the directory and copy them to the new location.
- FileInfo[] files = dir.GetFiles();
- foreach (FileInfo file in files)
- {
- string temppath = Path.Combine(destDirName, file.Name);
- file.CopyTo(temppath, false);
- }
- // If copying subdirectories, copy them and their contents to new location.
- if (copySubDirs)
- {
- foreach (DirectoryInfo subdir in dirs)
- {
- string temppath = Path.Combine(destDirName, subdir.Name);
- DirectoryCopy(subdir.FullName, temppath, copySubDirs);
- }
- }
- }
- private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
- {
- MessageBox.Show($@"Pour tous ce qui est unitées et mines, faliase, bois ça se trouve dans Age Of Empire II/Data/graphics.drs
- {Environment.NewLine} Pour ce qui est terrain et fermes ça se trouve dans Age Of Empire II/Data/terrain.drs ");
- }
- private void parcourirToolStripMenuItem_Click(object sender, EventArgs e)
- {
- try
- {
- folderPath = "";
- FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
- if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
- {
- folderPath = folderBrowserDialog1.SelectedPath;
- if (folderPath == "")
- flag = false;
- else
- flag = true;
- if (!Directory.Exists($@"Data\") && !Directory.Exists($@"dll\"))
- {
- Directory.CreateDirectory($@"Data\");
- Directory.CreateDirectory($@"dll\");
- if (folderPath != "")
- {
- DirectoryCopy($@"{folderPath}\Data\", $@"Data\", true);
- DirectoryInfo d = new DirectoryInfo($@"{folderPath}");
- FileInfo[] Files_dll = d.GetFiles("*.dll"); //Getting Text files
- for (int i = 0; i < Files_dll.Count(); i++)
- {
- Files_dll[i].CopyTo($@"dll\{Files_dll[i]}", false);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("" + ex);
- }
- }
- public void add_mod(string s, string drs, string ext)
- {
- DirectoryInfo d_resp = new DirectoryInfo($@"{s}\resp");//Assuming Test is your Folder
- DirectoryInfo d = new DirectoryInfo($@"{s}\");//Assuming Test is your Folder
- FileInfo[] Files_resp = d_resp.GetFiles(ext); //Getting Text files
- FileInfo[] Files = d.GetFiles(ext); //Getting Text files
- string cmd = "";
- string Arg = "/e ";
- // on extrait
- for (int i = 0; i < Files.Count(); i++)
- {
- if (Files_resp.Count() == 0) //si le fichier est vide alors on sauvegard la version slp du graphic.drs
- {
- cmd = $@"{Arg} ""{folderPath}\data\{drs}.drs"" {Files[i].ToString()} /o {s}\resp\ ";
- Thread.Sleep(500); //sinon le process bug
- ExecuteCommandAsync(cmd);
- Thread.Sleep(500); //sinon le process bug
- }
- }
- Arg = "/r";
- cmd = "";
- //ramplace
- cmd = $@"{Arg} ""{folderPath}\Data\{drs}.drs"" {s}\{ext}";
- ExecuteCommandAsync(cmd);
- }
- //back_to_old_mod("HdFirev2", "graphics", "*.slp");
- public void back_to_old_mod(string s, string drs, string ext)
- {
- DirectoryInfo d_resp = new DirectoryInfo($@"{s}\resp");//Assuming Test is your Folder
- DirectoryInfo d = new DirectoryInfo($@"{s}\");//Assuming Test is your Folder
- string cmd = "";
- string Arg = "/r ";
- //on remplace par les anciens
- cmd = $@"{Arg} ""{folderPath}\Data\{drs}.drs"" {s}\resp\{ext} ";
- ExecuteCommandAsync(cmd);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (radioButton_AOENormal.Checked)
- {
- if (modpath == "")
- {
- FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
- modpath = "";
- if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
- {
- modpath = folderBrowserDialog1.SelectedPath;
- if (radioButton_Terrain.Checked)
- back_to_old_mod(modpath, "terrain", "*.slp");
- if (radioButton_Graphic.Checked)
- back_to_old_mod(modpath, "graphics", "*.slp");
- if (radioButton_Interfac.Checked)
- back_to_old_mod(modpath, "interfac", "*.slp");
- }
- }
- else
- {
- if (radioButton_Terrain.Checked)
- back_to_old_mod(modpath, "terrain", "*.slp");
- if (radioButton_Graphic.Checked)
- back_to_old_mod(modpath, "graphics", "*.slp");
- if (radioButton_Interfac.Checked)
- back_to_old_mod(modpath, "interfac", "*.slp");
- }
- }
- //C:\Program Files (x86)\Steam\steamapps\common\Age2HD\resources\_common\drs\graphics
- if (radioButton_AOEHD.Checked)
- {
- FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
- modpath = "";
- if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
- {
- modpath = folderBrowserDialog1.SelectedPath;
- Directory.CreateDirectory($@"{modpath}\respHd");
- DirectoryInfo d_resphd = new DirectoryInfo($@"{modpath}\respHd");//Assuming Test is your Folder
- DirectoryInfo d_pourhd = new DirectoryInfo($@"{modpath}\PourHD");
- DirectoryInfo d = new DirectoryInfo($@"{modpath}\");
- FileInfo[] Files = d.GetFiles("*.slp"); //Getting Text files
- FileInfo[] FilesPourHd = d_pourhd.GetFiles("*.slp");
- FileInfo[] Fileresphd = d_resphd.GetFiles("*.slp");
- string steamPath = "";
- steamPath = $@" C:\Program Files (x86)\Steam\steamapps\common\Age2HD\resources\_common\drs\graphics ";
- var verif = Directory.Exists(@" C:\Program Files (x86)\Steam\steamapps\common\Age2HD\resources\_common\drs\graphics");
- if (!verif)//!Directory.Exists(@" C:\Program Files (x86)\Steam\steamapps\common\Age2HD\resources\_common\drs\graphics")) ;
- {
- steamPath = "";
- MessageBox.Show(@"Veuillez parcourir: Steam\steamapps\common\Age2HD\resources\_common\drs\graphics");
- FolderBrowserDialog folderBrowserDialog2 = new FolderBrowserDialog();
- if (folderBrowserDialog2.ShowDialog() == DialogResult.OK)
- {
- steamPath = folderBrowserDialog2.SelectedPath;
- }
- }
- DirectoryInfo d_steam = new DirectoryInfo(steamPath);
- FileInfo[] filesSteam = d_steam.GetFiles("*.slp");
- // Get the files in the directory and copy them to the new location.
- //on supprime les fichier dans Steam\steamapps\common\Age2HD\resources\_common\drs\graphics
- foreach (FileInfo file in FilesPourHd)
- {
- foreach (FileInfo f in filesSteam)
- {
- if (file.Name == f.Name) // on supprime les fichiers qui sont identique au mod
- {
- f.Delete();
- }
- }
- }
- //on copie les fichier de sauvegarder dans respHD
- foreach (FileInfo file in FilesPourHd)
- {
- foreach (FileInfo f in Fileresphd)
- {
- if (file.Name == f.Name)
- {
- string temppath = Path.Combine(steamPath, file.Name);
- f.CopyTo(temppath, false);
- }
- }
- }
- }
- }
- }
- public string modpath;
- private void button1_Click(object sender, EventArgs e)
- {
- if (radioButton_AOENormal.Checked)
- {
- FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
- modpath = "";
- if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
- {
- modpath = folderBrowserDialog1.SelectedPath;
- if (!Directory.Exists($@"{modpath}\resp"))
- Directory.CreateDirectory($@"{modpath}\resp");
- if (radioButton_Terrain.Checked)
- add_mod(modpath, "terrain", "*.slp");
- if (radioButton_Graphic.Checked)
- add_mod(modpath, "graphics", "*.slp");
- if (radioButton_Interfac.Checked)
- add_mod(modpath, "interfac", "*.slp");
- }
- }
- if(radioButton_AOEHD.Checked)
- {
- FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
- modpath = "";
- if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
- {
- modpath = folderBrowserDialog1.SelectedPath;
- Directory.CreateDirectory($@"{modpath}\respHd");
- DirectoryInfo d_resphd = new DirectoryInfo($@"{modpath}\respHd");//Assuming Test is your Folder
- DirectoryInfo d_pourhd = new DirectoryInfo($@"{modpath}\PourHD");
- DirectoryInfo d = new DirectoryInfo($@"{modpath}\");
- FileInfo[] Files = d.GetFiles("*.slp"); //Getting Text files
- FileInfo[] FilesPourHd = d_pourhd.GetFiles("*.slp");
- FileInfo[] Fileresp = d_resphd.GetFiles("*.slp");
- string steamPath = "";
- steamPath = $@" C:\Program Files (x86)\Steam\steamapps\common\Age2HD\resources\_common\drs\graphics ";
- var verif = Directory.Exists(@" C:\Program Files (x86)\Steam\steamapps\common\Age2HD\resources\_common\drs\graphics");
- if (!verif)//!Directory.Exists(@" C:\Program Files (x86)\Steam\steamapps\common\Age2HD\resources\_common\drs\graphics")) ;
- {
- steamPath = "";
- MessageBox.Show(@"Veuillez parcourir: Steam\steamapps\common\Age2HD\resources\_common\drs\graphics");
- FolderBrowserDialog folderBrowserDialog2 = new FolderBrowserDialog();
- if (folderBrowserDialog2.ShowDialog() == DialogResult.OK)
- {
- steamPath = folderBrowserDialog2.SelectedPath;
- }
- }
- DirectoryInfo d_steam = new DirectoryInfo(steamPath);
- FileInfo[] filesSteam = d_steam.GetFiles("*.slp");
- // Get the files in the directory and copy them to the new location.
- //on copie les fichier de Steam\steamapps\common\Age2HD\resources\_common\drs\graphics dans le répértoir respHd
- foreach (FileInfo file in filesSteam)
- {
- foreach (FileInfo f in FilesPourHd)
- {
- if (file.Name == f.Name)
- {
- string temppath = Path.Combine($@"{modpath}\respHd", file.Name);
- file.CopyTo(temppath, true);
- }
- }
- }
- //on supprime les fichier dans Steam\steamapps\common\Age2HD\resources\_common\drs\graphics
- foreach (FileInfo file in FilesPourHd)
- {
- foreach (FileInfo f in filesSteam)
- {
- if (file.Name == f.Name) // on supprime les fichiers qui sont identique au mod
- {
- f.Delete();
- }
- }
- }
- //on copie les fichier du mode dans Steam\steamapps\common\Age2HD\resources\_common\drs\graphics
- foreach (FileInfo file in FilesPourHd)
- {
- string temppath = Path.Combine(steamPath, file.Name);
- file.CopyTo(temppath, false);
- }
- }
- }
- }
- private void infoToolStripMenuItem_Click(object sender, EventArgs e)
- {
- }
- private void formatDeFichierToolStripMenuItem_Click(object sender, EventArgs e)
- {
- MessageBox.Show(@" je rappel le chemin: Age Of Empire II/data
- Les fichiers .slp de graphic.drs doivent avoir gra devant leur nom par exmple: gra00576.slp"
- +Environment.NewLine+ "Les fichiers .slp de terrain.drs doivent avoir ter devant leur nom par exmple: ter15001.slp"
- +Environment.NewLine+ " Les fichiers .slp de Interface.drs doivent avoir int leur nom par exmple: int50500.bin"
- +Environment.NewLine + "Les Fichiers doivent avoir un nombre avec 5 zéros par exemple: gra00001.slp ");
- }
- private void formatDeFichierAOE2HDToolStripMenuItem_Click(object sender, EventArgs e)
- {
- MessageBox.Show("Pour les fichier du HDLa régle des 5 zéros ne s'applique pas ainsi que les préfix Exemple de fichier: 576.slp ou 1636.slp ");
- }
- private void renomeUnFichierToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var f = new RenameFile();
- f.ShowDialog();
- }
- private void radioButton_AOENormal_CheckedChanged(object sender, EventArgs e)
- {
- panel_type_drs.Visible = true;
- }
- private void radioButton_AOEHD_CheckedChanged(object sender, EventArgs e)
- {
- panel_type_drs.Visible = false;
- }
- }
- }
Add Comment
Please, Sign In to add comment