private void LoadLogic(string logicString) { logicString = Migrator.ApplyMigrations(logicString); var logic = LogicFile.FromJson(logicString); try { var itemsById = logic.Logic.ToDictionary(item => item.Id); VerifyLogic(logic, itemsById); _logic = logic; _itemsById = itemsById; _singleItemSelectorForm.SetLogicFile(_logic); _multiItemSelectorForm.SetLogicFile(_logic); nItem.Maximum = _logic.Logic.Count - 1; SetIndex((int)nItem.Value); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Reset() { _logic = new LogicFile { Logic = Enum.GetValues <Item>().Where(item => item >= 0).Select(item => new JsonFormatLogicItem { Id = item.ToString(), RequiredItems = new List <string>(), ConditionalItems = new List <List <string> >(), TimeAvailable = TimeOfDay.None, TimeNeeded = TimeOfDay.None, IsTrick = false, TrickTooltip = string.Empty, }).ToList(), }; _singleItemSelectorForm?.SetLogicFile(_logic); _multiItemSelectorForm?.SetLogicFile(_logic); _itemsById = _logic.Logic.ToDictionary(item => item.Id); }