-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
289 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.vscode | ||
/.idea | ||
/bin | ||
/Downloader/src/dlver.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule imgui
updated
10 files
+4 −0 | backends/imgui_impl_glfw.cpp | |
+14 −9 | backends/imgui_impl_opengl3.cpp | |
+55 −1 | docs/CHANGELOG.txt | |
+1 −1 | examples/example_win32_opengl3/main.cpp | |
+169 −71 | imgui.cpp | |
+56 −22 | imgui.h | |
+108 −46 | imgui_demo.cpp | |
+31 −10 | imgui_internal.h | |
+2 −2 | imgui_tables.cpp | |
+8 −8 | imgui_widgets.cpp |
Submodule utility
updated
5 files
+2 −1 | CMakeLists.txt | |
+3 −2 | Event.hpp | |
+2 −1 | README.md | |
+78 −0 | ThreadPool.hpp | |
+21 −0 | examples/ThreadPool.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "pch.h" | ||
#include "VersionManager.h" | ||
|
||
#include "network/HttpRequest.h" | ||
#include "utils/gui_utils.h" | ||
|
||
void misc::VersionManager::CheckUpdate(const bool force) { | ||
static bool checked = false; | ||
static bool inCheck = false; | ||
|
||
if (inCheck) | ||
return; | ||
|
||
if (checked && !force) | ||
return; | ||
|
||
GET_LANG(); | ||
inCheck = true; | ||
GuiHelper::ShowInfoToast(lang.getTextCStr("VersionChecking")); | ||
static std::vector<std::string> headers = { | ||
"Accept: application/vnd.github+json", | ||
"X-GitHub-Api-Version: 2022-11-28" | ||
}; | ||
net::curl_get_async( | ||
"https://api.github.com/repos/KyuubiRan/BeatmapDownloader/releases/latest", headers, | ||
[&](const int code, std::string &res) { | ||
if (code != 200) { | ||
LOGW("Cannot check update, response code: %d, response body: %s", code, res.c_str()); | ||
GuiHelper::ShowWarnToast(lang.getTextCStr("VersionCheckFailed"), code); | ||
inCheck = false; | ||
return; | ||
} | ||
nlohmann::json j = nlohmann::json::parse(res); | ||
s_LatestVersionName = j["name"]; | ||
const std::string vc = j["tag_name"]; | ||
s_LatestVersionCode = std::stoi(vc); | ||
checked = true; | ||
inCheck = false; | ||
if (IsLatest()) { | ||
LOGI("Downloader is up to date"); | ||
GuiHelper::ShowSuccessToast(lang.getTextCStr("VersionIsLatest")); | ||
} else { | ||
LOGI("Found new version: %s(%d)", s_LatestVersionName.c_str(), s_LatestVersionCode); | ||
GuiHelper::ShowInfoToast(lang.getTextCStr("FoundNewVersion"), s_LatestVersionName.c_str(), | ||
s_LatestVersionCode); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
// dlver.h will auto generated by `update_version.py` before build | ||
// if you cant run this script, please copy this code to src/dlver.h | ||
/* | ||
#pragma once | ||
#define LATEST_UPDATE_TIMESTAMP 0 | ||
#define DOWNLOADER_VERSION 0 | ||
#define DOWNLOADER_VERSION_STR "unknown" | ||
*/ | ||
#include "dlver.h" | ||
|
||
namespace misc { | ||
class VersionManager { | ||
inline static int s_LatestVersionCode = 0; | ||
inline static std::string s_LatestVersionName = "unknown"; | ||
|
||
public: | ||
static void CheckUpdate(bool force = false); | ||
static int GetLatestVersionCode() { return s_LatestVersionCode; } | ||
static std::string_view GetLatestVersionName() { return s_LatestVersionName; } | ||
|
||
static int GetCurrentVersionCode() { return DOWNLOADER_VERSION; } | ||
static std::string_view GetCurrentVersionName() { return DOWNLOADER_VERSION_STR; } | ||
|
||
static bool IsLatest() { | ||
return GetCurrentVersionCode() >= s_LatestVersionCode; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include <ThreadPool.hpp> | ||
|
||
namespace glob { | ||
inline static thread::ThreadPool s_ThreadPool{}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.