Compare commits
6 Commits
389dabfc77
...
066ce6ac70
Author | SHA1 | Date |
---|---|---|
Guillaume Jacquemin | 066ce6ac70 | |
Guillaume Jacquemin | 57b4af4637 | |
Guillaume Jacquemin | e4ef5d4423 | |
Guillaume Jacquemin | a7b0c894d0 | |
Guillaume Jacquemin | 088f357a6b | |
Guillaume Jacquemin | 938bf7b8b5 |
|
@ -27,8 +27,10 @@ endif()
|
|||
find_package(Magnum REQUIRED GL Sdl2Application)
|
||||
find_package(MagnumIntegration REQUIRED ImGui)
|
||||
find_package(CURL REQUIRED HTTPS)
|
||||
find_package(libzip REQUIRED)
|
||||
find_package(efsw REQUIRED)
|
||||
if(SAVETOOL_USE_SYSTEM_LIBS)
|
||||
find_package(libzip REQUIRED)
|
||||
find_package(efsw REQUIRED)
|
||||
endif()
|
||||
|
||||
set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
|
||||
|
||||
|
@ -41,7 +43,7 @@ if(CORRADE_TARGET_WINDOWS)
|
|||
set(SAVETOOL_RC_FILE resource.rc)
|
||||
endif()
|
||||
|
||||
add_executable(MassBuilderSaveTool WIN32
|
||||
add_executable(MassBuilderSaveTool
|
||||
main.cpp
|
||||
SaveTool/SaveTool.h
|
||||
SaveTool/SaveTool.cpp
|
||||
|
@ -107,6 +109,10 @@ add_executable(MassBuilderSaveTool WIN32
|
|||
${Assets}
|
||||
)
|
||||
|
||||
if(CORRADE_TARGET_WINDOWS)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE $<CONFIG:Release>)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
target_compile_definitions(Logger PRIVATE SAVETOOL_DEBUG_BUILD)
|
||||
target_compile_definitions(MassBuilderSaveTool PRIVATE SAVETOOL_DEBUG_BUILD)
|
||||
|
@ -140,11 +146,15 @@ target_link_libraries(MassBuilderSaveTool PRIVATE
|
|||
MagnumIntegration::ImGui
|
||||
Logger
|
||||
UESaveFile
|
||||
efsw::efsw
|
||||
libzip::zip
|
||||
CURL::libcurl_static
|
||||
)
|
||||
|
||||
if(SAVETOOL_USE_SYSTEM_LIBS)
|
||||
target_link_libraries(MassBuilderSaveTool PRIVATE libzip::zip efsw::efsw)
|
||||
else()
|
||||
target_link_libraries(MassBuilderSaveTool PRIVATE zip efsw)
|
||||
endif()
|
||||
|
||||
if(CORRADE_TARGET_WINDOWS)
|
||||
target_link_libraries(MassBuilderSaveTool PRIVATE
|
||||
Corrade::Main
|
||||
|
|
|
@ -16,10 +16,12 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#ifndef SAVETOOL_DEBUG_BUILD
|
||||
#include <Corrade/Containers/Optional.h>
|
||||
#include <Corrade/Containers/Pair.h>
|
||||
#include <Corrade/Utility/Debug.h>
|
||||
#include <Corrade/Utility/Path.h>
|
||||
#endif
|
||||
#include <Corrade/Utility/Debug.h>
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
|
@ -36,9 +38,9 @@ Logger::instance() {
|
|||
|
||||
void
|
||||
Logger::initialise() {
|
||||
#ifndef SAVETOOL_DEBUG_BUILD
|
||||
auto exe_path = Utility::Path::split(*Utility::Path::executableLocation()).first();
|
||||
_logFile.open(Utility::Path::join(exe_path, "SaveToolLog.txt").cbegin(), std::ios::trunc);
|
||||
#ifndef SAVETOOL_DEBUG_BUILD
|
||||
_logFile << "In case you encounter a bug:\n" <<
|
||||
"1. Do not run the Save Tool again, as this log will be cleared.\n" <<
|
||||
"2. Go to either the official Sekai Project Discord guild, or the community M.A.S.S. Builder one.\n" <<
|
||||
|
@ -63,7 +65,13 @@ Logger::unindent() {
|
|||
|
||||
void
|
||||
Logger::log(EntryType type, StringView location, StringView message) {
|
||||
Debug d{&_logFile};
|
||||
Debug d{
|
||||
#ifdef SAVETOOL_DEBUG_BUILD
|
||||
&std::cout
|
||||
#else
|
||||
&_logFile
|
||||
#endif
|
||||
};
|
||||
|
||||
switch(type) {
|
||||
case EntryType::Info:
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
#include <ctime>
|
||||
|
||||
#ifndef SAVETOOL_DEBUG_BUILD
|
||||
#include <fstream>
|
||||
#endif
|
||||
#include <mutex>
|
||||
|
||||
#include <Corrade/Containers/String.h>
|
||||
|
@ -58,7 +60,9 @@ class Logger {
|
|||
private:
|
||||
Logger() = default;
|
||||
|
||||
#ifndef SAVETOOL_DEBUG_BUILD
|
||||
std::ofstream _logFile;
|
||||
#endif
|
||||
|
||||
std::uint32_t _indentLevel = 0;
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ void
|
|||
SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||
_updateThread.join();
|
||||
|
||||
LOG_INFO("in updateCheckEvent().");
|
||||
|
||||
switch(static_cast<UpdateChecker::Result>(event.user.code)) {
|
||||
case UpdateChecker::Success:
|
||||
_checkerMutex.lock();
|
||||
|
|
|
@ -132,14 +132,16 @@ SaveTool::drawMainMenu() {
|
|||
_updateThread = std::thread{[this]{ checkForUpdates(); }};
|
||||
}
|
||||
|
||||
if(_checker && (_checkerMutex.try_lock() && _checker->updateAvailable())) {
|
||||
drawAlignedText("Version %s is available.", Containers::String{_checker->version()}.data());
|
||||
if(ImGui::Button(ICON_FA_FILE_SIGNATURE " Release notes")) {
|
||||
openUri("https://williamjcm.ovh/mbst");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button(ICON_FA_DOWNLOAD " Download now")) {
|
||||
openUri(_checker->downloadLink());
|
||||
if(_checker && _checkerMutex.try_lock()) {
|
||||
if(_checker->updateAvailable()) {
|
||||
drawAlignedText("Version %s is available.", Containers::String{_checker->version()}.data());
|
||||
if(ImGui::Button(ICON_FA_FILE_SIGNATURE " Release notes")) {
|
||||
openUri("https://williamjcm.ovh/mbst");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button(ICON_FA_DOWNLOAD " Download now")) {
|
||||
openUri(_checker->downloadLink());
|
||||
}
|
||||
}
|
||||
_checkerMutex.unlock();
|
||||
}
|
||||
|
|
|
@ -37,6 +37,17 @@ UpdateChecker::~UpdateChecker() {
|
|||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
writeCallback(char* data, std::size_t size, std::size_t nmemb, void* user_data) {
|
||||
if(!data || !user_data) return std::size_t{};
|
||||
|
||||
auto* s = static_cast<Containers::String*>(user_data);
|
||||
(*s) = (*s) + Containers::StringView{data, size * nmemb};
|
||||
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
UpdateChecker::Result
|
||||
UpdateChecker::check() {
|
||||
auto curl = curl_easy_init();
|
||||
|
@ -48,16 +59,11 @@ UpdateChecker::check() {
|
|||
|
||||
Containers::String response_body{Containers::AllocatedInit, ""};
|
||||
Containers::String error_buffer{ValueInit, CURL_ERROR_SIZE};
|
||||
static auto write_data = [](char* ptr, std::size_t size, std::size_t nmemb, Containers::String* buf){
|
||||
if(!ptr || !buf) return std::size_t{};
|
||||
(*buf) = Utility::format("{}{}", *buf, Containers::StringView{ptr, size * nmemb});
|
||||
return size * nmemb;
|
||||
};
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://williamjcm.ovh/mbst/version");
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_body);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer.data());
|
||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 0L);
|
||||
|
|
Loading…
Reference in New Issue