Skip to content

Conversation

pixelkingliam
Copy link

Added new DevConsole system. scenes that are allowed to spawn and use the developer console need to inherit ConsoleEnabledScene instead of Control, base._Input is required. I've made some example commands in MainMenu, but they can be registered from anywhere

@pixelkingliam pixelkingliam added the enhancement New feature or request label Dec 14, 2024
@pixelkingliam pixelkingliam self-assigned this Dec 14, 2024
{
base._Input(@event);
if (@event is InputEventKey eKey ) {
// Key is `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can simplify here.
eKey { KeyLabel = Key.QuoteLedt } && eKey.IsReleased()

{
cFunc.Call(context);
}
if (command is CVar<string> cVarString)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably export this to new func with type probably HandleVar(T varType, comman

}
public void Print(object what)
{
ConsoleManager.Contents += what;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can simplify here by $"{what}\n";


public static Node GetConsole()
{
var console = SceneManager.GetPackedScene("DevConsole").Instantiate() as DevConsole;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do additional checks if exists, if does not disable the console

/// </summary>
/// <param name="name">The name of the command</param>
/// <param name="CFuncOrCVar">A CVar or CFunc Command</param>
public static void Register(string name, Command CFuncOrCVar)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have an unregister

Description = description;
// Check at runtime if the type is one of the allowed types
if (typeof(T) != typeof(int) && typeof(T) != typeof(float) &&
typeof(T) != typeof(bool) && typeof(T) != typeof(string))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to use any number type. [interface exist for it]
string, bool is good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants