Beispiel #1
0
        public static void AddControl(List <System.Windows.Forms.Control> control, int level, ToolProficiencyChoiceConditionFeature f)
        {
            if (!tpccfitems.ContainsKey(f))
            {
                tpccfitems.Add(f, Utils.Filter(Program.Context, f.Condition));
            }
            List <Item> items = tpccfitems[f];

            if (!tpccfboxes.ContainsKey(f))
            {
                tpccfboxes.Add(f, new List <System.Windows.Forms.ListBox>(f.Amount));
            }
            if (!tpccflabels.ContainsKey(f))
            {
                tpccflabels.Add(f, new List <System.Windows.Forms.Label>(f.Amount));
            }
            List <System.Windows.Forms.ListBox> choiceboxes  = tpccfboxes[f];
            List <System.Windows.Forms.Label>   choicelabels = tpccflabels[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_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);
            }
        }
Beispiel #2
0
 public ToolProficiencyChoice(PlayerModel model, ToolProficiencyChoiceConditionFeature feature) : base(model, feature.UniqueID, feature.Amount, feature, Utils.Filter(model.Context, feature.Condition))
 {
 }