Example #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;
 }
Example #2
0
 private void mImport_Click(object sender, EventArgs e)
 {
     if (openLogic.ShowDialog() == DialogResult.OK)
     {
         StreamReader LogicFile = new StreamReader(File.Open(openLogic.FileName, FileMode.Open));
         ItemList = new List <ItemLogic>();
         var logicString = LogicFile.ReadToEnd();
         logicString = Migrator.ApplyMigrations(logicString);
         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].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]);
                 ItemList.Add(l);
                 i += 4;
             };
         }
         ;
         LogicFile.Close();
         nItem.Value   = 1;
         nItem.Value   = 0;
         nItem.Maximum = ITEM_NAMES.Length - 1;
     }
     ;
 }
Example #3
0
        private void LoadLogic(string 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].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]);
                    ItemList.Add(l);
                    i += 4;
                };
            }
            ;

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