Пример #1
0
        private void LoadScript()
        {
            Log.Info("[ASL] Loading new script: " + _settings.ScriptPath);

            _fs_watcher.Path   = Path.GetDirectoryName(_settings.ScriptPath);
            _fs_watcher.Filter = Path.GetFileName(_settings.ScriptPath);
            _fs_watcher.EnableRaisingEvents = true;

            // New script
            Script = ASLParser.Parse(File.ReadAllText(_settings.ScriptPath));

            Script.RefreshRateChanged += (sender, rate) => _update_timer.Interval = (int)Math.Round(1000 / rate);
            _update_timer.Interval     = (int)Math.Round(1000 / Script.RefreshRate);

            Script.GameVersionChanged += (sender, version) => _settings.SetGameVersion(version);
            _settings.SetGameVersion(null);

            // Give custom ASL settings to GUI, which populates the list and
            // stores the ASLSetting objects which are shared between the GUI
            // and ASLScript
            try
            {
                ASLSettings settings = Script.RunStartup(_state);
                _settings.SetASLSettings(settings);
            }
            catch (Exception ex)
            {
                // Script already created, but startup failed, so clean up again
                Log.Error(ex);
                ScriptCleanup();
            }
        }
Пример #2
0
        private void SetSplitList()
        {
            var aslSettings = new ASLSettings();

            aslSettings.AddBasicSetting("resethardware");
            aslSettings.AddBasicSetting("debug");
            if (_autostart != null)
            {
                aslSettings.AddBasicSetting("start");
            }
            if (_game.Splits.Count > 0)
            {
                aslSettings.AddBasicSetting("split");
            }

            _splits.Clear();
            foreach (Split split in _game.Splits)
            {
                aslSettings.AddSetting(split.Name, split.Active || split.IsCategory(), split.Description, null);
                if (!split.IsCategory())
                {
                    _splits.AddRange(Enumerable.Repeat(split, split.Repeat + 1).ToList());
                }
                else
                {
                    foreach (Split s in split.Splits)
                    {
                        _splits.AddRange(Enumerable.Repeat(s, s.Repeat + 1).ToList());
                        aslSettings.AddSetting(s.Name, s.Active, s.Description, split.Name);
                    }
                }
            }

            _aslSettings = aslSettings;
            _settings.SetASLSettings(aslSettings);
        }