Form1.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. // At some point add in the option to use either MoveToLocation()
  2. // or MovementLoopAddLocation() for looping or for one time path
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text.RegularExpressions;
  9. using System.Threading;
  10. using System.Windows.Forms;
  11. namespace Movement_Loop_Generator_2._0
  12. {
  13. public partial class Form1 : Form
  14. {
  15. float x;
  16. float y;
  17. float z;
  18. int rowNumber;
  19. List<DataStruct> dataLoc = new List<DataStruct>();
  20. Dictionary<string, string> NPCList = new Dictionary<string, string>();
  21. private OpenFileDialog file_dialog = new OpenFileDialog();
  22. StreamReader streamReader;
  23. public Form1()
  24. {
  25. InitializeComponent();
  26. userToolStripMenuItem.Text = Properties.Settings.Default.Author;
  27. //Thread.CurrentThread.CurrentCulture = new CultureInfo("eu-fr");
  28. }
  29. /*********************************************************************************************************************************
  30. * Drag and Drop handler
  31. *********************************************************************************************************************************/
  32. private void Form1_DragEnter(object sender, DragEventArgs e)
  33. {
  34. if (e.Data.GetDataPresent(DataFormats.FileDrop))
  35. e.Effect = DragDropEffects.All;
  36. else
  37. e.Effect = DragDropEffects.None;
  38. }
  39. private void Form1_DragDrop(object sender, DragEventArgs e)
  40. {
  41. string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, true);
  42. string filename = Path.GetFullPath(FileList[0]);
  43. ResetListView(true);
  44. ResetTextBoxes();
  45. NPCList.Clear();
  46. listBox_NPCs.Items.Clear();
  47. dataLoc.Clear();
  48. richTextBox_OutputView.Clear();
  49. this.textBox_LogFile.Text = filename;
  50. //richTextBox_OutputView.Text = "Clearing listview, textboxes, and location data.\nGetting spawn and author information.\nGetting spawn location data.\n" +
  51. //"Loading list with spawn location data.\n";
  52. if (checkBox_ReversePath.Checked == true)
  53. {
  54. checkBox_ReversePath.Checked = false;
  55. }
  56. ParseNPC();
  57. ListviewLoad();
  58. }
  59. /*********************************************************************************************************************************
  60. * Load DataStruct List
  61. *********************************************************************************************************************************/
  62. private void ParseData()
  63. {
  64. if (listBox_NPCs.SelectedIndex < 0)
  65. {
  66. return;
  67. }
  68. checkBox_ReversePath.Visible = true;
  69. bool found = false;
  70. int npcname_count = 0;
  71. string [] split = NPCList[listBox_NPCs.SelectedItem.ToString()].Split(' ');
  72. string npcname = split[0];
  73. if (split.Length > 1)
  74. {
  75. npcname_count = Convert.ToInt32(split[1]);
  76. }
  77. string line;
  78. string locSpeed = "'loc_speed ";
  79. string locDelay = "'loc_delay ";
  80. string locStart = "'loc_start ";
  81. string locEnd = "'";
  82. string locStop = "'loc_stop'";
  83. int namecount = 0;
  84. int count = 0;
  85. int setSpeed = 0;
  86. int index;
  87. int setDelay = 0;
  88. int delindex;
  89. dataLoc = new List<DataStruct>();
  90. ResetListView(true);
  91. // Parse button throws an exception Unhandled if the logfile text box is empty
  92. streamReader = new StreamReader(this.textBox_LogFile.Text);
  93. try
  94. {
  95. while ((line = streamReader.ReadLine()) != null)
  96. {
  97. if (line.Contains(locSpeed))
  98. {
  99. index = line.IndexOf("Unknown command: 'loc_speed") + 28;
  100. setSpeed = Convert.ToInt32(line.Substring(index, (line.Length - index) - 1));
  101. }
  102. if (line.Contains(locDelay))
  103. {
  104. delindex = line.IndexOf("Unknown command: 'loc_delay") + 28;
  105. setDelay = Convert.ToInt32(line.Substring(delindex, (line.Length - delindex) - 1));
  106. }
  107. // Test to see if I can advanced to the next name and get the loc from the second collect
  108. if (line.Contains(locStart + npcname + locEnd) && npcname_count < 1)
  109. {
  110. found = true;
  111. count++;
  112. }
  113. if (line.Contains(locStart + npcname + locEnd) && npcname_count >= 1)
  114. {
  115. if (npcname_count == namecount)
  116. {
  117. found = true;
  118. count++;
  119. namecount = 0;
  120. }
  121. else
  122. {
  123. found = false;
  124. namecount++;
  125. }
  126. }
  127. if (line.Contains(locStop))
  128. {
  129. if (count >= 1)
  130. {
  131. streamReader.Close();
  132. return;
  133. }
  134. else
  135. {
  136. found = false;
  137. }
  138. }
  139. if (found)
  140. {
  141. if (line.Contains("Your location is"))
  142. {
  143. Match matchPosition = Regex.Match(line, @"Your location is.*Your orientation is", RegexOptions.IgnoreCase);
  144. string[] location = matchPosition.Value.Replace(@"Your location is ", "").Replace(@". Your orientation is", "").Split(',');
  145. if (location.Count() == 3)
  146. {
  147. x = float.Parse(location[0].Trim(), CultureInfo.InvariantCulture);
  148. y = float.Parse(location[1].Trim(), CultureInfo.InvariantCulture);
  149. z = float.Parse(location[2].Trim(), CultureInfo.InvariantCulture);
  150. DataStruct locData;
  151. if (npcname_count >= 1)
  152. {
  153. locData.Name = npcname + "_" + npcname_count.ToString();
  154. }
  155. else
  156. {
  157. locData.Name = npcname;
  158. }
  159. locData.Author = Properties.Settings.Default.Author;
  160. locData.XLoc = x;
  161. locData.YLoc = y;
  162. locData.ZLoc = z;
  163. if (setSpeed > 0)
  164. {
  165. locData.Speed = setSpeed;
  166. setSpeed = 0;
  167. }
  168. else
  169. {
  170. locData.Speed = 2;
  171. }
  172. if (setDelay > 0)
  173. {
  174. locData.Delay = setDelay;
  175. setDelay = 0;
  176. }
  177. else
  178. {
  179. locData.Delay = 0;
  180. }
  181. locData.Function = textBox_Function.Text;
  182. dataLoc.Add(locData);
  183. }
  184. }
  185. }
  186. }
  187. streamReader.Close();
  188. }
  189. catch
  190. {
  191. MessageBox.Show("Cannot read log file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  192. }
  193. }
  194. private void ParseNPC()
  195. {
  196. string line;
  197. string locStart = "'loc_start ";
  198. int index = 0;
  199. int multipleNPC = 0;
  200. streamReader = new StreamReader(this.textBox_LogFile.Text);
  201. while ((line = streamReader.ReadLine()) != null)
  202. {
  203. if (line.Contains(locStart))
  204. {
  205. index = line.IndexOf(locStart) + 11;
  206. string npc_name = line.Substring(index, (line.Length - index) - 1);
  207. if (NPCList.ContainsKey(npc_name))
  208. {
  209. multipleNPC++;
  210. string newNPCName = npc_name + " " + Convert.ToString(multipleNPC);
  211. NPCList.Add(newNPCName, newNPCName);
  212. listBox_NPCs.Items.Add(newNPCName);
  213. }
  214. else
  215. {
  216. NPCList.Add(npc_name, npc_name);
  217. listBox_NPCs.Items.Add(npc_name);
  218. }
  219. }
  220. }
  221. streamReader.Close();
  222. }
  223. /*********************************************************************************************************************************
  224. * List View & Rich TextBox Load
  225. *********************************************************************************************************************************/
  226. private void ListviewLoad()
  227. {
  228. foreach(DataStruct locData in dataLoc)
  229. {
  230. ListViewItem loc = new ListViewItem();
  231. loc.SubItems.Add(locData.XLoc.ToString(CultureInfo.InvariantCulture));
  232. loc.SubItems.Add(locData.YLoc.ToString(CultureInfo.InvariantCulture));
  233. loc.SubItems.Add(locData.ZLoc.ToString(CultureInfo.InvariantCulture));
  234. loc.SubItems.Add(locData.Speed.ToString(CultureInfo.InvariantCulture));
  235. loc.SubItems.Add(locData.Delay.ToString(CultureInfo.InvariantCulture));
  236. loc.SubItems.Add(locData.Function);
  237. listView_Loaded.Items.Add(loc);
  238. }
  239. }
  240. private void RTBLoad()
  241. {
  242. foreach (DataStruct locData in dataLoc)
  243. {
  244. string Output;
  245. string name = locData.Name;
  246. string author = locData.Author;
  247. string x = locData.XLoc.ToString();
  248. string y = locData.YLoc.ToString();
  249. string z = locData.ZLoc.ToString();
  250. string speed = locData.Speed.ToString();
  251. string delay = locData.Delay.ToString();
  252. string function = locData.Function;
  253. if (string.IsNullOrEmpty(function))
  254. {
  255. Output = "MovementLoopAddLocation(NPC, " + x + ", " + y + ", " + z + ", " + speed + ", " + delay + ")" + System.Environment.NewLine;
  256. this.richTextBox_OutputView.Text += Output;
  257. }
  258. else
  259. {
  260. Output = "MovementLoopAddLocation(NPC, " + x + ", " + y + ", " + z + ", " + speed + ", " + delay + ", " + function + ")" + System.Environment.NewLine;
  261. this.richTextBox_OutputView.Text += Output;
  262. }
  263. }
  264. }
  265. /*********************************************************************************************************************************
  266. * ListView Select Loads TextBoxes
  267. *********************************************************************************************************************************/
  268. private void listView_Loaded_SelectedIndexChanged(object sender, EventArgs e)
  269. {
  270. if (listView_Loaded.SelectedIndices.Count == 0 || listView_Loaded.SelectedIndices[0] == -1)
  271. {
  272. ResetListView(false);
  273. return;
  274. }
  275. ListViewItem loc = listView_Loaded.Items[listView_Loaded.SelectedIndices[0]];
  276. textBox_XLOC.Text = loc.SubItems[1].Text;
  277. textBox_YLOC.Text = loc.SubItems[2].Text;
  278. textBox_ZLOC.Text = loc.SubItems[3].Text;
  279. textBox_Speed.Text = loc.SubItems[4].Text;
  280. textBox_Delay.Text = loc.SubItems[5].Text;
  281. textBox_Function.Text = loc.SubItems[6].Text;
  282. rowNumber = listView_Loaded.FocusedItem.Index;
  283. richTextBox_OutputView.Clear();
  284. richTextBox_OutputView.Text = "Data Loaded";
  285. button_InsertAbove.Enabled = true;
  286. button_InsertBelow.Enabled = true;
  287. button_Update.Enabled = true;
  288. button_Remove.Enabled = true;
  289. button_Reset.Enabled = true;
  290. }
  291. /*********************************************************************************************************************************
  292. * Reset ListView & TextBoxes
  293. *********************************************************************************************************************************/
  294. private void ResetListView(bool include_listview)
  295. {
  296. if (include_listview)
  297. listView_Loaded.Items.Clear();
  298. }
  299. private void ResetTextBoxes()
  300. {
  301. textBox_XLOC.Clear();
  302. textBox_YLOC.Clear();
  303. textBox_ZLOC.Clear();
  304. textBox_Speed.Clear();
  305. textBox_Delay.Clear();
  306. textBox_Function.Clear();
  307. }
  308. /*********************************************************************************************************************************
  309. * Buttons
  310. *********************************************************************************************************************************/
  311. private void btn_Browse_Click(object sender, EventArgs e)
  312. {
  313. file_dialog.Title = "Load Log File";
  314. file_dialog.Filter = "Text|*.txt|All|*.*";
  315. if (this.file_dialog.ShowDialog() == DialogResult.OK)
  316. {
  317. this.textBox_LogFile.Text = this.file_dialog.FileName;
  318. ResetListView(true);
  319. ResetTextBoxes();
  320. NPCList.Clear();
  321. listBox_NPCs.Items.Clear();
  322. dataLoc.Clear();
  323. //richTextBox_OutputView.Text = "Clearing listview, textboxes, and location data.\nGetting spawn and author information.\nGetting spawn location data.\n" +
  324. //"Loading list with spawn location data.\n";
  325. rowNumber = 0; // resetting since setting reversepath to false calls this as part of the [] iterator
  326. if (checkBox_ReversePath.Checked == true)
  327. {
  328. checkBox_ReversePath.Checked = false;
  329. }
  330. ParseNPC();
  331. richTextBox_OutputView.Clear();
  332. int total_npcs = NPCList.Count;
  333. richTextBox_OutputView.Text = total_npcs + " NPC's Found and listed on the left\n\nDouble Click an NPC's name to load its waypoints.";
  334. ListviewLoad();
  335. }
  336. }
  337. private void textBox_LogFile_DoubleClick(object sender, EventArgs e)
  338. {
  339. btn_Browse_Click(sender, e);
  340. }
  341. private void button_Update_Click(object sender, EventArgs e)
  342. {
  343. richTextBox_OutputView.Clear();
  344. if (textBox_XLOC.Text == String.Empty || textBox_YLOC.Text == String.Empty || textBox_ZLOC.Text == String.Empty || textBox_Speed.Text == String.Empty)
  345. {
  346. listView_Loaded_SelectedIndexChanged(sender, e);
  347. }
  348. else
  349. {
  350. DataStruct locData = dataLoc[rowNumber];
  351. locData.XLoc = float.Parse(textBox_XLOC.Text);
  352. locData.YLoc = float.Parse(textBox_YLOC.Text);
  353. locData.ZLoc = float.Parse(textBox_ZLOC.Text);
  354. locData.Speed = Convert.ToInt32(textBox_Speed.Text);
  355. locData.Delay = Convert.ToInt32(textBox_Delay.Text);
  356. locData.Function = textBox_Function.Text;
  357. dataLoc.Insert(rowNumber, locData);
  358. dataLoc.RemoveAt(rowNumber + 1);
  359. ResetTextBoxes();
  360. ResetListView(true);
  361. ListviewLoad();
  362. richTextBox_OutputView.Text = "Updated Entry";
  363. }
  364. }
  365. private void button_InsertAbove_Click(object sender, EventArgs e)
  366. {
  367. richTextBox_OutputView.Clear();
  368. if (listView_Loaded.SelectedIndices.Count == 0 || listView_Loaded.SelectedIndices[0] == -1)
  369. {
  370. MessageBox.Show("You must select something from the list first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  371. return;
  372. }
  373. if (textBox_XLOC.Text == String.Empty || textBox_YLOC.Text == String.Empty || textBox_ZLOC.Text == String.Empty)
  374. {
  375. MessageBox.Show("You are missing either X, Y, or Z coordinates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  376. return;
  377. }
  378. if (string.IsNullOrEmpty(textBox_Speed.Text))
  379. {
  380. textBox_Speed.Text = "2";
  381. }
  382. if (string.IsNullOrEmpty(textBox_Delay.Text))
  383. {
  384. textBox_Delay.Text = "0";
  385. }
  386. DataStruct locData = dataLoc[rowNumber];
  387. locData.XLoc = float.Parse(textBox_XLOC.Text);
  388. locData.YLoc = float.Parse(textBox_YLOC.Text);
  389. locData.ZLoc = float.Parse(textBox_ZLOC.Text);
  390. locData.Speed = Convert.ToInt32(textBox_Speed.Text);
  391. locData.Delay = Convert.ToInt32(textBox_Delay.Text);
  392. locData.Function = textBox_Function.Text;
  393. dataLoc.Insert(rowNumber, locData);
  394. ResetTextBoxes();
  395. ResetListView(true);
  396. ListviewLoad();
  397. richTextBox_OutputView.Text = "Inserted New Entry";
  398. }
  399. private void button_InsertBelow_Click(object sender, EventArgs e)
  400. {
  401. richTextBox_OutputView.Clear();
  402. if (listView_Loaded.SelectedIndices.Count == 0 || listView_Loaded.SelectedIndices[0] == -1)
  403. {
  404. MessageBox.Show("You must select something from the list first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  405. return;
  406. }
  407. if (textBox_XLOC.Text == String.Empty || textBox_YLOC.Text == String.Empty || textBox_ZLOC.Text == String.Empty)
  408. {
  409. MessageBox.Show("You are missing either X, Y, or Z coordinates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  410. return;
  411. }
  412. if (string.IsNullOrEmpty(textBox_Speed.Text))
  413. {
  414. textBox_Speed.Text = "2";
  415. }
  416. if (string.IsNullOrEmpty(textBox_Delay.Text))
  417. {
  418. textBox_Delay.Text = "0";
  419. }
  420. DataStruct locData = dataLoc[rowNumber];
  421. locData.XLoc = float.Parse(textBox_XLOC.Text);
  422. locData.YLoc = float.Parse(textBox_YLOC.Text);
  423. locData.ZLoc = float.Parse(textBox_ZLOC.Text);
  424. locData.Speed = Convert.ToInt32(textBox_Speed.Text);
  425. locData.Delay = Convert.ToInt32(textBox_Delay.Text);
  426. locData.Function = textBox_Function.Text;
  427. dataLoc.Insert(rowNumber + 1, locData);
  428. ResetTextBoxes();
  429. ResetListView(true);
  430. ListviewLoad();
  431. richTextBox_OutputView.Text = "Inserted New Entry";
  432. }
  433. private void button_Remove_Click(object sender, EventArgs e)
  434. {
  435. richTextBox_OutputView.Clear();
  436. DataStruct locData = dataLoc[rowNumber];
  437. dataLoc.RemoveAt(rowNumber);
  438. ResetTextBoxes();
  439. ResetListView(true);
  440. ListviewLoad();
  441. richTextBox_OutputView.Text = "Removed Selected Entry";
  442. }
  443. private void checkBox_ReversePath_CheckedChanged(object sender, EventArgs e)
  444. {
  445. // might be a reload so don't crash trying to pull beyond the array!
  446. if (dataLoc.Count() <= rowNumber)
  447. return;
  448. int rowCount = dataLoc.Count;
  449. // Throws an error here if the checkbox has been unchecked and checked a second time
  450. DataStruct locData = dataLoc[rowNumber];
  451. bool firstRun = true;
  452. // Reverse the path
  453. if (checkBox_ReversePath.Checked)
  454. {
  455. rowNumber = rowCount - 1;
  456. while (rowCount > 0)
  457. {
  458. if (firstRun == true)
  459. {
  460. rowCount = (rowCount - 2);
  461. firstRun = false;
  462. }
  463. else
  464. {
  465. rowCount--;
  466. }
  467. locData = dataLoc[rowCount];
  468. float tmpXLoc = locData.XLoc;
  469. float tmpYLoc = locData.YLoc;
  470. float tmpZLoc = locData.ZLoc;
  471. int tmpSpeed = locData.Speed;
  472. int tmpDelay = locData.Delay;
  473. string tmpFunction = locData.Function;
  474. locData.XLoc = tmpXLoc;
  475. locData.YLoc = tmpYLoc;
  476. locData.ZLoc = tmpZLoc;
  477. locData.Speed = tmpSpeed;
  478. locData.Delay = tmpDelay;
  479. locData.Function = tmpFunction;
  480. dataLoc.Add(locData);
  481. }
  482. ResetListView(true);
  483. ResetTextBoxes();
  484. richTextBox_OutputView.Clear();
  485. richTextBox_OutputView.Text = "The waypoints have been reverse, added to the current list of waypoints, and the spawn path will now loop";
  486. ListviewLoad();
  487. }
  488. else
  489. {
  490. // Revert Changes if checkbox is unchecked
  491. int revertrowcount = rowCount / 2;
  492. int count = 0;
  493. while (count < revertrowcount)
  494. {
  495. count++;
  496. dataLoc.RemoveAt(rowNumber);
  497. rowNumber--;
  498. }
  499. ResetListView(true);
  500. ResetTextBoxes();
  501. richTextBox_OutputView.Clear();
  502. ListviewLoad();
  503. }
  504. }
  505. private void button_Save_Click(object sender, EventArgs e)
  506. {
  507. richTextBox_OutputView.Clear();
  508. DateTime dateTime = DateTime.Now;
  509. List<string> checkfunctions = new List<string>();
  510. DataStruct locData = dataLoc[rowNumber];
  511. string spawnName = locData.Name + ".lua";
  512. StreamWriter streamWriter = new StreamWriter(spawnName);
  513. string script = "--[[\n\tScript Name\t\t:\t" + spawnName + "\n\tScript Purpose\t:\tWaypoint Path for " + spawnName + "\n\tScript Author\t:\t" +
  514. locData.Author + "\n\tScript Date\t\t:\t" + dateTime.ToString("MM/dd/yyyy hh:mm:ss tt") + "\n\tScript Notes\t:\tLocations collected from Live\n--]]\n\n" +
  515. "function spawn(NPC)\n\twaypoints(NPC)\nend\n\nfunction hailed(NPC, Spawn)\n\tFaceTarget(NPC, Spawn)\nend\n\nfunction respawn(NPC)\n\tspawn(NPC)\nend\n\n" +
  516. "function waypoints(NPC)";
  517. streamWriter.WriteLine(script);
  518. for (int i = 0; i < dataLoc.Count; i++)
  519. {
  520. //rowNumber = i;
  521. locData = dataLoc[i];
  522. if (!String.IsNullOrEmpty(locData.Function.ToString()))
  523. {
  524. string output = " MovementLoopAddLocation(NPC, " + locData.XLoc.ToString(CultureInfo.InvariantCulture) + ", " + locData.YLoc.ToString(CultureInfo.InvariantCulture) + ", " + locData.ZLoc.ToString(CultureInfo.InvariantCulture) + ", " +
  525. locData.Speed + ", " + locData.Delay + ", " +
  526. "\"" + locData.Function.ToString() + "\")";
  527. streamWriter.WriteLine(output);
  528. }
  529. else
  530. {
  531. string output = " MovementLoopAddLocation(NPC, " + locData.XLoc.ToString(CultureInfo.InvariantCulture) + ", " + locData.YLoc.ToString(CultureInfo.InvariantCulture) + ", " + locData.ZLoc.ToString(CultureInfo.InvariantCulture) + ", " +
  532. locData.Speed + ", " + locData.Delay + ")";
  533. streamWriter.WriteLine(output);
  534. }
  535. }
  536. streamWriter.WriteLine("end\n\n");
  537. for (int i = 0; i < dataLoc.Count; i++)
  538. {
  539. //need to check for duplicates of the movement function
  540. locData = dataLoc[i];
  541. if (!String.IsNullOrEmpty(locData.Function.ToString()))
  542. {
  543. string movementfunctions = "function " + locData.Function.ToString() + "(NPC)\n\t Say(NPC, " + "\"" + "This is the " + locData.Function.ToString() + " function\"" + ")\nend";
  544. streamWriter.WriteLine(movementfunctions + "\n\n");
  545. }
  546. }
  547. streamWriter.Close();
  548. richTextBox_OutputView.Text = "Saved to " + spawnName + "";
  549. }
  550. private void button_Reset_Click(object sender, EventArgs e)
  551. {
  552. richTextBox_OutputView.Clear();
  553. ResetTextBoxes();
  554. DataStruct locData = dataLoc[rowNumber];
  555. richTextBox_OutputView.Text = "Cleared Textboxes";
  556. }
  557. private void button_ParseDetalis_Click(object sender, EventArgs e)
  558. {
  559. ParseData();
  560. ListviewLoad();
  561. }
  562. /*********************************************************************************************************************************
  563. * MENU ITEMS
  564. *********************************************************************************************************************************/
  565. private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
  566. {
  567. Application.Exit();
  568. }
  569. private void collectWaypointsToolStripMenuItem_Click(object sender, EventArgs e)
  570. {
  571. MessageBox.Show("Begin by using this line" + System.Environment.NewLine +
  572. System.Environment.NewLine +
  573. "/loc_start <name of spawn>" + System.Environment.NewLine +
  574. "Example: /loc_start a trained wolf" + System.Environment.NewLine +
  575. System.Environment.NewLine +
  576. "Use /loc at each point the spawn stops/turns to log location" + System.Environment.NewLine +
  577. System.Environment.NewLine +
  578. "Use /loc_speed to change the movement between waypoints" + System.Environment.NewLine +
  579. "Example: /loc_speed 4"+ System.Environment.NewLine +
  580. "to make spawn run from point to point" + System.Environment.NewLine +
  581. System.Environment.NewLine +
  582. "Use /loc_delay to pause at a waypoint. /loc_delay 3" + System.Environment.NewLine +
  583. "Example /loc_delay 3" + System.Environment.NewLine +
  584. "to make spawn pause for 3 seconds" + System.Environment.NewLine +
  585. System.Environment.NewLine +
  586. "End the session by using this line" + System.Environment.NewLine +
  587. "/loc_stop", "Collecting location Waypoints", MessageBoxButtons.OK, MessageBoxIcon.Information);
  588. }
  589. private void editinglogsToolStripMenuItem_Click(object sender, EventArgs e)
  590. {
  591. MessageBox.Show("Choose a line of waypoints in the list to work on" + System.Environment.NewLine +
  592. "Edit the values in the boxes on the bottom" + System.Environment.NewLine +
  593. System.Environment.NewLine +
  594. "Use the Update button to update the line" + System.Environment.NewLine +
  595. System.Environment.NewLine +
  596. "Add a new waypoint to the list by using the Insert Above or Insert Below buttons" + System.Environment.NewLine +
  597. "Add a function here if the spawns does something at a stop/turn" + System.Environment.NewLine +
  598. "Otherwise leave blank"+ System.Environment.NewLine +
  599. "Note: If a function is added it auto creates a new function in the script" + System.Environment.NewLine +
  600. "Once script is saved you can edit the function in an editor" + System.Environment.NewLine +
  601. System.Environment.NewLine +
  602. "Once you are finished click on the Parse button to save or edit", "Editing Locations", MessageBoxButtons.OK, MessageBoxIcon.Information);
  603. }
  604. private void loadingLogsToolStripMenuItem_Click(object sender, EventArgs e)
  605. {
  606. MessageBox.Show("Use the browse button in the generator to locate your log." + System.Environment.NewLine +
  607. "these are located in your EverQuest II->logs folder inside the folder of your live client." + System.Environment.NewLine +
  608. System.Environment.NewLine +
  609. "Double click your spawn from the list on the left" + System.Environment.NewLine +
  610. "You can use the Parse button as well" + System.Environment.NewLine +
  611. "Example a trained wolf" + System.Environment.NewLine +
  612. "Note: Change the default author under file menu" + System.Environment.NewLine +
  613. "File->Settings->Author and edit in the textbox" + System.Environment.NewLine +
  614. "Hit enter to save.", "Loading Logs", MessageBoxButtons.OK, MessageBoxIcon.Information);
  615. }
  616. // This loads the saved settings for Author into the toolStripTextBox
  617. private void authorToolStripMenuItem_MouseEnter(object sender, EventArgs e)
  618. {
  619. toolStripTextBox_Author.Text = Properties.Settings.Default.Author;
  620. }
  621. //Code for toolStripTextBoxAuthor Key Event set in the toolStripTextBoxAuthor Properties
  622. private void toolStripTextBoxAuthor_KeyDown(object sender, KeyEventArgs e)
  623. {
  624. if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
  625. {
  626. Properties.Settings.Default.Author = toolStripTextBox_Author.Text;
  627. Properties.Settings.Default.Save();
  628. userToolStripMenuItem.Text = Properties.Settings.Default.Author;
  629. e.Handled = true;
  630. e.SuppressKeyPress = true;
  631. fileToolStripMenuItem.HideDropDown(); // Hides the menu after enter key is pressed
  632. }
  633. }
  634. private void listBox_NPCs_MouseDoubleClick(object sender, MouseEventArgs e)
  635. {
  636. if (checkBox_ReversePath.Checked == true)
  637. {
  638. checkBox_ReversePath.Checked = false;
  639. }
  640. ParseData();
  641. ListviewLoad();
  642. int total_wapoints = dataLoc.Count;
  643. richTextBox_OutputView.Text = richTextBox_OutputView.Text + "\n\n\n" + total_wapoints + " Waypoints were loaded\n\nClick a waypoint to edit it in the boxes below";
  644. }
  645. /*********************************************************************************************************************************
  646. * Notes
  647. *********************************************************************************************************************************/
  648. }
  649. }