forked from Brickworks/yahs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e206cdd
commit 60bfc4e
Showing
8 changed files
with
67 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,24 +19,24 @@ path = "src/simulator/src/lib.rs" | |
name = "yahs" | ||
path = "src/cli/src/main.rs" | ||
|
||
# Include the GUI binary as "yahs-ui" | ||
[[bin]] | ||
name = "yahs-ui" | ||
path = "src/ui/src/main.rs" | ||
|
||
# These are the dependencies for the project when building it from the root | ||
# These are the dependencies when building the CLI from the project root | ||
[dependencies] | ||
# Simulator dependencies | ||
yahs-simulator = { path = "src/simulator" } | ||
yahs-ui = { path = "src/ui" } | ||
yahs-cli = { path = "src/cli" } | ||
bevy = { workspace = true } | ||
avian3d = { workspace = true } | ||
bevy-trait-query = { workspace = true } | ||
|
||
# CLI dependencies | ||
yahs-cli = { path = "src/cli" } | ||
bevy_ratatui = "0.7.0" | ||
ratatui = "0.29" | ||
color-eyre = "0.6.3" | ||
crossterm = "0.28.1" | ||
|
||
[features] | ||
default = ["dev"] | ||
dev = ["yahs-ui/dev", "yahs-cli/dev", "yahs-simulator/dev"] | ||
inspect = ["yahs-ui/inspect"] | ||
dev = ["yahs-cli/dev", "yahs-simulator/dev"] | ||
|
||
[workspace.package] | ||
authors = ["Philip Linden <[email protected]>"] | ||
|
@@ -46,15 +46,15 @@ license = "MIT or Apache-2.0" | |
[workspace] | ||
resolver = "2" # Important for Bevy | ||
members = [ | ||
"src/yahs-simulator", | ||
"src/yahs-ui", | ||
"src/yahs-cli" | ||
"src/simulator", | ||
"src/cli", | ||
"src/ui" | ||
] | ||
|
||
[workspace.dependencies] | ||
# Shared dependencies with fixed versions | ||
bevy = { version = "0.15.0", default-features = false, features = [ | ||
"bevy_asset", "bevy_state", "multi_threaded" | ||
"bevy_state", "multi_threaded" | ||
] } | ||
avian3d = { git = "https://github.com/Jondolf/avian.git", branch = "main" } | ||
bevy-trait-query = "0.7.0" | ||
|
@@ -84,6 +84,7 @@ opt-level = 1 | |
# Enable a large amount of optimization in the dev profile for dependencies. | ||
[profile.dev.package."*"] | ||
opt-level = 3 | ||
debug = false | ||
|
||
# The default profile is optimized for Wasm builds because that's what [Trunk | ||
# reads](https://github.com/trunk-rs/trunk/issues/605). Optimize for size in the | ||
|
@@ -92,9 +93,6 @@ opt-level = 3 | |
# Compile the entire crate as one unit. Slows compile times, marginal | ||
# improvements. | ||
codegen-units = 1 | ||
# Do a second optimization pass over the entire program, including | ||
# dependencies. Slows compile times, marginal improvements. | ||
lto = "thin" | ||
# Optimize with size in mind (also try "z", sometimes it is better). | ||
# Slightly slows compile times, great improvements to file size and runtime | ||
# performance. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# yahs-cli | ||
|
||
This is the CLI for the yahs project. | ||
|
||
```bash | ||
cargo run --bin yahs-cli | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
use bevy::{prelude::*, state::app::StatesPlugin}; | ||
use yahs_simulator::prelude::SimulatorPlugins; | ||
|
||
use bevy::{ | ||
app::{AppExit, ScheduleRunnerPlugin}, | ||
prelude::*, | ||
}; | ||
use bevy_ratatui::{ | ||
error::exit_on_error, event::KeyEvent, terminal::RatatuiContext, RatatuiPlugins, | ||
}; | ||
fn main() { | ||
let wait_duration = std::time::Duration::from_secs_f64(1. / 60.); // 60 FPS | ||
App::new() | ||
.add_plugins(( | ||
MinimalPlugins, | ||
StatesPlugin, | ||
SimulatorPlugins, | ||
)) | ||
.add_plugins(RatatuiPlugins::default()) | ||
.add_plugins(ScheduleRunnerPlugin::run_loop(wait_duration)) | ||
.add_systems(PreUpdate, keyboard_input_system) | ||
.add_systems(Update, hello_world.pipe(exit_on_error)) | ||
.run(); | ||
} | ||
} | ||
|
||
fn hello_world(mut context: ResMut<RatatuiContext>) -> color_eyre::Result<()> { | ||
context.draw(|frame| { | ||
let text = ratatui::text::Text::raw("hello world\nPress 'q' to Quit"); | ||
frame.render_widget(text, frame.area()) | ||
})?; | ||
Ok(()) | ||
} | ||
|
||
fn keyboard_input_system(mut events: EventReader<KeyEvent>, mut exit: EventWriter<AppExit>) { | ||
use crossterm::event::KeyCode; | ||
for event in events.read() { | ||
match event.code { | ||
KeyCode::Char('q') | KeyCode::Esc => { | ||
exit.send_default(); | ||
} | ||
_ => {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters