Form1.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. using System.Collections;
  10. namespace DefSorter
  11. {
  12. public partial class Form1 : Form
  13. {
  14. int bledy;
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. int ile = 0;
  19. bledy = 0;
  20. string[] pliczki = Directory.GetFiles(Directory.GetCurrentDirectory());
  21. foreach (string ss in pliczki)
  22. {
  23. if ((!(ss.EndsWith(".DEF")))&&(!(ss.EndsWith(".def"))))
  24. continue;
  25. else ile++;
  26. }
  27. label2.Text = ile.ToString();
  28. progressBar1.Visible = false;
  29. }
  30. private void button1_Click(object sender, EventArgs e)
  31. {
  32. int s12 = 0, s13 = 0, s14 = 0, s15 = 0, s16 = 0, s17 = 0, s18 = 0,
  33. s19 = 0, s20 = 0, s21 = 0;
  34. Form2 pozegnanie = new Form2();
  35. ArrayList defy = new ArrayList();
  36. string[] pliczki = Directory.GetFiles(Directory.GetCurrentDirectory(),"*.DEF");
  37. progressBar1.Visible = true;
  38. progressBar1.Minimum = progressBar1.Value = 0;
  39. progressBar1.Maximum = Convert.ToInt32(label2.Text);
  40. foreach (string ss in pliczki)
  41. {
  42. if ((!(ss.EndsWith(".DEF"))) && (!(ss.EndsWith(".def"))))
  43. continue;
  44. FileStream czytacz = File.OpenRead(ss);
  45. int coTo = czytacz.ReadByte();
  46. czytacz.Close();
  47. int poczP = ss.LastIndexOf('\\');
  48. string nazwa = ss.Substring(poczP + 1, ss.Length - poczP - 1);
  49. try
  50. {
  51. switch (coTo)
  52. {
  53. case 64:
  54. if (!Directory.Exists("40Spell"))
  55. Directory.CreateDirectory("40Spell");
  56. File.Copy(ss, "40Spell\\" + nazwa);
  57. s12++;
  58. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  59. {
  60. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "40Spell\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  61. }
  62. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  63. {
  64. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "40Spell\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  65. }
  66. break;
  67. case 65:
  68. if (!Directory.Exists("41SpriteDef"))
  69. Directory.CreateDirectory("41SpriteDef");
  70. File.Copy(ss, "41SpriteDef\\" + nazwa);
  71. s13++;
  72. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  73. {
  74. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "41SpriteDef\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  75. }
  76. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  77. {
  78. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "41SpriteDef\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  79. }
  80. break;
  81. case 66:
  82. if (!Directory.Exists("42Creature"))
  83. Directory.CreateDirectory("42Creature");
  84. File.Copy(ss, "42Creature\\" + nazwa);
  85. s14++;
  86. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  87. {
  88. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "42Creature\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  89. }
  90. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  91. {
  92. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "42Creature\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  93. }
  94. break;
  95. case 67:
  96. if (!Directory.Exists("43AdvObject"))
  97. Directory.CreateDirectory("43AdvObject");
  98. File.Copy(ss, "43AdvObject\\" + nazwa);
  99. s15++;
  100. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  101. {
  102. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "43AdvObject\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  103. }
  104. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  105. {
  106. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "43AdvObject\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  107. }
  108. break;
  109. case 68:
  110. if (!Directory.Exists("44Hero"))
  111. Directory.CreateDirectory("44Hero");
  112. File.Copy(ss, "44Hero\\" + nazwa);
  113. s16++;
  114. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  115. {
  116. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "44Hero\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  117. }
  118. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  119. {
  120. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "44Hero\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  121. }
  122. break;
  123. case 69:
  124. if (!Directory.Exists("45Terrain"))
  125. Directory.CreateDirectory("45Terrain");
  126. File.Copy(ss, "45Terrain\\" + nazwa);
  127. s17++;
  128. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4)+".MSK"))
  129. {
  130. File.Copy(nazwa.Substring(0, nazwa.Length - 4)+".MSK","45Terrain\\"+nazwa.Substring(0, nazwa.Length - 4)+".MSK");
  131. }
  132. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4)+".MSG"))
  133. {
  134. File.Copy(nazwa.Substring(0, nazwa.Length - 4)+".MSG","45Terrain\\"+nazwa.Substring(0, nazwa.Length - 4)+".MSG");
  135. }
  136. break;
  137. case 70:
  138. if (!Directory.Exists("46Cursor"))
  139. Directory.CreateDirectory("46Cursor");
  140. File.Copy(ss, "46Cursor\\" + nazwa);
  141. s18++;
  142. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  143. {
  144. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "46Cursor\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  145. }
  146. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  147. {
  148. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "46Cursor\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  149. }
  150. break;
  151. case 71:
  152. if (!Directory.Exists("47Interface"))
  153. Directory.CreateDirectory("47Interface");
  154. File.Copy(ss, "47Interface\\" + nazwa);
  155. s19++;
  156. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  157. {
  158. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "47Interface\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  159. }
  160. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  161. {
  162. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "47Interface\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  163. }
  164. break;
  165. case 72:
  166. if (!Directory.Exists("48Spriteframe"))
  167. Directory.CreateDirectory("48Spriteframe");
  168. File.Copy(ss, "48Spriteframe\\" + nazwa);
  169. s20++;
  170. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  171. {
  172. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "48Spriteframe\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  173. }
  174. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  175. {
  176. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "48Spriteframe\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  177. }
  178. break;
  179. case 73:
  180. if (!Directory.Exists("49CombatHero"))
  181. Directory.CreateDirectory("49CombatHero");
  182. File.Copy(ss, "49CombatHero\\" + nazwa);
  183. s21++;
  184. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSK"))
  185. {
  186. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSK", "49CombatHero\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSK");
  187. }
  188. if (File.Exists(nazwa.Substring(0, nazwa.Length - 4) + ".MSG"))
  189. {
  190. File.Copy(nazwa.Substring(0, nazwa.Length - 4) + ".MSG", "49CombatHero\\" + nazwa.Substring(0, nazwa.Length - 4) + ".MSG");
  191. }
  192. break;
  193. }
  194. }
  195. catch (Exception ee)
  196. {
  197. bledy++;
  198. Form3 niedobrze = new Form3();
  199. niedobrze.textBox1.Text += ee.Message;
  200. DialogResult res = niedobrze.ShowDialog();
  201. switch (res)
  202. {
  203. case DialogResult.Ignore:
  204. break;
  205. case DialogResult.Cancel:
  206. try { Directory.Delete("40Spell"); }catch(Exception){};
  207. try { Directory.Delete("41SpriteDef"); }catch(Exception){};
  208. try { Directory.Delete("42Creature"); }catch(Exception){};
  209. try { Directory.Delete("43AdvObject"); }catch(Exception){};
  210. try { Directory.Delete("45Terrain"); }catch(Exception){};
  211. try { Directory.Delete("46Cursor"); }catch(Exception){};
  212. try { Directory.Delete("47Interface"); }catch(Exception){};
  213. try { Directory.Delete("48Spriteframe"); }catch(Exception){};
  214. try { Directory.Delete("49CombatHero"); }catch(Exception){};
  215. Application.Exit();
  216. break;
  217. }
  218. }
  219. progressBar1.Value++;
  220. if (progressBar1.Value % 100 == 5)
  221. this.Update();
  222. }
  223. progressBar1.Visible = false;
  224. pozegnanie.label12.Text = s12.ToString();
  225. pozegnanie.label13.Text = s13.ToString();
  226. pozegnanie.label14.Text = s14.ToString();
  227. pozegnanie.label15.Text = s15.ToString();
  228. pozegnanie.label16.Text = s16.ToString();
  229. pozegnanie.label17.Text = s17.ToString();
  230. pozegnanie.label18.Text = s18.ToString();
  231. pozegnanie.label19.Text = s19.ToString();
  232. pozegnanie.label20.Text = s20.ToString();
  233. pozegnanie.label21.Text = s21.ToString();
  234. pozegnanie.label34.Text = bledy.ToString();
  235. if (bledy == 0)
  236. pozegnanie.label35.Text = ":)";
  237. pozegnanie.Show();
  238. pozegnanie.Activate();
  239. }
  240. }
  241. }