Skip to content

Commit

Permalink
cw2 magwells not in magazines
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Oct 14, 2023
1 parent 6a6111e commit d389e49
Show file tree
Hide file tree
Showing 37 changed files with 371 additions and 129 deletions.
62 changes: 37 additions & 25 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"libs/config",
"libs/pbo",
"libs/preprocessor",
"libs/project",
"libs/signing",
]
resolver = "2"
Expand Down
2 changes: 1 addition & 1 deletion bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ hemtt-common = { path = "../libs/common", version = "1.0.0" }
hemtt-config = { path = "../libs/config", version = "1.0.0" }
hemtt-pbo = { path = "../libs/pbo", version = "1.0.1" }
hemtt-preprocessor = { path = "../libs/preprocessor", version = "1.0.0" }
hemtt-project = { path = "../libs/project", version = "1.0.0" }
hemtt-signing = { path = "../libs/signing", version = "1.0.0" }

anyhow = "1.0.75"
Expand All @@ -42,7 +43,6 @@ serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
steamlocate = "2.0.0-alpha.0"
time = { version = "0.3.29", features = ["formatting"] }
toml = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { version = "0.3.17", features = ["json"] }
vfs = { workspace = true }
Expand Down
9 changes: 5 additions & 4 deletions bin/src/addons.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use std::{fs::DirEntry, path::PathBuf, str::FromStr};

use hemtt_common::prefix::{self, Prefix};
use hemtt_project::AddonConfig;

use crate::{config::addon::Configuration, error::Error};
use crate::error::Error;

#[derive(Debug, Clone)]
pub struct Addon {
name: String,
location: Location,
config: Option<Configuration>,
config: Option<AddonConfig>,
prefix: Prefix,
}

Expand All @@ -26,7 +27,7 @@ impl Addon {
config: {
let path = path.join("addon.toml");
if path.exists() {
Some(Configuration::from_file(&path)?)
Some(AddonConfig::from_file(&path)?)
} else {
None
}
Expand Down Expand Up @@ -86,7 +87,7 @@ impl Addon {
}

#[must_use]
pub const fn config(&self) -> Option<&Configuration> {
pub const fn config(&self) -> Option<&AddonConfig> {
self.config.as_ref()
}

Expand Down
5 changes: 3 additions & 2 deletions bin/src/commands/launch.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::path::{Path, PathBuf};

use clap::{ArgMatches, Command};
use hemtt_project::ProjectConfig;
use steamlocate::SteamDir;

use crate::{config::project::Configuration, error::Error, utils::create_link};
use crate::{error::Error, utils::create_link};

use super::dev;

Expand Down Expand Up @@ -37,7 +38,7 @@ pub fn cli() -> Command {
/// # Errors
/// [`Error`] depending on the modules
pub fn execute(matches: &ArgMatches) -> Result<(), Error> {
let config = Configuration::from_file(&Path::new(".hemtt").join("project.toml"))?;
let config = ProjectConfig::from_file(&Path::new(".hemtt").join("project.toml"))?;
let Some(mainprefix) = config.mainprefix() else {
return Err(Error::MainPrefixNotFound(String::from(
"Required for launch",
Expand Down
2 changes: 0 additions & 2 deletions bin/src/config/mod.rs

This file was deleted.

15 changes: 8 additions & 7 deletions bin/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ use std::{
};

use hemtt_common::workspace::{Workspace, WorkspacePath};
use hemtt_project::ProjectConfig;

use crate::{addons::Addon, config::project::Configuration, error::Error};
use crate::{addons::Addon, error::Error};

#[derive(Debug, Clone)]
pub struct Context {
config: Configuration,
config: ProjectConfig,
folder: String,
addons: Vec<Addon>,
workspace: WorkspacePath,
Expand All @@ -37,7 +38,7 @@ impl Context {
if !path.exists() {
return Err(Error::ConfigNotFound);
}
Configuration::from_file(&path)?
ProjectConfig::from_file(&path)?
};
let tmp = {
let mut tmp = temp_dir().join("hemtt");
Expand Down Expand Up @@ -80,12 +81,12 @@ impl Context {
};
{
let version = config.version().get(workspace.vfs());
if let Err(Error::Git(_)) = version {
if let Err(hemtt_project::Error::Git(_)) = version {
error!("Failed to find a git repository with at least one commit, if you are not using git add the following to your project.toml");
println!("\n[version]\ngit_hash = 0\n");
std::process::exit(1);
};
info!("Config loaded for {} {}", config.name(), version?,);
info!("Config loaded for {} {}", config.name(), version?);
}
Ok(Self {
config,
Expand All @@ -102,7 +103,7 @@ impl Context {
#[must_use]
pub fn filter<F>(self, mut filter: F) -> Self
where
F: FnMut(&Addon, &Configuration) -> bool,
F: FnMut(&Addon, &ProjectConfig) -> bool,
{
let config = self.config.clone();
Self {
Expand All @@ -116,7 +117,7 @@ impl Context {
}

#[must_use]
pub const fn config(&self) -> &Configuration {
pub const fn config(&self) -> &ProjectConfig {
&self.config
}

Expand Down
6 changes: 2 additions & 4 deletions bin/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use hemtt_common::error::thiserror;
pub enum Error {
#[error("`.hemtt/project.toml` not found")]
ConfigNotFound,
#[error("Invalid config: {0}")]
ConfigInvalid(String),
#[error("Launch config not found: {0}")]
LaunchConfigNotFound(String),

Expand Down Expand Up @@ -53,6 +51,8 @@ pub enum Error {
Pbo(#[from] hemtt_pbo::Error),
#[error("Prefix error: {0}")]
Prefix(#[from] hemtt_common::prefix::Error),
#[error("`a hemtt project file is invalid: {0}")]
Project(#[from] hemtt_project::Error),
#[error("Signing error: {0}")]
Signing(#[from] hemtt_signing::Error),
#[error("Version Error: {0}")]
Expand All @@ -75,8 +75,6 @@ pub enum Error {
Io(#[from] std::io::Error),
#[error("serde_json Error: {0}")]
SerdeJson(#[from] serde_json::Error),
#[error("Toml Error: {0}")]
Toml(#[from] toml::de::Error),
#[error("Vfs Error {0}")]
Vfs(Box<vfs::VfsError>),
#[error("Walkdir Error: {0}")]
Expand Down
1 change: 0 additions & 1 deletion bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ extern crate tracing;

pub mod addons;
pub mod commands;
pub mod config;
pub mod context;
pub mod error;
pub mod executor;
Expand Down
4 changes: 2 additions & 2 deletions bin/src/modules/rapifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Module for Rapifier {
}
}

pub fn rapify(path: WorkspacePath, _ctx: &Context) -> (Vec<String>, Result<(), Error>) {
pub fn rapify(path: WorkspacePath, ctx: &Context) -> (Vec<String>, Result<(), Error>) {
let processed = match Processor::run(&path) {
Ok(processed) => processed,
Err(e) => {
Expand All @@ -92,7 +92,7 @@ pub fn rapify(path: WorkspacePath, _ctx: &Context) -> (Vec<String>, Result<(), E
messages.push(warning);
}
}
let configreport = parse(&processed);
let configreport = parse(Some(ctx.config()), &processed);
if let Err(errors) = configreport {
for e in &errors {
eprintln!("{e}");
Expand Down
1 change: 1 addition & 0 deletions libs/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ bench = false
hemtt-common = { path = "../common", version = "1.0.0" }

hemtt-preprocessor = { path = "../preprocessor", version = "1.0.0" }
hemtt-project = { path = "../project", version = "1.0.0" }

ariadne = { workspace = true }
byteorder = { workspace = true }
Expand Down
Loading

0 comments on commit d389e49

Please sign in to comment.