Skip to content

Commit

Permalink
build: multiproject
Browse files Browse the repository at this point in the history
  • Loading branch information
francisdb committed Jan 17, 2025
1 parent 30f3e48 commit 6ed8b1f
Show file tree
Hide file tree
Showing 30 changed files with 8,361 additions and 138 deletions.
68 changes: 46 additions & 22 deletions Cargo.lock

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

65 changes: 7 additions & 58 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,63 +1,12 @@
[package]
name = "vpxtool"
version = "0.1.0"
edition = "2021"
rust-version = "1.71.1"
[workspace]
members = [
"vpxtool",
"vpxgui",
"shared"
]
resolver = "2"


[lib]
path = "src/lib.rs"

[[bin]]
path = "src/main.rs"
name = "vpxtool"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
base64 = "0.22.1"
#see https://github.com/chronotope/chrono/issues/602#issuecomment-1242149249
chrono = { version = "0.4.39", default-features = false, features = ["clock"] }
clap = { version = "4.5.26", features = ["derive", "string"] }
colored = "3.0.0"
console = "0.15.10"
dialoguer = { version = "0.11.0", features = ["fuzzy-select"] }
dirs = "6.0.0"
image = { version = "0.25", default-features = true, features = ["jpeg", "png"] }
git-version = "0.3.9"
indicatif = "0.17.9"
jojodiff = "0.1.2"
log = "0.4.22"
logging_timer = "1.1.1"
pretty_env_logger = "0.5.0"
quick-xml = { version = "0.37.1", features = ["serialize"] }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = { version = "1.0.135", features = ["preserve_order"] }
shellexpand = "3.1.0"
walkdir = "2.5.0"
wild = "2.2.1"
figment = { version = "0.10", features = ["toml", "env"] }
toml = "0.8.19"
is_executable = "1.0.4"
imagesize = "0.13.0"
regex = { version = "1.11.1", features = [] }
vpin = { version = "0.17.2" }
rust-ini = "0.21.1"
edit = "0.1.5"
bevy = "0.15.0"
bevy_asset = "0.15.0"
bevy_asset_loader = "0.22.0"
bevy_egui = "0.31.1"
eframe = "0.29.1"
egui_extras = { version = "0.29.1", features = ["image"] }
crossbeam-channel = "0.5.13"
pinmame-nvram = "0.3.9"

[dev-dependencies]
pretty_assertions = "1.4.1"
rand = "0.8.5"
testdir = "0.9.3"

[profile.test]
# level 0 is very slow for writing to compound files
# see https://github.com/mdsteele/rust-cfb/issues/42
Expand Down
25 changes: 25 additions & 0 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "shared"
edition = "2021"

[lib]

[dependencies]
vpin = { version = "0.17.2" }
#see https://github.com/chronotope/chrono/issues/602#issuecomment-1242149249
chrono = { version = "0.4.39", default-features = false, features = ["clock"] }
rust-ini = "0.21.1"
dirs = "6.0.0"
toml = "0.8.19"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = { version = "1.0.135", features = ["preserve_order"] }
log = "0.4.22"
figment = { version = "0.10", features = ["toml", "env"] }
dialoguer = "0.11.0"
regex = { version = "1.11.1", features = [] }
walkdir = "2.5.0"

[dev-dependencies]
pretty_assertions = "1.4.1"
rand = "0.8.5"
testdir = "0.9.3"
18 changes: 9 additions & 9 deletions src/config.rs → shared/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ pub struct ResolvedConfig {
/// PlayfieldHeight = 960
///
/// Note: For macOS with hidpi screen this these are logical sizes/locations, not pixel sizes
pub(crate) struct PlayfieldInfo {
pub(crate) fullscreen: bool,
pub(crate) x: Option<u32>,
pub(crate) y: Option<u32>,
pub(crate) width: Option<u32>,
pub(crate) height: Option<u32>,
pub struct PlayfieldInfo {
pub fullscreen: bool,
pub x: Option<u32>,
pub y: Option<u32>,
pub width: Option<u32>,
pub height: Option<u32>,
}

pub(crate) struct VPinballConfig {
pub struct VPinballConfig {
ini: ini::Ini,
}

Expand Down Expand Up @@ -178,7 +178,7 @@ pub enum SetupConfigResult {
Existing(PathBuf),
}

pub(crate) fn setup_config() -> io::Result<SetupConfigResult> {
pub fn setup_config() -> io::Result<SetupConfigResult> {
// TODO check if the config file already exists
let existing_config_path = config_path();
match existing_config_path {
Expand Down Expand Up @@ -236,7 +236,7 @@ fn read_config(config_path: &Path) -> io::Result<ResolvedConfig> {
Ok(resolved_config)
}

pub(crate) fn tables_index_path(tables_folder: &Path) -> PathBuf {
pub fn tables_index_path(tables_folder: &Path) -> PathBuf {
tables_folder.join("vpxtool_index.json")
}

Expand Down
34 changes: 19 additions & 15 deletions src/indexer.rs → shared/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ use std::{
path::{Path, PathBuf},
};

use colored::Colorize;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use vpin::vpx;
use vpin::vpx::jsonmodel::json_to_info;
use vpin::vpx::tableinfo::TableInfo;
use walkdir::{DirEntry, FilterEntry, IntoIter, WalkDir};

use crate::tableinfo::TableInfo;
use crate::vpx;
use crate::vpx::gamedata::GameData;
use vpx::gamedata::GameData;

/// Introduced because we want full control over serialization
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
Expand Down Expand Up @@ -128,7 +127,7 @@ impl TablesIndex {
}
}

pub(crate) fn len(&self) -> usize {
pub fn len(&self) -> usize {
self.tables.len()
}

Expand Down Expand Up @@ -290,6 +289,13 @@ pub trait Progress {
fn finish_and_clear(&self);
}

pub struct VoidProgress;
impl Progress for VoidProgress {
fn set_length(&self, _len: u64) {}
fn set_position(&self, _i: u64) {}
fn finish_and_clear(&self) {}
}

pub enum IndexError {
FolderDoesNotExist(PathBuf),
IoError(io::Error),
Expand All @@ -304,6 +310,11 @@ impl Debug for IndexError {
}
}
}
impl From<IndexError> for io::Error {
fn from(e: IndexError) -> io::Error {
io::Error::new(io::ErrorKind::Other, format!("{:?}", e))
}
}

impl From<io::Error> for IndexError {
fn from(e: io::Error) -> Self {
Expand Down Expand Up @@ -405,7 +416,7 @@ pub fn index_vpx_files(
Err(e) => {
// TODO we want to return any failures instead of printing here
let warning =
format!("Not a valid vpx file {}: {}", vpx_file.path.display(), e).red();
format!("Not a valid vpx file {}: {}", vpx_file.path.display(), e);
println!("{}", warning);
None
}
Expand Down Expand Up @@ -464,7 +475,7 @@ fn index_vpx_file(
Ok((indexed.path.clone(), indexed))
}

pub(crate) fn get_romname_from_vpx(vpx_path: &Path) -> io::Result<Option<String>> {
pub fn get_romname_from_vpx(vpx_path: &Path) -> io::Result<Option<String>> {
let mut vpx_file = vpx::open(vpx_path)?;
let game_data = vpx_file.read_gamedata()?;
let code = consider_sidecar_vbs(vpx_path, game_data)?;
Expand Down Expand Up @@ -644,17 +655,10 @@ fn unify_line_endings(code: &str) -> String {
#[cfg(test)]
mod tests {
use super::*;
use crate::vpx;
use serde_json::json;
use std::io::Write;
use testdir::testdir;

struct VoidProgress;
impl Progress for VoidProgress {
fn set_length(&self, _len: u64) {}
fn set_position(&self, _i: u64) {}
fn finish_and_clear(&self) {}
}
use vpin::vpx;

#[test]
fn test_index_vpx_files() -> io::Result<()> {
Expand Down
2 changes: 2 additions & 0 deletions shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod config;
pub mod indexer;
Binary file removed src/assets/Pinball.ogg
Binary file not shown.
Binary file removed src/assets/blankwheel.png
Binary file not shown.
Binary file removed src/assets/left-flipper.png
Binary file not shown.
Binary file removed src/assets/right-flipper.png
Binary file not shown.
20 changes: 20 additions & 0 deletions vpxgui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "vpxgui"
edition = "2021"

[[bin]]
name = "vpxgui"
path = "src/main.rs"


[dependencies]
shared = { path = "../shared" }
bevy = "0.15.0"
bevy_asset = "0.15.0"
bevy_asset_loader = "0.22.0"
bevy_egui = "0.31.1"
eframe = "0.29.1"
egui_extras = { version = "0.29.1", features = ["image"] }
crossbeam-channel = "0.5.13"
image = { version = "0.25", default-features = true, features = ["jpeg", "png"] }
is_executable = "1.0.4"
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 6ed8b1f

Please sign in to comment.