Update to bevy 0.14 + Add 0BSD Option
This commit is contained in:
parent
f6b9eda55d
commit
345e0665bf
29
Cargo.toml
29
Cargo.toml
@ -1,24 +1,17 @@
|
||||
[package]
|
||||
name = "bevy_terminal_display"
|
||||
version = "0.2.2"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
license = "0BSD OR MIT OR Apache-2.0"
|
||||
description = "A plugin for the Bevy game engine which enables rendering to a terminal using unicode braille characters."
|
||||
|
||||
[dependencies]
|
||||
crossterm = "0.27.0"
|
||||
downcast-rs = "1.2.1"
|
||||
once_cell = "1.19.0"
|
||||
|
||||
[dependencies.bevy]
|
||||
version = "0.13"
|
||||
|
||||
[dependencies.bevy_framebuffer_extract]
|
||||
git = "https://github.com/exvacuum/bevy_framebuffer_extract"
|
||||
tag = "v0.1.2"
|
||||
|
||||
[dependencies.bevy_dither_post_process]
|
||||
git = "https://github.com/exvacuum/bevy_dither_post_process"
|
||||
tag = "v0.1.4"
|
||||
|
||||
[dependencies.ratatui]
|
||||
version = "0.26.2"
|
||||
crossbeam-channel = "0.5"
|
||||
crossterm = "0.27"
|
||||
downcast-rs = "1.2"
|
||||
once_cell = "1.19"
|
||||
bevy = "0.14"
|
||||
bevy_headless_render = "0.1"
|
||||
bevy_dither_post_process = "0.2"
|
||||
ratatui = "0.26"
|
||||
|
||||
|
5
LICENSE-0BSD
Normal file
5
LICENSE-0BSD
Normal file
@ -0,0 +1,5 @@
|
||||
Copyright (C) 2024 by Silas Bartha silas@exvacuum.dev
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
10
README.md
10
README.md
@ -1,5 +1,6 @@
|
||||
# bevy_terminal_display
|
||||
|
||||
[](https://crates.io/crates/bevy_terminal_display)
|
||||

|
||||

|
||||

|
||||
@ -24,10 +25,17 @@ Features Include:
|
||||
|
||||
| Crate Version | Bevy Version |
|
||||
|--- |--- |
|
||||
| 0.3 | 0.14 |
|
||||
| 0.2 | 0.13 |
|
||||
|
||||
## Installation
|
||||
|
||||
### crates.io
|
||||
```toml
|
||||
[dependencies]
|
||||
bevy_terminal_display = "0.3"
|
||||
```
|
||||
|
||||
### Using git URL in Cargo.toml
|
||||
```toml
|
||||
[dependencies.bevy_terminal_display]
|
||||
@ -69,5 +77,7 @@ commands.spawn((
|
||||
));
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This crate is licensed under your choice of 0BSD, Apache-2.0, or MIT license.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use bevy::{prelude::*, render::render_resource::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages}};
|
||||
use bevy_dither_post_process::components::DitherPostProcessSettings;
|
||||
use bevy_framebuffer_extract::{components::{ExtractFramebufferBundle, FramebufferExtractDestination}, render_assets::FramebufferExtractSource};
|
||||
use bevy_headless_render::{components::{HeadlessRenderBundle, HeadlessRenderDestination}, render_assets::HeadlessRenderSource};
|
||||
|
||||
/// Marker component for terminal display
|
||||
#[derive(Component)]
|
||||
@ -11,8 +11,8 @@ pub struct TerminalDisplay;
|
||||
#[derive(Bundle)]
|
||||
pub struct TerminalDisplayBundle {
|
||||
_terminal_display: TerminalDisplay,
|
||||
extract_framebuffer_bundle: ExtractFramebufferBundle,
|
||||
dither_post_process_settings: DitherPostProcessSettings,
|
||||
_headless_render_bundle: HeadlessRenderBundle,
|
||||
_dither_post_process_settings: DitherPostProcessSettings,
|
||||
image_handle: Handle<Image>,
|
||||
}
|
||||
|
||||
@ -48,16 +48,16 @@ impl TerminalDisplayBundle {
|
||||
let image_handle = asset_server.add(image);
|
||||
|
||||
let framebuffer_extract_source =
|
||||
asset_server.add(FramebufferExtractSource(image_handle.clone()));
|
||||
asset_server.add(HeadlessRenderSource(image_handle.clone()));
|
||||
|
||||
Self {
|
||||
_terminal_display: TerminalDisplay,
|
||||
extract_framebuffer_bundle: ExtractFramebufferBundle {
|
||||
_headless_render_bundle: HeadlessRenderBundle {
|
||||
source: framebuffer_extract_source,
|
||||
dest: FramebufferExtractDestination::default(),
|
||||
dest: HeadlessRenderDestination::default(),
|
||||
},
|
||||
image_handle,
|
||||
dither_post_process_settings: DitherPostProcessSettings::new(
|
||||
_dither_post_process_settings: DitherPostProcessSettings::new(
|
||||
dither_level,
|
||||
asset_server,
|
||||
),
|
||||
|
@ -2,9 +2,7 @@ use bevy::{
|
||||
prelude::*,
|
||||
render::render_resource::{Extent3d, TextureFormat},
|
||||
};
|
||||
use bevy_framebuffer_extract::{
|
||||
components::FramebufferExtractDestination, render_assets::FramebufferExtractSource,
|
||||
};
|
||||
use bevy_headless_render::{components::HeadlessRenderDestination, render_assets::HeadlessRenderSource};
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{
|
||||
style::Stylize,
|
||||
@ -27,7 +25,7 @@ const BRAILLE_DOT_BIT_POSITIONS: [u8; 8] = [0, 1, 2, 6, 3, 4, 5, 7];
|
||||
/// Prints out the contents of a render image to the terminal as braille characters
|
||||
pub fn print_to_terminal(
|
||||
mut terminal: ResMut<Terminal>,
|
||||
image_exports: Query<&FramebufferExtractDestination>,
|
||||
image_exports: Query<&HeadlessRenderDestination>,
|
||||
mut widgets: Query<&mut Widget>,
|
||||
) {
|
||||
for image_export in image_exports.iter() {
|
||||
@ -108,7 +106,7 @@ fn braille_char(mask: u8) -> char {
|
||||
/// Watches for terminal resize events and resizes the render image accordingly
|
||||
pub fn resize_handling(
|
||||
mut images: ResMut<Assets<Image>>,
|
||||
mut sources: ResMut<Assets<FramebufferExtractSource>>,
|
||||
mut sources: ResMut<Assets<HeadlessRenderSource>>,
|
||||
mut event_reader: EventReader<TerminalInputEvent>,
|
||||
) {
|
||||
for event in event_reader.read() {
|
||||
|
46
src/lib.rs
46
src/lib.rs
@ -10,15 +10,13 @@ use std::{
|
||||
|
||||
use bevy::{
|
||||
log::{
|
||||
tracing_subscriber::{self, prelude::*, Registry},
|
||||
tracing_subscriber::{self, layer::SubscriberExt, EnvFilter, Layer, Registry},
|
||||
Level, LogPlugin,
|
||||
},
|
||||
prelude::*,
|
||||
utils::tracing::level_filters::LevelFilter,
|
||||
}, prelude::*, utils::tracing::{level_filters::LevelFilter, subscriber}
|
||||
};
|
||||
use bevy_dither_post_process::DitherPostProcessPlugin;
|
||||
use bevy_framebuffer_extract::FramebufferExtractPlugin;
|
||||
|
||||
use bevy_headless_render::HeadlessRenderPlugin;
|
||||
pub use crossterm;
|
||||
use once_cell::sync::Lazy;
|
||||
pub use ratatui;
|
||||
@ -53,29 +51,25 @@ impl Plugin for TerminalDisplayPlugin {
|
||||
*LOG_PATH
|
||||
.lock()
|
||||
.expect("Failed to get lock on log path mutex") = self.log_path.clone();
|
||||
let log_file = OpenOptions::new()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.open(
|
||||
LOG_PATH
|
||||
.lock()
|
||||
.expect("Failed to get lock on log path mutex")
|
||||
.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let file_layer = tracing_subscriber::fmt::Layer::new()
|
||||
.with_writer(log_file)
|
||||
.with_filter(EnvFilter::builder().parse_lossy(format!("{},{}", Level::INFO, "wgpu=error,naga=warn")));
|
||||
let subscriber = Registry::default().with(file_layer);
|
||||
subscriber::set_global_default(subscriber).unwrap();
|
||||
app.add_plugins((
|
||||
DitherPostProcessPlugin,
|
||||
FramebufferExtractPlugin,
|
||||
LogPlugin {
|
||||
update_subscriber: Some(|_| {
|
||||
let log_file = OpenOptions::new()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.open(
|
||||
LOG_PATH
|
||||
.lock()
|
||||
.expect("Failed to get lock on log path mutex")
|
||||
.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let file_layer = tracing_subscriber::fmt::Layer::new()
|
||||
.with_writer(log_file)
|
||||
.with_filter(LevelFilter::from_level(Level::INFO));
|
||||
Box::new(Registry::default().with(file_layer))
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
HeadlessRenderPlugin,
|
||||
))
|
||||
.add_systems(Startup, input::systems::setup_input)
|
||||
.add_systems(
|
||||
|
Loading…
x
Reference in New Issue
Block a user