From 196c45ef1ee40bf22f4937bd33dd11b5bd12c17d Mon Sep 17 00:00:00 2001 From: nerdspice <49222223+nerdspice@users.noreply.github.com> Date: Thu, 12 Oct 2023 08:58:00 -0400 Subject: [PATCH] add --new option and color --- include/config.h | 1 + main.cpp | 1 + src/downloader.cpp | 8 +++++++- src/website.cpp | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/config.h b/include/config.h index 9ac33aa..4e2fd60 100644 --- a/include/config.h +++ b/include/config.h @@ -235,6 +235,7 @@ class Config bool bDownload; bool bRepair; bool bUpdated; + bool bNew; bool bCheckStatus; bool bShowWishlist; bool bNotifications; diff --git a/main.cpp b/main.cpp index 8ead453..fdafe34 100644 --- a/main.cpp +++ b/main.cpp @@ -208,6 +208,7 @@ int main(int argc, char *argv[]) ("create-xml", bpo::value(&Globals::globalConfig.sXMLFile)->implicit_value("automatic"), "Create GOG XML for file\n\"automatic\" to enable automatic XML creation") ("notifications", bpo::value(&Globals::globalConfig.bNotifications)->zero_tokens()->default_value(false), "Check notifications") ("updated", bpo::value(&Globals::globalConfig.bUpdated)->zero_tokens()->default_value(false), "List/download only games with update flag set") + ("new", bpo::value(&Globals::globalConfig.bNew)->zero_tokens()->default_value(false), "List/download only games with new flag set") ("clear-update-flags", bpo::value(&bClearUpdateNotifications)->zero_tokens()->default_value(false), "Clear update notification flags") ("check-orphans", bpo::value(&Globals::globalConfig.sOrphanRegex)->implicit_value(""), check_orphans_text.c_str()) ("status", bpo::value(&Globals::globalConfig.bCheckStatus)->zero_tokens()->default_value(false), "Show status of files\n\nOutput format:\nstatuscode gamename filename filesize filehash\n\nStatus codes:\nOK - File is OK\nND - File is not downloaded\nMD5 - MD5 mismatch, different version\nFS - File size mismatch, incomplete download\n\nSee also --no-fast-status-check option") diff --git a/src/downloader.cpp b/src/downloader.cpp index dc13aff..dd0b11e 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -533,8 +533,14 @@ int Downloader::listGames() if (gameItems[i].updates > 0) { gamename += " [" + std::to_string(gameItems[i].updates) + "]"; + std::string color = gameItems[i].isnew ? "01;34" : "32"; if (Globals::globalConfig.bColor) - gamename = "\033[32m" + gamename + "\033[0m"; + gamename = "\033[" + color + "m" + gamename + "\033[0m"; + } + else + { + if (Globals::globalConfig.bColor && gameItems[i].isnew) + gamename = "\033[01;34m" + gamename + "\033[0m"; } std::cout << gamename << std::endl; for (unsigned int j = 0; j < gameItems[i].dlcnames.size(); ++j) diff --git a/src/website.cpp b/src/website.cpp index 3bc6139..ca83c20 100644 --- a/src/website.cpp +++ b/src/website.cpp @@ -141,6 +141,7 @@ std::vector Website::getGames() gameItem game; game.name = product["slug"].asString(); game.id = product["id"].isInt() ? std::to_string(product["id"].asInt()) : product["id"].asString(); + game.isnew = product["isNew"].asBool(); if (product.isMember("updates")) { @@ -175,6 +176,10 @@ std::vector Website::getGames() if (product["worksOn"]["Linux"].asBool()) platform |= GlobalConstants::PLATFORM_LINUX; + // Skip if not new and flag is set + if (Globals::globalConfig.bNew && !game.isnew) + continue; + // Skip if platform doesn't match if (Globals::globalConfig.bPlatformDetection && !(platform & Globals::globalConfig.dlConf.iInstallerPlatform)) continue;