diff --git a/src/backend/model/gaming/Game.h b/src/backend/model/gaming/Game.h index b70688b92..b167e50e7 100644 --- a/src/backend/model/gaming/Game.h +++ b/src/backend/model/gaming/Game.h @@ -47,6 +47,7 @@ struct GameData { QStringList genres; QStringList tags; + QString age_rating; short player_count = 1; float rating = 0.0; QDate release_date; @@ -78,6 +79,7 @@ class Game : public QObject { GETTER(const QString&, sortBy, sort_by) GETTER(const QString&, summary, summary) GETTER(const QString&, description, description) + GETTER(const QString&, ageRating, age_rating) GETTER(const QDate&, releaseDate, release_date) GETTER(int, playerCount, player_count) GETTER(float, rating, rating) @@ -109,6 +111,7 @@ class Game : public QObject { SETTER(QString, SortBy, sort_by) SETTER(QString, Summary, summary) SETTER(QString, Description, description) + SETTER(QString, AgeRating, age_rating) SETTER(QDate, ReleaseDate, release_date) SETTER(QString, LaunchCmd, launch_params.launch_cmd) @@ -139,6 +142,7 @@ class Game : public QObject { Q_PROPERTY(QString sortBy READ sortBy CONSTANT) Q_PROPERTY(QString summary READ summary CONSTANT) Q_PROPERTY(QString description READ description CONSTANT) + Q_PROPERTY(QString age READ ageRating CONSTANT) Q_PROPERTY(QDate release READ releaseDate CONSTANT) Q_PROPERTY(int players READ playerCount CONSTANT) Q_PROPERTY(float rating READ rating CONSTANT) diff --git a/src/backend/providers/pegasus_metadata/PegasusMetadata.cpp b/src/backend/providers/pegasus_metadata/PegasusMetadata.cpp index 769eaefa3..8a8617309 100644 --- a/src/backend/providers/pegasus_metadata/PegasusMetadata.cpp +++ b/src/backend/providers/pegasus_metadata/PegasusMetadata.cpp @@ -75,6 +75,7 @@ enum class GameAttrib : unsigned char { PLAYER_COUNT, SHORT_DESC, LONG_DESC, + AGE, RELEASE, RATING, LAUNCH_CMD, @@ -131,6 +132,7 @@ Metadata::Metadata(QString log_tag) { QStringLiteral("summary"), GameAttrib::SHORT_DESC }, { QStringLiteral("description"), GameAttrib::LONG_DESC }, { QStringLiteral("release"), GameAttrib::RELEASE }, + { QStringLiteral("age"), GameAttrib::AGE }, { QStringLiteral("rating"), GameAttrib::RATING }, // sort title variations { QStringLiteral("sorttitle"), GameAttrib::SORT_BY }, @@ -369,6 +371,13 @@ void Metadata::apply_game_entry(ParserState& ps, const metafile::Entry& entry, S ps.cur_game->setDescription(std::move(text)); } break; + case GameAttrib::AGE: + { + QString text = metafile::merge_lines(entry.values); + replace_newlines(text); + ps.cur_game->setAgeRating(std::move(text)); + } + break; case GameAttrib::RELEASE: { const auto rx_match = rx_date.match(first_line_of(ps, entry)); diff --git a/tests/backend/providers/pegasus/data/with_meta/metadata.pegasus.txt b/tests/backend/providers/pegasus/data/with_meta/metadata.pegasus.txt index c9957a684..d62cce1dd 100644 --- a/tests/backend/providers/pegasus/data/with_meta/metadata.pegasus.txt +++ b/tests/backend/providers/pegasus/data/with_meta/metadata.pegasus.txt @@ -26,6 +26,7 @@ genres: genre with spaces sortby: Game IX players: 2-4 +age: 13+ rating: 80% # repeating single keys will overwrite release: 1998 diff --git a/tests/backend/providers/pegasus/data/with_meta/metadata.txt b/tests/backend/providers/pegasus/data/with_meta/metadata.txt index 8db796756..a34adc9c7 100644 --- a/tests/backend/providers/pegasus/data/with_meta/metadata.txt +++ b/tests/backend/providers/pegasus/data/with_meta/metadata.txt @@ -20,6 +20,7 @@ genres: genre1, genre2, players: 2-4 file: subdir/game_in_subdir.ext +age: 13+ rating: 80% # repeating keys will overwrite previous values release: 1998 diff --git a/tests/backend/providers/pegasus/test_PegasusProvider.cpp b/tests/backend/providers/pegasus/test_PegasusProvider.cpp index 31e4b6ca1..cfe6e9ecb 100644 --- a/tests/backend/providers/pegasus/test_PegasusProvider.cpp +++ b/tests/backend/providers/pegasus/test_PegasusProvider.cpp @@ -255,6 +255,7 @@ void test_PegasusProvider::with_meta() QCOMPARE(game.genreListConst(), QStringList({"genre1", "genre2", "genre with spaces"})); QCOMPARE(game.playerCount(), 4); QCOMPARE(game.releaseDate(), QDate(1998, 5, 1)); + QCOMPARE(game.ageRating(), QStringLiteral("13+")); QCOMPARE(game.summary(), QStringLiteral("something short here")); QCOMPARE(game.description(), QStringLiteral("a very long\n\ndescription")); QCOMPARE(game.rating(), 0.8f);