public static ISelector GetSelector(string description, int id, char param,string comparatorType) { ISelector selector; if (param == Const.CODE_COMPARATOR) selector = new ComparatorSelector(id, param,comparatorType); else if (description.StartsWith(Const.SELECTOR_QUESTTYPE)) selector = new QuestSelector(id, param); else if (description.StartsWith(Const.SELECTOR_GAMELIVING) || description.StartsWith(Const.SELECTOR_GAMENPC)) selector = new NPCSelector(id, param); else if (description.StartsWith(Const.SELECTOR_AREA)) selector = new AreaSelector(id, param); else if (description.StartsWith(Const.SELECTOR_ITEM)) selector = new ItemSelector(id, param); else if (description.StartsWith(Const.SELECTOR_WHIPSER)) selector = new WhisperSelector(id, param); else if (description.StartsWith(Const.SELECTOR_REGION)) selector = new RegionSelector(id, param); else if (description.StartsWith(Const.SELECTOR_ZONE)) selector = new ZoneSelector(id, param); else if (description.StartsWith(Const.SELECTOR_TEXTTYPE)) selector = new EnumerationSelector(id, param, typeof(eTextType).Name); else if (description.StartsWith(Const.SELECTOR_TEXT)) selector = new TextSelector(id, param); else if (description.StartsWith(Const.SELECTOR_LOCATION)) selector = new LocationSelector(id, param); else if (description.StartsWith(Const.SELECTOR_COMPARATOR)) selector = new ComparatorSelector(id, param,comparatorType); else if (description.StartsWith(Const.SELECTOR_EMOTE)) selector = new EnumerationSelector(id, param, typeof(eEmote).Name); else if (description.StartsWith(Const.SELECTOR_CHARACTERCLASS)) selector = new EnumerationSelector(id, param, typeof(DOL.GS.eCharacterClass).Name); else selector = new BaseSelector(id, param); return selector; }
private void questPartTextbox_LinkClicked(object sender, LinkClickedEventArgs e) { string code; char param; int id; try { code = e.LinkText.Substring(e.LinkText.LastIndexOf('#') + 1); id = Convert.ToInt32(code.Substring(0, code.IndexOf(':'))); param = Convert.ToChar(code.Substring(code.IndexOf(':') + 1)); } catch (FormatException ex) { throw new QuestPartConfigurationException("The internal Link representation was invalid. Should be of the form \"#Code:Id:Param\".\n LinkText: \""+e.LinkText+"\"",ex); } int questPartID = -1; ISelector selector = null; switch (param) { case Const.CODE_I: case Const.CODE_K: { DataRow[] rows = DB.TriggerTable.Select(DB.COL_QUESTPARTTRIGGER_ID+"=" + id); if (rows.Length > 0) { DataRow triggerRow = rows[0]; questPartID = (int) triggerRow[DB.COL_QUESTPARTTRIGGER_QUESTPARTID]; int triggerType = (int)triggerRow[DB.COL_QUESTPARTTRIGGER_TYPE]; DataRow triggerTypeRow = DB.GetTriggerTypeRowForID(triggerType); selector = SelectorFactory.GetSelector(Convert.ToString(triggerTypeRow[Const.CodeToColumn(param).ToLower()]), (int)triggerRow[DB.COL_QUESTPARTTRIGGER_ID], param); selector.SelectedValue = triggerRow[Const.CodeToColumn(param)]; } break; } case Const.CODE_N: case Const.CODE_V: case Const.CODE_COMPARATOR: { DataRow[] rows = DB.RequirementTable.Select(DB.COL_QUESTPARTREQUIREMENT_ID+"=" + id); if (rows.Length > 0) { DataRow requirementRow = rows[0]; questPartID = (int)requirementRow[DB.COL_QUESTPARTREQUIREMENT_QUESTPARTID]; int requirementType = (int)requirementRow[DB.COL_QUESTPARTREQUIREMENT_TYPE]; DataRow requirementTypeRow = DB.GetRequirementTypeRowForID(requirementType); if (requirementType ==(int) eRequirementType.Region && param == Const.CODE_N) { selector = new ZoneSelector((int)requirementRow[DB.COL_QUESTPARTREQUIREMENT_ID], param, requirementRow[DB.COL_QUESTPARTREQUIREMENT_V] != DBNull.Value ? Convert.ToInt32(requirementRow[DB.COL_QUESTPARTREQUIREMENT_V]) : -1); } else { string comparatorType = Convert.ToString(requirementTypeRow[DB.COL_QUESTPARTREQUIREMENT_COMPARATOR]); selector = SelectorFactory.GetSelector(Convert.ToString(requirementTypeRow[Const.CodeToColumn(param).ToLower()]), (int)requirementRow[DB.COL_QUESTPARTREQUIREMENT_ID], param, comparatorType); } selector.SelectedValue = requirementRow[Const.CodeToColumn(param)]; } break; } case Const.CODE_P: case Const.CODE_Q: { DataRow[] rows = DB.ActionTable.Select(DB.COL_QUESTPARTACTION_ID+"=" + id); if (rows.Length > 0) { DataRow actionRow = rows[0]; questPartID = (int)actionRow[DB.COL_QUESTPARTACTION_QUESTPARTID]; int actionType = (int)actionRow[DB.COL_QUESTPARTACTION_TYPE]; DataRow actionTypeRow = DB.GetActionTypeRowForID(actionType); selector = SelectorFactory.GetSelector(Convert.ToString(actionTypeRow[Const.CodeToColumn(param).ToLower()]), (int)actionRow[DB.COL_QUESTPARTACTION_ID], param); selector.SelectedValue = actionRow[Const.CodeToColumn(param)]; } break; } } if (selector != null) { selector.OnItemSelected += new OnItemSelectedEventHandler(itemSelector_OnItemSelected); selector.OnItemAdding += new OnItemSelectedEventHandler(selector_OnItemAdding); selector.OnItemDeleting += new OnItemSelectedEventHandler(selector_OnItemDeleting); if (selector is Form) { ((Form)selector).Location = this.PointToClient(Cursor.Position); Point pt = Cursor.Position; pt.Y = ((pt.Y / 13) + 1) * 13; popupHelper.ShowPopup(QuestDesignerMain.DesignerForm, (Form)selector, pt); } else { Log.Error("Encountered Selector that is no subclass of System.Windows.Form, and cannot be displayed therefore: " + selector.GetType().Name); } } // select the clicked questPart if (questPartID >= 0) { int index = DB.questPartBinding.Find(DB.COL_QUESTPART_ID, questPartID); if (index >= 0) { DataRowView questPartRow = (DataRowView)DB.questPartBinding[index]; QuestPartTextInfo info = GetInfoForQuestPartRow(questPartRow.Row); questPartTextbox.Select(info.BeginIndex, 0); } } }
public static ISelector GetSelector(string description, int id, char param, string comparatorType) { ISelector selector; if (param == Const.CODE_COMPARATOR) { selector = new ComparatorSelector(id, param, comparatorType); } else if (description.StartsWith(Const.SELECTOR_QUESTTYPE)) { selector = new QuestSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_GAMELIVING) || description.StartsWith(Const.SELECTOR_GAMENPC)) { selector = new NPCSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_AREA)) { selector = new AreaSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_ITEM)) { selector = new ItemSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_WHIPSER)) { selector = new WhisperSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_REGION)) { selector = new RegionSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_ZONE)) { selector = new ZoneSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_TEXTTYPE)) { selector = new EnumerationSelector(id, param, typeof(eTextType).Name); } else if (description.StartsWith(Const.SELECTOR_TEXT)) { selector = new TextSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_LOCATION)) { selector = new LocationSelector(id, param); } else if (description.StartsWith(Const.SELECTOR_COMPARATOR)) { selector = new ComparatorSelector(id, param, comparatorType); } else if (description.StartsWith(Const.SELECTOR_EMOTE)) { selector = new EnumerationSelector(id, param, typeof(eEmote).Name); } else if (description.StartsWith(Const.SELECTOR_CHARACTERCLASS)) { selector = new EnumerationSelector(id, param, typeof(DOL.GS.eCharacterClass).Name); } else { selector = new BaseSelector(id, param); } return(selector); }