Compare commits
No commits in common. "d0716d624281b35365040e3b65faa3ac24945286" and "14c5a76891a0bef6248eb5d50f3b5dc06b0cc466" have entirely different histories.
d0716d6242
...
14c5a76891
10 changed files with 4 additions and 168 deletions
4
.gitmodules
vendored
4
.gitmodules
vendored
|
@ -30,7 +30,3 @@
|
|||
path = third-party/cpr
|
||||
url = https://github.com/whoshuu/cpr
|
||||
branch = master
|
||||
[submodule "json.hpp"]
|
||||
path = third-party/json
|
||||
url = https://github.com/nlohmann/json
|
||||
branch = master
|
||||
|
|
|
@ -92,7 +92,4 @@ set(CPR_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|||
set(CMAKE_USE_LIBSSH2 OFF CACHE BOOL "" FORCE) # For some reason, even when HTTP_ONLY is set to ON, libcurl will try to link to libssh2.
|
||||
add_subdirectory(third-party/cpr EXCLUDE_FROM_ALL)
|
||||
|
||||
set(JSON_BuildTests OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(third-party/json)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
|
|
@ -78,6 +78,5 @@ target_link_libraries(MassBuilderSaveTool PRIVATE
|
|||
efsw
|
||||
zip
|
||||
cpr::cpr
|
||||
nlohmann_json::nlohmann_json
|
||||
imm32
|
||||
wtsapi32)
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
|
||||
#include <cpr/cpr.h>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <windef.h>
|
||||
#include <winuser.h>
|
||||
#include <processthreadsapi.h>
|
||||
|
@ -135,11 +133,6 @@ SaveTool::SaveTool(const Arguments& arguments):
|
|||
}
|
||||
|
||||
initialiseConfiguration();
|
||||
|
||||
if(_checkUpdatesOnStartup) {
|
||||
_thread = std::thread{[this]{ checkForUpdates(); }};
|
||||
_queue.addToast(Toast::Type::Default, "Checking for updates...");
|
||||
}
|
||||
}
|
||||
|
||||
SaveTool::~SaveTool() {
|
||||
|
@ -293,67 +286,7 @@ void SaveTool::initEvent(SDL_Event& event) {
|
|||
void SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||
_thread.join();
|
||||
|
||||
cpr::Response r{std::move(*static_cast<cpr::Response*>(event.user.data1))};
|
||||
delete static_cast<cpr::Response*>(event.user.data1);
|
||||
|
||||
if(r.elapsed > 10.0) {
|
||||
_queue.addToast(Toast::Type::Error, "The request timed out.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(r.status_code != 200) {
|
||||
_queue.addToast(Toast::Type::Error, Utility::formatString("The request failed with error code {}: {}", r.status_code, r.reason));
|
||||
return;
|
||||
}
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
json response = json::parse(r.text);
|
||||
|
||||
struct Version {
|
||||
explicit Version(const std::string& str) {
|
||||
std::size_t start_point = 0;
|
||||
|
||||
if(str[0] == 'v') {
|
||||
start_point++;
|
||||
}
|
||||
|
||||
major = std::atoi(str.c_str() + start_point);
|
||||
start_point = str.find('.', start_point) + 1;
|
||||
minor = std::atoi(str.c_str() + start_point);
|
||||
start_point = str.find('.', start_point) + 1;
|
||||
patch = std::atoi(str.c_str() + start_point);
|
||||
}
|
||||
Int major;
|
||||
Int minor;
|
||||
Int patch;
|
||||
|
||||
bool operator==(const Version& other) const {
|
||||
return (major == other.major) && (minor == other.minor) && (patch == other.patch);
|
||||
}
|
||||
bool operator>(const Version& other) const {
|
||||
return ( major * 10000 + minor * 100 + patch) >
|
||||
(other.major * 10000 + other.minor * 100 + other.patch);
|
||||
}
|
||||
};
|
||||
|
||||
static const Version current_ver{SAVETOOL_VERSION};
|
||||
Version latest_ver{response[0]["tag_name"]};
|
||||
|
||||
if(latest_ver == current_ver) {
|
||||
_queue.addToast(Toast::Type::Success, "The application is already up to date.");
|
||||
}
|
||||
else if(latest_ver > current_ver) {
|
||||
_queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information.",
|
||||
std::chrono::milliseconds{5000});
|
||||
_updateAvailable = true;
|
||||
_latestVersion = Utility::formatString("{}.{}.{}", latest_ver.major, latest_ver.minor, latest_ver.patch);
|
||||
_releaseLink = response[0]["html_url"];
|
||||
_downloadLink = response[0]["assets"][0]["browser_download_url"];
|
||||
}
|
||||
else if(current_ver > latest_ver) {
|
||||
_queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???");
|
||||
}
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
void SaveTool::initialiseConfiguration() {
|
||||
|
@ -661,13 +594,10 @@ void SaveTool::checkGameState() {
|
|||
}
|
||||
|
||||
void SaveTool::checkForUpdates() {
|
||||
cpr::Response r = cpr::Get(cpr::Url{"https://williamjcm.ovh/git/api/v1/repos/williamjcm/MassBuilderSaveTool/releases"},
|
||||
cpr::Parameters{{"limit", "1"}}, cpr::Timeout{10000});
|
||||
// TODO: implement
|
||||
|
||||
SDL_Event event;
|
||||
SDL_zero(event);
|
||||
event.type = _updateEventId;
|
||||
event.user.code = r.status_code;
|
||||
event.user.data1 = new cpr::Response{std::move(r)};
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
#include "../ProfileManager/ProfileManager.h"
|
||||
#include "../MassManager/MassManager.h"
|
||||
#include "../ToastQueue/ToastQueue.h"
|
||||
|
||||
using namespace Corrade;
|
||||
using namespace Magnum;
|
||||
|
@ -162,8 +161,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
|||
bool _metricsWindow{false};
|
||||
#endif
|
||||
|
||||
ToastQueue _queue;
|
||||
|
||||
std::thread _thread; // used for threaded operations such as profile manager init or update checking.
|
||||
|
||||
UnsignedInt _initEventId;
|
||||
|
@ -199,9 +196,4 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
|||
|
||||
bool _checkUpdatesOnStartup{true};
|
||||
bool _unsafeMode{false};
|
||||
|
||||
bool _updateAvailable{false};
|
||||
std::string _latestVersion;
|
||||
std::string _releaseLink;
|
||||
std::string _downloadLink;
|
||||
};
|
||||
|
|
|
@ -251,58 +251,6 @@ void SaveTool::drawAbout() {
|
|||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if(ImGui::TreeNodeEx("C++ Requests (cpr)", ImGuiTreeNodeFlags_SpanAvailWidth)) {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
const char* cpr_website = "https://whoshuu.github.io/cpr/";
|
||||
ImGui::Text(ICON_FA_GLOBE " %s", cpr_website);
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("Copy to clipboard")) {
|
||||
ImGui::SetClipboardText(cpr_website);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("Open in browser")) {
|
||||
openUri(cpr_website);
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted("Licence: MIT");
|
||||
|
||||
static const auto cpr_licence = _rs.get("LICENSE.cpr");
|
||||
if(ImGui::BeginChild("##cprLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(cpr_licence.c_str());
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if(ImGui::TreeNodeEx("JSON for Modern C++ (aka json.hpp)", ImGuiTreeNodeFlags_SpanAvailWidth)) {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
const char* json_website = "https://json.nlohmann.me/";
|
||||
ImGui::Text(ICON_FA_GLOBE " %s", json_website);
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("Copy to clipboard")) {
|
||||
ImGui::SetClipboardText(json_website);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("Open in browser")) {
|
||||
openUri(json_website);
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted("Licence: MIT");
|
||||
|
||||
static const auto json_licence = _rs.get("LICENSE.json");
|
||||
if(ImGui::BeginChild("##jsonLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
|
||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
||||
ImGui::TextUnformatted(json_licence.c_str());
|
||||
ImGui::PopFont();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if(ImGui::TreeNodeEx("Font Awesome", ImGuiTreeNodeFlags_SpanAvailWidth)) {
|
||||
ImGui::TextUnformatted("Version used: 5.15.3");
|
||||
ImGui::AlignTextToFramePadding();
|
||||
|
|
|
@ -62,22 +62,7 @@ void SaveTool::drawMainMenu() {
|
|||
|
||||
ImGui::Checkbox("Check for updates on startup", &_checkUpdatesOnStartup);
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) {
|
||||
_queue.addToast(Toast::Type::Default, "Checking for updates...");
|
||||
_thread = std::thread{[this]{ checkForUpdates(); }};
|
||||
}
|
||||
|
||||
if(_updateAvailable) {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("Version %s is available.", _latestVersion.c_str());
|
||||
if(ImGui::Button(ICON_FA_FILE_SIGNATURE " Release notes")) {
|
||||
openUri(_releaseLink);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button(ICON_FA_DOWNLOAD " Download now")) {
|
||||
openUri(_downloadLink);
|
||||
}
|
||||
}
|
||||
ImGui::Button(ICON_FA_SYNC_ALT " Check now");
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
|
|
@ -138,9 +138,7 @@ void ToastQueue::draw(Vector2i viewport_size) {
|
|||
break;
|
||||
}
|
||||
|
||||
if(current->type() != Toast::Type::Default) {
|
||||
ImGui::SameLine();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
if(current->message().length() > 127) {
|
||||
ImGui::TextColored(colour, "%.*s...", 127, current->message().c_str());
|
||||
|
|
|
@ -43,11 +43,3 @@ alias=LICENSE.libzip
|
|||
[file]
|
||||
filename=../third-party/efsw/LICENSE
|
||||
alias=LICENSE.efsw
|
||||
|
||||
[file]
|
||||
filename=../third-party/cpr/LICENSE
|
||||
alias=LICENSE.cpr
|
||||
|
||||
[file]
|
||||
filename=../third-party/json/LICENSE.MIT
|
||||
alias=LICENSE.json
|
||||
|
|
1
third-party/json
vendored
1
third-party/json
vendored
|
@ -1 +0,0 @@
|
|||
Subproject commit 350ff4f7ced7c4117eae2fb93df02823c8021fcb
|
Loading…
Reference in a new issue