Esempio n. 1
0
 private static void ExitEvalMode()
 {
     Unpatch(ref ReadPatch);
     Unpatch(ref EvalPatch);
     Unpatch(ref ShowLinePatch);
     SetConsoleInputPlaceholder("Enter command...", Color.grey);
     GameConsoleWindow.Create().Write("Exiting C# Shell.");
 }
Esempio n. 2
0
        internal static void WriteConsole(DateTime time, string level, string line)
        {
            if (string.IsNullOrWhiteSpace(line))
            {
                return;
            }
            if (time < StartTime)
            {
                time = StartTime;
            }
            var fullline = string.Format("{0} {1} {2}", FormatTime(time - StartTime), level, line);

            if (fullline.Length > 300)
            {
                // Trim long message from console to avoid 65000 vertices error, but write the full log.
                OverrideAppendToLogFile_AddToQueue(fullline, null);
                line = line.Split(new char[] { '\r', '\n' }, 2)[0].Trim();
                if (line.Length > 250)
                {
                    line = line.Substring(0, 250);
                }
                if (level.StartsWith("<color="))
                {
                    line += "</color>";
                }
                WriteConsole(time, level, EscLine(line) + $"... ({fullline.Length} chars)<b></b>");
                return;
            }

            /*
             * var pos = line.IndexOf( ' ' );
             * if ( pos > 0 ) { // Skip duplicates
             * var timeless = line.Substring( pos );
             * if ( timeless.Equals( LastLine ) ) {
             *    OverrideAppendToLogFile_AddToQueue( line, null );
             *    return;
             * }
             * LastLine = timeless;
             * }
             */
            if (Config.Log_Game || Config.Log_Modnix)
            {
                lock (ConsoleBuffer) ConsoleBuffer.Add(fullline);
            }
            else // No log = no buffer patch
            {
                GameConsoleWindow.Create().WriteLine(fullline);
            }
        }
Esempio n. 3
0
 private static void BufferToConsole()
 {
     try {
         string[] lines;
         lock ( ConsoleBuffer ) {
             if (ConsoleBuffer.Count == 0)
             {
                 return;
             }
             lines = ConsoleBuffer.ToArray();
             ConsoleBuffer.Clear();
         }
         var console = GameConsoleWindow.Create();
         foreach (var line in lines)
         {
             console.WriteLine(EscLine(line));
         }
     } catch (Exception ex) { Error(ex); }
 }
Esempio n. 4
0
 private static void WriteError(string line) => GameConsoleWindow.Create().WriteLine($"<color=red>{line}</color>");
Esempio n. 5
0
 private static void SetConsoleInputPlaceholder(string hint, Color color)
 {
     try {
         var input = typeof(GameConsoleWindow).GetField("_inputField", NonPublic | Instance)?.GetValue(GameConsoleWindow.Create()) as InputField;
         var text  = input.placeholder.GetComponent <Text>();
         text.text  = hint;
         text.color = color;
     } catch (NullReferenceException) { }
 }