Skip to content

Commit 6989905

Browse files
authored
Merge pull request #157 from IwantHappiness/main
2 parents ec3d41c + fc7870a commit 6989905

File tree

8 files changed

+19
-56
lines changed

8 files changed

+19
-56
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dfint-installer"
33
version = "0.4.6"
4-
edition = "2021"
4+
edition = "2024"
55
build = "build.rs"
66

77
[profile.release]

src/app.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,10 @@ impl eframe::App for App {
212212
self.hook_metadata.manifest.df == self.bin.checksum,
213213
self.hook_metadata.manifest.checksum == self.hook_checksum,
214214
self.hook_metadata.manifest.checksum == 0,
215-
self.hook_metadata.vec_manifests.len() == 0,
215+
self.hook_metadata.vec_manifests.is_empty(),
216216
) {
217217
(_, _, true, true) => (format!("✖ {}", t!("hook data was not loaded")), COLOR_ERROR),
218-
(false, _, _, _) => (
219-
format!("✖ {}", t!("this DF version is not supported")),
220-
COLOR_ERROR,
221-
),
218+
(false, _, _, _) => (format!("✖ {}", t!("this DF version is not supported")),COLOR_ERROR),
222219
(true, true, _, _) => (format!("✅ {}", t!("up-to-date")), COLOR_UP_TO_DATE),
223220
(true, false, _, _) => (format!("⚠ {}", t!("update available")), COLOR_UPDATE_AVAILABLE),
224221
};
@@ -249,13 +246,12 @@ impl eframe::App for App {
249246
item.language.clone(),
250247
)
251248
.clicked()
249+
&& self.selected_language != "None"
252250
{
253-
if self.selected_language != "None" {
254-
self
255-
.dict_metadata
256-
.pick_language_by_name(self.selected_language.clone())
257-
}
258-
};
251+
self
252+
.dict_metadata
253+
.pick_language_by_name(self.selected_language.clone())
254+
}
259255
}
260256
});
261257
ui.label(self.dict_checksum.to_string());
@@ -268,12 +264,9 @@ impl eframe::App for App {
268264
let (text, color) = match (
269265
self.dict_metadata.manifest.checksum == self.dict_checksum,
270266
self.selected_language == "None",
271-
self.dict_metadata.vec_manifests.len() == 0,
267+
self.dict_metadata.vec_manifests.is_empty(),
272268
) {
273-
(_, _, true) => (
274-
format!("✖ {}", t!("dictionary data was not loaded")),
275-
COLOR_ERROR,
276-
),
269+
(_, _, true) => (format!("✖ {}", t!("dictionary data was not loaded")), COLOR_ERROR),
277270
(true, false, false) => (format!("✅ {}", t!("up-to-date")), COLOR_UP_TO_DATE),
278271
(false, false, false) => (format!("⚠ {}", t!("update available")), COLOR_UPDATE_AVAILABLE),
279272
(_, true, false) => (format!("⚠ {}", t!("choose language")), COLOR_CHOOSE_LANGUAGE),

src/df_binary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Default for DfBinary {
4545

4646
impl std::fmt::Display for DfBinary {
4747
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
48-
std::write!(f, "{}", self.path.as_path().display().to_string())
48+
std::write!(f, "{}", self.path.as_path().display())
4949
}
5050
}
5151

@@ -76,7 +76,7 @@ impl DfBinary {
7676
}
7777
}
7878

79-
fn os(path: &PathBuf) -> OS {
79+
fn os(path: &Path) -> OS {
8080
if path.file_name() == Some(OsStr::new("Dwarf Fortress.exe")) {
8181
OS::Windows
8282
} else {

src/dict_metadata.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,12 @@ impl Default for Manifest {
2323
}
2424
}
2525

26+
#[derive(Default)]
2627
pub struct DictMetadata {
2728
pub manifest: Manifest,
2829
pub vec_manifests: Vec<Manifest>,
2930
}
3031

31-
impl Default for DictMetadata {
32-
fn default() -> Self {
33-
Self {
34-
manifest: Manifest::default(),
35-
vec_manifests: vec![],
36-
}
37-
}
38-
}
39-
4032
impl DictMetadata {
4133
pub async fn from_url(url: &str, pick_language: Option<String>) -> Result<Self> {
4234
let manifests: Vec<Manifest> = ureq::get(url).call()?.into_json()?;

src/hook_metadata.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Result;
22

3-
#[derive(Debug, Serialize, Deserialize, Clone)]
3+
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
44
pub struct Manifest {
55
pub df: u32,
66
pub checksum: u32,
@@ -10,33 +10,12 @@ pub struct Manifest {
1010
pub dfhooks: String,
1111
}
1212

13-
impl Default for Manifest {
14-
fn default() -> Self {
15-
Self {
16-
df: 0,
17-
checksum: 0,
18-
lib: "".to_string(),
19-
config: "".to_string(),
20-
offsets: "".to_string(),
21-
dfhooks: "".to_string(),
22-
}
23-
}
24-
}
25-
13+
#[derive(Default)]
2614
pub struct HookMetadata {
2715
pub manifest: Manifest,
2816
pub vec_manifests: Vec<Manifest>,
2917
}
3018

31-
impl Default for HookMetadata {
32-
fn default() -> Self {
33-
Self {
34-
manifest: Manifest::default(),
35-
vec_manifests: vec![],
36-
}
37-
}
38-
}
39-
4019
impl HookMetadata {
4120
pub async fn from_url(url: &str, pick_df_checksum: Option<u32>) -> Result<Self> {
4221
let manifests: Vec<Manifest> = ureq::get(url).call()?.into_json()?;

src/logic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl App {
327327
}
328328

329329
pub fn remove_hook_data(&self) {
330-
let _ = std::fs::write(self.bin.dir.join(PATH_FONT), &ORIGINAL_FONT);
330+
let _ = std::fs::write(self.bin.dir.join(PATH_FONT), ORIGINAL_FONT);
331331
let _ = std::fs::remove_file(self.bin.lib_path.clone());
332332
let _ = std::fs::remove_dir_all(self.bin.dir.join("dfint-data"));
333333
}

src/persistent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Store {
2626
}
2727

2828
pub fn save(&self) -> Result<()> {
29-
let _ = std::fs::write(PATH_CACHE_FILE, serde_json::to_string_pretty(self)?)?;
29+
std::fs::write(PATH_CACHE_FILE, serde_json::to_string_pretty(self)?)?;
3030
Ok(())
3131
}
3232

src/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn checksum_for_files(vec: Vec<PathBuf>) -> Result<u32> {
1616

1717
pub fn scan_df() -> Option<PathBuf> {
1818
let current = std::env::current_dir().unwrap();
19-
let pathes = vec![
19+
let pathes = [
2020
current.join("Dwarf Fortress.exe"),
2121
current.join("dwarfort"),
2222
PathBuf::from("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Dwarf Fortress\\Dwarf Fortress.exe"),
@@ -29,8 +29,7 @@ pub async fn is_df_running() -> bool {
2929
System::new_all()
3030
.processes()
3131
.values()
32-
.find(|val: &&Process| ["Dwarf Fortress.exe", "dwarfort", "Dwarf Fortress."].contains(&val.name()))
33-
.is_some()
32+
.any(|val: &Process| ["Dwarf Fortress.exe", "dwarfort", "Dwarf Fortress."].contains(&val.name()))
3433
}
3534

3635
pub async fn download_to_file(url: String, file: PathBuf) -> Result<()> {

0 commit comments

Comments
 (0)