Example #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();
            }
        }
 public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
 {
     if (Settings.ScriptPath != OldScriptPath)
     {
         Script        = ASLParser.Parse(File.ReadAllText(Settings.ScriptPath));
         OldScriptPath = Settings.ScriptPath;
     }
     Script.Update(state);
 }