File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66
77## [ Unreleased]
88- Added properties for accessing the current average fps and milliseconds per frame.
9+ - Changed cs_evaluate to also work without the command name being specified.
910- Changed stats_fontsize command to also affect the fps display.
1011- Fixed stats created via the custom attribute not restoring display status between sessions.
1112- Fixed font size issue in console input for commands with a long signature.
Original file line number Diff line number Diff line change @@ -693,6 +693,14 @@ internal bool RunCommand(string rawInput)
693693
694694 if ( command == null )
695695 {
696+ // No command found, try to evaluate as C# expression
697+ string expressionResult = TryEvaluateInput ( rawInput ) ;
698+ if ( ! string . IsNullOrEmpty ( expressionResult ) )
699+ {
700+ Log ( expressionResult ) ;
701+ return false ;
702+ }
703+
696704 LogError ( $ "Could not find the specified command: \" { input [ 0 ] } \" .") ;
697705 return false ;
698706 }
@@ -3593,6 +3601,28 @@ private void InitMonoEvaluator()
35933601 }
35943602 }
35953603
3604+ /// <summary>
3605+ /// Attempt to evaluate user input as an evaluation.
3606+ /// </summary>
3607+ /// <param name="rawInput"></param>
3608+ /// <returns></returns>
3609+ private string TryEvaluateInput ( string rawInput )
3610+ {
3611+ if ( _monoEvaluator == null )
3612+ {
3613+ return null ;
3614+ }
3615+
3616+ try
3617+ {
3618+ return _monoEvaluator . Evaluate ( rawInput + ";" ) ? . ToString ( ) ?? null ;
3619+ }
3620+ catch ( Exception )
3621+ {
3622+ return null ;
3623+ }
3624+ }
3625+
35963626 #endregion
35973627
35983628 #region Stat methods
You can’t perform that action at this time.
0 commit comments