Coder Social home page Coder Social logo

bevy-console's People

Contributors

brainbacon avatar johanhelsing avatar makspll avatar msklosak avatar reachpw avatar richodemus avatar soniczentropy avatar starkat99 avatar striezel avatar tqwewe avatar umut-sahin avatar victor-n-suadicani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bevy-console's Issues

Console window infinitely expands downwards

When the console key is pressed, and the console window is shown, it constantly expands downwards until it hits the bottom of the window. When it does, it starts expanding from the top until it fills the screen. Once it fills the screen, it starts expanding from the bottom again off screen and never stops. I have about as bare bones of a project as you can have so unsure but doubtful its something unique to my usecase.

Could not compile `bevy_console` due to 10 previous errors

hi, I want to use the crate in wasm. look like this:

#[wasm_bindgen]
pub fn run() {
    App::new()
        .insert_resource(Msaa { samples: 1 })
        .insert_resource(ClearColor(Color::rgb(0.4, 0.4, 0.4)))
        .add_plugins(DefaultPlugins)
        .add_plugin(GamePlugin)
        .add_plugin(ConsolePlugin)
        .insert_resource(ConsoleConfiguration {
            // override config here
            ..Default::default()
        })
        .add_console_command::<LogCommand, _, _>(log_command)
        .run();
}

but compile failed. can you help me? thank you.

Compiling bevy_console v0.3.0

error: there is no argument named `name`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/commands/help.rs:39:43
   |
39 |                 let mut line = format!("  {name}{}", " ".repeat(longest_command_name - name.len()));
   |                                           ^^^^^^

error: there is no argument named `description`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/commands/help.rs:45:48
   |
45 |                     line.push_str(&format!(" - {description}"));
   |                                                ^^^^^^^^^^^^^

error: there is no argument named `name`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:154:26
    |
154 |             write!(buf, "{name}");
    |                          ^^^^^^

error: there is no argument named `description`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:174:28
    |
174 |             writeln!(buf, "{description}");
    |                            ^^^^^^^^^^^^^

error: there is no argument named `name`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:193:22
    |
193 |                 "    {name} {}",
    |                      ^^^^^^

error: there is no argument named `ty`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:201:26
    |
201 |             write!(buf, "{ty}");
    |                          ^^^^

error: there is no argument named `description`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:211:41
    |
211 |                     writeln!(buf, "   - {description}");
    |                                         ^^^^^^^^^^^^^

error: there is no argument named `expected`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/value.rs:64:36
   |
64 |                 "[error] expected '{expected}' but got '{received}' for arg #{}",
   |                                    ^^^^^^^^^^

error: there is no argument named `received`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/value.rs:64:57
   |
64 |                 "[error] expected '{expected}' but got '{received}' for arg #{}",
   |                                                         ^^^^^^^^^^

error: there is no argument named `msg`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/value.rs:75:63
   |
75 |             FromValueError::Custom(msg) => write!(f, "[error] {msg}"),
   |                                                               ^^^^^

error: could not compile `bevy_console` due to 10 previous errors

Input event still passed down to the game when I type inside the console.

Hi. I was able to smack this bad boy into my game and it is working correctly. My problem is that if I have controls assigned to certain characters for example 'A', 'D' etc.. The game still registers this.

Is that possible to block the capturing of the input events to the game when the terminal is up?

Integration with `clap`

Clap is a CLI argument parser for rust. It is clear it contains functionality which could be very useful to this crate. It is entirely possible that a large amount of logic can be outsourced to clap which would be very beneficial.

Clap offers argument formats which are much more flexible than the current parser can handle at the moment.

We might still need a macro on top of the original clap macro to control which options are available to the user (since some features like env variables should likely not be made available)

Access to trait 'Parser' from this crate.

Hi. It would be easier to make commands by importing the 'Parser' trait (or the entire 'clap' lib) from your lib. In this case, users don't need to add 'clap' to their project to create commands.

Update `bevy_egui` to v0.24

When bevy-console is used with bevy-inspector-egui, adding the console plugin crashes with:

Error adding plugin bevy_egui::EguiPlugin: : plugin was already added in application

I think the reason for this is that both v0.23 and v0.24 gets included in the build and somehow this check fails:

bevy-console/src/lib.rs

Lines 77 to 81 in 44d431c

// Don't initialize an egui plugin if one already exists.
// This can happen if another plugin is using egui and was installed before us.
if !app.is_plugin_added::<EguiPlugin>() {
app.add_plugins(EguiPlugin);
}

I'm not 100% sure that it'll solve the issue but I think it's worth a try!

Create unified trait for ConsoleCommands

Writing code like TC: CommandName + CommandArgs + CommandHelp is tedious and unclear.

Consider adding a ConsoleCommand: CommandName + CommandArgs + CommandHelp trait, and then creating blanket impl for it.

Seems like doc build fails

https://docs.rs/crate/bevy_console/0.3.0/builds/517246

# rustc version
rustc 1.61.0-nightly (10cc7a6d0 2022-02-26)
# docs.rs version
docsrs 0.6.0 (3968c84 2022-02-20)

# build log
[INFO] running `Command { std: "docker" "create" "-v" "/home/cratesfyi/workspace/builds/bevy_console-0.3.0/target:/opt/rustwide/target:rw,Z" "-v" "/home/cratesfyi/workspace/builds/bevy_console-0.3.0/source:/opt/rustwide/workdir:ro,Z" "-v" "/home/cratesfyi/workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/home/cratesfyi/workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "DOCS_RS=1" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "3221225472" "--cpus" "3" "--user" "1001:1001" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:0cd99ca24d8e8c98e67c542213511d985b8778b5bdcbb160e038429496686047" "/opt/rustwide/cargo-home/bin/cargo" "+nightly" "rustdoc" "--lib" "-Zrustdoc-map" "-Z" "unstable-options" "--config" "build.rustdocflags=[\"-Z\", \"unstable-options\", \"--emit=invocation-specific\", \"--resource-suffix\", \"-20220226-1.61.0-nightly-10cc7a6d0\", \"--static-root-path\", \"/\", \"--cap-lints\", \"warn\", \"--disable-per-crate-search\"]" "-Zunstable-options" "--config=doc.extern-map.registries.crates-io=\"https://docs.rs/{pkg_name}/{version}/x86_64-unknown-linux-gnu\"" "-j3" "--target" "x86_64-unknown-linux-gnu", kill_on_drop: false }`
[INFO] [stderr] WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
[INFO] [stdout] aca9076cdcf3dcea9b766591b4ead5b550d6edc4e29e3afeeaff5da784921503
[INFO] running `Command { std: "docker" "start" "-a" "aca9076cdcf3dcea9b766591b4ead5b550d6edc4e29e3afeeaff5da784921503", kill_on_drop: false }`
[INFO] [stderr]    Compiling anyhow v1.0.55
[INFO] [stderr]     Checking owned_ttf_parser v0.15.0
[INFO] [stderr]    Compiling xcb v0.8.2
[INFO] [stderr]     Checking regex v1.5.4
[INFO] [stderr]     Checking nom-supreme v0.6.0
[INFO] [stderr] error: failed to run custom build command for `xcb v0.8.2`
[INFO] [stderr] 
[INFO] [stderr] Caused by:
[INFO] [stderr]   process didn't exit successfully: `/opt/rustwide/target/debug/build/xcb-efe71022a80f5e43/build-script-build` (exit status: 101)
[INFO] [stderr]   --- stderr
[INFO] [stderr]   error occured in handler:  ('request: ', ('xcb', 'SELinux', 'GetClientContext'))
[INFO] [stderr]   Traceback (most recent call last):
[INFO] [stderr]     File "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/rs_client.py", line 2448, in <module>
[INFO] [stderr]       module.generate()
[INFO] [stderr]     File "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/xcbgen/state.py", line 108, in generate
[INFO] [stderr]       self.close()
[INFO] [stderr]     File "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/rs_client.py", line 296, in rs_close
[INFO] [stderr]       _f.writeout(os.path.join(module.rs_srcdir, "ffi", "%s.rs" % _module_name(_ns.ext_name)))
[INFO] [stderr]     File "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/rs_client.py", line 114, in writeout
[INFO] [stderr]       with open(path, 'w') as f:
[INFO] [stderr]   OSError: [Errno 30] Read-only file system: '/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/src/ffi/selinux.rs'
[INFO] [stderr]   Error in sys.excepthook:
[INFO] [stderr]   Traceback (most recent call last):
[INFO] [stderr]     File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 119, in apport_excepthook
[INFO] [stderr]       pr.add_user_info()
[INFO] [stderr]     File "/usr/lib/python3/dist-packages/apport/report.py", line 426, in add_user_info
[INFO] [stderr]       user = pwd.getpwuid(os.geteuid())[0]
[INFO] [stderr]   KeyError: 'getpwuid(): uid not found: 1001'
[INFO] [stderr] 
[INFO] [stderr]   Original exception was:
[INFO] [stderr]   Traceback (most recent call last):
[INFO] [stderr]     File "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/rs_client.py", line 2448, in <module>
[INFO] [stderr]       module.generate()
[INFO] [stderr]     File "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/xcbgen/state.py", line 108, in generate
[INFO] [stderr]       self.close()
[INFO] [stderr]     File "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/rs_client.py", line 296, in rs_close
[INFO] [stderr]       _f.writeout(os.path.join(module.rs_srcdir, "ffi", "%s.rs" % _module_name(_ns.ext_name)))
[INFO] [stderr]     File "/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/rs_client.py", line 114, in writeout
[INFO] [stderr]       with open(path, 'w') as f:
[INFO] [stderr]   OSError: [Errno 30] Read-only file system: '/opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/src/ffi/selinux.rs'
[INFO] [stderr]   thread 'main' panicked at 'processing of /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/xml/xselinux.xml returned non-zero (1)', /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/xcb-0.8.2/build.rs:75:17
[INFO] [stderr]   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[INFO] [stderr] warning: build failed, waiting for other jobs to finish...
[INFO] [stderr] error: build failed
[INFO] running `Command { std: "docker" "inspect" "aca9076cdcf3dcea9b766591b4ead5b550d6edc4e29e3afeeaff5da784921503", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "aca9076cdcf3dcea9b766591b4ead5b550d6edc4e29e3afeeaff5da784921503", kill_on_drop: false }`
[INFO] [stdout] aca9076cdcf3dcea9b766591b4ead5b550d6edc4e29e3afeeaff5da784921503

Run UI system depending on `run_if` instead of key press

It would be nice to allow the ConsolePlugin to accept a run condition on which to run the UI system, rather than a key press being the only possible way to toggle the console show/hide. I propose a solution like bevy_inspector_egui taking a fn run_if, which allows a user to set the run condition.

An example use case would be:

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, States)]
pub enum DebugState {
    #[default]
    Closed,
    Opened,
}

app
    .add_state::<DebugState>()
    .add_plugins(ConsolePlugin.run_if(in_state(DebugState::Opened)))

And another part of the app would be responsible for changing the current DebugState.

Please add a config option to NOT init the egui plugin

thread 'main' panicked at src/world_interaction/dialog.rs:10:9:
Error adding plugin bevy_egui::EguiPlugin: : plugin was already added in application
note: run with RUST_BACKTRACE=1 environment variable to display a backtrac

Add check the existing of EguiContext Resource

It makes hard to work with bevy_console when there are other plugins which uses bevy_egui

That could fix it well
// init egui if !app.world.contains_resource::<EguiContext>() { app.add_plugin(EguiPlugin); }

Command systems run all the time

Currently the system provided to add_console_command run every frame, this seems inefficient to me,
would it be possible instead to run these systems only when the command event fires instead ?

Crash when exit_condition "DontExit"

I need to run some systems before closing the game, so I set the exit_condition of the WindowPlugin to "ExitCondition::DontExit".

When closing the game i get following errors:

thread 'Compute Task Pool (11)' panicked at '`EguiContexts::ctx_mut` was called for an uninitialized context (primary window), make sure your system is run after [`EguiSet::InitContexts`] (or [`EguiStartupSet::InitContexts`] for startup systems)', 
stack backtrace: ....
Encountered a panic in system `bevy_console::console::console_ui`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
error: process didn't exit successfully: (exit code: 101)

Support for a more terminal-like experience

This is useful for making "terminal games" that can be run on the web.

Desired features:

  • Console cannot be moved or closed
  • Console typically fills screen, and resizes to it
  • Console size can still be set, in order to share the screen

Stretch goals:

  • Ability to seamlessly change out the terminal backend for a Real Terminal
  • Basic turn-based game architecture

See fork created here for Bevy Jam 1.0 :)

Can't open the console on a french keyboard

Hi,
I just found this crate, and working on a french keyboard. I had hard time to find out why it wasn't working. But i think there is a problem between how the ~ is done?
If i switch my keyboard in eng, i've no problem making the prompt appear. But in french, no way to see it.
I know the french way is quite weird: the ~ is done with Alt-Gr + é
But even so, maybe cause os a weird french encoding: to do a ~ alone we need to hit: Alt-Gr + é followed by space. And it doesn't open the prompt.
Maybe there is a problem with this weird way of doing things?

Some way to avoid having to wrap things in an `if`

It's slightly annoying that, even for commands that have no body, I still have to wrap the entire body in an if statement. For the common case where you only want to handle fully-formed valid commands, maybe an API like

#[derive(Parser, ConsoleCommand)]
struct DoSomething {
  arg: u32
}

fn do_something_system(
  In(command): In<DoSomething>,
  resource: Res<SomeResource>
) {
  todo!()
}

would work. The in-parameter can then be inferred so you wouldn't need to pass it again in add_console_command. Could also allow In(command): In<Result<DoSomething>> if you want to handle parse errors in your system.

Add github action

It would be nice to have a small github action that makes sure that the code compiles and that tests run
maybe even do some clippy

Bevy 0.8 Support

Hey there

Super excited to use with bevy 0.8!

Any plans to support?

Possible licensing issue

bevy_console_parser depends on nom-supreme, which is licensed with MPL-2.0.
This is a copyleft license, and as far as I understand it, it requires you to distribute your library under the same license.

bevy-console uses the MIT license, which probably doesn't comply with the MPL licensing terms.

This issue was discovered using cargo-deny in a project that depends on bevy-console.

Correctly account for size of margins

Currently, setting the size of the console does not result in a window of the correct size, due to the implicit addition of margins.

See strategy used here for a fix.

This margin size could also be configurable, but I'm not entirely sure it's worthwhile.

Hide ugly `add_terminal_command` type parameters

By wrapping this method in a public method with only the single useful type parameter, you can create a prettier API:

trait ActionExt {
    fn add_action<TC: Commandliket>(&mut self, action: Action);
}

impl ActionExt for App {
    fn add_action<TC: Commandlike>(&mut self, action: Action) {

        self.add_terminal_command::<TC, _, _>(start_action_system);
    }
}

Execute the examples all black.

图片

$ cargo run --example log_command
Compiling bevy_console v0.7.0 (/Users/liangyongrui/code/github/bevy-console)
Finished dev [unoptimized + debuginfo] target(s) in 5.36s
Running target/debug/examples/log_command
2023-03-21T12:34:54.594627Z INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon Pro 5300M", vendor: 0, device: 0, device_type: DiscreteGpu, driver: "", driver_info: "", backend: Metal }
2023-03-21T12:34:55.107354Z INFO bevy_winit::system: Creating new window "Bevy App" (0v0)
2023-03-21T12:34:55.334038Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 13.2.1 ", kernel: "22.3.0", cpu: "Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz", core_count: "6", memory: "16.0 GiB" }
2023-03-21T12:34:59.001059Z INFO bevy_window::system: No windows are open, exiting
2023-03-21T12:34:59.002596Z INFO bevy_winit::system: Closing window 0v0

Can we not fix the version of clap?

Hey there, I would love to use this package but the version of clap is fixed and not up-to-date. Can't you set that without the equal sign and make the clap version more flexible or are you using some internal things that don't allow you to update it?

Edit: I changed it in a fork and it works like a charm. So maybe we can just drop the = in =X.Y.Z for clap?

Fix failing doctest in derive_console_command

the doctest for the function derive_console_command in bevy_console_derive/src/lib.rs was failing so I ignored it in order to enable more strict CI checks

hopefully I (or someone else) can fix it :)

Couldn't satisfy dependencies of my project with bevy-console = "0.4.0"

Hello,
I've recently tried to add bevy-console to my Cargo.toml , and then i've go an error message :
bug_bev

I find out, that if i add bevy with disabled default-features :
bevy = { version = "0.9.0", default-features = false }
It let me build, but anyway of course it fails to build. Could you suggest something ?

Also this is whole Cargo.toml file:
image

Fork proposal.

RichoDemus appears to be inactive. I'm not sure what his Discord is, so couldn't DM him.

I'm proposing a fork of bevy-console in order to move the project forward. However, I want to make sure this is done with due respect and acknowledgment to RichoDemus and out of the understanding that we appreciate the project and want to keep it alive.

Initial goals of the fork:

  • Ship a crate compatible with Bevy 0.8
  • Review and triage previous issues.
  • Pursue a re-license under MIT / Apache 2.0

This will sit here for at least 7 days to gather comments.

Update crates.io published code to support bevy 0.9

Currently adding bevy_console 0.4 to a cargo file using bevy 0.9 results in this rust-analyzer message:

Previously selected package `notify v5.0.0-pre.15`
    ... which satisfies dependency `notify = "=5.0.0-pre.15"` of package `bevy_asset v0.8.1`
    ... which satisfies dependency `bevy_asset = "^0.8.0"` of package `bevy_internal v0.8.0`
    ... which satisfies dependency `bevy_internal = "^0.8.0"` of package `bevy v0.8.0`
    ... which satisfies dependency `bevy = "^0.8.0"` of package `bevy_console v0.4.0`
    ... which satisfies dependency `bevy_console = "^0.4.0"` of package `debug_tools v0.0.2 

and the crates.io page shows the last update as 4 months ago.

Add support for customizing internal `egui::style::Style`

@RichoDemus / @tqwewe, the default egui look/feel is nice, but from what I can tell this crate doesn't allow changing the style of the console window. If people are going to use this plugin in games I'm guessing they'll want to change the style of the console to fit in with the style of their game's UI.

Simply exposing a public wrapper method over Context::set_style or the console window's Frame (and possibly re-exporting bevy-console's internal egui or bevy-egui) should be enough to let developers make the console look however they want.

Does this seem like something inside the scope of this project? If so, let me know and I'll create a draft PR and work on adding it in the next week or so 👍🏽.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.