veloren_voxygen/credits.rs
1use common::assets;
2use serde::Deserialize;
3use std::path::PathBuf;
4
5// NOTE: we are free to split the manifest asset format and the format processed
6// for display into separate structs but they happen to be identical for now
7
8// See best practices for attribution: https://wiki.creativecommons.org/wiki/Best_practices_for_attribution
9
10#[expect(dead_code)]
11#[derive(Clone, Deserialize)]
12pub struct Art {
13 /// Name of the art.
14 pub name: String,
15 /// Link if the asset is from or derived from an external source that can be
16 /// linked.
17 #[serde(default)]
18 pub source_link: String,
19 /// List of authors for the credited art, field can be omitted if there are
20 /// no authors to list.
21 #[serde(default)]
22 pub authors: Vec<String>,
23 /// Relative path to the asset from the top level asset folder.
24 /// Used so we can keep track of the actual files, but not currently used in
25 /// the credits screen to display anything.
26 pub asset_path: PathBuf,
27 /// License that the art is under, can be omitted, if not present assumed to
28 /// be GPL3.
29 #[serde(default)]
30 pub license: String,
31 /// Link to the license if one is available.
32 #[serde(default)]
33 pub license_link: String,
34 /// Notes on any modifications that were made if the original work was
35 /// modified by us.
36 #[serde(default)]
37 pub modifications: String,
38 /// Any additional attribution notes that may be desired and/or required by
39 /// the respective license that can't be conveyed or would be awkward to
40 /// convey with the other provided fields.
41 #[serde(default)]
42 pub notes: String,
43}
44
45#[derive(Clone, Deserialize)]
46pub struct Contributor {
47 pub name: String,
48 /// Short note or description of the contributions
49 /// Optional, can be left empty/omitted
50 #[serde(default)]
51 pub contributions: String,
52}
53
54/// Credits manifest processed into format for display in the UI
55#[derive(Clone, Deserialize)]
56pub struct Credits {
57 pub music: Vec<Art>,
58 pub fonts: Vec<Art>,
59 pub other_art: Vec<Art>,
60 pub contributors: Vec<Contributor>,
61 // TODO: include credits for dependencies where the license requires attribution?
62}
63
64impl assets::Asset for Credits {
65 type Loader = assets::RonLoader;
66
67 const EXTENSION: &'static str = "ron";
68}
69
70#[cfg(test)]
71mod tests {
72 use super::*;
73
74 #[test]
75 fn all_art_asset_paths_exists() {
76 use assets::AssetExt;
77 let credits = Credits::load_expect_cloned("credits");
78
79 credits
80 .music
81 .into_iter()
82 .chain(credits.fonts)
83 .chain(credits.other_art)
84 .for_each(|art| {
85 assert!(
86 assets::ASSETS_PATH.join(&art.asset_path).exists(),
87 "assets/{} does not exist!",
88 art.asset_path.display(),
89 );
90 });
91 }
92}