DropBuilderForm.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. using Server.MirEnvir;
  2. namespace Server.MirForms.DropBuilder
  3. {
  4. public class MonsterDropInfo
  5. {
  6. public string Name { get; set; }
  7. public string Path { get; set; }
  8. public override string ToString()
  9. {
  10. return Name;
  11. }
  12. }
  13. public partial class DropGenForm : Form
  14. {
  15. string Gold = "0", GoldOdds;
  16. List<DropItem>
  17. Weapon = new List<DropItem>(),
  18. Armour = new List<DropItem>(),
  19. Helmet = new List<DropItem>(),
  20. Necklace = new List<DropItem>(),
  21. Bracelet = new List<DropItem>(),
  22. Ring = new List<DropItem>(),
  23. Amulet = new List<DropItem>(),
  24. Belt = new List<DropItem>(),
  25. Boot = new List<DropItem>(),
  26. Stone = new List<DropItem>(),
  27. Torch = new List<DropItem>(),
  28. Potion = new List<DropItem>(),
  29. Ore = new List<DropItem>(),
  30. Meat = new List<DropItem>(),
  31. CraftingMaterial = new List<DropItem>(),
  32. Scrolls = new List<DropItem>(),
  33. Gem = new List<DropItem>(),
  34. Mount = new List<DropItem>(),
  35. Book = new List<DropItem>(),
  36. Nothing = new List<DropItem>(),
  37. Script = new List<DropItem>(),
  38. Reins = new List<DropItem>(),
  39. Bells = new List<DropItem>(),
  40. Saddle = new List<DropItem>(),
  41. Ribbon = new List<DropItem>(),
  42. Mask = new List<DropItem>(),
  43. Food = new List<DropItem>(),
  44. Hook = new List<DropItem>(),
  45. Float = new List<DropItem>(),
  46. Bait = new List<DropItem>(),
  47. Finder = new List<DropItem>(),
  48. Reel = new List<DropItem>(),
  49. Fish = new List<DropItem>(),
  50. Quest = new List<DropItem>(),
  51. Awakening = new List<DropItem>(),
  52. Pets = new List<DropItem>(),
  53. Transform = new List<DropItem>();
  54. List<DropItem>[] ItemLists;
  55. ListBox[] ItemListBoxes;
  56. public DropGenForm()
  57. {
  58. InitializeComponent();
  59. // Array of items
  60. ItemLists = new List<DropItem>[37]
  61. {
  62. Weapon,
  63. Armour,
  64. Helmet,
  65. Necklace,
  66. Bracelet,
  67. Ring,
  68. Amulet,
  69. Belt,
  70. Boot,
  71. Stone,
  72. Torch,
  73. Potion,
  74. Ore,
  75. Meat,
  76. CraftingMaterial,
  77. Scrolls,
  78. Gem,
  79. Mount,
  80. Book,
  81. Nothing,
  82. Script,
  83. Reins,
  84. Bells,
  85. Saddle,
  86. Ribbon,
  87. Mask,
  88. Food,
  89. Hook,
  90. Float,
  91. Bait,
  92. Finder,
  93. Reel,
  94. Fish,
  95. Quest,
  96. Awakening,
  97. Pets,
  98. Transform
  99. };
  100. // Array of item list boxes
  101. ItemListBoxes = new ListBox[37]
  102. {
  103. listBoxWeapon,
  104. listBoxArmour,
  105. listBoxHelmet,
  106. listBoxNecklace,
  107. listBoxBracelet,
  108. listBoxRing,
  109. listBoxAmulet,
  110. listBoxBelt,
  111. listBoxBoot,
  112. listBoxStone,
  113. listBoxTorch,
  114. listBoxPotion,
  115. listBoxOre,
  116. listBoxMeat,
  117. listBoxCraftingMaterial,
  118. listBoxScroll,
  119. listBoxGem,
  120. listBoxMount,
  121. listBoxBook,
  122. listBoxNothing,
  123. listBoxScript,
  124. listBoxReins,
  125. listBoxBells,
  126. listBoxSaddle,
  127. listBoxRibbon,
  128. listBoxMask,
  129. listBoxFood,
  130. listBoxHook,
  131. listBoxFloat,
  132. listBoxBait,
  133. listBoxFinder,
  134. listBoxReel,
  135. listBoxFish,
  136. listBoxQuest,
  137. listBoxAwakening,
  138. listBoxPets,
  139. listBoxTransform
  140. };
  141. // Add monsters to list
  142. for (int i = 0; i < Envir.MonsterInfoList.Count; i++)
  143. {
  144. listBoxMonsters.Items.Add(new MonsterDropInfo { Name = Envir.MonsterInfoList[i].Name, Path = Envir.MonsterInfoList[i].DropPath });
  145. }
  146. tabControlSeperateItems_SelectedIndexChanged(tabControlSeperateItems, null);
  147. listBoxMonsters.SelectedIndex = 0;
  148. labelMonsterList.Text = $"Monster Count: {Envir.MonsterInfoList.Count}";
  149. }
  150. // Gets server data
  151. public Envir Envir => SMain.EditEnvir;
  152. // Updates the drop file text
  153. private void UpdateDropFile()
  154. {
  155. textBoxDropList.Clear();
  156. textBoxDropList.Text += $";Gold{Environment.NewLine}";
  157. if (Gold != "0")
  158. {
  159. textBoxDropList.Text += $"1/{GoldOdds} Gold {Gold}{Environment.NewLine}";
  160. textBoxGoldAmount.Text = Gold;
  161. textBoxGoldOdds.Text = GoldOdds;
  162. }
  163. else
  164. {
  165. textBoxGoldAmount.Text = "0";
  166. textBoxGoldOdds.Text = string.Empty;
  167. }
  168. textBoxDropList.Text += string.Format("{0};Weapons{0}", Environment.NewLine);
  169. for (int i = 0; i < Weapon.Count; i++)
  170. textBoxDropList.Text += $"{Weapon[i].Odds} {Weapon[i].Name} {Weapon[i].Quest}{Environment.NewLine}";
  171. textBoxDropList.Text += string.Format("{0};Armours{0}", Environment.NewLine);
  172. for (int i = 0; i < Armour.Count; i++)
  173. textBoxDropList.Text += $"{Armour[i].Odds} {Armour[i].Name} {Armour[i].Quest}{Environment.NewLine}";
  174. textBoxDropList.Text += string.Format("{0};Helmets{0}", Environment.NewLine);
  175. for (int i = 0; i < Helmet.Count; i++)
  176. textBoxDropList.Text += $"{Helmet[i].Odds} {Helmet[i].Name} {Helmet[i].Quest}{Environment.NewLine}";
  177. textBoxDropList.Text += string.Format("{0};Necklaces{0}", Environment.NewLine);
  178. for (int i = 0; i < Necklace.Count; i++)
  179. textBoxDropList.Text +=
  180. $"{Necklace[i].Odds} {Necklace[i].Name} {Necklace[i].Quest}{Environment.NewLine}";
  181. textBoxDropList.Text += string.Format("{0};Bracelets{0}", Environment.NewLine);
  182. for (int i = 0; i < Bracelet.Count; i++)
  183. textBoxDropList.Text +=
  184. $"{Bracelet[i].Odds} {Bracelet[i].Name} {Bracelet[i].Quest}{Environment.NewLine}";
  185. textBoxDropList.Text += string.Format("{0};Rings{0}", Environment.NewLine);
  186. for (int i = 0; i < Ring.Count; i++)
  187. textBoxDropList.Text += $"{Ring[i].Odds} {Ring[i].Name} {Ring[i].Quest}{Environment.NewLine}";
  188. textBoxDropList.Text += string.Format("{0};Amulets{0}", Environment.NewLine);
  189. for (int i = 0; i < Amulet.Count; i++)
  190. textBoxDropList.Text += $"{Amulet[i].Odds} {Amulet[i].Name} {Amulet[i].Quest}{Environment.NewLine}";
  191. textBoxDropList.Text += string.Format("{0};Belts{0}", Environment.NewLine);
  192. for (int i = 0; i < Belt.Count; i++)
  193. textBoxDropList.Text += $"{Belt[i].Odds} {Belt[i].Name} {Belt[i].Quest}{Environment.NewLine}";
  194. textBoxDropList.Text += string.Format("{0};Boots{0}", Environment.NewLine);
  195. for (int i = 0; i < Boot.Count; i++)
  196. textBoxDropList.Text += $"{Boot[i].Odds} {Boot[i].Name} {Boot[i].Quest}{Environment.NewLine}";
  197. textBoxDropList.Text += string.Format("{0};Stones{0}", Environment.NewLine);
  198. for (int i = 0; i < Stone.Count; i++)
  199. textBoxDropList.Text += $"{Stone[i].Odds} {Stone[i].Name} {Stone[i].Quest}{Environment.NewLine}";
  200. textBoxDropList.Text += string.Format("{0};Torches{0}", Environment.NewLine);
  201. for (int i = 0; i < Torch.Count; i++)
  202. textBoxDropList.Text += $"{Torch[i].Odds} {Torch[i].Name} {Torch[i].Quest}{Environment.NewLine}";
  203. textBoxDropList.Text += string.Format("{0};Potions{0}", Environment.NewLine);
  204. for (int i = 0; i < Potion.Count; i++)
  205. textBoxDropList.Text += $"{Potion[i].Odds} {Potion[i].Name} {Potion[i].Quest}{Environment.NewLine}";
  206. textBoxDropList.Text += string.Format("{0};Ores{0}", Environment.NewLine);
  207. for (int i = 0; i < Ore.Count; i++)
  208. textBoxDropList.Text += $"{Ore[i].Odds} {Ore[i].Name} {Ore[i].Quest}{Environment.NewLine}";
  209. textBoxDropList.Text += string.Format("{0};Meat{0}", Environment.NewLine);
  210. for (int i = 0; i < Meat.Count; i++)
  211. textBoxDropList.Text += $"{Meat[i].Odds} {Meat[i].Name} {Meat[i].Quest}{Environment.NewLine}";
  212. textBoxDropList.Text += string.Format("{0};Crafting Materials{0}", Environment.NewLine);
  213. for (int i = 0; i < CraftingMaterial.Count; i++)
  214. textBoxDropList.Text +=
  215. $"{CraftingMaterial[i].Odds} {CraftingMaterial[i].Name} {CraftingMaterial[i].Quest}{Environment.NewLine}";
  216. textBoxDropList.Text += string.Format("{0};Scrolls{0}", Environment.NewLine);
  217. for (int i = 0; i < Scrolls.Count; i++)
  218. textBoxDropList.Text += $"{Scrolls[i].Odds} {Scrolls[i].Name} {Scrolls[i].Quest}{Environment.NewLine}";
  219. textBoxDropList.Text += string.Format("{0};Gems{0}", Environment.NewLine);
  220. for (int i = 0; i < Gem.Count; i++)
  221. textBoxDropList.Text += $"{Gem[i].Odds} {Gem[i].Name} {Gem[i].Quest}{Environment.NewLine}";
  222. textBoxDropList.Text += string.Format("{0};Mount{0}", Environment.NewLine);
  223. for (int i = 0; i < Mount.Count; i++)
  224. textBoxDropList.Text += $"{Mount[i].Odds} {Mount[i].Name} {Mount[i].Quest}{Environment.NewLine}";
  225. textBoxDropList.Text += string.Format("{0};Books{0}", Environment.NewLine);
  226. for (int i = 0; i < Book.Count; i++)
  227. textBoxDropList.Text += $"{Book[i].Odds} {Book[i].Name} {Book[i].Quest}{Environment.NewLine}";
  228. textBoxDropList.Text += string.Format("{0};Nothing{0}", Environment.NewLine);
  229. for (int i = 0; i < Nothing.Count; i++)
  230. textBoxDropList.Text += $"{Nothing[i].Odds} {Nothing[i].Name} {Nothing[i].Quest}{Environment.NewLine}";
  231. textBoxDropList.Text += string.Format("{0};Script{0}", Environment.NewLine);
  232. for (int i = 0; i < Script.Count; i++)
  233. textBoxDropList.Text += $"{Script[i].Odds} {Script[i].Name} {Script[i].Quest}{Environment.NewLine}";
  234. textBoxDropList.Text += string.Format("{0};Reins{0}", Environment.NewLine);
  235. for (int i = 0; i < Reins.Count; i++)
  236. textBoxDropList.Text += $"{Reins[i].Odds} {Reins[i].Name} {Reins[i].Quest}{Environment.NewLine}";
  237. textBoxDropList.Text += string.Format("{0};Bells{0}", Environment.NewLine);
  238. for (int i = 0; i < Bells.Count; i++)
  239. textBoxDropList.Text += $"{Bells[i].Odds} {Bells[i].Name} {Bells[i].Quest}{Environment.NewLine}";
  240. textBoxDropList.Text += string.Format("{0};Saddle{0}", Environment.NewLine);
  241. for (int i = 0; i < Saddle.Count; i++)
  242. textBoxDropList.Text += $"{Saddle[i].Odds} {Saddle[i].Name} {Saddle[i].Quest}{Environment.NewLine}";
  243. textBoxDropList.Text += string.Format("{0};Ribbon{0}", Environment.NewLine);
  244. for (int i = 0; i < Ribbon.Count; i++)
  245. textBoxDropList.Text += $"{Ribbon[i].Odds} {Ribbon[i].Name} {Ribbon[i].Quest}{Environment.NewLine}";
  246. textBoxDropList.Text += string.Format("{0};Mask{0}", Environment.NewLine);
  247. for (int i = 0; i < Mask.Count; i++)
  248. textBoxDropList.Text += $"{Mask[i].Odds} {Mask[i].Name} {Mask[i].Quest}{Environment.NewLine}";
  249. textBoxDropList.Text += string.Format("{0};Food{0}", Environment.NewLine);
  250. for (int i = 0; i < Food.Count; i++)
  251. textBoxDropList.Text += $"{Food[i].Odds} {Food[i].Name} {Food[i].Quest}{Environment.NewLine}";
  252. textBoxDropList.Text += string.Format("{0};Hook{0}", Environment.NewLine);
  253. for (int i = 0; i < Hook.Count; i++)
  254. textBoxDropList.Text += $"{Hook[i].Odds} {Hook[i].Name} {Hook[i].Quest}{Environment.NewLine}";
  255. textBoxDropList.Text += string.Format("{0};Float{0}", Environment.NewLine);
  256. for (int i = 0; i < Float.Count; i++)
  257. textBoxDropList.Text += $"{Float[i].Odds} {Float[i].Name} {Float[i].Quest}{Environment.NewLine}";
  258. textBoxDropList.Text += string.Format("{0};Bait{0}", Environment.NewLine);
  259. for (int i = 0; i < Bait.Count; i++)
  260. textBoxDropList.Text += $"{Bait[i].Odds} {Bait[i].Name} {Bait[i].Quest}{Environment.NewLine}";
  261. textBoxDropList.Text += string.Format("{0};Finder{0}", Environment.NewLine);
  262. for (int i = 0; i < Finder.Count; i++)
  263. textBoxDropList.Text += $"{Finder[i].Odds} {Finder[i].Name} {Finder[i].Quest}{Environment.NewLine}";
  264. textBoxDropList.Text += string.Format("{0};Reel{0}", Environment.NewLine);
  265. for (int i = 0; i < Reel.Count; i++)
  266. textBoxDropList.Text += $"{Reel[i].Odds} {Reel[i].Name} {Reel[i].Quest}{Environment.NewLine}";
  267. textBoxDropList.Text += string.Format("{0};Fish{0}", Environment.NewLine);
  268. for (int i = 0; i < Fish.Count; i++)
  269. textBoxDropList.Text += $"{Fish[i].Odds} {Fish[i].Name} {Fish[i].Quest}{Environment.NewLine}";
  270. textBoxDropList.Text += string.Format("{0};Quest{0}", Environment.NewLine);
  271. for (int i = 0; i < Quest.Count; i++)
  272. textBoxDropList.Text += $"{Quest[i].Odds} {Quest[i].Name} {Quest[i].Quest}{Environment.NewLine}";
  273. textBoxDropList.Text += string.Format("{0};Awakening{0}", Environment.NewLine);
  274. for (int i = 0; i < Awakening.Count; i++)
  275. textBoxDropList.Text +=
  276. $"{Awakening[i].Odds} {Awakening[i].Name} {Awakening[i].Quest}{Environment.NewLine}";
  277. textBoxDropList.Text += string.Format("{0};Pets{0}", Environment.NewLine);
  278. for (int i = 0; i < Pets.Count; i++)
  279. textBoxDropList.Text += $"{Pets[i].Odds} {Pets[i].Name} {Pets[i].Quest}{Environment.NewLine}";
  280. textBoxDropList.Text += string.Format("{0};Transform{0}", Environment.NewLine);
  281. for (int i = 0; i < Transform.Count; i++)
  282. textBoxDropList.Text +=
  283. $"{Transform[i].Odds} {Transform[i].Name} {Transform[i].Quest}{Environment.NewLine}";
  284. SaveDropFile();
  285. }
  286. // Item tab change, draw appropriate items
  287. private void tabControlSeperateItems_SelectedIndexChanged(object sender, EventArgs e)
  288. {
  289. TabControl Tab = (TabControl)sender;
  290. foreach (var list in ItemListBoxes)
  291. list.Items.Clear();
  292. ListBox TempListBox = new ListBox();
  293. for (int i = 0; i < Envir.ItemInfoList.Count; i++)
  294. {
  295. if (Envir.ItemInfoList[i].Type.ToString() == Tab.SelectedTab.Tag.ToString())
  296. {
  297. try
  298. {
  299. if (textBoxMinLevel.Text == string.Empty || textBoxMaxLevel.Text == string.Empty)
  300. TempListBox.Items.Add(Envir.ItemInfoList[i].Name);
  301. else if (Envir.ItemInfoList[i].RequiredAmount >= int.Parse(textBoxMinLevel.Text) &
  302. Envir.ItemInfoList[i].RequiredAmount <= int.Parse(textBoxMaxLevel.Text))
  303. TempListBox.Items.Add(Envir.ItemInfoList[i].Name);
  304. }
  305. catch (Exception)
  306. {
  307. MessageBox.Show("Unreadable level filters.");
  308. break;
  309. }
  310. }
  311. }
  312. switch (Tab.SelectedTab.Tag.ToString())
  313. {
  314. case "Weapon":
  315. listBoxWeapon.Items.AddRange(TempListBox.Items);
  316. break;
  317. case "Armour":
  318. listBoxArmour.Items.AddRange(TempListBox.Items);
  319. break;
  320. case "Helmet":
  321. listBoxHelmet.Items.AddRange(TempListBox.Items);
  322. break;
  323. case "Necklace":
  324. listBoxNecklace.Items.AddRange(TempListBox.Items);
  325. break;
  326. case "Bracelet":
  327. listBoxBracelet.Items.AddRange(TempListBox.Items);
  328. break;
  329. case "Ring":
  330. listBoxRing.Items.AddRange(TempListBox.Items);
  331. break;
  332. case "Amulet":
  333. listBoxAmulet.Items.AddRange(TempListBox.Items);
  334. break;
  335. case "Belt":
  336. listBoxBelt.Items.AddRange(TempListBox.Items);
  337. break;
  338. case "Boots":
  339. listBoxBoot.Items.AddRange(TempListBox.Items);
  340. break;
  341. case "Stone":
  342. listBoxStone.Items.AddRange(TempListBox.Items);
  343. break;
  344. case "Torch":
  345. listBoxTorch.Items.AddRange(TempListBox.Items);
  346. break;
  347. case "Potion":
  348. listBoxPotion.Items.AddRange(TempListBox.Items);
  349. break;
  350. case "Ore":
  351. listBoxOre.Items.AddRange(TempListBox.Items);
  352. break;
  353. case "Meat":
  354. listBoxMeat.Items.AddRange(TempListBox.Items);
  355. break;
  356. case "CraftingMaterial":
  357. listBoxCraftingMaterial.Items.AddRange(TempListBox.Items);
  358. break;
  359. case "Scroll":
  360. listBoxScroll.Items.AddRange(TempListBox.Items);
  361. break;
  362. case "Gem":
  363. listBoxGem.Items.AddRange(TempListBox.Items);
  364. break;
  365. case "Mount":
  366. listBoxMount.Items.AddRange(TempListBox.Items);
  367. break;
  368. case "Book":
  369. listBoxBook.Items.AddRange(TempListBox.Items);
  370. break;
  371. case "Nothing":
  372. listBoxNothing.Items.AddRange(TempListBox.Items);
  373. break;
  374. case "Script":
  375. listBoxScript.Items.AddRange(TempListBox.Items);
  376. break;
  377. case "Reins":
  378. listBoxReins.Items.AddRange(TempListBox.Items);
  379. break;
  380. case "Bells":
  381. listBoxBells.Items.AddRange(TempListBox.Items);
  382. break;
  383. case "Saddle":
  384. listBoxSaddle.Items.AddRange(TempListBox.Items);
  385. break;
  386. case "Ribbon":
  387. listBoxRibbon.Items.AddRange(TempListBox.Items);
  388. break;
  389. case "Mask":
  390. listBoxMask.Items.AddRange(TempListBox.Items);
  391. break;
  392. case "Food":
  393. listBoxFood.Items.AddRange(TempListBox.Items);
  394. break;
  395. case "Hook":
  396. listBoxHook.Items.AddRange(TempListBox.Items);
  397. break;
  398. case "Float":
  399. listBoxFloat.Items.AddRange(TempListBox.Items);
  400. break;
  401. case "Bait":
  402. listBoxBait.Items.AddRange(TempListBox.Items);
  403. break;
  404. case "Finder":
  405. listBoxFinder.Items.AddRange(TempListBox.Items);
  406. break;
  407. case "Reel":
  408. listBoxReel.Items.AddRange(TempListBox.Items);
  409. break;
  410. case "Fish":
  411. listBoxFish.Items.AddRange(TempListBox.Items);
  412. break;
  413. case "Quest":
  414. listBoxQuest.Items.AddRange(TempListBox.Items);
  415. break;
  416. case "Awakening":
  417. listBoxAwakening.Items.AddRange(TempListBox.Items);
  418. break;
  419. case "Pets":
  420. listBoxPets.Items.AddRange(TempListBox.Items);
  421. break;
  422. case "Transform":
  423. listBoxTransform.Items.AddRange(TempListBox.Items);
  424. break;
  425. }
  426. }
  427. // Update the results to show them filtered
  428. private void FilterValueChange(object sender, EventArgs e)
  429. {
  430. tabControlSeperateItems_SelectedIndexChanged(tabControlSeperateItems, null);
  431. }
  432. // Add the item to the drop list
  433. private void buttonAdd_Click(object sender, EventArgs e)
  434. {
  435. int dropChance;
  436. int.TryParse(textBoxItemOdds.Text, out dropChance);
  437. if (dropChance < 1) dropChance = 1;
  438. string quest = QuestOnlyCheckBox.Checked ? "Q" : "";
  439. try
  440. {
  441. switch (tabControlSeperateItems.SelectedTab.Tag.ToString())
  442. {
  443. case "Weapon":
  444. Weapon.Add(new DropItem { Name = listBoxWeapon.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  445. $"1/{dropChance}", Quest = quest });
  446. break;
  447. case "Armour":
  448. Armour.Add(new DropItem { Name = listBoxArmour.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  449. $"1/{dropChance}", Quest = quest });
  450. break;
  451. case "Helmet":
  452. Helmet.Add(new DropItem { Name = listBoxHelmet.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  453. $"1/{dropChance}", Quest = quest });
  454. break;
  455. case "Necklace":
  456. Necklace.Add(new DropItem { Name = listBoxNecklace.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  457. $"1/{dropChance}", Quest = quest });
  458. break;
  459. case "Bracelet":
  460. Bracelet.Add(new DropItem { Name = listBoxBracelet.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  461. $"1/{dropChance}", Quest = quest });
  462. break;
  463. case "Ring":
  464. Ring.Add(new DropItem { Name = listBoxRing.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  465. $"1/{dropChance}", Quest = quest });
  466. break;
  467. case "Amulet":
  468. Amulet.Add(new DropItem { Name = listBoxAmulet.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  469. $"1/{dropChance}", Quest = quest });
  470. break;
  471. case "Belt":
  472. Belt.Add(new DropItem { Name = listBoxBelt.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  473. $"1/{dropChance}", Quest = quest });
  474. break;
  475. case "Boots":
  476. Boot.Add(new DropItem { Name = listBoxBoot.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  477. $"1/{dropChance}", Quest = quest });
  478. break;
  479. case "Stone":
  480. Stone.Add(new DropItem { Name = listBoxStone.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  481. $"1/{dropChance}", Quest = quest });
  482. break;
  483. case "Torch":
  484. Torch.Add(new DropItem { Name = listBoxTorch.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  485. $"1/{dropChance}", Quest = quest });
  486. break;
  487. case "Potion":
  488. Potion.Add(new DropItem { Name = listBoxPotion.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  489. $"1/{dropChance}", Quest = quest });
  490. break;
  491. case "Ore":
  492. Ore.Add(new DropItem { Name = listBoxOre.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  493. $"1/{dropChance}", Quest = quest });
  494. break;
  495. case "Meat":
  496. Meat.Add(new DropItem { Name = listBoxMeat.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  497. $"1/{dropChance}", Quest = quest });
  498. break;
  499. case "CraftingMaterial":
  500. CraftingMaterial.Add(new DropItem { Name = listBoxCraftingMaterial.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  501. $"1/{dropChance}"
  502. });
  503. break;
  504. case "Scroll":
  505. Scrolls.Add(new DropItem { Name = listBoxScroll.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  506. $"1/{dropChance}", Quest = quest });
  507. break;
  508. case "Gem":
  509. Gem.Add(new DropItem { Name = listBoxGem.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  510. $"1/{dropChance}", Quest = quest });
  511. break;
  512. case "Mount":
  513. Mount.Add(new DropItem { Name = listBoxMount.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  514. $"1/{dropChance}", Quest = quest });
  515. break;
  516. case "Book":
  517. Book.Add(new DropItem { Name = listBoxBook.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  518. $"1/{dropChance}", Quest = quest });
  519. break;
  520. case "Nothing":
  521. Nothing.Add(new DropItem { Name = listBoxNothing.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  522. $"1/{dropChance}", Quest = quest });
  523. break;
  524. case "Script":
  525. Script.Add(new DropItem { Name = listBoxScript.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  526. $"1/{dropChance}", Quest = quest });
  527. break;
  528. case "Reins":
  529. Reins.Add(new DropItem { Name = listBoxReins.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  530. $"1/{dropChance}", Quest = quest });
  531. break;
  532. case "Bells":
  533. Bells.Add(new DropItem { Name = listBoxBells.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  534. $"1/{dropChance}", Quest = quest });
  535. break;
  536. case "Saddle":
  537. Saddle.Add(new DropItem { Name = listBoxSaddle.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  538. $"1/{dropChance}", Quest = quest });
  539. break;
  540. case "Ribbon":
  541. Ribbon.Add(new DropItem { Name = listBoxRibbon.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  542. $"1/{dropChance}", Quest = quest });
  543. break;
  544. case "Mask":
  545. Mask.Add(new DropItem { Name = listBoxMask.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  546. $"1/{dropChance}", Quest = quest });
  547. break;
  548. case "Food":
  549. Food.Add(new DropItem { Name = listBoxFood.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  550. $"1/{dropChance}", Quest = quest });
  551. break;
  552. case "Hook":
  553. Hook.Add(new DropItem { Name = listBoxHook.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  554. $"1/{dropChance}", Quest = quest });
  555. break;
  556. case "Float":
  557. Float.Add(new DropItem { Name = listBoxFloat.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  558. $"1/{dropChance}", Quest = quest });
  559. break;
  560. case "Bait":
  561. Bait.Add(new DropItem { Name = listBoxBait.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  562. $"1/{dropChance}", Quest = quest });
  563. break;
  564. case "Finder":
  565. Finder.Add(new DropItem { Name = listBoxFinder.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  566. $"1/{dropChance}", Quest = quest });
  567. break;
  568. case "Reel":
  569. Reel.Add(new DropItem { Name = listBoxReel.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  570. $"1/{dropChance}", Quest = quest });
  571. break;
  572. case "Fish":
  573. Fish.Add(new DropItem { Name = listBoxFish.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  574. $"1/{dropChance}", Quest = quest });
  575. break;
  576. case "Quest":
  577. Quest.Add(new DropItem { Name = listBoxQuest.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  578. $"1/{dropChance}", Quest = quest });
  579. break;
  580. case "Awakening":
  581. Awakening.Add(new DropItem { Name = listBoxAwakening.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  582. $"1/{dropChance}", Quest = quest });
  583. break;
  584. case "Pets":
  585. Pets.Add(new DropItem { Name = listBoxPets.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  586. $"1/{dropChance}", Quest = quest });
  587. break;
  588. case "Transform":
  589. Transform.Add(new DropItem { Name = listBoxTransform.SelectedItem.ToString().Replace(" ", string.Empty), Odds =
  590. $"1/{dropChance}", Quest = quest });
  591. break;
  592. }
  593. UpdateDropFile();
  594. }
  595. catch
  596. {
  597. //No item selected when trying to add an item to the drop
  598. }
  599. }
  600. // Choose another monster.
  601. private void listBoxMonsters_SelectedItemChanged(object sender, EventArgs e)
  602. {
  603. // Empty List<DropItem>'s
  604. foreach (var item in ItemLists)
  605. item.Clear();
  606. LoadDropFile(false);
  607. UpdateDropFile();
  608. textBoxMinLevel.Text = string.Empty;
  609. textBoxMaxLevel.Text = string.Empty;
  610. checkBoxCap.Checked = false;
  611. labelMobLevel.Text =
  612. $"Currently Editing: {((MonsterDropInfo)listBoxMonsters.SelectedItem).Name} - Level: {Envir.MonsterInfoList[listBoxMonsters.SelectedIndices[0]].Level}";
  613. }
  614. public string GetPathOfSelectedItem()
  615. {
  616. var selectedItem = (MonsterDropInfo)listBoxMonsters.SelectedItem;
  617. if (selectedItem == null) return null;
  618. var path = "";
  619. if (string.IsNullOrEmpty(selectedItem.Path))
  620. {
  621. path = Path.Combine(Settings.DropPath, $"{selectedItem.Name}.txt");
  622. }
  623. else
  624. {
  625. path = Path.Combine(Settings.DropPath, selectedItem.Path + ".txt");
  626. }
  627. return path;
  628. }
  629. // Load the monster.txt drop file.
  630. private void LoadDropFile(bool edit)
  631. {
  632. var lines = (edit == false) ? File.ReadAllLines(GetPathOfSelectedItem()) : textBoxDropList.Lines;
  633. for (int i = 0; i < lines.Length; i++)
  634. {
  635. if (lines[i].StartsWith(";Gold"))
  636. {
  637. if (lines[i + 1].StartsWith("1/"))
  638. {
  639. var workingLine = lines[i + 1].Split(' ');
  640. GoldOdds = workingLine[0].Remove(0,2);
  641. Gold = workingLine[2];
  642. break;
  643. }
  644. else
  645. {
  646. GoldOdds = "0";
  647. Gold = "0";
  648. }
  649. }
  650. }
  651. string[] Headers = new string[37]
  652. {
  653. ";Weapons",
  654. ";Armours",
  655. ";Helmets",
  656. ";Necklaces",
  657. ";Bracelets",
  658. ";Rings",
  659. ";Amulets",
  660. ";Belts",
  661. ";Boots",
  662. ";Stones",
  663. ";Torches",
  664. ";Potions",
  665. ";Ores",
  666. ";Meat",
  667. ";Crafting Materials",
  668. ";Scrolls",
  669. ";Gems",
  670. ";Mount",
  671. ";Books",
  672. ";Nothing",
  673. ";Script",
  674. ";Reins",
  675. ";Bells",
  676. ";Saddle",
  677. ";Ribbon",
  678. ";Mask",
  679. ";Food",
  680. ";Hook",
  681. ";Float",
  682. ";Bait",
  683. ";Finder",
  684. ";Reel",
  685. ";Fish",
  686. ";Quest",
  687. ";Awakening",
  688. ";Pets",
  689. ";Transform"
  690. };
  691. for (int i = 0; i < Headers.Length; i++)
  692. {
  693. for (int j = 0; j < lines.Length; j++)
  694. {
  695. if (lines[j].StartsWith(Headers[i]))
  696. {
  697. for (int k = j + 1; k < lines.Length; k++)
  698. {
  699. if (lines[k].StartsWith(";")) break;
  700. var workingLine = lines[k].Split(' ');
  701. if (workingLine.Length < 2) continue;
  702. var quest = "";
  703. if(workingLine.Length > 2 && workingLine[2] == "Q")
  704. {
  705. quest = workingLine[2];
  706. }
  707. DropItem newDropItem = new DropItem { Odds = workingLine[0], Name = workingLine[1], Quest = quest };
  708. switch (i)
  709. {
  710. case 0:
  711. Weapon.Add(newDropItem);
  712. break;
  713. case 1:
  714. Armour.Add(newDropItem);
  715. break;
  716. case 2:
  717. Helmet.Add(newDropItem);
  718. break;
  719. case 3:
  720. Necklace.Add(newDropItem);
  721. break;
  722. case 4:
  723. Bracelet.Add(newDropItem);
  724. break;
  725. case 5:
  726. Ring.Add(newDropItem);
  727. break;
  728. case 6:
  729. Amulet.Add(newDropItem);
  730. break;
  731. case 7:
  732. Belt.Add(newDropItem);
  733. break;
  734. case 8:
  735. Boot.Add(newDropItem);
  736. break;
  737. case 9:
  738. Stone.Add(newDropItem);
  739. break;
  740. case 10:
  741. Torch.Add(newDropItem);
  742. break;
  743. case 11:
  744. Potion.Add(newDropItem);
  745. break;
  746. case 12:
  747. Ore.Add(newDropItem);
  748. break;
  749. case 13:
  750. Meat.Add(newDropItem);
  751. break;
  752. case 14:
  753. CraftingMaterial.Add(newDropItem);
  754. break;
  755. case 15:
  756. Scrolls.Add(newDropItem);
  757. break;
  758. case 16:
  759. Gem.Add(newDropItem);
  760. break;
  761. case 17:
  762. Mount.Add(newDropItem);
  763. break;
  764. case 18:
  765. Book.Add(newDropItem);
  766. break;
  767. case 19:
  768. Nothing.Add(newDropItem);
  769. break;
  770. case 20:
  771. Script.Add(newDropItem);
  772. break;
  773. case 21:
  774. Reins.Add(newDropItem);
  775. break;
  776. case 22:
  777. Bells.Add(newDropItem);
  778. break;
  779. case 23:
  780. Saddle.Add(newDropItem);
  781. break;
  782. case 24:
  783. Ribbon.Add(newDropItem);
  784. break;
  785. case 25:
  786. Mask.Add(newDropItem);
  787. break;
  788. case 26:
  789. Food.Add(newDropItem);
  790. break;
  791. case 27:
  792. Hook.Add(newDropItem);
  793. break;
  794. case 28:
  795. Float.Add(newDropItem);
  796. break;
  797. case 29:
  798. Bait.Add(newDropItem);
  799. break;
  800. case 30:
  801. Finder.Add(newDropItem);
  802. break;
  803. case 31:
  804. Reel.Add(newDropItem);
  805. break;
  806. case 32:
  807. Fish.Add(newDropItem);
  808. break;
  809. case 33:
  810. Quest.Add(newDropItem);
  811. break;
  812. case 34:
  813. Awakening.Add(newDropItem);
  814. break;
  815. case 35:
  816. Pets.Add(newDropItem);
  817. break;
  818. case 36:
  819. Transform.Add(newDropItem);
  820. break;
  821. default:
  822. break;
  823. }
  824. }
  825. }
  826. }
  827. }
  828. }
  829. // Save the monster.txt drop file
  830. private void SaveDropFile()
  831. {
  832. var dropFile = GetPathOfSelectedItem();
  833. if (dropFile == null) return;
  834. using (FileStream fs = new FileStream(dropFile, FileMode.Create))
  835. {
  836. using (StreamWriter sw = new StreamWriter(fs))
  837. {
  838. foreach (string line in textBoxDropList.Lines)
  839. sw.Write(line + sw.NewLine);
  840. }
  841. }
  842. }
  843. //Edit gold amount/odds
  844. private void GoldDropChange(object sender, EventArgs e)
  845. {
  846. if (textBoxGoldOdds.Text != GoldOdds || textBoxGoldAmount.Text != Gold)
  847. buttonUpdateGold.Enabled = true;
  848. else
  849. buttonUpdateGold.Enabled = false;
  850. }
  851. //Switch to Edit mode
  852. private void buttonEdit_Click(object sender, EventArgs e)
  853. {
  854. if (buttonEdit.Text == "Accept")
  855. {
  856. textBoxDropList.ReadOnly = true;
  857. textBoxDropList.BackColor = System.Drawing.Color.Cornsilk;
  858. buttonEdit.Text = "Edit Drop File";
  859. //buttonEdit.Image = Properties.Resources.edit;
  860. // Empty List<DropItem>'s
  861. foreach (var item in ItemLists)
  862. item.Clear();
  863. LoadDropFile(true);
  864. UpdateDropFile();
  865. buttonAdd.Enabled = true;
  866. listBoxMonsters.Enabled = true;
  867. tabControlSeperateItems.Enabled = true;
  868. groupBoxGold.Enabled = true;
  869. groupBoxItem.Enabled = true;
  870. }
  871. else
  872. {
  873. textBoxDropList.ReadOnly = false;
  874. textBoxDropList.BackColor = System.Drawing.Color.Honeydew;
  875. buttonEdit.Text = "Accept";
  876. //buttonEdit.Image = Properties.Resources.accept;
  877. buttonAdd.Enabled = false;
  878. listBoxMonsters.Enabled = false;
  879. tabControlSeperateItems.Enabled = false;
  880. groupBoxGold.Enabled = false;
  881. groupBoxItem.Enabled = false;
  882. }
  883. }
  884. //Cap item range to monsters level
  885. private void checkBoxCap_CheckedChanged(object sender, EventArgs e)
  886. {
  887. if (checkBoxCap.Checked == true)
  888. {
  889. textBoxMinLevel.Text = "0";
  890. textBoxMaxLevel.Text = Envir.MonsterInfoList[listBoxMonsters.SelectedIndices[0]].Level.ToString();
  891. tabControlSeperateItems_SelectedIndexChanged(tabControlSeperateItems, null);
  892. }
  893. else
  894. {
  895. textBoxMinLevel.Text = string.Empty;
  896. textBoxMaxLevel.Text = string.Empty;
  897. tabControlSeperateItems_SelectedIndexChanged(tabControlSeperateItems, null);
  898. }
  899. }
  900. private void buttonUpdateGold_Click(object sender, EventArgs e)
  901. {
  902. Gold = textBoxGoldAmount.Text;
  903. GoldOdds = textBoxGoldOdds.Text;
  904. UpdateDropFile();
  905. buttonUpdateGold.Enabled = false;
  906. tabControlSeperateItems.Focus();
  907. }
  908. private void textBoxSearch_TextChanged(object sender, EventArgs e)
  909. {
  910. int index = listBoxMonsters.FindString(textBoxSearch.Text, -1);
  911. if (index != -1)
  912. {
  913. textBoxSearch.BackColor = System.Drawing.SystemColors.Info;
  914. listBoxMonsters.SetSelected(index, true);
  915. }
  916. else
  917. {
  918. textBoxSearch.BackColor = System.Drawing.Color.FromArgb(0xCC, 0x33, 0x33);
  919. }
  920. }
  921. }
  922. // Item setup
  923. public class DropItem
  924. {
  925. public string Name, Odds, Quest;
  926. }
  927. }