WIP: The Road to 1.4 #23

Closed
williamjcm wants to merge 24 commits from the-road-to-1point4 into master
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