private void itemChoiceFeatureToolStripMenuItem_Click(object sender, EventArgs e) { ItemChoiceFeature f = new ItemChoiceFeature(); f = new FeatureForms.ItemChoiceFeatureForm(f).edit(HistoryManager); list.Add(f); fill(); }
public static void AddControl(List <System.Windows.Forms.Control> control, int level, ItemChoiceFeature f) { if (!icfboxes.ContainsKey(f)) { icfboxes.Add(f, new List <System.Windows.Forms.ListBox>(f.Amount)); } if (!icflabels.ContainsKey(f)) { icflabels.Add(f, new List <System.Windows.Forms.Label>(f.Amount)); } List <System.Windows.Forms.ListBox> choiceboxes = icfboxes[f]; List <System.Windows.Forms.Label> choicelabels = icflabels[f]; int offset = Program.Context.Player.GetChoiceOffset(f, f.UniqueID, f.Amount); if (!icfitems.ContainsKey(f)) { List <Item> it = new List <Item>(); foreach (String s in f.Items) { it.Add(Program.Context.GetItem(s, f.Source)); } icfitems.Add(f, it); } List <Item> items = icfitems[f]; List <String> taken = new List <string>(); for (int c = 0; c < Program.Context.Player.GetChoiceTotal(f.UniqueID); c++) { String counter = ""; if (c > 0) { counter = "_" + c.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 + offset > 0) { counter = "_" + (c + offset).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_DisplayItem); 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(items.FindAll(e => !taken.Exists(t => ConfigManager.SourceInvariantComparer.Equals(t, e.Name + " " + ConfigManager.SourceSeperator + " " + e.Source))).ToArray()); } else { cbox.ForeColor = Config.SelectColor; cbox.Items.Add(Program.Context.GetItem(cho.Value, f.Source)); } cbox.Height = cbox.Items.Count * cbox.ItemHeight + 10; control.Add(cbox); } }
public ItemChoice(PlayerModel model, ItemChoiceFeature feature) : base(model, feature.UniqueID, feature.Amount, feature, (from i in feature.Items select model.Context.GetItem(i, feature.Source)).ToList()) { }