Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Dev Console #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Added Dev Console #2

wants to merge 2 commits into from

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()

csharp/Client/UI/DevConsole.cs Outdated Show resolved Hide resolved
csharp/Client/UI/DevConsole.cs Outdated Show resolved Hide resolved
{
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

csharp/Managers/ConsoleManager.cs Show resolved Hide resolved
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