private void addQuestToListView(LBA2Quest quest) { ListViewItem lvi = new ListViewItem(); lvi.Text = quest.memoryOffset.ToString("X2"); lvi.SubItems.Add(quest.name); lvi.Tag = quest; lvQuest.Items.Add(lvi); }
private LBA2Quest[] getQuests(XmlNodeList nodes) { LBA2Quest[] quests = new LBA2Quest[nodes.Count]; int i; for (i = 0; i < nodes.Count; i++) { quests[i] = getQuest(nodes[i]); } return(quests); }
private LBA2Quest getQuest(XmlNode xn) { LBA2Quest quest = new LBA2Quest(); quest.name = xn.SelectSingleNode("name").InnerText.Trim(); string s = xn.SelectSingleNode("memoryOffset").InnerText.Trim(); quest.memoryOffset = uint.Parse(s, System.Globalization.NumberStyles.HexNumber); quest.size = ushort.Parse(xn.SelectSingleNode("size").InnerText.Trim()); quest.subquests = getSubquests(xn.ChildNodes.Item(xn.ChildNodes.Count - 1).ChildNodes); return(quest); }
//Add new subquest to the subquest array of the quest where //OffsetValue.offset = quest.offset private LBA2Quest.Subquest[] addNewSubitem(LBA2Quest q, OffsetValue ov) { //No previous items if (null == q.subquests) { q.subquests = new LBA2Quest.Subquest[1]; q.subquests[0] = new LBA2Quest.Subquest("New", ov.value); return(q.subquests); } else { LBA2Quest.Subquest[] additional = new LBA2Quest.Subquest[q.subquests.Count() + 1]; int copied = 0; int i = 0; for (copied = 0; copied < additional.Count(); copied++) { //Insert new in correct place and copy rest if ( null == ov || //Already done it ( q.subquests.Count() != i && //Not already copied everything (must be new) ov.value > q.subquests[i].value ) ) { additional[copied] = q.subquests[i]; i++; } else { LBA2Quest.Subquest[] sq = new LBA2Quest.Subquest[1]; sq[0] = new LBA2Quest.Subquest("New", ov.value); GetSubItem gsi = new GetSubItem(new LBA2Quest(q.name, q.memoryOffset, q.size, sq)); gsi.ShowDialog(); if (null == gsi.q) { return(null); //If we cancel the form ignore } q.name = gsi.q.name; additional[copied] = gsi.q.subquests[0]; gsi.Dispose(); ov = null; } } return(additional); } }
public GetSubItem(LBA2Quest q) { InitializeComponent(); if (null == q) { MessageBox.Show("No Quest set"); return; } txtQuestName.Text = q.name; txtOffset.Text = q.memoryOffset.ToString("X2"); txtSubquestName.Text = q.subquests[0].name; txtValue.Text = q.subquests[0].value.ToString(); lblAreacodeVal.Text = new Mem().readVal(AREACODE, 2).ToString("X2"); this.q = q; }
private void btnAdd_Click(object sender, EventArgs e) { int questIndex = lvQuest.SelectedItems[0].Index; if (0 == questIndex) { return; } LBA2Quest q = quests.quests[questIndex]; OffsetValue ov = new OffsetValue(q.memoryOffset, ushort.Parse(txtValue.Text)); quests.quests[questIndex].subquests = addNewSubitem(quests.quests[questIndex], ov); load(false); }
private LBA2Quests padQuests(LBA2Quests input) { uint count = ((input.quests[input.quests.Count() - 1].memoryOffset - input.quests[0].memoryOffset) + 1) / 2; LBA2Quest[] output = new LBA2Quest[count + 1]; //for (int i = 0, j = 0; i < count; i++) for (int i = 0, copied = 0; i < output.Count(); i++) { //Always copy first item (No previous item to compare against if (0 != i && ((input.quests[copied].memoryOffset - 2) > output[i - 1].memoryOffset)) { output[i] = new LBA2Quest("Unknown", output[i - 1].memoryOffset + 2, 1, null);//pad item; } else { output[i] = input.quests[copied++];//Copy item and increment source index } } input.quests = output; return(input); }
private void btnCancel_Click(object sender, EventArgs e) { q = null; this.Close(); }