Exemple #1
0
        private void UpdateConditional(int n, int?conditionalIndex = null)
        {
            List <int> selectedItems = null;

            if (conditionalIndex.HasValue)
            {
                selectedItems = ItemList[n].Conditional[conditionalIndex.Value];
            }
            ItemSelectorForm ItemSelect = new ItemSelectorForm(selectedItems);
            DialogResult     R          = ItemSelect.ShowDialog();

            if (R == DialogResult.OK)
            {
                List <int> Returned = ItemSelectorForm.ReturnItems;
                if (Returned.Count == 0)
                {
                    return;
                }
                ;
                if (conditionalIndex.HasValue)
                {
                    ItemList[n].Conditional[conditionalIndex.Value] = Returned;
                }
                else
                {
                    ItemList[n].Conditional.Add(Returned);
                }
                FillConditional(n);
            }
            ;
        }
Exemple #2
0
        private void UpdateDependence(int n)
        {
            ItemSelectorForm ItemSelect = new ItemSelectorForm();
            DialogResult     R          = ItemSelect.ShowDialog();

            if (R == DialogResult.OK)
            {
                List <int> Returned = ItemSelectorForm.ReturnItems;
                if (Returned.Count == 0)
                {
                    return;
                }
                ;
                for (int i = 0; i < Returned.Count; i++)
                {
                    if (!ItemList[n].Dependence.Contains(Returned[i]))
                    {
                        ItemList[n].Dependence.Add(Returned[i]);
                    }
                    ;
                }
                ;
                FillDependence(n);
            }
            ;
        }
Exemple #3
0
        private void bDeleteItem_Click(object sender, EventArgs e)
        {
            string            message;
            string            caption;
            MessageBoxButtons buttons;
            var usedBy = ItemList.Where(il => il.Dependence.Contains(n) || il.Conditional.Any(c => c.Contains(n))).ToList();

            if (usedBy.Any())
            {
                // in use
                caption = "Error";
                message = "This item is in use by:\n" + string.Join("\n", usedBy.Take(5).Select(il => "* " + ITEM_NAMES[ItemList.IndexOf(il)]));
                if (usedBy.Count > 5)
                {
                    message += $"\nand {usedBy.Count-5} other{(usedBy.Count > 6 ? "s" : "")}.";
                }
                buttons = MessageBoxButtons.OK;
            }
            else
            {
                // not in use
                caption = "Warning";
                message = "Are you sure you want to delete this item?";
                buttons = MessageBoxButtons.YesNo;
            }
            var result = MessageBox.Show(message, caption, buttons);

            if (result == DialogResult.Yes)
            {
                ItemList.RemoveAt(n);
                ITEM_NAMES = ITEM_NAMES.Where((_, i) => i != n).ToArray();
                ItemSelectorForm.RemoveItem(n);
                foreach (var itemLogic in ItemList)
                {
                    for (var i = 0; i < itemLogic.Dependence.Count; i++)
                    {
                        if (itemLogic.Dependence[i] > n)
                        {
                            itemLogic.Dependence[i]--;
                        }
                    }
                    foreach (var conditionals in itemLogic.Conditional)
                    {
                        for (var i = 0; i < conditionals.Count; i++)
                        {
                            if (conditionals[i] > n)
                            {
                                conditionals[i]--;
                            }
                        }
                    }
                }
                SetIndex(n);
            }
        }
Exemple #4
0
        private void button_goto_Click(object sender, EventArgs e)
        {
            var itemSelect = new ItemSelectorForm(checkboxes: false);
            var result     = itemSelect.ShowDialog();

            if (result == DialogResult.OK && ItemSelectorForm.ReturnItems.Any())
            {
                var itemIndex = ItemSelectorForm.ReturnItems.First();
                nItem.Value = itemIndex;
            }
        }
Exemple #5
0
 public LogicEditorForm()
 {
     InitializeComponent();
     Reset();
     _defaultItemCount       = _logic.Logic.Count;
     nItem.Minimum           = 0;
     nItem.Maximum           = _logic.Logic.Count - 1;
     nItem.Value             = 0;
     _singleItemSelectorForm = new ItemSelectorForm(_logic, false);
     _multiItemSelectorForm  = new ItemSelectorForm(_logic, true);
 }
Exemple #6
0
 private void bRenameItem_Click(object sender, EventArgs e)
 {
     using (var newItemForm = new NewItemForm())
     {
         var result = newItemForm.ShowDialog();
         if (result == DialogResult.OK)
         {
             ITEM_NAMES[n] = newItemForm.ReturnValue;
             ItemSelectorForm.RenameItem(n, newItemForm.ReturnValue);
             lIName.Text = newItemForm.ReturnValue;
         }
     }
 }
Exemple #7
0
        private void bAddLevel_Click(object sender, EventArgs e)
        {
            var form = new ItemSelectorForm(ItemUtils.AllLocations(), Enumerable.Empty <Item>());

            form.ShowDialog();

            if (form.DialogResult == DialogResult.OK && form.ReturnItems.Count > 0)
            {
                Result.Add(form.ReturnItems);

                tHintPriorities.SuspendLayout();
                AddItems(form.ReturnItems, false);
                tHintPriorities.ResumeLayout();
            }
        }
Exemple #8
0
 private void mNew_Click(object sender, EventArgs e)
 {
     ItemSelectorForm.ResetItems();
     ITEM_NAMES    = DEFAULT_ITEM_NAMES.ToArray();
     nItem.Minimum = 0;
     nItem.Maximum = ITEM_NAMES.Length - 1;
     ItemList      = new List <ItemLogic>();
     for (int i = 0; i < ITEM_NAMES.Length; i++)
     {
         ItemLogic l = new ItemLogic();
         ItemList.Add(l);
     }
     ;
     nItem.Value = 1;
     nItem.Value = 0;
 }
Exemple #9
0
 private void btn_new_item_Click(object sender, EventArgs e)
 {
     using (var newItemForm = new NewItemForm())
     {
         var result = newItemForm.ShowDialog();
         if (result == DialogResult.OK)
         {
             var newList = ITEM_NAMES.ToList();
             newList.Add(newItemForm.ReturnValue);
             ITEM_NAMES    = newList.ToArray();
             nItem.Maximum = ITEM_NAMES.Length - 1;
             ItemList.Add(new ItemLogic());
             nItem.Value = nItem.Maximum;
             ItemSelectorForm.AddItem(newItemForm.ReturnValue);
         }
     }
 }
Exemple #10
0
        private void lConditional_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var index = lConditional.IndexFromPoint(e.Location);

            if (index != ListBox.NoMatches)
            {
                var conditions = ItemList[n].Conditional[index];
                if (conditions.Count == 1)
                {
                    nItem.Value = conditions[0];
                }
                else
                {
                    var itemSelect = new ItemSelectorForm(checkboxes: false, highlightedItems: conditions);
                    var result     = itemSelect.ShowDialog();
                    if (result == DialogResult.OK && ItemSelectorForm.ReturnItems.Any())
                    {
                        var itemIndex = ItemSelectorForm.ReturnItems.First();
                        nItem.Value = itemIndex;
                    }
                }
            }
        }
Exemple #11
0
        private void editButton_Click(object sender, EventArgs e)
        {
            var control = (Control)sender;
            var index   = tHintPriorities.GetRow(control);

            var form = new ItemSelectorForm(ItemUtils.AllLocations(), Result[index]);

            form.ShowDialog();

            if (form.DialogResult == DialogResult.OK)
            {
                if (form.ReturnItems.Count > 0)
                {
                    Result[index] = form.ReturnItems;
                    var label = (Label)tHintPriorities.GetControlFromPosition(3, index);
                    label.Text = string.Join(", ", Result[index].Select(item => item.Location()));
                }
                else
                {
                    DeleteRow(index);
                }
            }
        }
Exemple #12
0
        private void LoadLogic(string logicString)
        {
            logicString = Migrator.ApplyMigrations(logicString);
            ItemList    = new List <ItemLogic>();
            string[] lines = logicString.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
            ItemSelectorForm.ResetItems();
            ITEM_NAMES = DEFAULT_ITEM_NAMES.ToArray();
            int i = 0;

            while (true)
            {
                if (i == lines.Length)
                {
                    break;
                }
                if (lines[i].StartsWith("#"))
                {
                    i++;
                    continue;
                }
                if (lines[i].Contains("-"))
                {
                    var itemName = lines[i].Substring(2);
                    if (ItemList.Count >= ITEM_NAMES.Length)
                    {
                        var newList = ITEM_NAMES.ToList();
                        newList.Add(itemName);
                        ItemSelectorForm.AddItem(itemName);
                        ITEM_NAMES = newList.ToArray();
                    }
                    i++;
                    continue;
                }
                else
                {
                    ItemLogic l = new ItemLogic();
                    l.Dependence = new List <int>();
                    if (lines[i] != "")
                    {
                        foreach (string j in lines[i].Split(','))
                        {
                            l.Dependence.Add(Convert.ToInt32(j));
                        }
                        ;
                    }
                    ;
                    l.Conditional = new List <List <int> >();
                    if (lines[i + 1] != "")
                    {
                        foreach (string j in lines[i + 1].Split(';'))
                        {
                            List <int> c = new List <int>();
                            foreach (string k in j.Split(','))
                            {
                                c.Add(Convert.ToInt32(k));
                            }
                            ;
                            l.Conditional.Add(c);
                        }
                        ;
                    }
                    ;
                    l.Time_Needed    = Convert.ToInt32(lines[i + 2]);
                    l.Time_Available = Convert.ToInt32(lines[i + 3]);
                    var trickInfo = lines[i + 4].Split(new char[] { ';' }, 2);
                    l.IsTrick      = trickInfo.Length > 1;
                    l.TrickTooltip = l.IsTrick ? trickInfo[1] : null;
                    if (string.IsNullOrWhiteSpace(l.TrickTooltip))
                    {
                        l.TrickTooltip = null;
                    }
                    ItemList.Add(l);
                    i += 5;
                };
            }
            ;

            nItem.Maximum = ITEM_NAMES.Length - 1;
            SetIndex((int)nItem.Value);
        }