diff --git a/CMakeLists.txt b/CMakeLists.txt index 392e0bd..b29cd88 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.2) +project(SearchHistory VERSION 1.0.3) add_library(${PROJECT_NAME} SHARED src/main.cpp diff --git a/README.md b/README.md index a39c891..9151110 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ A mod that allows you to view your search history. ## Features - A button in the level search menu that allows you to view your search history - A popup that shows your search history, including a filter text box, and entries that can be used to search again +- Incognito mode, which allows you to search without saving to your search history ## Credits - [Kabslantivity](https://gdbrowser.com/u/17597362) - Initial idea for the mod diff --git a/about.md b/about.md index f9b48b0..8adf304 100644 --- a/about.md +++ b/about.md @@ -4,6 +4,7 @@ A mod that allows you to view your search history. ## Features - A button in the level search menu that allows you to view your search history - A popup that shows your search history, including a filter text box, and entries that can be used to search again +- Incognito mode, which allows you to search without saving to your search history ## Credits - [Kabslantivity](user:17597362) - Initial idea for the mod @@ -11,5 +12,5 @@ A mod that allows you to view your search history. - [hiimjustin000](user:7466002) - Creator of the mod ## Gallery -![Search History Popup 1](hiimjustin000.search_history/image1.png?scale=0.6)\ -![Search History Popup 2](hiimjustin000.search_history/image2.png?scale=0.6) \ No newline at end of file +![Search History Popup 1](hiimjustin000.search_history/image1.png?scale=0.625)\ +![Search History Popup 2](hiimjustin000.search_history/image2.png?scale=0.625) \ No newline at end of file diff --git a/changelog.md b/changelog.md index 557efc9..7c5adff 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # Search History Changelog +## v1.0.3 (2024-08-20) +- Added incognito mode + ## v1.0.2 (2024-08-08) - Removed the search confirmation popup diff --git a/mod.json b/mod.json index 07dbe01..2d7fa45 100644 --- a/mod.json +++ b/mod.json @@ -5,7 +5,7 @@ "win": "2.206", "mac": "2.206" }, - "version": "v1.0.2", + "version": "v1.0.3", "id": "hiimjustin000.search_history", "name": "Search History", "developer": "hiimjustin000", @@ -29,6 +29,12 @@ } }, "settings": { + "incognito-mode": { + "name": "Incognito Mode", + "description": "Whether or not to hide the search history button and not save any searches.", + "type": "bool", + "default": false + }, "12-hour-time": { "name": "12-Hour Time", "description": "Whether or not to use 12-hour time on the time label.", diff --git a/src/SearchHistory.cpp b/src/SearchHistory.cpp index eb10576..1bfbe99 100644 --- a/src/SearchHistory.cpp +++ b/src/SearchHistory.cpp @@ -4,13 +4,13 @@ void SearchHistory::add(GJSearchObject* search, time_t time, int type) { auto history = Mod::get()->getSavedValue>("search-history"); auto difficultyStrings = search->m_difficulty != "-" ? string::split(search->m_difficulty, ",") : std::vector(); - auto difficulties = std::vector(); + std::vector difficulties; for (auto const& str : difficultyStrings) { difficulties.push_back(std::stoi(str)); } auto lengthStrings = search->m_length != "-" ? string::split(search->m_length, ",") : std::vector(); - auto lengths = std::vector(); + std::vector lengths; for (auto const& str : lengthStrings) { lengths.push_back(std::stoi(str)); } @@ -42,7 +42,7 @@ void SearchHistory::add(GJSearchObject* search, time_t time, int type) { } void SearchHistory::clear() { - Mod::get()->setSavedValue("search-history", std::vector()); + Mod::get()->setSavedValue>("search-history", {}); } std::vector SearchHistory::get() { diff --git a/src/SearchHistory.hpp b/src/SearchHistory.hpp index dee2fb1..190a4af 100644 --- a/src/SearchHistory.hpp +++ b/src/SearchHistory.hpp @@ -36,15 +36,15 @@ class SearchHistory { template<> struct matjson::Serialize> { static std::vector from_json(matjson::Value const& value) { - auto vec = std::vector(); + std::vector vec; for (auto const& elem : value.as_array()) { - auto difficulties = std::vector(); + std::vector difficulties; for (auto const& e : elem["difficulties"].as_array()) { difficulties.push_back(e.as_int()); } - auto lengths = std::vector(); + std::vector lengths; for (auto const& e : elem["lengths"].as_array()) { lengths.push_back(e.as_int()); } @@ -77,15 +77,15 @@ struct matjson::Serialize> { } static matjson::Value to_json(std::vector const& vec) { - auto arr = matjson::Array(); + matjson::Array arr; for (auto const& obj : vec) { - auto difficulties = matjson::Array(); + matjson::Array difficulties; for (int const& e : obj.difficulties) { difficulties.push_back(e); } - auto lengths = matjson::Array(); + matjson::Array lengths; for (int const& e : obj.lengths) { lengths.push_back(e); } diff --git a/src/SearchHistoryNode.cpp b/src/SearchHistoryNode.cpp index 3e51b33..1fd910a 100644 --- a/src/SearchHistoryNode.cpp +++ b/src/SearchHistoryNode.cpp @@ -122,7 +122,7 @@ bool SearchHistoryNode::init(SearchHistoryObject const& object, int index, Searc addChild(difficultiesNode); for (auto difficulty : object.difficulties) { - auto difficultyFrame = std::string(); + std::string difficultyFrame; switch (difficulty) { case -1: difficultyFrame = "diffIcon_00_btn_001.png"; break; case -2: difficultyFrame = "diffIcon_06_btn_001.png"; break; @@ -142,7 +142,7 @@ bool SearchHistoryNode::init(SearchHistoryObject const& object, int index, Searc } if (type < 1) for (auto time : object.lengths) { - auto length = std::string(); + auto length = ""; switch (time) { case 0: length = "Tiny"; break; case 1: length = "Short"; break; @@ -152,7 +152,7 @@ bool SearchHistoryNode::init(SearchHistoryObject const& object, int index, Searc case 5: length = "Plat."; break; } - auto lengthLabel = CCLabelBMFont::create(length.c_str(), "bigFont.fnt"); + auto lengthLabel = CCLabelBMFont::create(length, "bigFont.fnt"); lengthLabel->setScale(0.3f); difficultiesNode->addChild(lengthLabel); } @@ -198,8 +198,14 @@ bool SearchHistoryNode::init(SearchHistoryObject const& object, int index, Searc } std::stringstream ss; - auto time = (time_t)object.time; + time_t time = object.time; + #ifdef GEODE_IS_WINDOWS + struct tm tm; + localtime_s(&tm, &time); + ss << std::put_time(&tm, h12 ? "%Y-%m-%d %I:%M:%S %p" : "%Y-%m-%d %H:%M:%S"); + #else ss << std::put_time(std::localtime(&time), h12 ? "%Y-%m-%d %I:%M:%S %p" : "%Y-%m-%d %H:%M:%S"); + #endif auto timeLabel = CCLabelBMFont::create(ss.str().c_str(), "chatFont.fnt"); timeLabel->setColor(white ? ccColor3B { 255, 255, 255 } : ccColor3B { 51, 51, 51 }); diff --git a/src/SearchHistoryPopup.cpp b/src/SearchHistoryPopup.cpp index 1309ea7..0d5b262 100644 --- a/src/SearchHistoryPopup.cpp +++ b/src/SearchHistoryPopup.cpp @@ -78,7 +78,7 @@ bool SearchHistoryPopup::setup(SearchHistoryCallback callback) { void SearchHistoryPopup::page(int p) { m_scrollLayer->m_contentLayer->removeAllChildren(); - auto history = std::vector(); + std::vector history; auto query = string::toLower(m_searchInput->getString()); for (auto const& object : SearchHistory::get()) { if (string::toLower(object.query).find(query) != std::string::npos) history.push_back(object); diff --git a/src/main.cpp b/src/main.cpp index 6b68fa1..eb39983 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,8 @@ class $modify(SHLevelSearchLayer, LevelSearchLayer) { bool init(int type) { if (!LevelSearchLayer::init(type)) return false; + if (Mod::get()->getSettingValue("incognito-mode")) return true; + auto historyButtonSprite = CircleButtonSprite::createWithSprite("SH_historyBtn_001.png"_spr); historyButtonSprite->getTopNode()->setScale(1.0f); historyButtonSprite->setScale(0.8f); @@ -64,11 +66,13 @@ class $modify(SHLevelSearchLayer, LevelSearchLayer) { void onSearch(CCObject* sender) { LevelSearchLayer::onSearch(sender); + if (Mod::get()->getSettingValue("incognito-mode")) return; SearchHistory::add(getSearchObject(SearchType::Search, m_searchInput->getString()), time(0), m_type); } void onSearchUser(CCObject* sender) { LevelSearchLayer::onSearchUser(sender); + if (Mod::get()->getSettingValue("incognito-mode")) return; SearchHistory::add(getSearchObject(SearchType::Users, m_searchInput->getString()), time(0), 2); } };