doonv / bevy_dev_console

Source-inspired developer console plugin for the Bevy game engine.
Apache License 2.0
112 stars 10 forks source link

Add user-end console config #14

Closed Godnoken closed 7 months ago

Godnoken commented 7 months ago

Objective

Let the user change the theme & 'open console' key.

Having a modifiable key is especially important, as the KeyCode::Grave simply isn't useable on my Swedish keyboard.

Solution

Add ConsoleConfig as a param to DevConsolePlugin


I don't have any real experience with how things should be written in this aspect, so let me know if anything ought to be done differently.

doonv commented 7 months ago

Thanks for contributing to bevy_dev_console!

You can already change how the dev console looks by inserting the ConsoleConfig resource via App::insert_resource. (It doesn't matter if it's before or after the DevConsolePlugin)

This works because App::init_resource::<ConsoleConfig>() (what we use in DevConsolePlugin) does not override the ConsoleConfig resource if it was already defined.

Here's an example:

App::new()
    .insert_resource(ConsoleConfig {
        theme: ConsoleTheme::ONE_DARK,
        open_key: KeyCode::Escape
    })
    .add_plugins((
        ConsoleLogPlugin::default(),
        DefaultPlugins.build().disable::<LogPlugin>(),
        DevConsolePlugin,
    ))
    .run();

So I don't think this PR is necessary in that case, since you could already customize it.

Godnoken commented 7 months ago

Doh! Had no idea that it was possible to do that.

Thank you very much for this crate, it will be very useful & time saving for me.

doonv commented 7 months ago

Thank you for using my crate, I'm glad you like it.