Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        public static LogicFile ReadRulesetFromResources(LogicMode mode, string userLogicFileName)
        {
            if (mode == LogicMode.Casual)
            {
                return(LogicFile.FromJson(Properties.Resources.REQ_CASUAL));
            }
            else if (mode == LogicMode.Glitched)
            {
                return(LogicFile.FromJson(Properties.Resources.REQ_GLITCH));
            }
            else if (mode == LogicMode.UserLogic)
            {
                using (StreamReader Req = new StreamReader(File.OpenRead(userLogicFileName)))
                {
                    var logic = Req.ReadToEnd();

                    var logicConfiguration = Configuration.FromJson(logic);
                    if (logicConfiguration.GameplaySettings != null)
                    {
                        logic = logicConfiguration.GameplaySettings.Logic;
                    }

                    return(LogicFile.FromJson(logic));
                }
            }

            return(null);
        }
Beispiel #3
0
        public static LogicFile ReadRulesetFromResources(LogicMode mode, string userLogicFileName)
        {
            if (mode == LogicMode.Casual)
            {
                return(LogicFile.FromJson(Properties.Resources.REQ_CASUAL));
            }
            else if (mode == LogicMode.Glitched)
            {
                return(LogicFile.FromJson(Properties.Resources.REQ_GLITCH));
            }
            else if (mode == LogicMode.UserLogic)
            {
                using (StreamReader Req = new StreamReader(File.OpenRead(userLogicFileName)))
                {
                    var logic = Req.ReadToEnd();

                    return(LogicFile.FromJson(logic));

                    // TODO handle logic within settings file
                }
            }

            return(null);
        }