Esempio n. 1
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;
 }
Esempio n. 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);
        }