コード例 #1
0
ファイル: Component.cs プロジェクト: mysidia/LiveSplit-Sid
        private void ScriptCleanup()
        {
            if (Script == null)
            {
                return;
            }

            try
            {
                Script.RunShutdown(_state);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            finally
            {
                _settings.SetGameVersion(null);
                _settings.ResetASLSettings();

                // Script should no longer be used, even in case of error
                // (which the ASL shutdown method may contain)
                Script = null;
            }
        }
コード例 #2
0
ファイル: Component.cs プロジェクト: mysidia/LiveSplit-Sid
        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();
            }
        }
コード例 #3
0
 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);
 }
コード例 #4
0
 public void Unload()
 {
     this.aslEngine = null;
     this.aslScript = null;
 }