private void featureChoiceFeatureToolStripMenuItem_Click(object sender, EventArgs e) { ChoiceFeature f = new ChoiceFeature(); f = new FeatureForms.ChoiceFeatureForm(f).edit(HistoryManager); list.Add(f); fill(); }
public TotemFeatureControl(WizardManager inputWizardManager, ChoiceFeature inputFeature) { wm = inputWizardManager; Visited = false; feature = inputFeature; InitializeComponent(); }
/// <summary> /// gets a list of all hunter features and options for the given subclass/level /// </summary> /// <param name="subclass">chosen subclass</param> /// <param name="level">current level</param> public List <ChoiceFeature> getHunterFeatures(string subclass, int level) { List <ChoiceFeature> featureList = new List <ChoiceFeature>(); ChoiceFeature feature = new ChoiceFeature(); using (SQLiteConnection connection = new SQLiteConnection(ConnectionString)) using (SQLiteCommand command = new SQLiteCommand(connection)) { connection.Open(); command.CommandText = "SELECT hunterFeatures.name, hunterFeatures.description, hunterOptions.name, hunterOptions.description " + "FROM hunterFeatures " + "INNER JOIN subclasses ON subclasses.subclassId = hunterFeatures.subclassId " + "INNER JOIN hunterOptions ON hunterOptions.hunterFeatureId=hunterFeatures.hunterFeatureId " + "WHERE subclasses.name = @Subclass AND hunterFeatures.level BETWEEN 1 and @Level"; command.Parameters.AddWithValue("@Subclass", subclass); command.Parameters.AddWithValue("@Level", level.ToString()); using (SQLiteDataReader dbReader = command.ExecuteReader()) { while (dbReader.Read()) { if (!dbReader.IsDBNull(0)) { if (feature.Name != dbReader.GetString(0)) { if (!string.IsNullOrEmpty(feature.Name)) { featureList.Add(feature); } feature = new ChoiceFeature(dbReader.GetString(0), dbReader.GetString(1)); } feature.addOption(new ChoiceFeatureOption(dbReader.GetString(2), dbReader.GetString(3), false)); } } if (!featureList.Contains(feature) && !string.IsNullOrEmpty(feature.Name)) { featureList.Add(feature); } } } return(featureList); }
public static void AddControl(List <System.Windows.Forms.Control> control, int level, ChoiceFeature f) { if (!cfboxes.ContainsKey(f)) { cfboxes.Add(f, new List <System.Windows.Forms.ListBox>(f.Amount)); } if (!cflabels.ContainsKey(f)) { cflabels.Add(f, new List <System.Windows.Forms.Label>(f.Amount)); } List <System.Windows.Forms.ListBox> choiceboxes = cfboxes[f]; List <System.Windows.Forms.Label> choicelabels = cflabels[f]; List <String> taken = new List <string>(); int offset = Program.Context.Player.GetChoiceOffset(f, f.UniqueID, f.Amount); for (int c = 0; c < Program.Context.Player.GetChoiceTotal(f.UniqueID); c++) { String counter = ""; if (c + offset > 0) { counter = "_" + (c + offset).ToString(); } Choice cho = Program.Context.Player.GetChoice(f.UniqueID + counter); if (cho != null && cho.Value != "") { taken.Add(cho.Value); } } for (int c = 0; c < f.Amount; c++) { String counter = ""; if (c > 0) { counter = "_" + c.ToString(); } if (choiceboxes.Count <= c) { choiceboxes.Add(new System.Windows.Forms.ListBox()); System.Windows.Forms.ListBox choicebox = choiceboxes[c]; choicebox.Dock = System.Windows.Forms.DockStyle.Top; choicebox.FormattingEnabled = true; choicebox.Name = f.UniqueID + counter; choicebox.Size = new System.Drawing.Size(472, 95); choicebox.SelectedIndexChanged += new System.EventHandler(Program.MainWindow.Choice_DisplayFeature); choicebox.DoubleClick += new System.EventHandler(Program.MainWindow.Choice_DoubleClick); choicebox.Leave += new System.EventHandler(Program.MainWindow.listbox_Deselect_on_Leave); choicebox.MouseWheel += Program.MainWindow.listbox_MouseWheel; } if (choicelabels.Count <= c) { choicelabels.Add(new System.Windows.Forms.Label()); System.Windows.Forms.Label choicelabel = choicelabels[c]; choicelabel.AutoSize = true; choicelabel.Dock = System.Windows.Forms.DockStyle.Top; choicelabel.Name = f.UniqueID + counter + "_label"; choicelabel.Padding = new System.Windows.Forms.Padding(0, (c > 0 ? 3 : 8), 0, 3); choicelabel.Text = f.Name + (f.Amount > 1 ? " (" + (c + 1) + "/" + f.Amount + ")" : ""); } control.Add(choicelabels[c]); Choice cho = Program.Context.Player.GetChoice(f.UniqueID + counter); System.Windows.Forms.ListBox cbox = choiceboxes[c]; cbox.Items.Clear(); cbox.ForeColor = System.Drawing.SystemColors.WindowText; if (cho == null || cho.Value == "") { cbox.Items.AddRange(f.Choices.FindAll(e => f.AllowSameChoice || !taken.Exists(t => ConfigManager.SourceInvariantComparer.Equals(t, e.Name + " " + ConfigManager.SourceSeperator + " " + e.Source))).ToArray()); } else { cbox.ForeColor = Config.SelectColor; Feature res = f.Choices.Find(feat => feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source == cho.Value); if (res == null) { res = f.Choices.Find(feat => ConfigManager.SourceInvariantComparer.Equals(feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source, cho.Value)); } if (res != null) { cbox.Items.Add(res); } } cbox.Height = cbox.Items.Count * cbox.ItemHeight + 10; control.Add(cbox); } }
public ChoiceFeatureChoice(PlayerModel model, ChoiceFeature feature) : base(model, feature.UniqueID, feature.Amount, feature, feature.Choices, feature.AllowSameChoice) { }