示例#1
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);
         }
     }
 }
示例#2
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);
        }