Compare commits
3 commits
39d71a7a09
...
ecdf7d736f
Author | SHA1 | Date | |
---|---|---|---|
ecdf7d736f | |||
3fc9243c81 | |||
81430de345 |
5 changed files with 24 additions and 26 deletions
|
@ -16,7 +16,10 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <Corrade/Containers/Optional.h>
|
||||||
|
#include <Corrade/Containers/Pair.h>
|
||||||
#include <Corrade/Utility/Debug.h>
|
#include <Corrade/Utility/Debug.h>
|
||||||
|
#include <Corrade/Utility/Path.h>
|
||||||
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
|
@ -33,12 +36,13 @@ Logger::instance() {
|
||||||
|
|
||||||
void
|
void
|
||||||
Logger::initialise() {
|
Logger::initialise() {
|
||||||
|
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
|
#ifndef SAVETOOL_DEBUG_BUILD
|
||||||
_logFile.open("SaveToolLog.txt", std::ios::trunc);
|
|
||||||
_logFile << "In case you encounter a bug:\n" <<
|
_logFile << "In case you encounter a bug:\n" <<
|
||||||
"1. Do not run the Save Tool again, as this log will be cleared.\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" <<
|
"2. Go to either the official Sekai Project Discord guild, or the community M.A.S.S. Builder one.\n" <<
|
||||||
"3. Mention me (William JCM#2301) to get my attention, with a description of the bug.\n"
|
"3. Mention me (@williamjcm) to get my attention, with a description of the bug.\n"
|
||||||
" Please include as many details as possible, I don't want to play \"20 questions\", and neither do you.\n" <<
|
" Please include as many details as possible, I don't want to play \"20 questions\", and neither do you.\n" <<
|
||||||
"4. Send me this file _when I ask for it_, preferably in DMs.\n" <<
|
"4. Send me this file _when I ask for it_, preferably in DMs.\n" <<
|
||||||
std::endl;
|
std::endl;
|
||||||
|
@ -59,31 +63,19 @@ Logger::unindent() {
|
||||||
|
|
||||||
void
|
void
|
||||||
Logger::log(EntryType type, StringView location, StringView message) {
|
Logger::log(EntryType type, StringView location, StringView message) {
|
||||||
Debug d{
|
Debug d{&_logFile};
|
||||||
#ifndef SAVETOOL_DEBUG_BUILD
|
|
||||||
&_logFile
|
|
||||||
#else
|
|
||||||
&std::cout
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef SAVETOOL_DEBUG_BUILD
|
|
||||||
#define COLOURED_TEXT(colour, text) Debug::color(Debug::Color::colour) << (text) << Debug::resetColor
|
|
||||||
#else
|
|
||||||
#define COLOURED_TEXT(colour, text) (text)
|
|
||||||
#endif
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case EntryType::Info:
|
case EntryType::Info:
|
||||||
d << COLOURED_TEXT(Default, "[ INFO]"_s);
|
d << "[ INFO]"_s;
|
||||||
break;
|
break;
|
||||||
case EntryType::Warning:
|
case EntryType::Warning:
|
||||||
d << COLOURED_TEXT(Yellow, "[WARNING]"_s);
|
d << "[WARNING]"_s;
|
||||||
break;
|
break;
|
||||||
case EntryType::Error:
|
case EntryType::Error:
|
||||||
d << COLOURED_TEXT(Red, "[ ERROR]"_s);
|
d << "[ ERROR]"_s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#undef COLOURED_TEXT
|
|
||||||
|
|
||||||
d << "["_s << Debug::nospace << location << Debug::nospace << "]";
|
d << "["_s << Debug::nospace << location << Debug::nospace << "]";
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,8 @@
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
#ifndef SAVETOOL_DEBUG_BUILD
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#endif
|
#include <mutex>
|
||||||
|
|
||||||
#include <Corrade/Containers/String.h>
|
#include <Corrade/Containers/String.h>
|
||||||
#include <Corrade/Containers/ArrayView.h>
|
#include <Corrade/Containers/ArrayView.h>
|
||||||
|
@ -60,9 +58,7 @@ class Logger {
|
||||||
private:
|
private:
|
||||||
Logger() = default;
|
Logger() = default;
|
||||||
|
|
||||||
#ifndef SAVETOOL_DEBUG_BUILD
|
|
||||||
std::ofstream _logFile;
|
std::ofstream _logFile;
|
||||||
#endif
|
|
||||||
|
|
||||||
std::uint32_t _indentLevel = 0;
|
std::uint32_t _indentLevel = 0;
|
||||||
|
|
||||||
|
|
|
@ -431,6 +431,8 @@ SaveTool::drawCheckbox(Containers::StringView label, bool value) {
|
||||||
void
|
void
|
||||||
SaveTool::openUri(Containers::StringView uri) {
|
SaveTool::openUri(Containers::StringView uri) {
|
||||||
ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri.data()), nullptr, nullptr, SW_SHOWDEFAULT);
|
ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri.data()), nullptr, nullptr, SW_SHOWDEFAULT);
|
||||||
|
// TODO: have it open folders through winebrowser.exe when running using Wine/Proton.
|
||||||
|
// URLs like Discord invites or Steam Browser Protocol links should be disabled entirely there.
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -198,9 +198,17 @@ SaveTool::findGameDataDirectory() -> bool {
|
||||||
|
|
||||||
wchar_t* localappdata_path = nullptr;
|
wchar_t* localappdata_path = nullptr;
|
||||||
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};
|
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};
|
||||||
if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK)
|
auto result = SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr, &localappdata_path);
|
||||||
|
if(result != S_OK)
|
||||||
{
|
{
|
||||||
_lastError = Utility::format("SHGetKnownFolderPath() failed with error code {}.", GetLastError());
|
char* message_buffer = nullptr;
|
||||||
|
auto size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
nullptr, result, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
|
||||||
|
reinterpret_cast<char*>(&message_buffer), 0, nullptr);
|
||||||
|
String message{message_buffer, size};
|
||||||
|
LocalFree(message_buffer);
|
||||||
|
|
||||||
|
_lastError = Utility::format("SHGetKnownFolderPath() failed with error code {}: {}", result, message);
|
||||||
LOG_ERROR(_lastError);
|
LOG_ERROR(_lastError);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ int main(int argc, char** argv) {
|
||||||
Containers::StringView locale{str};
|
Containers::StringView locale{str};
|
||||||
LOG_INFO_FORMAT("Current locale: {}", locale);
|
LOG_INFO_FORMAT("Current locale: {}", locale);
|
||||||
|
|
||||||
if(!locale.hasSuffix(".utf8")) {
|
if(!locale.hasSuffix(".utf8") && !locale.hasSuffix(".65001")) {
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
||||||
"Your system doesn't support UTF-8.", nullptr);
|
"Your system doesn't support UTF-8.", nullptr);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
Loading…
Reference in a new issue