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