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

Add menu and file explorer to TUI #8

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion plastic_tui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plastic_tui"
version = "0.3.1"
version = "0.3.2"
authors = ["Amjad Alsharafi <[email protected]>"]
edition = "2021"
description = "An accurate NES emulator. Front-end terminal interface (TUI) for plastic-core"
Expand All @@ -17,4 +17,7 @@ crossterm = "0.28"
gilrs = "0.11"
dynwave = "0.1.0"
ratatui = "0.28.1"
tui-menu = "0.2.4"
directories = "5.0"
ratatui-explorer = "0.1.2"

25 changes: 20 additions & 5 deletions plastic_tui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,35 @@ use std::env::args;
fn main() {
let args = args().collect::<Vec<String>>();

if args.len() < 2 {
eprintln!("USAGE: {} <rom-file> [-a]\n-a: remove audio", args[0]);
let mut file = args.get(1).map(|s| s.as_str());

if file == Some("-h") || file == Some("--help") {
eprintln!("USAGE: {} [rom-file] [-a]\n-a: remove audio", args[0]);
return;
}

let nes = match NES::new(&args[1]) {
let mut has_audio = true;

if file == Some("-a") {
file = None;
has_audio = false;
}

if has_audio && args.get(2).map(|s| s.as_str()) == Some("-a") {
has_audio = false;
}

let nes = match file {
Some(f) => NES::new(f),
None => Ok(NES::new_without_file()),
};
let nes = match nes {
Ok(nes) => nes,
Err(e) => {
eprintln!("Error: {}", e);
return;
}
};

let has_audio = !(args.len() == 3 && args[2] == "-a");

ui::Ui::new(nes, has_audio).run();
}
Loading
Loading