diff --git a/src/API/APIClient.cpp b/src/API/APIClient.cpp index e20031f..f1062aa 100644 --- a/src/API/APIClient.cpp +++ b/src/API/APIClient.cpp @@ -64,16 +64,15 @@ json APIClient::Get(std::string aEndpoint, std::string aParameters) if (cachedResponse != nullptr) { long long diff = Timestamp() - cachedResponse->Timestamp; - Log(("APIClient::" + BaseURL).c_str(), "diff: %d | curr: %d | cache: %d", diff, Timestamp(), cachedResponse->Timestamp); if (diff < CacheLifetime && cachedResponse->Content != nullptr) { - LogDebug(("APIClient::" + BaseURL).c_str(), "Cached message %d seconds old. Reading from cache.", diff); + //LogDebug(("APIClient::" + BaseURL).c_str(), "Cached message %d seconds old. Reading from cache.", diff); return cachedResponse->Content; } else { - LogDebug(("APIClient::" + BaseURL).c_str(), "Cached message %d seconds old. CacheLifetime %d. Queueing request.", diff, CacheLifetime); + //LogDebug(("APIClient::" + BaseURL).c_str(), "Cached message %d seconds old. CacheLifetime %d. Queueing request.", diff, CacheLifetime); } } @@ -295,8 +294,16 @@ void APIClient::ProcessRequests() std::filesystem::path normalizedPath = GetNormalizedPath(request.Query); + auto it = ResponseCache.find(normalizedPath); + + if (it != ResponseCache.end()) + { + delete it->second; + ResponseCache.erase(normalizedPath); + } + ResponseCache.insert({ normalizedPath, cached }); - + // notify caller *(request.IsComplete) = true; request.CV->notify_all(); diff --git a/src/GUI/GUI.cpp b/src/GUI/GUI.cpp index 6c7856c..7ed6662 100644 --- a/src/GUI/GUI.cpp +++ b/src/GUI/GUI.cpp @@ -661,11 +661,6 @@ namespace GUI /* add shortcut */ QuickAccess::AddShortcut(QA_MENU, ICON_NEXUS, ICON_NEXUS_HOVER, KB_MENU, "Nexus Menu"); - if (IsUpdateAvailable && NotifyChangelog) - { - QuickAccess::NotifyShortcut(QA_MENU); - } - if (!Settings::Settings.is_null()) { if (!Settings::Settings[OPT_ACCEPTEULA].is_null()) @@ -761,6 +756,11 @@ namespace GUI } } + if (IsUpdateAvailable && NotifyChangelog) + { + QuickAccess::NotifyShortcut(QA_MENU); + } + if (!HasAcceptedEULA) { EULAModal* eulaModal = new EULAModal(); diff --git a/src/GUI/Widgets/Changelog/ChangelogWindow.cpp b/src/GUI/Widgets/Changelog/ChangelogWindow.cpp index 82c94a6..3898f35 100644 --- a/src/GUI/Widgets/Changelog/ChangelogWindow.cpp +++ b/src/GUI/Widgets/Changelog/ChangelogWindow.cpp @@ -8,6 +8,8 @@ #include "Paths.h" #include "State.h" +#include "GUI/Widgets/QuickAccess/QuickAccess.h" + #include "imgui.h" #include "imgui_extensions.h" @@ -25,6 +27,8 @@ namespace GUI { if (!Visible) { return; } + QuickAccess::SetNotificationShortcut(QA_MENU, false); + ImGui::SetNextWindowSize(ImVec2(chlWidth * ImGui::GetFontSize(), chlHeight * ImGui::GetFontSize()), ImGuiCond_FirstUseEver); if (ImGui::Begin(Name.c_str(), &Visible, ImGuiWindowFlags_NoCollapse)) { @@ -33,11 +37,11 @@ namespace GUI if (IsUpdateAvailable) { - ImGui::TextDisabled("These changes take effect the next time you start the game:"); + ImGui::TextColored(ImVec4(0, 0.580f, 1, 1), "These changes take effect the next time you start the game:"); } else { - ImGui::TextDisabled("Last changes:"); + ImGui::Text("Last changes:"); } if (!ChangelogText.empty()) diff --git a/src/GUI/Widgets/QuickAccess/QuickAccess.cpp b/src/GUI/Widgets/QuickAccess/QuickAccess.cpp index ac37eda..ebe7620 100644 --- a/src/GUI/Widgets/QuickAccess/QuickAccess.cpp +++ b/src/GUI/Widgets/QuickAccess/QuickAccess.cpp @@ -301,6 +301,21 @@ namespace GUI } QuickAccess::Mutex.unlock(); } + void SetNotificationShortcut(const char* aIdentifier, bool aState) + { + std::string str = aIdentifier; + + QuickAccess::Mutex.lock(); + { + auto it = Registry.find(str); + + if (it != Registry.end()) + { + it->second.HasNotification = aState; + } + } + QuickAccess::Mutex.unlock(); + } void AddSimpleShortcut(const char* aIdentifier, GUI_RENDER aShortcutRenderCallback) { diff --git a/src/GUI/Widgets/QuickAccess/QuickAccess.h b/src/GUI/Widgets/QuickAccess/QuickAccess.h index b0f4754..0b9f47e 100644 --- a/src/GUI/Widgets/QuickAccess/QuickAccess.h +++ b/src/GUI/Widgets/QuickAccess/QuickAccess.h @@ -41,6 +41,7 @@ namespace GUI void AddShortcut(const char* aIdentifier, const char* aTextureIdentifier, const char* aTextureHoverIdentifier, const char* aKeybindIdentifier, const char* aTooltipText); void RemoveShortcut(const char* aIdentifier); void NotifyShortcut(const char* aIdentifier); + void SetNotificationShortcut(const char* aIdentifier, bool aState); void AddSimpleShortcut(const char* aIdentifier, GUI_RENDER aShortcutRenderCallback); void RemoveSimpleShortcut(const char* aIdentifier); diff --git a/src/Loader/Loader.cpp b/src/Loader/Loader.cpp index 98ea1fa..519e6a0 100644 --- a/src/Loader/Loader.cpp +++ b/src/Loader/Loader.cpp @@ -1087,7 +1087,7 @@ namespace Loader } } - LogInfo(CH_LOADER, "Successfully installed %s.", aAddon->Name); + LogInfo(CH_LOADER, "Successfully installed %s.", aAddon->Name.c_str()); } AddonAPI* GetAddonAPI(int aVersion) diff --git a/src/Textures/TextureLoader.cpp b/src/Textures/TextureLoader.cpp index 94f6005..9a957d1 100644 --- a/src/Textures/TextureLoader.cpp +++ b/src/Textures/TextureLoader.cpp @@ -43,7 +43,7 @@ namespace TextureLoader void LoadFromFile(const char* aIdentifier, const char* aFilename, TEXTURES_RECEIVECALLBACK aCallback) { - LogInfo(CH_TEXTURES, "TextureLoader::LoadFromFile(aIdentifier: %s, aFilename: %s, aCallback: %p)", aIdentifier, aFilename, aCallback); + //LogInfo(CH_TEXTURES, "TextureLoader::LoadFromFile(aIdentifier: %s, aFilename: %s, aCallback: %p)", aIdentifier, aFilename, aCallback); std::string str = aIdentifier; @@ -72,7 +72,7 @@ namespace TextureLoader } void LoadFromResource(const char* aIdentifier, unsigned aResourceID, HMODULE aModule, TEXTURES_RECEIVECALLBACK aCallback) { - LogInfo(CH_TEXTURES, "TextureLoader::LoadFromResource(aIdentifier: %s, aResourceID: %u, aModule: %p, aCallback: %p)", aIdentifier, aResourceID, aModule, aCallback); + //LogInfo(CH_TEXTURES, "TextureLoader::LoadFromResource(aIdentifier: %s, aResourceID: %u, aModule: %p, aCallback: %p)", aIdentifier, aResourceID, aModule, aCallback); std::string str = aIdentifier; @@ -123,7 +123,7 @@ namespace TextureLoader } void LoadFromURL(const char* aIdentifier, const char* aRemote, const char* aEndpoint, TEXTURES_RECEIVECALLBACK aCallback) { - LogInfo(CH_TEXTURES, "TextureLoader::LoadFromURL(aIdentifier: %s, aRemote: %s, aEndpoint: %s, aCallback: %p)", aIdentifier, aRemote, aEndpoint, aCallback); + //LogInfo(CH_TEXTURES, "TextureLoader::LoadFromURL(aIdentifier: %s, aRemote: %s, aEndpoint: %s, aCallback: %p)", aIdentifier, aRemote, aEndpoint, aCallback); std::string str = aIdentifier; @@ -170,7 +170,7 @@ namespace TextureLoader } void LoadFromMemory(const char* aIdentifier, void* aData, size_t aSize, TEXTURES_RECEIVECALLBACK aCallback) { - LogInfo(CH_TEXTURES, "TextureLoader::LoadFromMemory(aIdentifier: %s, aData: %p, aSize: %u, aCallback: %p)", aIdentifier, aData, aSize, aCallback); + //LogInfo(CH_TEXTURES, "TextureLoader::LoadFromMemory(aIdentifier: %s, aData: %p, aSize: %u, aCallback: %p)", aIdentifier, aData, aSize, aCallback); std::string str = aIdentifier; @@ -207,7 +207,7 @@ namespace TextureLoader { std::string str = aIdentifier; - LogDebug(CH_TEXTURES, "Queued %s", str.c_str()); + //LogDebug(CH_TEXTURES, "Queued %s", str.c_str()); QueuedTexture raw{}; raw.Identifier = str;