Add authors and license to model file

This commit is contained in:
Epicalert 2021-11-13 00:43:45 +08:00
parent 678393ccb1
commit 972a0cc9b9
No known key found for this signature in database
GPG key ID: CAA46F858D0979BD
4 changed files with 37 additions and 4 deletions

View file

@ -6,7 +6,6 @@
## models ## models
- clipping (alpha stencil) - clipping (alpha stencil)
- model copyright and authors
## Bugs ## Bugs
- incorrect appdata location on Windows - incorrect appdata location on Windows

View file

@ -1,10 +1,13 @@
[format] [format]
version_major = 0 version_major = 0
version_minor = 2 version_minor = 5
[model_info] [model_info]
name = "Richard Stallman" name = "Richard Stallman"
version = "1.0" version = "1.1"
artist = "Ruben Rodriguez"
modeler = "Epicalert"
license = "CC-BY-4.0"
[[part]] [[part]]
texture = "bg.webp" texture = "bg.webp"

View file

@ -12,7 +12,7 @@
#define BUFFER_SIZE_TEXTURE 16777220 // 16 MiB #define BUFFER_SIZE_TEXTURE 16777220 // 16 MiB
#define SUPPORTED_MODEL_MAJOR 0 #define SUPPORTED_MODEL_MAJOR 0
#define SUPPORTED_MODEL_MINOR 4 #define SUPPORTED_MODEL_MINOR 5
void textureFromArchive(zip_t* archive, const char* path, ModelPart* part, size_t slot, std::string triggerName) { void textureFromArchive(zip_t* archive, const char* path, ModelPart* part, size_t slot, std::string triggerName) {
zip_file_t* textureFile = zip_fopen(archive, path, 0); zip_file_t* textureFile = zip_fopen(archive, path, 0);
@ -90,7 +90,29 @@ Model::Model(const char* path) {
} else { } else {
name = nameResult.second; name = nameResult.second;
} }
// get authors
// artist (or photographer if image)
auto artistResult = modelInfo->getString("artist");
if (artistResult.first) {
artist = artistResult.second;
} }
// rigger/modeler
auto modelerResult = modelInfo->getString("modeler");
if (modelerResult.first) {
modeler = modelerResult.second;
}
// get license (SPDX identifier, if not present file is assumed to be proprietary)
auto licenseResult = modelInfo->getString("license");
if (licenseResult.first) {
license = licenseResult.second;
}
}
// parse parts // parse parts
auto partsDescArray = modelDesc.table->getArray("part"); auto partsDescArray = modelDesc.table->getArray("part");
@ -212,3 +234,7 @@ std::string Model::getName() {
return name; return name;
} }
std::string Model::getInfoString() {
return fmt::format("{}\n{}\n\nArtist: {}\nModeler: {}",
name, license, artist, modeler);
}

View file

@ -10,6 +10,10 @@ class Model {
std::string name; std::string name;
std::string artist;
std::string modeler;
std::string license;
public: public:
Model(const char* path); Model(const char* path);
@ -18,6 +22,7 @@ class Model {
void updateTransforms(struct FaceData faceData); void updateTransforms(struct FaceData faceData);
std::string getName(); std::string getName();
std::string getInfoString();
}; };
#endif #endif