diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 301cd8c..b2bb2ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,7 @@ jobs: config: - name: Windows os: windows-latest + build-config: RelWithDebInfo - name: macOS os: macos-latest @@ -35,7 +36,7 @@ jobs: - name: Build the mod uses: geode-sdk/build-geode-mod@main with: - build-config: RelWithDebInfo + build-config: ${{ matrix.config.build-config || 'Release' }} export-pdb: true combine: true target: ${{ matrix.config.target }} diff --git a/CMakeLists.txt b/CMakeLists.txt index b29cd88..74f8ca2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64") set(CMAKE_CXX_VISIBILITY_PRESET hidden) -project(SearchHistory VERSION 1.0.3) +project(SearchHistory VERSION 1.0.4) add_library(${PROJECT_NAME} SHARED src/main.cpp diff --git a/README.md b/README.md index 9151110..ac56dd4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ A mod that allows you to view your search history. ## Credits - [Kabslantivity](https://gdbrowser.com/u/17597362) - Initial idea for the mod - [at4pm](https://gdbrowser.com/u/27791517) - Additional ideas for the mod +- [Krintop](https://gdbrowser.com/u/7242014) - Designer of the mod's button texture - [hiimjustin000](https://gdbrowser.com/u/7466002) - Creator of the mod ## Gallery diff --git a/about.md b/about.md index 8adf304..05db883 100644 --- a/about.md +++ b/about.md @@ -9,6 +9,7 @@ A mod that allows you to view your search history. ## Credits - [Kabslantivity](user:17597362) - Initial idea for the mod - [at4pm](user:27791517) - Additional ideas for the mod +- [Krintop](user:7242014) - Designer of the mod's button texture - [hiimjustin000](user:7466002) - Creator of the mod ## Gallery diff --git a/changelog.md b/changelog.md index 7c5adff..805979b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ # Search History Changelog +## v1.0.4 (2024-09-07) +- Removed properties from saved.json that are default values +- Changed the search history button texture and mod logo + ## v1.0.3 (2024-08-20) - Added incognito mode diff --git a/logo.png b/logo.png index 0fc387f..5fd11fe 100644 Binary files a/logo.png and b/logo.png differ diff --git a/mod.json b/mod.json index 2d7fa45..a6f3ef8 100644 --- a/mod.json +++ b/mod.json @@ -5,7 +5,7 @@ "win": "2.206", "mac": "2.206" }, - "version": "v1.0.3", + "version": "v1.0.4", "id": "hiimjustin000.search_history", "name": "Search History", "developer": "hiimjustin000", @@ -48,6 +48,11 @@ "default": false } }, + "links": { + "community": "https://discord.gg/QVKmbvBXA7", + "source": "https://github.com/hiimjustin000/SearchHistory", + "homepage": "https://www.hiimjustin000.com" + }, "tags": [ "enhancement", "interface", diff --git a/resources/SH_historyBtn_001.png b/resources/SH_historyBtn_001.png index 50e95e9..30665e6 100644 Binary files a/resources/SH_historyBtn_001.png and b/resources/SH_historyBtn_001.png differ diff --git a/src/SearchHistory.hpp b/src/SearchHistory.hpp index 190a4af..ea6c306 100644 --- a/src/SearchHistory.hpp +++ b/src/SearchHistory.hpp @@ -33,6 +33,8 @@ class SearchHistory { static void remove(int); }; +#define PROPERTY_OR_DEFAULT(obj, prop, isFunc, asFunc, def) (obj.contains(prop) && obj[prop].isFunc() ? obj[prop].asFunc() : def) + template<> struct matjson::Serialize> { static std::vector from_json(matjson::Value const& value) { @@ -40,36 +42,40 @@ struct matjson::Serialize> { for (auto const& elem : value.as_array()) { std::vector difficulties; - for (auto const& e : elem["difficulties"].as_array()) { - difficulties.push_back(e.as_int()); + if (elem.contains("difficulties") && elem["difficulties"].is_array()) { + for (auto const& e : elem["difficulties"].as_array()) { + difficulties.push_back(e.as_int()); + } } std::vector lengths; - for (auto const& e : elem["lengths"].as_array()) { - lengths.push_back(e.as_int()); + if (elem.contains("lengths") && elem["lengths"].is_array()) { + for (auto const& e : elem["lengths"].as_array()) { + lengths.push_back(e.as_int()); + } } vec.push_back({ - .time = (int64_t)elem["time"].as_double(), - .type = elem["type"].as_int(), - .query = elem["query"].as_string(), + .time = (int64_t)PROPERTY_OR_DEFAULT(elem, "time", is_number, as_double, 0), + .type = PROPERTY_OR_DEFAULT(elem, "type", is_number, as_int, 0), + .query = PROPERTY_OR_DEFAULT(elem, "query", is_string, as_string, ""), .difficulties = difficulties, .lengths = lengths, - .uncompleted = elem["uncompleted"].as_bool(), - .completed = elem["completed"].as_bool(), - .featured = elem["featured"].as_bool(), - .original = elem["original"].as_bool(), - .twoPlayer = elem["two-player"].as_bool(), - .coins = elem["coins"].as_bool(), - .epic = elem["epic"].as_bool(), - .legendary = elem["legendary"].as_bool(), - .mythic = elem["mythic"].as_bool(), - .song = elem["song"].as_bool(), - .customSong = elem["custom-song"].as_bool(), - .songID = elem["song-id"].as_int(), - .demonFilter = elem["demon-filter"].as_int(), - .noStar = elem["no-star"].as_bool(), - .star = elem["star"].as_bool() + .uncompleted = PROPERTY_OR_DEFAULT(elem, "uncompleted", is_bool, as_bool, false), + .completed = PROPERTY_OR_DEFAULT(elem, "completed", is_bool, as_bool, false), + .featured = PROPERTY_OR_DEFAULT(elem, "featured", is_bool, as_bool, false), + .original = PROPERTY_OR_DEFAULT(elem, "original", is_bool, as_bool, false), + .twoPlayer = PROPERTY_OR_DEFAULT(elem, "two-player", is_bool, as_bool, false), + .coins = PROPERTY_OR_DEFAULT(elem, "coins", is_bool, as_bool, false), + .epic = PROPERTY_OR_DEFAULT(elem, "epic", is_bool, as_bool, false), + .legendary = PROPERTY_OR_DEFAULT(elem, "legendary", is_bool, as_bool, false), + .mythic = PROPERTY_OR_DEFAULT(elem, "mythic", is_bool, as_bool, false), + .song = PROPERTY_OR_DEFAULT(elem, "song", is_bool, as_bool, false), + .customSong = PROPERTY_OR_DEFAULT(elem, "custom-song", is_bool, as_bool, false), + .songID = PROPERTY_OR_DEFAULT(elem, "song-id", is_number, as_int, 0), + .demonFilter = PROPERTY_OR_DEFAULT(elem, "demon-filter", is_number, as_int, 0), + .noStar = PROPERTY_OR_DEFAULT(elem, "no-star", is_bool, as_bool, false), + .star = PROPERTY_OR_DEFAULT(elem, "star", is_bool, as_bool, false) }); } @@ -90,28 +96,31 @@ struct matjson::Serialize> { lengths.push_back(e); } - arr.push_back(matjson::Object { - { "time", obj.time }, - { "type", obj.type }, - { "query", obj.query }, - { "difficulties", difficulties }, - { "lengths", lengths }, - { "uncompleted", obj.uncompleted }, - { "completed", obj.completed }, - { "featured", obj.featured }, - { "original", obj.original }, - { "two-player", obj.twoPlayer }, - { "coins", obj.coins }, - { "epic", obj.epic }, - { "legendary", obj.legendary }, - { "mythic", obj.mythic }, - { "song", obj.song }, - { "custom-song", obj.customSong }, - { "song-id", obj.songID }, - { "demon-filter", obj.demonFilter }, - { "no-star", obj.noStar }, - { "star", obj.star } - }); + matjson::Object historyObject; + historyObject["time"] = obj.time; + historyObject["type"] = obj.type; + if (!obj.query.empty()) historyObject["query"] = obj.query; + if (!difficulties.empty()) historyObject["difficulties"] = difficulties; + if (!lengths.empty()) historyObject["lengths"] = lengths; + if (obj.uncompleted) historyObject["uncompleted"] = obj.uncompleted; + if (obj.completed) historyObject["completed"] = obj.completed; + if (obj.featured) historyObject["featured"] = obj.featured; + if (obj.original) historyObject["original"] = obj.original; + if (obj.twoPlayer) historyObject["two-player"] = obj.twoPlayer; + if (obj.coins) historyObject["coins"] = obj.coins; + if (obj.epic) historyObject["epic"] = obj.epic; + if (obj.legendary) historyObject["legendary"] = obj.legendary; + if (obj.mythic) historyObject["mythic"] = obj.mythic; + if (obj.song) { + historyObject["song"] = obj.song; + if (obj.customSong) historyObject["custom-song"] = obj.customSong; + historyObject["song-id"] = obj.songID; + } + if (obj.demonFilter != 0) historyObject["demon-filter"] = obj.demonFilter; + if (obj.noStar) historyObject["no-star"] = obj.noStar; + if (obj.star) historyObject["star"] = obj.star; + + arr.push_back(historyObject); } return arr;