cleanup console stuff

This commit is contained in:
2024-04-06 15:16:03 +03:00
parent e7dc19b1a1
commit c17614e393
13 changed files with 270 additions and 370 deletions

1
.gitignore vendored
View File

@@ -29,6 +29,5 @@ Tests/obj/
Assets/desktop.ini Assets/desktop.ini
Assets/Maps/autosave/ Assets/Maps/autosave/
Demos/ Demos/
console.log console.log
console-1.log console-1.log

View File

@@ -3,7 +3,7 @@
namespace Game; namespace Game;
// Holds common miscellaneous Console variables and commands // Holds common miscellaneous Console variables and commands
public static class CommonCommands public static class CommonConsoleCommands
{ {
[ConsoleVariable("developer")] [ConsoleVariable("developer")]
public static string Developer public static string Developer

View File

@@ -7,7 +7,6 @@ using FidelityFX;
#if COMPILE_WITH_DLSS #if COMPILE_WITH_DLSS
using NVIDIA; using NVIDIA;
#endif #endif
using FlaxEditor.Content.Settings;
using FlaxEngine; using FlaxEngine;
using FlaxEngine.Networking; using FlaxEngine.Networking;
@@ -22,8 +21,13 @@ public enum UpscalingMode
} }
// Holds Console variables and commands to control engine behaviour // 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 #if COMPILE_WITH_FSR1
private static FSR _fsrPlugin; private static FSR _fsrPlugin;
public 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<PlayerActor>().First(/*x =>
x.GetScript<PlayerMovement>().PlayerId == NetworkManager.LocalPlayerClientId*/);
string demoPath = Path.Combine(AssetManager.DemoPath, demoName);
if (File.Exists(demoPath))
playerActor.GetScript<PlayerMovement>().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")] [ConsoleCommand("quit", "exit")]
public static void ExitCommand() public static void ExitCommand()
{ {

View File

@@ -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<PlayerActor>().First(/*x =>
x.GetScript<PlayerMovement>().PlayerId == NetworkManager.LocalPlayerClientId*/);
string demoPath = Path.Combine(AssetManager.DemoPath, demoName);
if (File.Exists(demoPath))
playerActor.GetScript<PlayerMovement>().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();
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace Game; namespace Game;
@@ -6,18 +7,14 @@ public class Config
{ {
private Dictionary<string, string> dictionary = new Dictionary<string, string>(); private Dictionary<string, string> dictionary = new Dictionary<string, string>();
public Config()
{
}
public string this[string key] public string this[string key]
{ {
get => dictionary[key]; get => dictionary[key];
set => dictionary[key] = value; set => dictionary[key] = value;
} }
// This is for debugging only, remove this later // TODO: This is for debugging only, remove this later
public string[] Commands; public string[] Commands = Array.Empty<string>();
public string[] GetLines() public string[] GetLines()
{ {

View File

@@ -3,13 +3,8 @@ using System.IO;
namespace Game; namespace Game;
public class ConfigParser public static class ConfigParser
{ {
private ConfigParser()
{
}
public static Config ParseFile(string path) public static Config ParseFile(string path)
{ {
Config config = new Config(); Config config = new Config();
@@ -18,8 +13,8 @@ public class ConfigParser
Console.Print($"Config file not found in path: {path}"); Console.Print($"Config file not found in path: {path}");
return config; return config;
} }
/*using*/ FileStream file = File.OpenRead(path); using FileStream file = File.OpenRead(path);
/*using*/ StreamReader sr = new StreamReader(file); using StreamReader sr = new StreamReader(file);
List<string> commands = new List<string>(); List<string> commands = new List<string>();
string line; string line;

View File

@@ -19,20 +19,11 @@ public struct ConsoleLine
content = line; content = line;
} }
public static implicit operator string(ConsoleLine line) public static implicit operator string(ConsoleLine line) => line.content;
{
return line.content;
}
public static explicit operator ConsoleLine(string line) public static explicit operator ConsoleLine(string line) => new ConsoleLine(line);
{
return new ConsoleLine(line);
}
public override string ToString() public override string ToString() => content;
{
return content;
}
} }
public static class Console public static class Console
@@ -79,7 +70,6 @@ public static class Console
public static ReadOnlySpan<ConsoleLine> Lines => instance.Lines; public static ReadOnlySpan<ConsoleLine> Lines => instance.Lines;
public static void Init() public static void Init()
{ {
if (instance != null) if (instance != null)
@@ -119,101 +109,57 @@ public static class Console
} }
#endif #endif
public static string GetBufferHistory(int index) public static string GetBufferHistory(int index) => instance.GetBufferHistory(index);
{
return instance.GetBufferHistory(index);
}
// Echoes text to Console // Echoes text to Console
public static void Print(string text) public static void Print(string text) => instance.Print(text);
{
instance.Print(text);
}
// Echoes warning text to Console // Echoes warning text to Console
public static void PrintWarning(string text) public static void PrintWarning(string text) => instance.PrintWarning(text);
{
instance.PrintWarning(text);
}
// Echoes error text to Console // Echoes error text to Console
[DebuggerHidden] [DebuggerHidden]
public static void PrintError(string text) public static void PrintError(string text) => instance.PrintError(text);
{
instance.PrintError(text);
}
// Echoes developer/debug text to Console // Echoes developer/debug text to Console
public static void PrintDebug(string text) public static void PrintDebug(string text) => instance.PrintDebug(1, false, text);
{
instance.PrintDebug(1, false, text);
}
// Echoes developer/debug text to Console // Echoes developer/debug text to Console
public static void PrintDebug(int verbosity, string text) public static void PrintDebug(int verbosity, string text) => instance.PrintDebug(verbosity, false, text);
{
instance.PrintDebug(verbosity, false, text);
}
// Echoes developer/debug text to Console // Echoes developer/debug text to Console
public static void PrintDebug(int verbosity, bool noRepeat, string text) public static void PrintDebug(int verbosity, bool noRepeat, string text) => instance.PrintDebug(verbosity, noRepeat, text);
{
instance.PrintDebug(verbosity, noRepeat, text);
}
// Opens the Console // Opens the Console
public static void Open() public static void Open() => instance.Open();
{
instance.Open();
}
// Closes the Console // Closes the Console
public static void Close() public static void Close() => instance.Close();
{
instance.Close();
}
// Clears the content of the Console // Clears the content of the Console
public static void Clear() public static void Clear() => instance.Clear();
{
instance.Clear();
}
public static void Execute(string str, bool bufferInput = false, bool noOutput = false) public static void Execute(string str, bool bufferInput = false, bool noOutput = false) => instance.Execute(str, bufferInput, noOutput);
{
instance.Execute(str, bufferInput, noOutput);
}
public static string GetVariable(string variableName) public static string GetVariable(string variableName) => instance.GetVariable(variableName);
{
return instance.GetVariable(variableName);
}
} }
public class ConsoleInstance : IDisposable public class ConsoleInstance : IDisposable
{ {
private readonly List<string> consoleBufferHistory = new List<string>(); private readonly List<string> consoleBufferHistory = new();
private readonly Dictionary<string, ConsoleCommand> consoleCommands = new Dictionary<string, ConsoleCommand>(); private readonly Dictionary<string, ConsoleCommand> consoleCommands = new();
private readonly List<ConsoleLine> consoleLines = new();
//private static List<string> consoleLines = new List<string>(); private readonly Dictionary<string, ConsoleVariable> consoleVariables = new();
private readonly List<ConsoleLine> consoleLines = new List<ConsoleLine>(); private readonly Stopwatch closeThrottleStopwatch = Stopwatch.StartNew();
private StreamWriter logStream;
private readonly Dictionary<string, ConsoleVariable> consoleVariables =
new Dictionary<string, ConsoleVariable>();
private readonly Stopwatch stopwatch = Stopwatch.StartNew();
// Echoes developer/debug text to Console // Echoes developer/debug text to Console
private string debugLastLine = ""; private string debugLastLine = "";
public Action OnClose;
public Action OnClose;
public Action OnOpen; public Action OnOpen;
public Action<string> OnPrint; public Action<string> OnPrint;
public bool ShowExecutedLines = true; public bool ShowExecutedLines = true;
private StreamWriter logStream;
internal ConsoleInstance() internal ConsoleInstance()
{ {
// Try different filename when running multiple instances // Try different filename when running multiple instances
@@ -224,7 +170,7 @@ public class ConsoleInstance : IDisposable
try try
{ {
#if FLAX_EDITOR #if FLAX_EDITOR
logStream = new StreamWriter(Path.Combine(@"C:\dev\GoakeFlax", logFilename), false); logStream = new StreamWriter(Path.Combine(Globals.ProjectFolder, logFilename), false);
#else #else
logStream = new StreamWriter(Path.Combine(Directory.GetCurrentDirectory(), logFilename), false); logStream = new StreamWriter(Path.Combine(Directory.GetCurrentDirectory(), logFilename), false);
#endif #endif
@@ -239,9 +185,7 @@ public class ConsoleInstance : IDisposable
} }
public bool IsOpen { get; internal set; } = true; public bool IsOpen { get; internal set; } = true;
public bool IsSafeToQuit => closeThrottleStopwatch.Elapsed.TotalSeconds > 0.1;
public bool IsSafeToQuit => stopwatch.Elapsed.TotalSeconds > 0.1;
public int DebugVerbosity { get; set; } = 1; public int DebugVerbosity { get; set; } = 1;
public string LinePrefix { get; internal set; } = "]"; public string LinePrefix { get; internal set; } = "]";
@@ -260,7 +204,6 @@ public class ConsoleInstance : IDisposable
// Initializes the Console system. // Initializes the Console system.
internal void InitConsoleSubsystems() internal void InitConsoleSubsystems()
{ {
//AppDomain currentDomain = AppDomain.CurrentDomain;
#if USE_NETCORE #if USE_NETCORE
var assemblies = Utils.GetAssemblies(); var assemblies = Utils.GetAssemblies();
#else #else
@@ -279,8 +222,13 @@ public class ConsoleInstance : IDisposable
assemblyName.StartsWith("FlaxEngine.") || assemblyName.StartsWith("FlaxEngine.") ||
assemblyName.StartsWith("JetBrains.") || assemblyName.StartsWith("JetBrains.") ||
assemblyName.StartsWith("Microsoft.") || assemblyName.StartsWith("Microsoft.") ||
assemblyName.StartsWith("nunit.")) assemblyName.StartsWith("nunit.") ||
assemblyName == "Snippets" ||
assemblyName == "Anonymously Hosted DynamicMethods Assembly" ||
assemblyName == "netstandard")
{
continue; continue;
}
foreach (Type type in assembly.GetTypes()) foreach (Type type in assembly.GetTypes())
{ {
@@ -296,6 +244,7 @@ public class ConsoleInstance : IDisposable
var attributes = Attribute.GetCustomAttributes(method); var attributes = Attribute.GetCustomAttributes(method);
foreach (Attribute attr in attributes) foreach (Attribute attr in attributes)
{
if (attr is ConsoleCommandAttribute cmdAttribute) if (attr is ConsoleCommandAttribute cmdAttribute)
{ {
//Console.Print("found cmd '" + cmdAttribute.name + "' bound to field '" + method.Name + "'"); //Console.Print("found cmd '" + cmdAttribute.name + "' bound to field '" + method.Name + "'");
@@ -333,6 +282,7 @@ public class ConsoleInstance : IDisposable
{ {
cmdInitializer = method; cmdInitializer = method;
} }
}
} }
foreach (var kv in cmdParsed) foreach (var kv in cmdParsed)
@@ -352,6 +302,7 @@ public class ConsoleInstance : IDisposable
var attributes = Attribute.GetCustomAttributes(field); var attributes = Attribute.GetCustomAttributes(field);
foreach (Attribute attr in attributes) foreach (Attribute attr in attributes)
{
if (attr is ConsoleVariableAttribute cvarAttribute) if (attr is ConsoleVariableAttribute cvarAttribute)
{ {
//Console.Print("found cvar '" + cvarAttribute.name + "' bound to field '" + field.Name + "'"); //Console.Print("found cvar '" + cvarAttribute.name + "' bound to field '" + field.Name + "'");
@@ -362,6 +313,7 @@ public class ConsoleInstance : IDisposable
new ConsoleVariable(cvarAttribute.name, new ConsoleVariable(cvarAttribute.name,
cvarAttribute.flags | ConsoleFlags.NoSerialize, field)); cvarAttribute.flags | ConsoleFlags.NoSerialize, field));
} }
}
} }
foreach (PropertyInfo prop in type.GetProperties()) foreach (PropertyInfo prop in type.GetProperties())
@@ -374,6 +326,7 @@ public class ConsoleInstance : IDisposable
var attributes = Attribute.GetCustomAttributes(prop); var attributes = Attribute.GetCustomAttributes(prop);
foreach (Attribute attr in attributes) foreach (Attribute attr in attributes)
{
if (attr is ConsoleVariableAttribute cvarAttribute) if (attr is ConsoleVariableAttribute cvarAttribute)
{ {
//Console.Print("found cvar '" + cvarAttribute.name + "' bound to field '" + field.Name + "'"); //Console.Print("found cvar '" + cvarAttribute.name + "' bound to field '" + field.Name + "'");
@@ -384,6 +337,7 @@ public class ConsoleInstance : IDisposable
new ConsoleVariable(cvarAttribute.name, new ConsoleVariable(cvarAttribute.name,
cvarAttribute.flags | ConsoleFlags.NoSerialize, getter, setter)); cvarAttribute.flags | ConsoleFlags.NoSerialize, getter, setter));
} }
}
} }
if (cmdInitializer != null) if (cmdInitializer != null)
@@ -410,16 +364,12 @@ public class ConsoleInstance : IDisposable
public void Print(string text) public void Print(string text)
{ {
debugLastLine = text; debugLastLine = text;
PrintLine(text); PrintLine(text);
} }
// Echoes warning text to Console // Echoes warning text to Console
public void PrintWarning(string text) public void PrintWarning(string text) => PrintLine(text);
{
PrintLine(text);
}
// Echoes error text to Console // Echoes error text to Console
//[DebuggerNonUserCode] //[DebuggerNonUserCode]
@@ -492,7 +442,7 @@ public class ConsoleInstance : IDisposable
IsOpen = false; IsOpen = false;
OnClose?.Invoke(); OnClose?.Invoke();
stopwatch.Restart(); closeThrottleStopwatch.Restart();
} }
// Clears the content of the Console // Clears the content of the Console

View File

@@ -37,22 +37,22 @@ public class ConsoleVariableAttribute : ConsoleBaseAttribute
[AttributeUsage(AttributeTargets.All)] [AttributeUsage(AttributeTargets.All)]
public class ConsoleCommandAttribute : ConsoleBaseAttribute public class ConsoleCommandAttribute : ConsoleBaseAttribute
{ {
/// <summary> /// <summary>
/// Registers a command to Console system. /// Registers a command to Console system.
/// </summary> /// </summary>
/// <param name="name">Name used for calling this command.</param> /// <param name="name">Name used for calling this command.</param>
public ConsoleCommandAttribute(string name) : base(name) public ConsoleCommandAttribute(string name) : base(name)
{ {
} }
/// <summary> /// <summary>
/// Registers a command to Console system. /// Registers a command to Console system.
/// </summary> /// </summary>
/// <param name="names"> /// <param name="names">
/// Names used for calling this command. First name is the main name for this command, rest of the /// Names used for calling this command. First name is the main name for this command, rest of the
/// names are aliases. /// names are aliases.
/// </param> /// </param>
public ConsoleCommandAttribute(params string[] names) : base(names) public ConsoleCommandAttribute(params string[] names) : base(names)
{ {
} }
} }

View File

@@ -48,9 +48,8 @@ public class ConsoleContentTextBox : Control
{ {
} }
public ConsoleContentTextBox(FontReference font, ConsoleInputTextBox inputBox, float x, float y, float width, public ConsoleContentTextBox(FontReference font, ConsoleInputTextBox inputBox, float x, float y, float width, float height)
float height) : base( : base(x, y, width, height)
x, y, width, height)
{ {
this.inputBox = inputBox; this.inputBox = inputBox;
Height = height; Height = height;

View File

@@ -14,8 +14,8 @@ public class ConsoleInputTextBox : ConsoleTextBoxBase
{ {
} }
public ConsoleInputTextBox(ConsoleContentTextBox contentBox, float x, float y, float width, float height) : public ConsoleInputTextBox(ConsoleContentTextBox contentBox, float x, float y, float width, float height)
base(x, y, width, height) : base(x, y, width, height)
{ {
this.contentBox = contentBox; this.contentBox = contentBox;
IsMultiline = true; // Not really but behaves better than single-line box IsMultiline = true; // Not really but behaves better than single-line box
@@ -40,6 +40,7 @@ public class ConsoleInputTextBox : ConsoleTextBoxBase
{ {
if (inputTextLower.Length > 0) 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) && if ((mapping.Key == KeyboardKeys.Backslash || mapping.Key == KeyboardKeys.BackQuote) &&
(inputTextLower.Contains('ö') || (inputTextLower.Contains('ö') ||
inputTextLower.Contains('æ') || inputTextLower.Contains('æ') ||

View File

@@ -147,67 +147,6 @@ public class ConsoleScript : Script
consoleInputBox.Location = locationFix; // workaround to UIControl.Control overriding the old position 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) => /*FlaxEditor.Editor.Options.OptionsChanged += (FlaxEditor.Options.EditorOptions options) =>
{ {
@@ -283,7 +222,7 @@ public class ConsoleScript : Script
if (Input.InputText.Length > 0) 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); var consoleKeys = Input.ActionMappings.Where(x => x.Name == "Console" && x.Key != KeyboardKeys.None);
bool backslash = consoleKeys.Any(x => x.Key == KeyboardKeys.Backslash); bool backslash = consoleKeys.Any(x => x.Key == KeyboardKeys.Backslash);
bool backquote = consoleKeys.Any(x => x.Key == KeyboardKeys.BackQuote); bool backquote = consoleKeys.Any(x => x.Key == KeyboardKeys.BackQuote);
@@ -299,7 +238,9 @@ public class ConsoleScript : Script
if (backslash && (Input.InputText.ToLowerInvariant().Contains('\\') || if (backslash && (Input.InputText.ToLowerInvariant().Contains('\\') ||
Input.InputText.ToLowerInvariant() Input.InputText.ToLowerInvariant()
.Contains('|'))) // US/International keyboard layouts .Contains('|'))) // US/International keyboard layouts
{
return; return;
}
} }
if (!consoleInputBox.IsFocused) if (!consoleInputBox.IsFocused)

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Text;
using FlaxEngine; using FlaxEngine;
using FlaxEngine.GUI; using FlaxEngine.GUI;
@@ -50,8 +51,9 @@ public class PerformanceWidget : Script
updateTimeAvg = elapsed / updateTimeCount; updateTimeAvg = elapsed / updateTimeCount;
updateTimeCount = 0; updateTimeCount = 0;
label.Text = ""; StringBuilder text = new StringBuilder(10);
#if false
long triangles = 0; long triangles = 0;
long drawCalls = 0; long drawCalls = 0;
@@ -64,9 +66,12 @@ public class PerformanceWidget : Script
} }
#endif #endif
label.Text += $"{triangles} tris\n {drawCalls} drawcalls\n"; text.AppendLine($"{triangles} tris\n {drawCalls} drawcalls");
label.Text += $"{(int)Math.Round(1.0f / updateTimeAvg2)}fps2\n"; text.AppendLine($"{(int)Math.Round(1.0f / updateTimeAvg2)}fps2\n");
label.Text += $"{(int)Math.Round(1.0f / updateTimeAvg)}fps"; #endif
text.Append($"{(int)Math.Round(1.0f / updateTimeAvg)}fps");
label.Text = text.ToString();
} }
#if false #if false

View File

@@ -330,10 +330,10 @@ public class Q3MapImporter : Script
#endif #endif
public override void OnStart() public override void OnStart()
{ {
sceneLighting = lastSceneLighting = EngineSubsystem.SceneLighting == "1"; sceneLighting = lastSceneLighting = EngineConsoleCommands.SceneLighting == "1";
sceneShadows = lastSceneShadows = EngineSubsystem.SceneShadows == "1"; sceneShadows = lastSceneShadows = EngineConsoleCommands.SceneShadows == "1";
staticBatching = lastStaticBatching = EngineSubsystem.StaticBatch == "1"; staticBatching = lastStaticBatching = EngineConsoleCommands.StaticBatch == "1";
globalIllumination = EngineSubsystem.GlobalIllumination == "1"; globalIllumination = EngineConsoleCommands.GlobalIllumination == "1";
LoadMap(false); LoadMap(false);
} }
@@ -350,25 +350,25 @@ public class Q3MapImporter : Script
private bool globalIllumination = false; private bool globalIllumination = false;
public override void OnUpdate() public override void OnUpdate()
{ {
sceneLighting = EngineSubsystem.SceneLighting == "1"; sceneLighting = EngineConsoleCommands.SceneLighting == "1";
if (lastSceneLighting != sceneLighting) if (lastSceneLighting != sceneLighting)
{ {
lastSceneLighting = sceneLighting; lastSceneLighting = sceneLighting;
dirtyLights = true; dirtyLights = true;
} }
sceneShadows = EngineSubsystem.SceneShadows == "1"; sceneShadows = EngineConsoleCommands.SceneShadows == "1";
if (lastSceneShadows != sceneShadows) if (lastSceneShadows != sceneShadows)
{ {
lastSceneShadows = sceneShadows; lastSceneShadows = sceneShadows;
dirtyLights = true; dirtyLights = true;
} }
var staticBatching = EngineSubsystem.StaticBatch == "1"; var staticBatching = EngineConsoleCommands.StaticBatch == "1";
if (lastStaticBatching != staticBatching) if (lastStaticBatching != staticBatching)
{ {
lastStaticBatching = staticBatching; lastStaticBatching = staticBatching;
StaticBatching = staticBatching; StaticBatching = staticBatching;
} }
globalIllumination = EngineSubsystem.GlobalIllumination == "1"; globalIllumination = EngineConsoleCommands.GlobalIllumination == "1";
if (lastGlobalIllumination != globalIllumination) if (lastGlobalIllumination != globalIllumination)
{ {
lastGlobalIllumination = globalIllumination; lastGlobalIllumination = globalIllumination;