public void editCompletion(Completion completion) { m_completion = completion; // TODO: Display Completion for edit guiTypeCbo.SelectedItem = m_completion.getCompletionType(); // Ensure fields are properly enabled // Display other values }
public void addCompletion(Completion completion) { if (m_completions == null) { m_completions = new List<Completion>(); } if (CheckBadCompletionDuplicates(completion)) { m_completions.Add(completion); } }
public DlgCompletions() { InitializeComponent(); m_completion = null; m_codeSearch = new Database.CodeDescSearch[2]; m_codeSearch[0] = new CodeDescSearch(guiValueTxt, guiValueDescriptionTxt, guiValueSearchBtn); m_codeSearch[1] = new CodeDescSearch(guiDataTxt, guiDataDescriptionTxt, guiDataSearchBtn); guiTypeCbo.Items.Clear(); CommonTools.Enumeration.AddSortedByName<CompletionType>(guiTypeCbo); guiTypeCbo.SelectedIndex = 0; }
public void removeCompletion(Completion completion) { if (m_completions != null) { m_completions.Remove(completion); } }
/// <summary> /// Parse the XML nodes /// </summary> /// <param name="xmlNode">The <Stage></Stage> nodes</param> public void fromXml(XmlNode xmlNode) { String value; Xml.getAttribute(xmlNode, XmlAttributes.ID, true, out value); setId(value); foreach (XmlNode stageChildNode in xmlNode.ChildNodes) { if (stageChildNode.Name.Equals(XmlTag.DESCRIPTION)) { Xml.getValue(stageChildNode, !getId().Equals("0"), out value); // Optional for stage 0, required for others setDescription(value); } else if (stageChildNode.Name.Equals(XmlTag.COMPLETION)) { Completion completion = new Completion(); completion.fromXml(stageChildNode); addCompletion(completion); } else if (stageChildNode.Name.Equals(XmlTag.REWARD)) { Reward reward = new Reward(); reward.fromXml(stageChildNode); addReward(reward); } else if (stageChildNode.Name.Equals(XmlTag.TALKTREE)) { TalkTree talkTree = new TalkTree(); talkTree.fromXML(stageChildNode); addTalkTree(talkTree); } else { MessageBox.Show("Unexpected node: " + stageChildNode.Name + " in the" + XmlTag.STAGE + " tag"); } } addValidations(ValidationType.Complete); /*if (!valid(ValidationType.Complete, out value)) { throw (new Exception(value + "\n\n" + xmlNode.InnerXml)); }*/ }
//TB to Rackle - is this the best way to do this? public Boolean CheckBadCompletionDuplicates(Completion completion) { switch (completion.getCompletionType()) { case CompletionType.Nearest_Nav: //there can be only one ... Nearest Nav if (completion.contains(m_completions, CompletionType.Nearest_Nav)) { //already contains a Nearest_Nav, don't allow another DataConfiguration.addValidation("You can only have one Nearest_Nav per stage completion."); return false; } break; default: break; } return true; }
/// <summary> /// Validate the entered data and close the dialog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onOk(object sender, EventArgs e) { m_completion = new Completion(); String value = ""; String data = ""; Int32 count = -1; CompletionType completionType = (CompletionType)guiTypeCbo.SelectedItem; m_completion.setCompletionType(completionType); if (guiValueTxt.Enabled) { value = guiValueTxt.Text; } if (guiDataTxt.Enabled) { data = guiDataTxt.Text; } if (guiAmountTxt.Enabled) { if (!Int32.TryParse(guiAmountTxt.Text, out count)) { count = -1; } } switch (completionType) { case CompletionType.Arrive_At: m_completion.setValue(value); break; case CompletionType.Nav_Message: m_completion.setValue(value); m_completion.setCount(count); break; case CompletionType.Proximity_To_Space_Npc: m_completion.setValue(value); break; case CompletionType.Talk_Space_Npc: m_completion.setValue(value); break; case CompletionType.Fight_Mob: m_completion.setValue(value); m_completion.setCount(count); break; case CompletionType.Give_Credits: m_completion.setValue(count.ToString()); break; case CompletionType.Give_Item: m_completion.setValue(value); m_completion.setCount(count); break; case CompletionType.Nearest_Nav: m_completion.setValue(value); break; case CompletionType.Obtain_Items: m_completion.setValue(value); break; /*case CompletionType.Obtain_Items_At_Location: m_completion.setValue(value); m_completion.setData(data); break;*/ case CompletionType.Possess_Item: m_completion.setValue(value); m_completion.setCount(count); break; case CompletionType.Receive_Item: m_completion.setValue(count.ToString()); break; case CompletionType.Current_Sector: m_completion.setValue(value); break; /*case CompletionType.Take_Item_To_Location: m_completion.setValue(value); m_completion.setData(data); break;*/ case CompletionType.Talk_To_Npc: m_completion.setValue(value); break; case CompletionType.Use_Skill_On_Mob_Type: m_completion.setValue(value); m_completion.setData(data); break; case CompletionType.Use_Skill_On_Object: m_completion.setValue(value); m_completion.setData(data); break; } String error; m_completion.addValidations(); if (Database.DataConfiguration.validate(out error)) //&& MissionEditor.Program.m_frmMission.isMissionValid(out error)) { m_madeSelection = true; this.Close(); } else { MessageBox.Show(error); } }
public Boolean getValues(out Completion completion) { completion = m_completion; return m_madeSelection; }