Skip to content

Commit

Permalink
feat: add genres, developer, publisher to db
Browse files Browse the repository at this point in the history
  • Loading branch information
goweiwen committed Jun 3, 2024
1 parent 655a399 commit afc6568
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 25 deletions.
2 changes: 1 addition & 1 deletion crates/allium-launcher/src/consoles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ mod tests {

#[test]
fn test_config() {
env::set_var("ALLIUM_BASE_DIR", "../static/.allium");
env::set_var("ALLIUM_BASE_DIR", "../../static/.allium");

let mut mapper = ConsoleMapper::new();
mapper.load_config().unwrap();
Expand Down
12 changes: 12 additions & 0 deletions crates/allium-launcher/src/entry/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ impl Directory {
core: None,
rating: game.rating,
release_date: game.release_date.map(|d| d.date()),
developer: game.developer,
publisher: game.publisher,
genres: game.genres,
}))
});

Expand Down Expand Up @@ -236,6 +239,9 @@ impl Directory {
core: game.core.clone(),
rating: game.rating,
release_date: game.release_date,
developer: game.developer.clone(),
publisher: game.publisher.clone(),
genres: game.genres.clone(),
}),
Entry::App(_) | Entry::Directory(_) => None,
})
Expand Down Expand Up @@ -284,6 +290,9 @@ impl Directory {
core: game.core.clone(),
rating: game.rating,
release_date: game.release_date,
developer: game.developer.clone(),
publisher: game.publisher.clone(),
genres: game.genres.clone(),
}),
Entry::App(_) | Entry::Directory(_) => None,
})
Expand Down Expand Up @@ -362,6 +371,9 @@ impl Directory {
core: game.core,
rating: game.rating,
release_date: game.release_date,
developer: game.developer,
publisher: game.publisher,
genres: game.genres,
}),
_ => None,
})
Expand Down
15 changes: 15 additions & 0 deletions crates/allium-launcher/src/entry/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ pub struct Game {
pub rating: Option<u8>,
/// Release date of the game, used to sort.
pub release_date: Option<NaiveDate>,
/// Developer of the game.
pub developer: Option<String>,
/// Publisher of the game.
pub publisher: Option<String>,
/// List of genres of the game.
pub genres: Vec<String>,
}

impl Game {
Expand All @@ -57,6 +63,9 @@ impl Game {
core: None,
rating: None,
release_date: None,
developer: None,
publisher: None,
genres: Vec::new(),
}
}

Expand Down Expand Up @@ -87,6 +96,9 @@ impl Game {
core: game.core,
rating: game.rating,
release_date: game.release_date,
developer: game.developer,
publisher: game.publisher,
genres: game.genres,
}
}

Expand Down Expand Up @@ -143,6 +155,9 @@ impl From<Game> for NewGame {
core: game.core,
rating: game.rating,
release_date: game.release_date,
developer: game.developer,
publisher: game.publisher,
genres: game.genres,
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions crates/allium-launcher/src/entry/gamelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ pub struct Game {
pub image: Option<PathBuf>,
#[serde(default, deserialize_with = "optional_path_buf_deserializer")]
pub thumbnail: Option<PathBuf>,
#[serde(default, rename = "genre", deserialize_with = "genre_deserializer")]
pub genres: Vec<String>,
#[serde(default, deserialize_with = "rating_deserializer")]
pub rating: Option<u8>,
#[serde(
Expand All @@ -31,6 +29,10 @@ pub struct Game {
deserialize_with = "optional_naivedatetime_deserializer"
)]
pub release_date: Option<NaiveDateTime>,
pub developer: Option<String>,
pub publisher: Option<String>,
#[serde(default, rename = "genre", deserialize_with = "genre_deserializer")]
pub genres: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
15 changes: 14 additions & 1 deletion crates/allium-launcher/src/entry/test/gamelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
<path>./Test & Test.gba</path>
<name>Test & Test</name>
<thumbnail>./Imgs/covers/Test & Test.jpg</thumbnail>
<rating/>
<rating>0.8</rating>
<releasedate>20020228T000000</releasedate>
<developer>Developer</developer>
<publisher>Publisher</publisher>
<genres>Action, Adventure</genres>
</game>
<game>
<path/>
<name/>
<thumbnail/>
<rating/>
<releasedate/>
<developer/>
<publisher/>
<genres/>
</game>
</gameList>
3 changes: 3 additions & 0 deletions crates/allium-launcher/src/view/recents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ impl Sort for RecentsSort {
core: game.core,
rating: game.rating,
release_date: game.release_date,
developer: game.developer,
publisher: game.publisher,
genres: game.genres,
})
})
.collect())
Expand Down
Loading

0 comments on commit afc6568

Please sign in to comment.