Guest User

Untitled

a guest
Apr 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13.  
  14. namespace AoeIIAllMod
  15. {
  16. public partial class Form1 : Form
  17. {
  18. public Form1()
  19. {
  20. InitializeComponent();
  21. this.Text = "AokMod Made by Katsuie*. Source Of .Slp on AokHeaven Forum";
  22. }
  23.  
  24. /// <span class="code-SummaryComment"><summary></span>
  25. /// Executes a shell command synchronously.
  26. /// <span class="code-SummaryComment"></summary></span>
  27. /// <span class="code-SummaryComment"><param name="command">string command</param></span>
  28. /// <span class="code-SummaryComment"><returns>string, as output of the command.</returns></span>
  29. public void ExecuteCommandSync(object command)
  30. {
  31. //try
  32. //{
  33. // create the ProcessStartInfo using "cmd" as the program to be run,
  34. // and "/c " as the parameters.
  35. // Incidentally, /c tells cmd that we want it to execute the command that follows,
  36. // and then exit.
  37.  
  38. System.Diagnostics.ProcessStartInfo procStartInfo =
  39. new System.Diagnostics.ProcessStartInfo("drsbuild", "" + command);
  40.  
  41. // The following commands are needed to redirect the standard output.
  42. // This means that it will be redirected to the Process.StandardOutput StreamReader.
  43. procStartInfo.RedirectStandardOutput = true;
  44. procStartInfo.UseShellExecute = false;
  45. // Do not create the black window.
  46. procStartInfo.CreateNoWindow = true;
  47. // Now we create a process, assign its ProcessStartInfo and start it
  48. System.Diagnostics.Process proc = new System.Diagnostics.Process();
  49. proc.StartInfo = procStartInfo;
  50. proc.Start();
  51. // Get the output into a string
  52. string result = proc.StandardOutput.ReadToEnd();
  53. // Display the command output.
  54. Console.WriteLine(result);
  55. //}
  56. //catch (Exception objException)
  57. //{
  58. // // Log the exception
  59. //}
  60. }
  61. /// <span class="code-SummaryComment"><summary></span>
  62. /// Execute the command Asynchronously.
  63. /// <span class="code-SummaryComment"></summary></span>
  64. /// <span class="code-SummaryComment"><param name="command">string command.</param></span>
  65. public void ExecuteCommandAsync(string command)
  66. {
  67. try
  68. {
  69. //Asynchronously start the Thread to process the Execute command request.
  70. Thread objThread = new Thread(new ParameterizedThreadStart(ExecuteCommandSync));
  71. //Make the thread as background thread.
  72. objThread.IsBackground = true;
  73. //Set the Priority of the thread.
  74. objThread.Priority = ThreadPriority.AboveNormal;
  75. //Start the thread.
  76. objThread.Start(command);
  77. }
  78. catch (ThreadStartException objException)
  79. {
  80. // Log the exception
  81. }
  82. catch (ThreadAbortException objException)
  83. {
  84. // Log the exception
  85. }
  86. catch (Exception objException)
  87. {
  88. // Log the exception
  89. }
  90. }
  91.  
  92. public void add_mod(string s, string drs, string ext)
  93. {
  94. DirectoryInfo d_resp = new DirectoryInfo($@"AokMod\{s}\resp");//Assuming Test is your Folder
  95. DirectoryInfo d = new DirectoryInfo($@"AokMod\{s}\");//Assuming Test is your Folder
  96. FileInfo[] Files_resp = d_resp.GetFiles(ext); //Getting Text files
  97. FileInfo[] Files = d.GetFiles(ext); //Getting Text files
  98. string cmd = "";
  99. string Arg = "/e ";
  100. // on extrait
  101. for (int i = 0; i < Files.Count(); i++)
  102. {
  103. if (Files_resp.Count() == 0) //si le fichier est vide alors on sauvegard la version slp du graphic.drs
  104. {
  105. cmd = $@"{Arg} {folderPath}\data\{drs}.drs {Files[i].ToString()} /o AokMod\{s}\resp\ ";
  106. ExecuteCommandAsync(cmd);
  107. }
  108. }
  109. Arg = "/r";
  110. //ramplace
  111. cmd = $@"{Arg} {folderPath}\Data\{drs}.drs AokMod\{s}\{ext}";
  112. ExecuteCommandAsync(cmd);
  113.  
  114.  
  115. }
  116. public bool flag;
  117. public void message()
  118. {
  119. if (folderPath == null)
  120. {
  121. MessageBox.Show("Choise Age of Rmpire II path !!! Click Browser");
  122. flag = false;
  123. }
  124. }
  125. public void back_to_old_mod(string s, string drs, string ext)
  126. {
  127. DirectoryInfo d_resp = new DirectoryInfo($@"AokMod\{s}\resp");//Assuming Test is your Folder
  128. DirectoryInfo d = new DirectoryInfo($@"AokMod\{s}\");//Assuming Test is your Folder
  129.  
  130. string cmd = "";
  131. string Arg = "/r ";
  132. //on remplace par les anciens
  133. cmd = $@"{Arg} {folderPath}\Data\{drs}.drs AokMod\{s}\resp\{ext} ";
  134. ExecuteCommandAsync(cmd);
  135. }
  136.  
  137. private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
  138. {
  139. // Get the subdirectories for the specified directory.
  140. DirectoryInfo dir = new DirectoryInfo(sourceDirName);
  141.  
  142. if (!dir.Exists)
  143. {
  144. throw new DirectoryNotFoundException(
  145. "Source directory does not exist or could not be found: "
  146. + sourceDirName);
  147. }
  148.  
  149. DirectoryInfo[] dirs = dir.GetDirectories();
  150. // If the destination directory doesn't exist, create it.
  151. if (!Directory.Exists(destDirName))
  152. {
  153. Directory.CreateDirectory(destDirName);
  154. }
  155.  
  156. // Get the files in the directory and copy them to the new location.
  157. FileInfo[] files = dir.GetFiles();
  158. foreach (FileInfo file in files)
  159. {
  160. string temppath = Path.Combine(destDirName, file.Name);
  161. file.CopyTo(temppath, false);
  162. }
  163.  
  164. // If copying subdirectories, copy them and their contents to new location.
  165. if (copySubDirs)
  166. {
  167. foreach (DirectoryInfo subdir in dirs)
  168. {
  169. string temppath = Path.Combine(destDirName, subdir.Name);
  170. DirectoryCopy(subdir.FullName, temppath, copySubDirs);
  171. }
  172. }
  173. }
  174. public string folderPath;
  175. private void button1_Click_1(object sender, EventArgs e)
  176. {
  177. try
  178. {
  179. folderPath = "";
  180. FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
  181. if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
  182. {
  183. folderPath = folderBrowserDialog1.SelectedPath;
  184. if (folderPath == "")
  185. flag = false;
  186. else
  187. flag = true;
  188.  
  189. Directory.CreateDirectory($@"Data\");
  190. Directory.CreateDirectory($@"dll\");
  191. if (folderPath != "")
  192. {
  193. DirectoryCopy($@"{folderPath}\Data\", $@"Data\", true);
  194. DirectoryInfo d = new DirectoryInfo($@"{folderPath}");
  195. FileInfo[] Files_dll = d.GetFiles("*.dll"); //Getting Text files
  196. for (int i = 0; i < Files_dll.Count(); i++)
  197. {
  198. Files_dll[i].CopyTo($@"dll\{Files_dll[i]}", false);
  199. }
  200.  
  201. }
  202. }
  203. }
  204. catch (Exception ex)
  205. {
  206. MessageBox.Show("" + ex);
  207. }
  208. }
  209.  
  210. private void button1_Click(object sender, EventArgs e)
  211. {
  212. message();
  213. if (flag)
  214. {
  215. if (checkBox_HdFirev2.Checked)
  216. {
  217. add_mod("HdFirev2", "graphics", "*.slp");
  218. }
  219. else
  220. {
  221. back_to_old_mod("HdFirev2", "graphics", "*.slp");
  222. }
  223. }
  224. }
  225.  
  226. private void button_HDTerrains_Click(object sender, EventArgs e)
  227. {
  228. message();
  229. if (flag)
  230. {
  231. if (checkBox_HD_Terrains.Checked)
  232. {
  233. add_mod("terrainHD", "terrain", "*.slp");
  234. }
  235. else
  236. {
  237. back_to_old_mod("terrainHD", "terrain", "*.slp");
  238. }
  239. }
  240. }
  241.  
  242. private void button_Short_Wall_Click(object sender, EventArgs e)
  243. {
  244. message();
  245. if (flag)
  246. {
  247. if (checkBox_Short_Wall.Checked)
  248. {
  249. add_mod("short-walls", "graphics", "*.slp");
  250. }
  251. else
  252. {
  253. back_to_old_mod("short-walls", "graphics", "*.slp");
  254. }
  255. }
  256. }
  257.  
  258. private void button_HD_Cliffs_Click(object sender, EventArgs e)
  259. {
  260. message();
  261. if (flag)
  262. {
  263. if (checkBox_HD_Cliffs.Checked)
  264. {
  265. add_mod("hd-cliffs", "graphics", "*.slp");
  266. }
  267. else
  268. {
  269. back_to_old_mod("hd-cliffs", "graphics", "*.slp");
  270. }
  271. }
  272. }
  273.  
  274. private void button_blue_berries_Click(object sender, EventArgs e)
  275. {
  276. message();
  277. if (flag)
  278. {
  279. if (checkBox_blue_berries.Checked)
  280. {
  281. add_mod("blue-berries", "graphics", "*.slp");
  282. add_mod("blue-berries", "interfac", "*.slp");
  283. }
  284. else
  285. {
  286. back_to_old_mod("blue-berries", "graphics", "*.slp");
  287. back_to_old_mod("blue-berries", "interfac", "*.slp");
  288. }
  289. }
  290. }
  291.  
  292. private void button_alpha_farms_Click(object sender, EventArgs e)
  293. {
  294. message();
  295. if (flag)
  296. {
  297. if (checkBox_alpha_farms.Checked)
  298. {
  299. add_mod("alpha-farms", "terrain", "*.slp");
  300. add_mod("alpha-farms", "interfac", "*.bin");
  301. }
  302. else
  303. {
  304. back_to_old_mod("alpha-farms", "terrain", "*.slp");
  305. back_to_old_mod("blue-berries", "interfac", "*.bin");
  306. }
  307. }
  308. }
  309.  
  310. private void button_Green_Farms_Click(object sender, EventArgs e)
  311. {
  312. message();
  313. if (flag)
  314. {
  315. if (checkBox_Green_Farms.Checked)
  316. {
  317. add_mod("green-Farms", "terrain", "*.slp");
  318. }
  319. else
  320. {
  321. back_to_old_mod("green-Farms", "terrain", "*.slp");
  322. }
  323. }
  324. }
  325.  
  326. private void button_HD_Water_Click(object sender, EventArgs e)
  327. {
  328. message();
  329. if (flag)
  330. {
  331. if (checkBox_alpha_water.Checked)
  332. {
  333. add_mod("alpha-water", "terrain", "*.slp");
  334. add_mod("alpha-water", "interfac", "*.bin");
  335. }
  336. else
  337. {
  338. back_to_old_mod("alpha-water", "terrain", "*.slp");
  339. back_to_old_mod("alpha-water", "interfac", "*.bin");
  340. }
  341. }
  342. }
  343.  
  344. private void button_HD_Fire_Arrows_Click(object sender, EventArgs e)
  345. {
  346. message();
  347. if (flag)
  348. {
  349. if (checkBox_HD_Fire_Arrows.Checked)
  350. {
  351. add_mod("hd-fire-arrows", "graphics", "*.slp");
  352. }
  353. else
  354. {
  355. back_to_old_mod("hd-fire-arrows", "graphics", "*.slp");
  356. }
  357. }
  358. }
  359.  
  360. private void button_HD_Mines_Click(object sender, EventArgs e)
  361. {
  362. message();
  363. if (flag)
  364. {
  365. if (checkBox_HD_Mines.Checked)
  366. {
  367. add_mod("hd-mines", "graphics", "*.slp");
  368. }
  369. else
  370. {
  371. back_to_old_mod("hd-mines", "graphics", "*.slp");
  372. }
  373. }
  374. }
  375.  
  376. private void button_Enhanced_Blood_Click(object sender, EventArgs e)
  377. {
  378. message();
  379. if (flag)
  380. {
  381. if (checkBox_Enhanced_Blood.Checked)
  382. {
  383. add_mod("enhanced-blood", "graphics", "*.slp");
  384. }
  385. else
  386. {
  387. back_to_old_mod("enhanced-blood", "graphics", "*.slp");
  388. }
  389. }
  390. }
  391.  
  392. private void button_Alpha_Buildings_Click(object sender, EventArgs e)
  393. {
  394. message();
  395. if (flag)
  396. {
  397. if (checkBox_Alpha_Buildings.Checked)
  398. {
  399. add_mod("alpha-buildings", "graphics", "*.slp");
  400. }
  401. else
  402. {
  403. back_to_old_mod("alpha-buildings", "graphics", "*.slp");
  404. }
  405. }
  406. }
  407.  
  408. private void button_Small_Tree_Click(object sender, EventArgs e)
  409. {
  410. message();
  411. if (flag)
  412. {
  413. if (checkBox_Small_Tree.Checked)
  414. {
  415. add_mod("small-trees", "graphics", "*.slp");
  416. }
  417. else
  418. {
  419. back_to_old_mod("small-trees", "graphics", "*.slp");
  420. }
  421. }
  422. }
  423.  
  424. private void button_Light_Grid_Terrains_Click(object sender, EventArgs e)
  425. {
  426. message();
  427. if (flag)
  428. {
  429. if (checkBox_Light_Grid_Terrains.Checked)
  430. {
  431. add_mod("grid-terrains", "terrain", "*.slp");
  432. }
  433. else
  434. {
  435. back_to_old_mod("grid-terrains", "terrain", "*.slp");
  436. }
  437. }
  438. }
  439.  
  440. private void button_Volcanic_Terrains_Click(object sender, EventArgs e)
  441. {
  442. message();
  443. if (flag)
  444. {
  445. if (checkBox_Volcanic_Terrains.Checked)
  446. {
  447. add_mod("volcanic-terrain", "terrain", "*.slp");
  448. }
  449. else
  450. {
  451. back_to_old_mod("volcanic-terrain", "terrain", "*.slp");
  452. }
  453. }
  454. }
  455. private void button_Rice_Farm_Click(object sender, EventArgs e)
  456. {
  457. message();
  458. if (flag)
  459. {
  460. if (checkBox_Rice_Farm.Checked)
  461. {
  462. add_mod("rice-farms", "terrain", "*.slp");
  463. }
  464. else
  465. {
  466. back_to_old_mod("rice-farms", "terrain", "*.slp");
  467. }
  468. }
  469. }
  470. private void addYouModeToolStripMenuItem_Click(object sender, EventArgs e)
  471. {
  472. var f = new Form2(folderPath);
  473. f.Show();
  474. }
  475.  
  476. private void button_Go_Back_Click(object sender, EventArgs e)
  477. {
  478. message();
  479. if (flag)
  480. {
  481. if (folderPath != "")
  482. {
  483. DirectoryInfo d_Age = new DirectoryInfo($@"{folderPath}");
  484. FileInfo[] Files_Age_dll = d_Age.GetFiles("*.dll"); //Getting Text files
  485.  
  486. for (int i = 0; i < Files_Age_dll.Count(); i++)
  487. {
  488. Files_Age_dll[i].Delete();
  489. }
  490.  
  491.  
  492. Directory.Delete($@"{folderPath}\Data\", true);
  493.  
  494.  
  495. DirectoryCopy($@"Data\", $@"{folderPath}\Data\", true);
  496.  
  497.  
  498. DirectoryInfo d = new DirectoryInfo($@"dll");
  499. FileInfo[] Files_dll = d.GetFiles("*.dll"); //Getting Text files
  500. for (int i = 0; i < Files_dll.Count(); i++)
  501. {
  502. Files_dll[i].CopyTo($@"{folderPath}\{Files_dll[i]}", false);
  503. }
  504.  
  505.  
  506. }
  507. }
  508.  
  509. }
  510.  
  511. private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  512. {
  513.  
  514. }
  515.  
  516. private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  517. {
  518. if (e.CloseReason == CloseReason.UserClosing)
  519. {
  520. DialogResult result = MessageBox.Show("Check if You game is working fine, if any erro click GoBack button!! Are you shure that you want to close?", "Important Question", MessageBoxButtons.YesNo);
  521. if (result == DialogResult.Yes)
  522. {
  523. if (Directory.Exists($@"Data\"))
  524. Directory.Delete($@"Data\", true);
  525. if (Directory.Exists($@"dll\"))
  526. Directory.Delete($@"dll\", true);
  527. Environment.Exit(0);
  528. }
  529. else
  530. {
  531. e.Cancel = true;
  532. }
  533. }
  534. else
  535. {
  536. e.Cancel = true;
  537. }
  538. }
  539.  
  540. private void Form1_Load(object sender, EventArgs e)
  541. {
  542.  
  543. }
  544.  
  545. private void button_AokWk_Click(object sender, EventArgs e)
  546. {
  547. try
  548. {
  549. DirectoryInfo d = new DirectoryInfo($@"AokWk");
  550. FileInfo[] Files = d.GetFiles("*.*"); //Getting Text files
  551.  
  552.  
  553. DirectoryInfo d_Age = new DirectoryInfo($@"{folderPath}");
  554. FileInfo[] Files_Age_dll = d_Age.GetFiles("language.dll"); //Getting Text files
  555. Files_Age_dll[0].Delete();
  556.  
  557.  
  558. DirectoryInfo d_Age_data = new DirectoryInfo($@"{folderPath}\Data");
  559. FileInfo[] Files_Age_data = d_Age_data.GetFiles("empires2.dat"); //Getting Text files
  560. Files_Age_data[0].Delete();
  561.  
  562.  
  563. DirectoryInfo d_Age_drs = new DirectoryInfo($@"{folderPath}\Data");
  564. FileInfo[] Files_Age_drs = d_Age_drs.GetFiles("graphics.drs"); //Getting Text files
  565. Files_Age_drs[0].Delete();
  566.  
  567. DirectoryInfo d_Age_gdata = new DirectoryInfo($@"{folderPath}\Data");
  568. FileInfo[] Files_Age_gdata = d_Age_drs.GetFiles("gamedata.drs"); //Getting Text files
  569. Files_Age_gdata[0].Delete();
  570.  
  571. for (int i = 0; i < Files.Count(); i++)
  572. {
  573. if (Files[i].ToString() == "language.dll")
  574. Files[i].CopyTo($@"{folderPath}\{Files[i]}");
  575. else
  576. Files[i].CopyTo($@"{folderPath}\Data\{Files[i]}");
  577. }
  578. }
  579. catch (Exception ex)
  580. {
  581. MessageBox.Show("" + ex);
  582. }
  583. }
  584.  
  585. private void button_Viking_Arch_Click(object sender, EventArgs e)
  586. {
  587. message();
  588. if (flag)
  589. {
  590. if (checkBox_Viking_Arch.Checked)
  591. {
  592. add_mod("Viking-Arch", "graphics", "*.slp");
  593. }
  594. else
  595. {
  596. back_to_old_mod("Viking-Arch", "graphics", "*.slp");
  597. }
  598. }
  599. }
  600.  
  601. private void chooseLanguageToolStripMenuItem_Click(object sender, EventArgs e)
  602. {
  603. ProcessStartInfo startInfo = new ProcessStartInfo();
  604. startInfo.CreateNoWindow = false;
  605. startInfo.UseShellExecute = false;
  606. startInfo.FileName = "AoC Language Switcher.exe";
  607. startInfo.WindowStyle = ProcessWindowStyle.Hidden;
  608. Process.Start(startInfo);
  609. }
  610.  
  611. private void changeVersionToolStripMenuItem_Click(object sender, EventArgs e)
  612. {
  613. ProcessStartInfo startInfo = new ProcessStartInfo();
  614. startInfo.CreateNoWindow = false;
  615. startInfo.UseShellExecute = true;
  616. startInfo.FileName = "Version Wololo.exe";
  617. startInfo.WindowStyle = ProcessWindowStyle.Hidden;
  618. startInfo.Verb = "runas";
  619. Process.Start(startInfo);
  620. }
  621.  
  622. private void button_New_Unit_Click(object sender, EventArgs e)
  623. {
  624. message();
  625. if (flag)
  626. {
  627. if (checkBox_New_Unit.Checked)
  628. {
  629. add_mod("New-Unit", "graphics", "*.slp");
  630. }
  631. else
  632. {
  633. back_to_old_mod("New-Unit", "graphics", "*.slp");
  634. }
  635. }
  636. }
  637.  
  638. private void button_real_Cliffs_Click(object sender, EventArgs e)
  639. {
  640. message();
  641. if (flag)
  642. {
  643. if (checkBox_Real_Cliff.Checked)
  644. {
  645. add_mod("real-clif", "graphics", "*.slp");
  646. }
  647. else
  648. {
  649. back_to_old_mod("real-clif", "graphics", "*.slp");
  650. }
  651. }
  652. }
  653.  
  654. private void infoToolStripMenuItem_Click(object sender, EventArgs e)
  655. {
  656. MessageBox.Show("Programme made by Yuri (Katsuie*) with aokheaven slp");
  657. }
  658. }
  659. }
Add Comment
Please, Sign In to add comment