Beispiel #1
0
        private void listBox2_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();

            Font  F     = e.Font;
            Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? Brushes.White : Brushes.Black;

            if (listBox2.Items[e.Index] is LogicEditor.RequiementConditional)
            {
                var test = e.Graphics.MeasureString("", F).Width;
                LogicEditor.RequiementConditional entry = listBox2.Items[e.Index] as LogicEditor.RequiementConditional;
                var drawComma = false;
                foreach (var i in entry.ItemIDs)
                {
                    if (drawComma)
                    {
                        e.Graphics.DrawString(",", F, brush, test, e.Bounds.Y, StringFormat.GenericDefault);
                        test += e.Graphics.MeasureString(",", F).Width;
                    }


                    if (i.ItemUseable(Instance))
                    {
                        F = new Font(F.FontFamily, F.Size, FontStyle.Bold);
                    }
                    var Printname = i.DictionaryName;
                    if (i.ItemName != null && !string.IsNullOrWhiteSpace(i.ItemName))
                    {
                        Printname = i.ItemName;
                    }
                    e.Graphics.DrawString(Printname, F, brush, test, e.Bounds.Y, StringFormat.GenericDefault);
                    test += e.Graphics.MeasureString(Printname, F).Width - e.Graphics.MeasureString(" ", F).Width;
                    F     = new Font(F.FontFamily, F.Size, FontStyle.Regular);

                    drawComma = true;
                }
            }
            else
            {
                e.Graphics.DrawString("Error", e.Font, brush, e.Bounds, StringFormat.GenericDefault);
            }
            e.DrawFocusRectangle();

            var Len = e.Graphics.MeasureString(listBox2.Items[e.Index].ToString(), F).Width;

            if (Len > listBox2.Width && (int)Len + 2 > listBox2.HorizontalExtent)
            {
                listBox2.HorizontalExtent = (int)Len + 2;
            }
        }
 private void Addconditional()
 {
     LogicEditor.EditorInstance.UnsavedChanges = true;
     Tools.SaveState(LogicEditor.EditorInstance);
     if (SelectedItems.Count < 1)
     {
         return;
     }
     if (AddCondSeperately)
     {
         foreach (var i in SelectedItems)
         {
             var entry = new LogicEditor.RequiementConditional {
                 DisplayName = (i.ItemName ?? i.DictionaryName), ItemIDs = new List <LogicObjects.LogicEntry> {
                     i
                 }
             };
             if (LogicEditor.EditorForm.LBConditional.Items.Contains(entry))
             {
                 continue;
             }
             LogicEditor.EditorForm.LBConditional.Items.Add(entry);
         }
     }
     else
     {
         LogicEditor.RequiementConditional entry = new LogicEditor.RequiementConditional {
             ItemIDs = new List <LogicObjects.LogicEntry>()
         };
         string Display  = "";
         string addComma = "";
         foreach (var i in SelectedItems)
         {
             Display  = Display + addComma + (i.ItemName ?? i.DictionaryName);
             addComma = ", ";
             entry.ItemIDs.Add(i);
         }
         entry.DisplayName = Display;
         if (entry.DisplayName == "" || entry.ItemIDs.Count < 1)
         {
             return;
         }
         if (!LogicEditor.EditorForm.LBConditional.Items.Contains(entry))
         {
             LogicEditor.EditorForm.LBConditional.Items.Add(entry);
         }
     }
     LogicEditor.EditorForm.UpdateReqAndCond();
     LogicEditor.EditorForm.WriteCurentItem((int)LogicEditor.EditorForm.nudIndex.Value);
 }
Beispiel #3
0
        public void WriteEntry()
        {
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            listBox2.HorizontalExtent = 0;
            this.Text = $"Requirements for {entry.LocationName ?? entry.DictionaryName}";
            foreach (var i in entry.Required ?? new int[0])
            {
                var ReqEntry = Instance.Logic[i];
                ReqEntry.DisplayName = ReqEntry.DisplayName ?? ReqEntry.DictionaryName;
                listBox1.Items.Add(ReqEntry);
            }

            if (entry.Conditionals != null && entry.Conditionals.Count() > 10000)
            {
                listBox2.Items.Add("To many conditionals to display");
            }
            else
            {
                foreach (var j in entry.Conditionals ?? new int[0][])
                {
                    var CondEntry = new LogicEditor.RequiementConditional {
                        ItemIDs = new List <LogicObjects.LogicEntry>()
                    };
                    foreach (var i in j ?? new int[0])
                    {
                        var ReqEntry = Instance.Logic[i];
                        CondEntry.DisplayName = ReqEntry.DisplayName ?? ReqEntry.DictionaryName;
                        CondEntry.ItemIDs.Add(ReqEntry);
                    }
                    listBox2.Items.Add(CondEntry);
                }
            }

            ND1.Checked = (((entry.AvailableOn >> 0) & 1) == 1);
            ND2.Checked = (((entry.AvailableOn >> 2) & 1) == 1);
            ND3.Checked = (((entry.AvailableOn >> 4) & 1) == 1);
            NN1.Checked = (((entry.AvailableOn >> 1) & 1) == 1);
            NN2.Checked = (((entry.AvailableOn >> 3) & 1) == 1);
            NN3.Checked = (((entry.AvailableOn >> 5) & 1) == 1);
        }