diff --git a/.gitignore b/.gitignore index ffada8b..5f011da 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,5 @@ Tests/obj/ Assets/desktop.ini Assets/Maps/autosave/ Demos/ - console.log console-1.log \ No newline at end of file diff --git a/Source/Game/Console/CommonCommands.cs b/Source/Game/Console/Commands/CommonConsoleCommands.cs similarity index 95% rename from Source/Game/Console/CommonCommands.cs rename to Source/Game/Console/Commands/CommonConsoleCommands.cs index ca666d1..a843d6a 100644 --- a/Source/Game/Console/CommonCommands.cs +++ b/Source/Game/Console/Commands/CommonConsoleCommands.cs @@ -3,7 +3,7 @@ namespace Game; // Holds common miscellaneous Console variables and commands -public static class CommonCommands +public static class CommonConsoleCommands { [ConsoleVariable("developer")] public static string Developer diff --git a/Source/Game/Console/EngineSubsystem.cs b/Source/Game/Console/Commands/EngineConsoleCommands.cs similarity index 77% rename from Source/Game/Console/EngineSubsystem.cs rename to Source/Game/Console/Commands/EngineConsoleCommands.cs index 7daf3f0..88c0e54 100644 --- a/Source/Game/Console/EngineSubsystem.cs +++ b/Source/Game/Console/Commands/EngineConsoleCommands.cs @@ -7,7 +7,6 @@ using FidelityFX; #if COMPILE_WITH_DLSS using NVIDIA; #endif -using FlaxEditor.Content.Settings; using FlaxEngine; using FlaxEngine.Networking; @@ -22,8 +21,13 @@ public enum UpscalingMode } // Holds Console variables and commands to control engine behaviour -public static class EngineSubsystem +public static class EngineConsoleCommands { + [ConsoleSubsystemInitializer] + public static void Initialize() + { + } + #if COMPILE_WITH_FSR1 private static FSR _fsrPlugin; public static FSR FsrPlugin @@ -568,177 +572,6 @@ public static class EngineSubsystem } } - [ConsoleCommand("playdemo")] - public static void PlayDemoCommand(string[] text) - { - string demoName; - if (text.Length < 1) - demoName = "638201307621505588_v2";//return; - else - demoName = text[0]; - - if (!demoName.EndsWith(".gdem")) - demoName += ".gdem"; - - string demoPath = Path.Combine(AssetManager.DemoPath, demoName); - NetworkManager.PlayDemo(demoPath); -#if false - PlayerActor playerActor = Level.GetActors().First(/*x => - x.GetScript().PlayerId == NetworkManager.LocalPlayerClientId*/); - - string demoPath = Path.Combine(AssetManager.DemoPath, demoName); - if (File.Exists(demoPath)) - playerActor.GetScript().SetInput(demoPath); -#endif - } - - private static Action timeDemoUpdate = null; - private static void TimeDemoOnUpdate() - { - if (timeDemoUpdate != null) - timeDemoUpdate(); - } - - [ConsoleCommand("timedemo")] - public static void TimeDemoCommand(string[] text) - { - string demoName; - if (text.Length < 1) - demoName = "638201307621505588_v2";//return; - else - demoName = text[0]; - - if (!demoName.EndsWith(".gdem")) - demoName += ".gdem"; - - string demoPath = Path.Combine(AssetManager.DemoPath, demoName); - NetworkManager.PlayDemo(demoPath); - - float oldPhysicsFps = Time.PhysicsFPS; - float oldFps = Time.UpdateFPS; - Time.PhysicsFPS = 0f; - Time.UpdateFPS = 0f; - Time.DrawFPS = 0f; - - float accumTime = 0f; - int accumTimes = 0; - timeDemoUpdate = () => - { - if (!NetworkManager.IsDemoPlaying) - { - Console.Print($"timedemo ended, time: {accumTimes} frames, avg: {(accumTime/(float)accumTimes)*1000.0f}"); - timeDemoUpdate = null; - Time.PhysicsFPS = oldPhysicsFps; - Time.UpdateFPS = oldFps; - Time.DrawFPS = oldFps; - return; - } - - if (accumTimes == 0) - Console.Print($"timedemo started"); - - accumTime += Time.DeltaTime; - accumTimes++; - - }; - - Scripting.Update -= TimeDemoOnUpdate; - Scripting.Update += TimeDemoOnUpdate; - } - - [ConsoleCommand("timedemo2")] - public static void TimeDemo2Command(string[] text) - { - string demoName; - if (text.Length < 1) - demoName = "638201307621505588_v2";//return; - else - demoName = text[0]; - - if (!demoName.EndsWith(".gdem")) - demoName += ".gdem"; - - string demoPath = Path.Combine(AssetManager.DemoPath, demoName); - NetworkManager.PlayDemo(demoPath); - - float oldPhysicsFps = Time.PhysicsFPS; - float oldFps = Time.UpdateFPS; - Time.PhysicsFPS = 0f; - Time.UpdateFPS = 5f; - Time.DrawFPS = 5f; - - float accumTime = 0f; - int accumTimes = 0; - timeDemoUpdate = () => - { - if (!NetworkManager.IsDemoPlaying) - { - Console.Print($"timedemo ended, time: {accumTimes} frames, avg: {(accumTime/(float)accumTimes)*1000.0f}"); - timeDemoUpdate = null; - Time.PhysicsFPS = oldPhysicsFps; - Time.UpdateFPS = oldFps; - Time.DrawFPS = oldFps; - return; - } - - if (accumTimes == 0) - Console.Print($"timedemo started"); - - accumTime += Time.DeltaTime; - accumTimes++; - - }; - - Scripting.FixedUpdate -= TimeDemoOnUpdate; - Scripting.FixedUpdate += TimeDemoOnUpdate; - } - - [ConsoleVariable("net_fakelag")] - public static string NetFakeLag - { - get - { - var driver = NetworkManager.server != null ? (NetworkManager.ServerNetworkDriver as NetworkLagDriver) : (NetworkManager.ClientNetworkDriver as NetworkLagDriver); - if (driver == null) - return 0.ToString(); - return ((int)driver.Lag).ToString(); - } - set - { - var driver = NetworkManager.server != null ? (NetworkManager.ServerNetworkDriver as NetworkLagDriver) : (NetworkManager.ClientNetworkDriver as NetworkLagDriver); - if (driver == null) - return; - - int intValue = 0; - if (int.TryParse(value, out intValue)) - { } - else if (float.TryParse(value, out float valueFloat)) - intValue = (int)valueFloat; - intValue = Math.Clamp(intValue, 0, 2000); - - driver.Lag = intValue; - } - } - - [ConsoleCommand("map")] - public static void MapCommand() - { - //NetworkManager.StartServer(true); - NetworkManager.StartServer(); - } - - [ConsoleCommand("connect")] - public static void ConnectCommand() - { - //GameMode.Connect(); - NetworkManager.ConnectServer(); - } - - [ConsoleSubsystemInitializer] - public static void Initialize() - { - } - [ConsoleCommand("quit", "exit")] public static void ExitCommand() { diff --git a/Source/Game/Console/Commands/WorldConsoleCommands.cs b/Source/Game/Console/Commands/WorldConsoleCommands.cs new file mode 100644 index 0000000..f9c93b8 --- /dev/null +++ b/Source/Game/Console/Commands/WorldConsoleCommands.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FlaxEditor.Content.Settings; +using FlaxEngine; +using FlaxEngine.Networking; + +namespace Game; + +public static class WorldConsoleCommands +{ + [ConsoleCommand("playdemo")] + public static void PlayDemoCommand(string[] text) + { + string demoName; + if (text.Length < 1) + demoName = "638201307621505588_v2";//return; + else + demoName = text[0]; + + if (!demoName.EndsWith(".gdem")) + demoName += ".gdem"; + + string demoPath = Path.Combine(AssetManager.DemoPath, demoName); + NetworkManager.PlayDemo(demoPath); +#if false + PlayerActor playerActor = Level.GetActors().First(/*x => + x.GetScript().PlayerId == NetworkManager.LocalPlayerClientId*/); + + string demoPath = Path.Combine(AssetManager.DemoPath, demoName); + if (File.Exists(demoPath)) + playerActor.GetScript().SetInput(demoPath); +#endif + } + + private static Action timeDemoUpdate = null; + private static void TimeDemoOnUpdate() + { + if (timeDemoUpdate != null) + timeDemoUpdate(); + } + + [ConsoleCommand("timedemo")] + public static void TimeDemoCommand(string[] text) + { + string demoName; + if (text.Length < 1) + demoName = "638201307621505588_v2";//return; + else + demoName = text[0]; + + if (!demoName.EndsWith(".gdem")) + demoName += ".gdem"; + + string demoPath = Path.Combine(AssetManager.DemoPath, demoName); + NetworkManager.PlayDemo(demoPath); + + float oldPhysicsFps = Time.PhysicsFPS; + float oldFps = Time.UpdateFPS; + Time.PhysicsFPS = 0f; + Time.UpdateFPS = 0f; + Time.DrawFPS = 0f; + + float accumTime = 0f; + int accumTimes = 0; + timeDemoUpdate = () => + { + if (!NetworkManager.IsDemoPlaying) + { + Console.Print($"timedemo ended, time: {accumTimes} frames, avg: {(accumTime / (float)accumTimes) * 1000.0f}"); + timeDemoUpdate = null; + Time.PhysicsFPS = oldPhysicsFps; + Time.UpdateFPS = oldFps; + Time.DrawFPS = oldFps; + return; + } + + if (accumTimes == 0) + Console.Print($"timedemo started"); + + accumTime += Time.DeltaTime; + accumTimes++; + + }; + + Scripting.Update -= TimeDemoOnUpdate; + Scripting.Update += TimeDemoOnUpdate; + } + + [ConsoleCommand("timedemo2")] + public static void TimeDemo2Command(string[] text) + { + string demoName; + if (text.Length < 1) + demoName = "638201307621505588_v2";//return; + else + demoName = text[0]; + + if (!demoName.EndsWith(".gdem")) + demoName += ".gdem"; + + string demoPath = Path.Combine(AssetManager.DemoPath, demoName); + NetworkManager.PlayDemo(demoPath); + + float oldPhysicsFps = Time.PhysicsFPS; + float oldFps = Time.UpdateFPS; + Time.PhysicsFPS = 0f; + Time.UpdateFPS = 5f; + Time.DrawFPS = 5f; + + float accumTime = 0f; + int accumTimes = 0; + timeDemoUpdate = () => + { + if (!NetworkManager.IsDemoPlaying) + { + Console.Print($"timedemo ended, time: {accumTimes} frames, avg: {(accumTime / (float)accumTimes) * 1000.0f}"); + timeDemoUpdate = null; + Time.PhysicsFPS = oldPhysicsFps; + Time.UpdateFPS = oldFps; + Time.DrawFPS = oldFps; + return; + } + + if (accumTimes == 0) + Console.Print($"timedemo started"); + + accumTime += Time.DeltaTime; + accumTimes++; + + }; + + Scripting.FixedUpdate -= TimeDemoOnUpdate; + Scripting.FixedUpdate += TimeDemoOnUpdate; + } + + [ConsoleVariable("net_fakelag")] + public static string NetFakeLag + { + get + { + var driver = NetworkManager.server != null ? (NetworkManager.ServerNetworkDriver as NetworkLagDriver) : (NetworkManager.ClientNetworkDriver as NetworkLagDriver); + if (driver == null) + return 0.ToString(); + return ((int)driver.Lag).ToString(); + } + set + { + var driver = NetworkManager.server != null ? (NetworkManager.ServerNetworkDriver as NetworkLagDriver) : (NetworkManager.ClientNetworkDriver as NetworkLagDriver); + if (driver == null) + return; + + int intValue = 0; + if (int.TryParse(value, out intValue)) + { } + else if (float.TryParse(value, out float valueFloat)) + intValue = (int)valueFloat; + intValue = Math.Clamp(intValue, 0, 2000); + + driver.Lag = intValue; + } + } + + [ConsoleCommand("map")] + public static void MapCommand() + { + //NetworkManager.StartServer(true); + NetworkManager.StartServer(); + } + + [ConsoleCommand("connect")] + public static void ConnectCommand() + { + //GameMode.Connect(); + NetworkManager.ConnectServer(); + } +} diff --git a/Source/Game/Console/Config.cs b/Source/Game/Console/Config.cs index 45a5ec2..1cf978a 100644 --- a/Source/Game/Console/Config.cs +++ b/Source/Game/Console/Config.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace Game; @@ -6,18 +7,14 @@ public class Config { private Dictionary dictionary = new Dictionary(); - public Config() - { - } - public string this[string key] { get => dictionary[key]; set => dictionary[key] = value; } - // This is for debugging only, remove this later - public string[] Commands; + // TODO: This is for debugging only, remove this later + public string[] Commands = Array.Empty(); public string[] GetLines() { diff --git a/Source/Game/Console/ConfigParser.cs b/Source/Game/Console/ConfigParser.cs index cee2f2f..f6bdb0f 100644 --- a/Source/Game/Console/ConfigParser.cs +++ b/Source/Game/Console/ConfigParser.cs @@ -3,13 +3,8 @@ using System.IO; namespace Game; -public class ConfigParser +public static class ConfigParser { - private ConfigParser() - { - - } - public static Config ParseFile(string path) { Config config = new Config(); @@ -18,8 +13,8 @@ public class ConfigParser Console.Print($"Config file not found in path: {path}"); return config; } - /*using*/ FileStream file = File.OpenRead(path); - /*using*/ StreamReader sr = new StreamReader(file); + using FileStream file = File.OpenRead(path); + using StreamReader sr = new StreamReader(file); List commands = new List(); string line; diff --git a/Source/Game/Console/Console.cs b/Source/Game/Console/Console.cs index 0cec629..f8ea2c3 100644 --- a/Source/Game/Console/Console.cs +++ b/Source/Game/Console/Console.cs @@ -19,20 +19,11 @@ public struct ConsoleLine content = line; } - public static implicit operator string(ConsoleLine line) - { - return line.content; - } + public static implicit operator string(ConsoleLine line) => line.content; - public static explicit operator ConsoleLine(string line) - { - return new ConsoleLine(line); - } + public static explicit operator ConsoleLine(string line) => new ConsoleLine(line); - public override string ToString() - { - return content; - } + public override string ToString() => content; } public static class Console @@ -79,7 +70,6 @@ public static class Console public static ReadOnlySpan Lines => instance.Lines; - public static void Init() { if (instance != null) @@ -119,101 +109,57 @@ public static class Console } #endif - public static string GetBufferHistory(int index) - { - return instance.GetBufferHistory(index); - } + public static string GetBufferHistory(int index) => instance.GetBufferHistory(index); // Echoes text to Console - public static void Print(string text) - { - instance.Print(text); - } - + public static void Print(string text) => instance.Print(text); // Echoes warning text to Console - public static void PrintWarning(string text) - { - instance.PrintWarning(text); - } + public static void PrintWarning(string text) => instance.PrintWarning(text); // Echoes error text to Console [DebuggerHidden] - public static void PrintError(string text) - { - instance.PrintError(text); - } + public static void PrintError(string text) => instance.PrintError(text); // Echoes developer/debug text to Console - public static void PrintDebug(string text) - { - instance.PrintDebug(1, false, text); - } + public static void PrintDebug(string text) => instance.PrintDebug(1, false, text); // Echoes developer/debug text to Console - public static void PrintDebug(int verbosity, string text) - { - instance.PrintDebug(verbosity, false, text); - } + public static void PrintDebug(int verbosity, string text) => instance.PrintDebug(verbosity, false, text); // Echoes developer/debug text to Console - public static void PrintDebug(int verbosity, bool noRepeat, string text) - { - instance.PrintDebug(verbosity, noRepeat, text); - } + public static void PrintDebug(int verbosity, bool noRepeat, string text) => instance.PrintDebug(verbosity, noRepeat, text); // Opens the Console - public static void Open() - { - instance.Open(); - } + public static void Open() => instance.Open(); // Closes the Console - public static void Close() - { - instance.Close(); - } + public static void Close() => instance.Close(); // Clears the content of the Console - public static void Clear() - { - instance.Clear(); - } + public static void Clear() => instance.Clear(); - public static void Execute(string str, bool bufferInput = false, bool noOutput = false) - { - instance.Execute(str, bufferInput, noOutput); - } + public static void Execute(string str, bool bufferInput = false, bool noOutput = false) => instance.Execute(str, bufferInput, noOutput); - public static string GetVariable(string variableName) - { - return instance.GetVariable(variableName); - } + public static string GetVariable(string variableName) => instance.GetVariable(variableName); } public class ConsoleInstance : IDisposable { - private readonly List consoleBufferHistory = new List(); - private readonly Dictionary consoleCommands = new Dictionary(); - - //private static List consoleLines = new List(); - private readonly List consoleLines = new List(); - - private readonly Dictionary consoleVariables = - new Dictionary(); - - private readonly Stopwatch stopwatch = Stopwatch.StartNew(); + private readonly List consoleBufferHistory = new(); + private readonly Dictionary consoleCommands = new(); + private readonly List consoleLines = new(); + private readonly Dictionary consoleVariables = new(); + private readonly Stopwatch closeThrottleStopwatch = Stopwatch.StartNew(); + private StreamWriter logStream; // Echoes developer/debug text to Console private string debugLastLine = ""; - public Action OnClose; + public Action OnClose; public Action OnOpen; public Action OnPrint; - public bool ShowExecutedLines = true; - private StreamWriter logStream; - internal ConsoleInstance() { // Try different filename when running multiple instances @@ -224,7 +170,7 @@ public class ConsoleInstance : IDisposable try { #if FLAX_EDITOR - logStream = new StreamWriter(Path.Combine(@"C:\dev\GoakeFlax", logFilename), false); + logStream = new StreamWriter(Path.Combine(Globals.ProjectFolder, logFilename), false); #else logStream = new StreamWriter(Path.Combine(Directory.GetCurrentDirectory(), logFilename), false); #endif @@ -239,9 +185,7 @@ public class ConsoleInstance : IDisposable } public bool IsOpen { get; internal set; } = true; - - public bool IsSafeToQuit => stopwatch.Elapsed.TotalSeconds > 0.1; - + public bool IsSafeToQuit => closeThrottleStopwatch.Elapsed.TotalSeconds > 0.1; public int DebugVerbosity { get; set; } = 1; public string LinePrefix { get; internal set; } = "]"; @@ -260,7 +204,6 @@ public class ConsoleInstance : IDisposable // Initializes the Console system. internal void InitConsoleSubsystems() { - //AppDomain currentDomain = AppDomain.CurrentDomain; #if USE_NETCORE var assemblies = Utils.GetAssemblies(); #else @@ -279,8 +222,13 @@ public class ConsoleInstance : IDisposable assemblyName.StartsWith("FlaxEngine.") || assemblyName.StartsWith("JetBrains.") || assemblyName.StartsWith("Microsoft.") || - assemblyName.StartsWith("nunit.")) + assemblyName.StartsWith("nunit.") || + assemblyName == "Snippets" || + assemblyName == "Anonymously Hosted DynamicMethods Assembly" || + assemblyName == "netstandard") + { continue; + } foreach (Type type in assembly.GetTypes()) { @@ -296,6 +244,7 @@ public class ConsoleInstance : IDisposable var attributes = Attribute.GetCustomAttributes(method); foreach (Attribute attr in attributes) + { if (attr is ConsoleCommandAttribute cmdAttribute) { //Console.Print("found cmd '" + cmdAttribute.name + "' bound to field '" + method.Name + "'"); @@ -333,6 +282,7 @@ public class ConsoleInstance : IDisposable { cmdInitializer = method; } + } } foreach (var kv in cmdParsed) @@ -352,6 +302,7 @@ public class ConsoleInstance : IDisposable var attributes = Attribute.GetCustomAttributes(field); foreach (Attribute attr in attributes) + { if (attr is ConsoleVariableAttribute cvarAttribute) { //Console.Print("found cvar '" + cvarAttribute.name + "' bound to field '" + field.Name + "'"); @@ -362,6 +313,7 @@ public class ConsoleInstance : IDisposable new ConsoleVariable(cvarAttribute.name, cvarAttribute.flags | ConsoleFlags.NoSerialize, field)); } + } } foreach (PropertyInfo prop in type.GetProperties()) @@ -374,6 +326,7 @@ public class ConsoleInstance : IDisposable var attributes = Attribute.GetCustomAttributes(prop); foreach (Attribute attr in attributes) + { if (attr is ConsoleVariableAttribute cvarAttribute) { //Console.Print("found cvar '" + cvarAttribute.name + "' bound to field '" + field.Name + "'"); @@ -384,6 +337,7 @@ public class ConsoleInstance : IDisposable new ConsoleVariable(cvarAttribute.name, cvarAttribute.flags | ConsoleFlags.NoSerialize, getter, setter)); } + } } if (cmdInitializer != null) @@ -410,16 +364,12 @@ public class ConsoleInstance : IDisposable public void Print(string text) { debugLastLine = text; - PrintLine(text); } // Echoes warning text to Console - public void PrintWarning(string text) - { - PrintLine(text); - } + public void PrintWarning(string text) => PrintLine(text); // Echoes error text to Console //[DebuggerNonUserCode] @@ -492,7 +442,7 @@ public class ConsoleInstance : IDisposable IsOpen = false; OnClose?.Invoke(); - stopwatch.Restart(); + closeThrottleStopwatch.Restart(); } // Clears the content of the Console diff --git a/Source/Game/Console/ConsoleAttributes.cs b/Source/Game/Console/ConsoleAttributes.cs index 79aebde..9c4dac4 100644 --- a/Source/Game/Console/ConsoleAttributes.cs +++ b/Source/Game/Console/ConsoleAttributes.cs @@ -37,22 +37,22 @@ public class ConsoleVariableAttribute : ConsoleBaseAttribute [AttributeUsage(AttributeTargets.All)] public class ConsoleCommandAttribute : ConsoleBaseAttribute { - /// - /// Registers a command to Console system. - /// - /// Name used for calling this command. - public ConsoleCommandAttribute(string name) : base(name) + /// + /// Registers a command to Console system. + /// + /// Name used for calling this command. + public ConsoleCommandAttribute(string name) : base(name) { } - /// - /// Registers a command to Console system. - /// - /// - /// Names used for calling this command. First name is the main name for this command, rest of the - /// names are aliases. - /// - public ConsoleCommandAttribute(params string[] names) : base(names) + /// + /// Registers a command to Console system. + /// + /// + /// Names used for calling this command. First name is the main name for this command, rest of the + /// names are aliases. + /// + public ConsoleCommandAttribute(params string[] names) : base(names) { } } diff --git a/Source/Game/Console/ConsoleContentTextBox.cs b/Source/Game/Console/ConsoleContentTextBox.cs index 9f5e021..ce4dbd9 100644 --- a/Source/Game/Console/ConsoleContentTextBox.cs +++ b/Source/Game/Console/ConsoleContentTextBox.cs @@ -48,9 +48,8 @@ public class ConsoleContentTextBox : Control { } - public ConsoleContentTextBox(FontReference font, ConsoleInputTextBox inputBox, float x, float y, float width, - float height) : base( - x, y, width, height) + public ConsoleContentTextBox(FontReference font, ConsoleInputTextBox inputBox, float x, float y, float width, float height) + : base(x, y, width, height) { this.inputBox = inputBox; Height = height; diff --git a/Source/Game/Console/ConsoleInputTextBox.cs b/Source/Game/Console/ConsoleInputTextBox.cs index 5339666..374a055 100644 --- a/Source/Game/Console/ConsoleInputTextBox.cs +++ b/Source/Game/Console/ConsoleInputTextBox.cs @@ -14,8 +14,8 @@ public class ConsoleInputTextBox : ConsoleTextBoxBase { } - public ConsoleInputTextBox(ConsoleContentTextBox contentBox, float x, float y, float width, float height) : - base(x, y, width, height) + public ConsoleInputTextBox(ConsoleContentTextBox contentBox, float x, float y, float width, float height) + : base(x, y, width, height) { this.contentBox = contentBox; IsMultiline = true; // Not really but behaves better than single-line box @@ -40,6 +40,7 @@ public class ConsoleInputTextBox : ConsoleTextBoxBase { if (inputTextLower.Length > 0) { + // TODO: Remove this shit when scancode input is implemented in the engine if ((mapping.Key == KeyboardKeys.Backslash || mapping.Key == KeyboardKeys.BackQuote) && (inputTextLower.Contains('ö') || inputTextLower.Contains('æ') || diff --git a/Source/Game/Console/ConsoleScript.cs b/Source/Game/Console/ConsoleScript.cs index fb0978d..571da11 100644 --- a/Source/Game/Console/ConsoleScript.cs +++ b/Source/Game/Console/ConsoleScript.cs @@ -147,67 +147,6 @@ public class ConsoleScript : Script consoleInputBox.Location = locationFix; // workaround to UIControl.Control overriding the old position } -#if false - //for (int i = 0; i < 10; i++) - { - string[] teststr = { - /* - "...loading 'scripts/devilpunch.shader'", - "...loading 'scripts/mkoxide.shader'", - "...loading 'scripts/cpm22.shader'", - "...loading 'scripts/cpm27.shader'", - "...loading 'scripts/island.shader'", - "...loading 'scripts/noodtex3.shader'", - "...loading 'scripts/nood_cosdglass.shader'", - "...loading 'scripts/nood_fog_1000.shader'", - "...loading 'scripts/nood_lightbeams.shader'", - "...loading 'scripts/nood_nightsky_nolight.shader'", - "Rescanning shaders", - @"Raw input type 0: [0] \\?\HID#VID_046D&PID_C231#2&229a2ea&0&0000#", - @"Raw input type 0: [18] \\?\HID#VID_046D&PID_C539&MI_01&Col01#8&24523410&0&0000#", - @"Raw input type 0: [19] \\?\HID#VID_28DE&PID_1102&MI_01#8&2fb9bb60&0&0000#", - @"Raw input type 0: [20] \\?\HID#VID_04D9&PID_A131&MI_02&Col01#8&197f95af&0&0000#", - "Raw input: initialized with 5 mice and 0 keyboards", - "WASAPI: overriding channels", - "WASAPI: 2 channel 32bit 48000khz non-exclusive", - "WASAPI: requested periodicity: 128, default: 480, min: 128, max: 480, step: 16", - "WASAPI: Low latency mode enabled", - "WASAPI: buffer size: 280", - "OpenGL renderer initialized", - "video restart took 0.291480 seconds", - "main thread video restart took 0.291798 secs", - "[------ Goake Initialized ------]", - "Initializing menu.dat", - "Couldn't load sound/ambience/water1.wav", - "Couldn't load sound/ambience/wind2.wav", - "Couldn't load sound/misc/menu2.wav", - "Couldn't load sound/misc/menu3.wav", - "]cl_maxfps 120", - "a very very very long long long line in repeat a very very very long long long line in repeat a very very very long long long line in repeat a very very very long long long line in repeat a very very very long long long line in repeat a very very very long long long line in repeat" - */ - "Warning: Unsupported entity field 'light'", - "Warning: Unsupported entity field '_keeplights'", - "Warning: Unsupported entity field 'light'", - "Warning: Unsupported entity field '_keeplights'", - "Warning: Unsupported entity field 'light'", - "Warning: Unsupported entity field '_keeplights'", - "Warning: Unsupported entity field 'light'", - "Warning: Unsupported entity field '_keeplights'", - "maps/aerowalk.bsp: Using lightmap format E5BGR9_UF", - "maps/devbox.bsp: Using lightmap format E5BGR9_UF", - "what", - "Game mode changed to: Free For All", - "what", - "641 additional FS searches", - "fixangle frame: 1427", - "Couldn't load sound/ambience/wind2.wav", - "Couldn't load sound/ambience/water1.wav" - }; - - foreach (var l in teststr) - Console.Print(l); - } -#endif /*FlaxEditor.Editor.Options.OptionsChanged += (FlaxEditor.Options.EditorOptions options) => { @@ -283,7 +222,7 @@ public class ConsoleScript : Script if (Input.InputText.Length > 0) { - // Really need rawinput support with separate ActionConfig.RawKey values, bound to physical keys/scancode instead of virtual ones + // TODO: Remove when engine has support for binding to physical keys/scancode instead of virtual ones var consoleKeys = Input.ActionMappings.Where(x => x.Name == "Console" && x.Key != KeyboardKeys.None); bool backslash = consoleKeys.Any(x => x.Key == KeyboardKeys.Backslash); bool backquote = consoleKeys.Any(x => x.Key == KeyboardKeys.BackQuote); @@ -299,7 +238,9 @@ public class ConsoleScript : Script if (backslash && (Input.InputText.ToLowerInvariant().Contains('\\') || Input.InputText.ToLowerInvariant() .Contains('|'))) // US/International keyboard layouts + { return; + } } if (!consoleInputBox.IsFocused) diff --git a/Source/Game/Hud/PerformanceWidget.cs b/Source/Game/Hud/PerformanceWidget.cs index 75832f3..f441725 100644 --- a/Source/Game/Hud/PerformanceWidget.cs +++ b/Source/Game/Hud/PerformanceWidget.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Text; using FlaxEngine; using FlaxEngine.GUI; @@ -50,8 +51,9 @@ public class PerformanceWidget : Script updateTimeAvg = elapsed / updateTimeCount; updateTimeCount = 0; - label.Text = ""; + StringBuilder text = new StringBuilder(10); +#if false long triangles = 0; long drawCalls = 0; @@ -64,9 +66,12 @@ public class PerformanceWidget : Script } #endif - label.Text += $"{triangles} tris\n {drawCalls} drawcalls\n"; - label.Text += $"{(int)Math.Round(1.0f / updateTimeAvg2)}fps2\n"; - label.Text += $"{(int)Math.Round(1.0f / updateTimeAvg)}fps"; + text.AppendLine($"{triangles} tris\n {drawCalls} drawcalls"); + text.AppendLine($"{(int)Math.Round(1.0f / updateTimeAvg2)}fps2\n"); +#endif + text.Append($"{(int)Math.Round(1.0f / updateTimeAvg)}fps"); + + label.Text = text.ToString(); } #if false diff --git a/Source/Game/Level/Q3MapImporter.cs b/Source/Game/Level/Q3MapImporter.cs index e6cf71b..8fab91d 100644 --- a/Source/Game/Level/Q3MapImporter.cs +++ b/Source/Game/Level/Q3MapImporter.cs @@ -330,10 +330,10 @@ public class Q3MapImporter : Script #endif public override void OnStart() { - sceneLighting = lastSceneLighting = EngineSubsystem.SceneLighting == "1"; - sceneShadows = lastSceneShadows = EngineSubsystem.SceneShadows == "1"; - staticBatching = lastStaticBatching = EngineSubsystem.StaticBatch == "1"; - globalIllumination = EngineSubsystem.GlobalIllumination == "1"; + sceneLighting = lastSceneLighting = EngineConsoleCommands.SceneLighting == "1"; + sceneShadows = lastSceneShadows = EngineConsoleCommands.SceneShadows == "1"; + staticBatching = lastStaticBatching = EngineConsoleCommands.StaticBatch == "1"; + globalIllumination = EngineConsoleCommands.GlobalIllumination == "1"; LoadMap(false); } @@ -350,25 +350,25 @@ public class Q3MapImporter : Script private bool globalIllumination = false; public override void OnUpdate() { - sceneLighting = EngineSubsystem.SceneLighting == "1"; + sceneLighting = EngineConsoleCommands.SceneLighting == "1"; if (lastSceneLighting != sceneLighting) { lastSceneLighting = sceneLighting; dirtyLights = true; } - sceneShadows = EngineSubsystem.SceneShadows == "1"; + sceneShadows = EngineConsoleCommands.SceneShadows == "1"; if (lastSceneShadows != sceneShadows) { lastSceneShadows = sceneShadows; dirtyLights = true; } - var staticBatching = EngineSubsystem.StaticBatch == "1"; + var staticBatching = EngineConsoleCommands.StaticBatch == "1"; if (lastStaticBatching != staticBatching) { lastStaticBatching = staticBatching; StaticBatching = staticBatching; } - globalIllumination = EngineSubsystem.GlobalIllumination == "1"; + globalIllumination = EngineConsoleCommands.GlobalIllumination == "1"; if (lastGlobalIllumination != globalIllumination) { lastGlobalIllumination = globalIllumination;