Compare commits

..

No commits in common. "e1277783a34b39a2ada46ada0fd233c477412ca8" and "6edd8e92c9b785121f8aaac268fe3070e05cacb9" have entirely different histories.

10 changed files with 525 additions and 611 deletions

1049
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -9,10 +9,10 @@ members = [
"lib/serde_sjson", "lib/serde_sjson",
"lib/luajit2-sys", "lib/luajit2-sys",
] ]
exclude = ["lib/color-eyre"]
[patch.crates-io] [patch.crates-io]
color-eyre = { path = "lib/color-eyre" } color-eyre = { path = "lib/color-eyre" }
ansi-parser = { path = "lib/ansi-parser" }
[profile.dev.package.backtrace] [profile.dev.package.backtrace]
opt-level = 3 opt-level = 3

View file

@ -286,18 +286,12 @@ pub(crate) async fn load_initial(path: PathBuf, is_default: bool) -> Result<Init
let game_info = tokio::task::spawn_blocking(dtmt_shared::collect_game_info) let game_info = tokio::task::spawn_blocking(dtmt_shared::collect_game_info)
.await .await
.wrap_err("Failed to spawn task to collect Steam game info")?; .wrap_err("Failed to collect Steam game info")?;
let game_info = match game_info { {
Ok(game_info) => game_info, if config.game_dir.is_none() && game_info.is_none() {
Err(err) => { tracing::error!("No Game Directory set. Head to the 'Settings' tab to set it manually",);
tracing::error!("Failed to collect game info: {:?}", err);
None
} }
};
if config.game_dir.is_none() && game_info.is_none() {
tracing::error!("No Game Directory set. Head to the 'Settings' tab to set it manually",);
} }
let mod_dir = config.data_dir.join("mods"); let mod_dir = config.data_dir.join("mods");

View file

@ -723,14 +723,6 @@ pub(crate) async fn deploy_mods(state: ActionState) -> Result<()> {
) )
.wrap_err("Failed to gather deployment information")?; .wrap_err("Failed to gather deployment information")?;
let game_info = match game_info {
Ok(game_info) => game_info,
Err(err) => {
tracing::error!("Failed to collect game info: {:#?}", err);
None
}
};
tracing::debug!(?game_info, ?deployment_info); tracing::debug!(?game_info, ?deployment_info);
if let Some(game_info) = game_info { if let Some(game_info) = game_info {

View file

@ -1,5 +1,6 @@
#![recursion_limit = "256"] #![recursion_limit = "256"]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(arc_unwrap_or_clone)]
#![feature(iterator_try_collect)] #![feature(iterator_try_collect)]
#![windows_subsystem = "windows"] #![windows_subsystem = "windows"]

View file

@ -42,7 +42,6 @@ impl Lens<State, Option<Arc<ModInfo>>> for SelectedModLens {
/// A Lens that maps an `im::Vector<T>` to `im::Vector<(usize, T)>`, /// A Lens that maps an `im::Vector<T>` to `im::Vector<(usize, T)>`,
/// where each element in the destination vector includes its index in the /// where each element in the destination vector includes its index in the
/// source vector. /// source vector.
#[allow(dead_code)]
pub(crate) struct IndexedVectorLens; pub(crate) struct IndexedVectorLens;
impl<T: Data> Lens<Vector<T>, Vector<(usize, T)>> for IndexedVectorLens { impl<T: Data> Lens<Vector<T>, Vector<(usize, T)>> for IndexedVectorLens {

View file

@ -69,10 +69,23 @@ pub mod gruvbox_dark {
} }
pub trait ColorExt { pub trait ColorExt {
fn lighten(&self, fac: f32) -> Self;
fn darken(&self, fac: f32) -> Self; fn darken(&self, fac: f32) -> Self;
} }
impl ColorExt for Color { impl ColorExt for Color {
fn lighten(&self, fac: f32) -> Self {
let (r, g, b, a) = self.as_rgba();
let rgb = Rgb::from(r as f32, g as f32, b as f32);
let rgb = rgb.lighten(fac);
Self::rgba(
rgb.get_red() as f64,
rgb.get_green() as f64,
rgb.get_blue() as f64,
a,
)
}
fn darken(&self, fac: f32) -> Self { fn darken(&self, fac: f32) -> Self {
let (r, g, b, a) = self.as_rgba(); let (r, g, b, a) = self.as_rgba();
let rgb = Rgb::from(r as f32, g as f32, b as f32); let rgb = Rgb::from(r as f32, g as f32, b as f32);

View file

@ -2,11 +2,16 @@ use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use druid::text::Formatter; use druid::text::Formatter;
use druid::{Data, Widget};
pub mod border; pub mod border;
pub mod button; pub mod button;
pub mod controller; pub mod controller;
pub trait ExtraWidgetExt<T: Data>: Widget<T> + Sized + 'static {}
impl<T: Data, W: Widget<T> + 'static> ExtraWidgetExt<T> for W {}
pub(crate) struct PathBufFormatter; pub(crate) struct PathBufFormatter;
impl PathBufFormatter { impl PathBufFormatter {

@ -1 +1 @@
Subproject commit b40962a61c748756d7da293d9fff26aca019603e Subproject commit 0fa05eba9954be223b06468c8760b97e660f9941

View file

@ -1,15 +1,12 @@
use std::path::PathBuf; use std::path::PathBuf;
use color_eyre::eyre::{OptionExt as _, WrapErr as _}; mod log;
use color_eyre::Result;
pub use log::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use steamlocate::SteamDir; use steamlocate::SteamDir;
use time::OffsetDateTime; use time::OffsetDateTime;
pub use log::*;
mod log;
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct ModConfigResources { pub struct ModConfigResources {
pub init: PathBuf, pub init: PathBuf,
@ -77,23 +74,25 @@ pub struct GameInfo {
pub last_updated: OffsetDateTime, pub last_updated: OffsetDateTime,
} }
pub fn collect_game_info() -> Result<Option<GameInfo>> { pub fn collect_game_info() -> Option<GameInfo> {
let dir = SteamDir::locate().wrap_err("Failed to locate Steam installation")?; let mut dir = if let Some(dir) = SteamDir::locate() {
dir
let found = dir } else {
.find_app(STEAMAPP_ID) tracing::debug!("Failed to locate Steam installation");
.wrap_err("Failed to look up game by Steam app ID")?; return None;
let Some((app, _)) = found else {
return Ok(None);
}; };
let last_updated = app let found = dir
.last_updated .app(&STEAMAPP_ID)
.ok_or_eyre("Missing field 'last_updated'")?; .and_then(|app| app.last_updated.map(|v| (app.path.clone(), v)));
Ok(Some(GameInfo { let Some((path, last_updated)) = found else {
path: app.install_dir.into(), tracing::debug!("Found Steam, but failed to find game installation");
return None;
};
Some(GameInfo {
path,
last_updated: last_updated.into(), last_updated: last_updated.into(),
})) })
} }