Compare commits

...

24 commits

Author SHA1 Message Date
bfa7049e49 Update Corrade and Magnum. 2022-09-11 20:12:34 +02:00
00be2eeaab Update Corrade and Magnum. 2022-07-21 09:20:19 +02:00
2a25dd371c resource.rc: update to use clearer macros. 2022-07-21 09:19:13 +02:00
65bb0d82a9 Logger: move away from the MassBuilderSaveTool namespace.
Might be useful if I ever use it in another project.
2022-05-27 14:16:01 +02:00
45c1cc2f9e Update Corrade and Magnum. 2022-05-25 09:09:41 +02:00
122d170ed4 CMakeLists: explicitly specify tests should be off.
Also allows me to quickly turn them on should I need to run a Corrade or
Magnum test.
2022-04-29 23:09:37 +02:00
7aa750b2b1 CMakeLists: disable deprecated stuff globally.
'Twas causing issues with Containers::Array vs Magnum::Array, the latter
of which is deprecated.
2022-04-29 22:19:13 +02:00
b0b227471a Logger: remove semicolons from the macro definitions.
This'll force adding a semicolon to macro calls. Dunno why I missed
that, considering the version that didn't lock the mutex also didn't
have the last semicolon.
2022-04-29 19:37:07 +02:00
2d1d46ec08 Logger: add an indent level system.
This will help when I'll re-add printing for property types.
2022-04-29 17:19:27 +02:00
98cb314725 Update README.md. 2022-04-29 15:51:58 +02:00
874dd9bd4c Logger: improve thread safety. 2022-04-25 08:24:56 +02:00
929e0c73ee Logger: add extra safety.
Though, that's not really enough for now.
2022-04-24 17:14:21 +02:00
4d94b10501 CMakeLists: build deprecated Corrade/Magnum for debug only. 2022-04-24 16:41:22 +02:00
3f580f77db CMakeLists: enable ANSI colours for Utility::Debug.
Will only have an impact in debug builds, though, due to output being
redirected to a file in release mode.
2022-04-24 16:40:27 +02:00
bf667e72d8 CMakeLists: ...and do that in the src one too. 2022-04-24 16:39:07 +02:00
c68a59d952 CMakeLists: re-enable Interconnect.
I'll need it for the new code structure.
2022-04-24 16:37:36 +02:00
8266ce11c8 Logger: improve for GUI display.
The biggest change is that the timestamp is pre-computed, because
calling strftime() 60 times (or more) per second is sure to have a
non-negligible cost.
2022-04-24 16:35:50 +02:00
dd6d2491fd Add Logger: a new thread-safe logging system.
Closes #25.
2022-04-24 14:25:47 +02:00
bb74a5c713 Resources: add version info to the exe.
Why the fuck is it so complicated ? Fuck you, Microsoft engineers who
designed this format.
2022-04-24 00:31:43 +02:00
56048f64ee CMakeLists: explicitly specify it's a C++ project. 2022-04-23 21:50:20 +02:00
4c4ac469e0 CMakeLists: ensure Corrade/Magnum builds deprecated stuff.
It usually should be for debug builds only, but, eh, I strip release
builds anyway.
2022-04-18 11:49:01 +02:00
2493cb5988 Update Corrade, Magnum, and ImGui. 2022-04-17 13:56:45 +02:00
c018bfc7f8 CMakeLists: bump version number.
And set a new codename, too.
2022-04-17 13:56:38 +02:00
269bdebca7 CMakeLists: do some dependency cleanup.
I guess I initially planned to make the Save Tool use Interconnect, and
there was a Magnum module that prevented me from disabling
PluginManager.
2022-04-17 13:55:48 +02:00
12 changed files with 355 additions and 12 deletions

View file

@ -15,7 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
project(MassBuilderSaveTool)
project(MassBuilderSaveTool CXX)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})
@ -25,10 +25,13 @@ set(BUILD_STATIC ON CACHE BOOL "" FORCE)
set(BUILD_STATIC_PIC ON CACHE BOOL "" FORCE)
set(BUILD_STATIC_UNIQUE_GLOBALS OFF CACHE BOOL "" FORCE)
set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(WITH_INTERCONNECT ON CACHE BOOL "" FORCE)
set(WITH_PLUGINMANAGER ON CACHE BOOL "" FORCE)
set(WITH_PLUGINMANAGER OFF CACHE BOOL "" FORCE)
set(WITH_TESTSUITE OFF CACHE BOOL "" FORCE)
set(WITH_MAIN ON CACHE BOOL "" FORCE)
set(BUILD_DEPRECATED OFF CACHE BOOL "" FORCE)
set(UTILITY_USE_ANSI_COLORS ON CACHE BOOL "" FORCE)
add_subdirectory(third-party/corrade EXCLUDE_FROM_ALL)
set(DIRECTX OFF CACHE BOOL "" FORCE) # We use OpenGL.
@ -56,6 +59,7 @@ set(WITH_GL ON CACHE BOOL "" FORCE)
set(WITH_MESHTOOLS OFF CACHE BOOL "" FORCE)
set(WITH_PRIMITIVES OFF CACHE BOOL "" FORCE)
set(WITH_SCENEGRAPH OFF CACHE BOOL "" FORCE)
set(WITH_SCENETOOLS OFF CACHE BOOL "" FORCE)
set(WITH_SHADERS ON CACHE BOOL "" FORCE)
set(WITH_SHADERTOOLS OFF CACHE BOOL "" FORCE)
set(WITH_TEXT OFF CACHE BOOL "" FORCE)

View file

@ -4,17 +4,19 @@ A save file manager and editor for M.A.S.S. Builder. Based on [wxMASSManager](ht
## Installing
Get the `MassBuilderSaveTool-<version>.zip` file from the [Releases](https://williamjcm.ovh/git/williamjcm/MassBuilderSaveTool/releases) page, and extract it somewhere. Then, launch `MassBuilderSaveTool.exe`.
Get the `MassBuilderSaveTool-<version>.zip` file from the [project's home page](https://williamjcm.ovh/coding/mbst/) or the [Releases](https://williamjcm.ovh/git/williamjcm/MassBuilderSaveTool/releases) tab, and extract it somewhere. Then, launch `MassBuilderSaveTool-<version>.exe`.
## Building on MSYS2 - IGNORE IF YOU JUST WANT TO USE THE APP!
1. Install the 64-bit (`x86_64`) version of [MSYS2](https://www.msys2.org/) in its default path (`C:\msys64`), and update it fully.
2. Run `pacman -S git mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja`.
3. In a `MINGW64` shell, type `git clone https://github.com/williamjcm/MassBuilderSaveTool`.
4. Type `cd MassBuilderSaveTool && git submodule init && git submodule update && mkdir build && cd build`.
3. In a `MINGW64` shell, type `git clone --recursive https://github.com/williamjcm/MassBuilderSaveTool`.
4. Type `cd MassBuilderSaveTool && mkdir build && cd build`.
5. Type `cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..`
6. Type `ninja`
7. ...
8. Profit!
You'll be able to find the executable in `build/Release/bin`.
**Note:** This should also work with the `ucrt64` or `clang64` repos. Just add `-ucrt` or `-clang` to `mingw-w64` when installing packages, and launch either a `UCRT64` or `CLANG64` shell in step 3.

View file

@ -18,7 +18,7 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(SAVETOOL_PROJECT_VERSION 1.3.3)
set(SAVETOOL_PROJECT_VERSION 1.4.0-pre)
find_package(Corrade REQUIRED Main Containers Utility Interconnect)
find_package(Magnum REQUIRED GL Sdl2Application)
@ -160,6 +160,10 @@ add_executable(MassBuilderSaveTool WIN32
Maps/WeaponTypes.hpp
ToastQueue/ToastQueue.h
ToastQueue/ToastQueue.cpp
Logger/Logger.h
Logger/Logger.cpp
Logger/MagnumLogBuffer.h
Logger/MagnumLogBuffer.cpp
Utilities/Crc32.h
FontAwesome/IconsFontAwesome5.h
FontAwesome/IconsFontAwesome5Brands.h
@ -170,7 +174,7 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_compile_definitions(SAVETOOL_DEBUG_BUILD)
endif()
add_compile_definitions(SAVETOOL_VERSION="${SAVETOOL_PROJECT_VERSION}"
SAVETOOL_CODENAME="Dickish Cyclops"
SAVETOOL_CODENAME="Enigmatic Ellenier"
SUPPORTED_GAME_VERSION="0.8.6")
if(CMAKE_BUILD_TYPE STREQUAL Release)

151
src/Logger/Logger.cpp Normal file
View file

@ -0,0 +1,151 @@
// MassBuilderSaveTool
// Copyright (C) 2021-2022 Guillaume Jacquemin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifdef SAVETOOL_DEBUG_BUILD
#include <iostream>
#else
#include <fstream>
#endif
#include <mutex>
#include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Utility/Debug.h>
#include <Magnum/Types.h>
#include "Logger.h"
using Containers::Array;
using Utility::Debug;
using Utility::Warning;
using Utility::Error;
using namespace Magnum;
namespace Logger {
#ifndef SAVETOOL_DEBUG_BUILD
static std::ofstream log_file{"SaveToolLog.txt", std::ios::trunc};
#endif
static UnsignedInt _indentLevel = 0;
static std::mutex _logMutex;
static Array<LogEntry> _entries;
inline Debug&
operator<<(Debug& out, const LogEntry& entry) {
using namespace Containers::Literals;
out << "["_s << Debug::nospace << entry.timestamp << Debug::nospace << "]"_s;
#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(entry.type) {
case EntryType::Info:
out << COLOURED_TEXT(Default, "[INFO]"_s);
break;
case EntryType::Success:
out << COLOURED_TEXT(Green, "[SUCCESS]"_s);
break;
case EntryType::Warning:
out << COLOURED_TEXT(Yellow, "[WARNING]"_s);
break;
case EntryType::Error:
out << COLOURED_TEXT(Red, "[ERROR]"_s);
break;
}
#undef COLOURED_TEXT
for(UnsignedInt i = 0; i < _indentLevel; i++) {
out << Debug::nospace << " "_s << Debug::nospace;
}
out << entry.message;
return out;
}
void
initialise() {
arrayReserve(_entries, 100);
}
void
indent() {
_indentLevel++;
}
void
unindent() {
if(_indentLevel > 0) {
_indentLevel--;
}
}
void
addEntry(EntryType type, StringView message) {
auto time = std::time(nullptr);
static char formatted_time[20] = {'\0'};
std::strftime(&formatted_time[0], sizeof(formatted_time)/sizeof(formatted_time[0]),
"%Y-%m-%d %H:%M:%S", // Because MSVCRT (which is the CRT I target by default) is not C99-compliant,
// I can't use "%F %T" as the format string.
std::localtime(&time));
LogEntry entry{
formatted_time, type,
(message.back() == '\n') ? String{message.exceptSuffix(1)} : String{message}
};
Debug{
#ifndef SAVETOOL_DEBUG_BUILD
&log_file
#else
&std::cout
#endif
} << entry;
arrayAppend(_entries, std::move(entry));
}
ArrayView<const LogEntry>
entries() {
return _entries;
}
void
lockMutex() {
_logMutex.lock();
}
void
unlockMutex() {
_logMutex.unlock();
}
bool
tryLockMutex() {
return _logMutex.try_lock();
}
} // Logger

77
src/Logger/Logger.h Normal file
View file

@ -0,0 +1,77 @@
#pragma once
// MassBuilderSaveTool
// Copyright (C) 2021-2022 Guillaume Jacquemin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <ctime>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Utility/Format.h>
using namespace Corrade;
using Containers::ArrayView;
using Containers::String;
using Containers::StringView;
namespace Logger {
enum class EntryType {
Info,
Success,
Warning,
Error,
};
struct LogEntry {
String timestamp;
EntryType type;
String message;
};
void initialise();
void indent();
void unindent();
void addEntry(EntryType type, StringView message);
auto entries() -> ArrayView<const LogEntry>;
void lockMutex();
void unlockMutex();
bool tryLockMutex();
} // Logger
#define LOG_INFO(message) Logger::lockMutex(); \
Logger::addEntry(Logger::EntryType::Info, message); \
Logger::unlockMutex()
#define LOG_SUCCESS(message) Logger::lockMutex(); \
Logger::addEntry(Logger::EntryType::Success, message); \
Logger::unlockMutex()
#define LOG_WARNING(message) Logger::lockMutex(); \
Logger::addEntry(Logger::EntryType::Warning, message); \
Logger::unlockMutex()
#define LOG_ERROR(message) Logger::lockMutex(); \
Logger::addEntry(Logger::EntryType::Error, message); \
Logger::unlockMutex()
#define LOG_INFO_FORMAT(message, ...) LOG_INFO(Utility::format(message, __VA_ARGS__))
#define LOG_SUCCESS_FORMAT(message, ...) LOG_SUCCESS(Utility::format(message, __VA_ARGS__))
#define LOG_WARNING_FORMAT(message, ...) LOG_WARNING(Utility::format(message, __VA_ARGS__))
#define LOG_ERROR_FORMAT(message, ...) LOG_ERROR(Utility::format(message, __VA_ARGS__))

View file

@ -0,0 +1,34 @@
// MassBuilderSaveTool
// Copyright (C) 2021-2022 Guillaume Jacquemin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "MagnumLogBuffer.h"
namespace MassBuilderSaveTool { namespace Logger {
MagnumLogBuffer::MagnumLogBuffer(EntryType type): std::stringbuf(std::ios_base::out), _type{type} {}
MagnumLogBuffer::~MagnumLogBuffer() = default;
int
MagnumLogBuffer::sync() {
addEntry(_type, str().c_str());
str({});
return 0;
}
} // Logger
} // MassBuilderSaveTool

View file

@ -0,0 +1,38 @@
#pragma once
// MassBuilderSaveTool
// Copyright (C) 2021-2022 Guillaume Jacquemin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <sstream>
#include "Logger.h"
namespace MassBuilderSaveTool { namespace Logger {
class MagnumLogBuffer : public std::stringbuf {
public:
explicit MagnumLogBuffer(EntryType type);
~MagnumLogBuffer();
private:
int sync() override;
EntryType _type;
};
} // Logger
} // MassBuilderSaveTool

View file

@ -14,6 +14,39 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <winuser.h>
#include <winver.h>
MAINICON ICON "mbst.ico"
1 24 "Application.manifest"
1 RT_MANIFEST "Application.manifest"
1 VERSIONINFO
FILEVERSION 1,4,0,0
PRODUCTVERSION 1,4,0,0
FILEOS VOS_NT_WINDOWS32
#ifdef SAVETOOL_DEBUG_BUILD
FILEFLAGS VS_FF_DEBUG
#endif
FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
{
BLOCK "080904B0"
{
VALUE "FileDescription", "M.A.S.S. Builder Save Tool"
VALUE "InternalName", "MassBuilderSaveTool.exe"
VALUE "OriginalFilename", "MassBuilderSaveTool.exe"
VALUE "CompanyName", "Guillaume Jacquemin"
VALUE "LegalCopyright", "Copyright \xA9 2021-2022 Guillaume Jacquemin."
VALUE "ProductName", "M.A.S.S. Builder Save Tool"
VALUE "FileVersion", "1.4.0.0"
VALUE "ProductVersion", "1.4.0.0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0809, 0x04B0
}
}

2
third-party/corrade vendored

@ -1 +1 @@
Subproject commit dc4f2eac6814b37b5257d295c2838bcde95272aa
Subproject commit e6b4d952e757ab99a0b67e516235b7f91904dca0

2
third-party/imgui vendored

@ -1 +1 @@
Subproject commit ddddabdccfdafffd8664fb4e29230dc4f848137e
Subproject commit eda7792b151d138e15df951578253b821ceed5a3

2
third-party/magnum vendored

@ -1 +1 @@
Subproject commit 3fc9028b5451aa95973f104d1ef2a1c0df589e64
Subproject commit da5d2fa958f22844adaec90e894e85270ed0a631

@ -1 +1 @@
Subproject commit 323c23f4e8e7cda9a7848c03401a3ba0a1de0bd4
Subproject commit c6c759def2090a821a97763fc2e15ec06d0396ce