Skip to content

Commit 98b7b58

Browse files
committed
Use ModIdentifier newtype for gameplay affecting status cache key
1 parent 5e0ceee commit 98b7b58

File tree

6 files changed

+22
-90
lines changed

6 files changed

+22
-90
lines changed

Cargo.lock

+3-80
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ uasset_utils = { git = "https://github.com/trumank/uasset_utils" }
7979
unreal_asset = { git = "https://github.com/trumank/unrealmodding", branch = "patches" }
8080
url = "2.5.0"
8181
zip = { version = "0.6.6", default-features = false, features = ["aes-crypto", "deflate", "time"] }
82-
serde_json_any_key = "2.0.0"
8382
repak = { workspace = true, features = ["oodle", "oodle_loader"] }
8483

8584
[target.'cfg(target_env = "msvc")'.dependencies]

mint_lib/src/mod_info.rs

+10
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ impl ModResolution {
103103
}
104104
}
105105

106+
/// Mod identifier used for tracking gameplay affecting status.
107+
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
108+
pub struct ModIdentifier(String);
109+
110+
impl ModIdentifier {
111+
pub fn new(s: &str) -> Self {
112+
Self(s.to_string())
113+
}
114+
}
115+
106116
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
107117
pub enum GameplayAffecting {
108118
/// Sandbox, approved and unknown mods

src/gui/message.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use crate::{
2424
state::ModConfig,
2525
};
2626

27+
use mint_lib::mod_info::ModIdentifier;
28+
2729
use super::SelfUpdateProgress;
2830
use super::{
2931
request_counter::{RequestCounter, RequestID},
@@ -218,7 +220,7 @@ impl Integrate {
218220
for (res, stat) in resolution_gameplay_affecting_map {
219221
app.state
220222
.store
221-
.update_gameplay_affecting_status(&res, *stat);
223+
.update_gameplay_affecting_status(ModIdentifier::new(&res.url), *stat);
222224
}
223225

224226
info!("integration complete");

src/gui/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ impl App {
560560
}
561561

562562
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
563-
if let Some(status) = self.state.store.get_gameplay_affecting_status(&info.resolution) {
563+
if let Some(status) = self.state.store.get_gameplay_affecting_status(&ModIdentifier::new(&info.resolution.url)) {
564564
match status {
565565
GameplayAffecting::Yes => {
566566
mk_searchable_tag(

src/providers/mod.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::write_file;
88

99
use anyhow::{Context, Result};
1010
use serde::{Deserialize, Serialize};
11-
use serde_json_any_key::*;
1211
use tokio::sync::mpsc::Sender;
1312
use tracing::{debug, info};
1413

@@ -32,8 +31,7 @@ pub struct Cache {
3231
#[obake(cfg(">=0.0.0"))]
3332
cache: HashMap<String, Box<dyn ModProviderCache>>,
3433
#[obake(cfg(">=0.1.0"))]
35-
#[serde(with = "any_key_map")]
36-
gameplay_affecting_cache: HashMap<ModResolution, GameplayAffecting>,
34+
gameplay_affecting_cache: HashMap<ModIdentifier, GameplayAffecting>,
3735
}
3836

3937
#[derive(Debug, Serialize, Deserialize)]
@@ -315,20 +313,20 @@ impl ModStore {
315313
.get_version_name(spec, self.cache.clone())
316314
}
317315

318-
pub fn update_gameplay_affecting_status(&self, res: &ModResolution, stat: GameplayAffecting) {
316+
pub fn update_gameplay_affecting_status(&self, id: ModIdentifier, stat: GameplayAffecting) {
319317
self.cache
320318
.write()
321319
.unwrap()
322320
.gameplay_affecting_cache
323-
.insert(res.clone(), stat);
321+
.insert(id, stat);
324322
}
325323

326-
pub fn get_gameplay_affecting_status(&self, res: &ModResolution) -> Option<GameplayAffecting> {
324+
pub fn get_gameplay_affecting_status(&self, id: &ModIdentifier) -> Option<GameplayAffecting> {
327325
self.cache
328326
.read()
329327
.unwrap()
330328
.gameplay_affecting_cache
331-
.get(res)
329+
.get(id)
332330
.copied()
333331
}
334332
}

0 commit comments

Comments
 (0)