Skip to content
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
12 changes: 6 additions & 6 deletions flake.lock

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

25 changes: 12 additions & 13 deletions src/gui/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ pub struct FetchModProgress {

impl FetchModProgress {
fn receive(self, app: &mut App) {
if let Some(MessageHandle { rid, state, .. }) = &mut app.integrate_rid {
if *rid == self.rid {
state.insert(self.spec, self.progress);
}
if let Some(MessageHandle { rid, state, .. }) = &mut app.integrate_rid
&& *rid == self.rid
{
state.insert(self.spec, self.progress);
}
}
}
Expand Down Expand Up @@ -339,11 +339,10 @@ impl CheckUpdates {
.tag_name
.strip_prefix('v')
.map(semver::Version::parse),
) {
if release_version > version {
app.available_update = Some(release);
app.show_update_time = Some(SystemTime::now());
}
) && release_version > version
{
app.available_update = Some(release);
app.show_update_time = Some(SystemTime::now());
}
}
Err(e) => tracing::warn!("failed to fetch update {e}"),
Expand Down Expand Up @@ -594,10 +593,10 @@ pub struct FetchSelfUpdateProgress {

impl FetchSelfUpdateProgress {
fn receive(self, app: &mut App) {
if let Some(MessageHandle { rid, state, .. }) = &mut app.self_update_rid {
if *rid == self.rid {
*state = self.progress;
}
if let Some(MessageHandle { rid, state, .. }) = &mut app.self_update_rid
&& *rid == self.rid
{
*state = self.progress;
}
}
}
Expand Down
130 changes: 58 additions & 72 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl LastAction {
let duration = Instant::now().duration_since(self.timestamp);
let seconds = duration.as_secs();
if seconds < 60 {
format!("{}s ago", seconds)
format!("{seconds}s ago")
} else if seconds < 3600 {
format!("{}m ago", seconds / 60)
} else {
Expand Down Expand Up @@ -456,22 +456,22 @@ impl App {
ui.add_enabled(false, icon);
}

if mc.enabled {
if let Some(req) = &self.integrate_rid {
match req.state.get(&mc.spec) {
Some(SpecFetchProgress::Progress { progress, size }) => {
ui.add(
egui::ProgressBar::new(*progress as f32 / *size as f32)
.show_percentage()
.desired_width(100.0),
);
}
Some(SpecFetchProgress::Complete) => {
ui.add(egui::ProgressBar::new(1.0).desired_width(100.0));
}
None => {
ui.spinner();
}
if mc.enabled
&& let Some(req) = &self.integrate_rid
{
match req.state.get(&mc.spec) {
Some(SpecFetchProgress::Progress { progress, size }) => {
ui.add(
egui::ProgressBar::new(*progress as f32 / *size as f32)
.show_percentage()
.desired_width(100.0),
);
}
Some(SpecFetchProgress::Complete) => {
ui.add(egui::ProgressBar::new(1.0).desired_width(100.0));
}
None => {
ui.spinner();
}
}
}
Expand Down Expand Up @@ -1033,15 +1033,14 @@ impl App {
if is_committed(&res) {
try_save = true;
}
if ui.button("browse").clicked() {
if let Some(fsd_pak) = rfd::FileDialog::new()
if ui.button("browse").clicked()
&& let Some(fsd_pak) = rfd::FileDialog::new()
.add_filter("DRG Pak", &["pak"])
.pick_file()
{
window.drg_pak_path = fsd_pak.to_string_lossy().to_string();
window.drg_pak_path_err = None;
}
}
});
ui.end_row();

Expand Down Expand Up @@ -1287,8 +1286,8 @@ impl App {
.show(ui, |ui| {
const AMBER: Color32 = Color32::from_rgb(255, 191, 0);

if let Some(conflicting_mods) = &report.conflicting_mods {
if !conflicting_mods.is_empty() {
if let Some(conflicting_mods) = &report.conflicting_mods
&& !conflicting_mods.is_empty() {
CollapsingHeader::new(
RichText::new("⚠ Mods(s) with conflicting asset modifications detected")
.color(AMBER),
Expand All @@ -1298,8 +1297,7 @@ impl App {
conflicting_mods.iter().for_each(|(path, mods)| {
CollapsingHeader::new(
RichText::new(format!(
"⚠ Conflicting modification of asset `{}`",
path
"⚠ Conflicting modification of asset `{path}`"
))
.color(AMBER),
)
Expand All @@ -1314,10 +1312,9 @@ impl App {
});
});
}
}

if let Some(asset_register_bin_mods) = &report.asset_register_bin_mods {
if !asset_register_bin_mods.is_empty() {
if let Some(asset_register_bin_mods) = &report.asset_register_bin_mods
&& !asset_register_bin_mods.is_empty() {
CollapsingHeader::new(
RichText::new("ℹ Mod(s) with `AssetRegistry.bin` included detected")
.color(Color32::LIGHT_BLUE),
Expand All @@ -1342,10 +1339,9 @@ impl App {
);
});
}
}

if let Some(shader_file_mods) = &report.shader_file_mods {
if !shader_file_mods.is_empty() {
if let Some(shader_file_mods) = &report.shader_file_mods
&& !shader_file_mods.is_empty() {
CollapsingHeader::new(
RichText::new(
"⚠ Mods(s) with shader files included detected",
Expand All @@ -1372,10 +1368,9 @@ impl App {
);
});
}
}

if let Some(outdated_pak_version_mods) = &report.outdated_pak_version_mods {
if !outdated_pak_version_mods.is_empty() {
if let Some(outdated_pak_version_mods) = &report.outdated_pak_version_mods
&& !outdated_pak_version_mods.is_empty() {
CollapsingHeader::new(
RichText::new(
"⚠ Mod(s) with outdated pak version detected",
Expand All @@ -1397,10 +1392,9 @@ impl App {
);
});
}
}

if let Some(empty_archive_mods) = &report.empty_archive_mods {
if !empty_archive_mods.is_empty() {
if let Some(empty_archive_mods) = &report.empty_archive_mods
&& !empty_archive_mods.is_empty() {
CollapsingHeader::new(
RichText::new(
"⚠ Mod(s) with empty archives detected",
Expand All @@ -1420,10 +1414,9 @@ impl App {
});
});
}
}

if let Some(archive_with_only_non_pak_files_mods) = &report.archive_with_only_non_pak_files_mods {
if !archive_with_only_non_pak_files_mods.is_empty() {
if let Some(archive_with_only_non_pak_files_mods) = &report.archive_with_only_non_pak_files_mods
&& !archive_with_only_non_pak_files_mods.is_empty() {
CollapsingHeader::new(
RichText::new(
"⚠ Mod(s) with only non-`.pak` files detected",
Expand All @@ -1443,10 +1436,9 @@ impl App {
});
});
}
}

if let Some(archive_with_multiple_paks_mods) = &report.archive_with_multiple_paks_mods {
if !archive_with_multiple_paks_mods.is_empty() {
if let Some(archive_with_multiple_paks_mods) = &report.archive_with_multiple_paks_mods
&& !archive_with_multiple_paks_mods.is_empty() {
CollapsingHeader::new(
RichText::new(
"⚠ Mod(s) with multiple `.pak`s detected",
Expand All @@ -1464,10 +1456,9 @@ impl App {
});
});
}
}

if let Some(non_asset_file_mods) = &report.non_asset_file_mods {
if !non_asset_file_mods.is_empty() {
if let Some(non_asset_file_mods) = &report.non_asset_file_mods
&& !non_asset_file_mods.is_empty() {
CollapsingHeader::new(
RichText::new(
"⚠ Mod(s) with non-asset files detected",
Expand All @@ -1492,10 +1483,9 @@ impl App {
});
});
}
}

if let Some(split_asset_pairs_mods) = &report.split_asset_pairs_mods {
if !split_asset_pairs_mods.is_empty() {
if let Some(split_asset_pairs_mods) = &report.split_asset_pairs_mods
&& !split_asset_pairs_mods.is_empty() {
CollapsingHeader::new(
RichText::new(
"⚠ Mod(s) with split {uexp, uasset} pairs detected",
Expand Down Expand Up @@ -1527,10 +1517,9 @@ impl App {
});
});
}
}

if let Some(unmodified_game_assets_mods) = &report.unmodified_game_assets_mods {
if !unmodified_game_assets_mods.is_empty() {
if let Some(unmodified_game_assets_mods) = &report.unmodified_game_assets_mods
&& !unmodified_game_assets_mods.is_empty() {
CollapsingHeader::new(
RichText::new(
"⚠ Mod(s) with unmodified game assets detected",
Expand All @@ -1555,7 +1544,6 @@ impl App {
});
});
}
}
});
} else {
ui.spinner();
Expand Down Expand Up @@ -1740,27 +1728,26 @@ impl eframe::App for App {
&& self.self_update_rid.is_none()
&& self.state.config.drg_pak_path.is_some(),
|ui| {
if let Some(args) = &self.args {
if ui
if let Some(args) = &self.args
&& ui
.button("Launch game")
.on_hover_ui(|ui| {
for arg in args {
ui.label(arg);
}
})
.clicked()
{
let args = args.clone();
std::thread::spawn(move || {
let mut iter = args.iter();
std::process::Command::new(iter.next().unwrap())
.args(iter)
.spawn()
.unwrap()
.wait()
.unwrap();
});
}
{
let args = args.clone();
std::thread::spawn(move || {
let mut iter = args.iter();
std::process::Command::new(iter.next().unwrap())
.args(iter)
.spawn()
.unwrap()
.wait()
.unwrap();
});
}

ui.add_enabled_ui(self.state.config.drg_pak_path.is_some(), |ui| {
Expand Down Expand Up @@ -1874,18 +1861,17 @@ impl eframe::App for App {
if ui.button("⚙").on_hover_text("Open settings").clicked() {
self.settings_window = Some(WindowSettings::new(&self.state));
}
if let Some(available_update) = &self.available_update {
if ui
if let Some(available_update) = &self.available_update
&& ui
.button(egui::RichText::new("\u{26A0}").color(ui.visuals().warn_fg_color))
.on_hover_text(format!(
"Update available: {}\n{}",
available_update.tag_name, available_update.html_url
))
.clicked()
{
ui.ctx()
.open_url(egui::OpenUrl::new_tab(&available_update.html_url));
}
{
ui.ctx()
.open_url(egui::OpenUrl::new_tab(&available_update.html_url));
}
ui.with_layout(egui::Layout::left_to_right(Align::TOP), |ui| {
if let Some(last_action) = &self.last_action {
Expand Down
Loading
Loading