Temp commit

This commit is contained in:
Guillaume Jacquemin 2023-02-24 15:19:05 +01:00
parent c4f061aa65
commit 8bef08ed88
6 changed files with 204 additions and 2 deletions

View file

@ -0,0 +1,77 @@
// 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 <Magnum/GL/DefaultFramebuffer.h>
#include <SDL_events.h>
#include "../Configuration/Configuration.h"
#include "../Logger/Logger.h"
#include "Application.h"
Application::Application(const Arguments& args):
Platform::ScreenedApplication(
args,
Configuration{}.setTitle("M.A.S.S. Builder Save Tool " SAVETOOL_VERSION " (\"" SAVETOOL_CODENAME "\")")
.setSize({960, 720})
)
{
//ctor
}
Application::~Application() {
LOG_INFO("Cleaning up.");
SDL_RemoveTimer(_gameCheckTimerId);
LOG_INFO("Saving the configuration.");
conf().save();
}
void
Application::globalBeforeDrawEvent() {
GL::defaultFramebuffer.clear(GL::FramebufferClear::Color);
}
void
Application::globalDrawEvent() {
swapBuffers();
if(conf().swapInterval() == 0 && conf().fpsCap() < 301.0f) {
while(_timeline.currentFrameDuration() < (1.0f / conf().fpsCap()));
}
redraw();
_timeline.nextFrame();
}
void
Application::globalViewportEvent(ViewportEvent& event) {
if(event.event().type & SDL_WINDOWEVENT_SIZE_CHANGED) {
GL::defaultFramebuffer.setViewport({{}, event.windowSize()});
const Vector2 size = Vector2{windowSize()}/dpiScaling();
_imgui.relayout(size, windowSize(), framebufferSize());
}
}
void
Application::anyEvent(SDL_Event& event) {
//
}

View file

@ -0,0 +1,51 @@
#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 <Magnum/Timeline.h>
#include <Magnum/ImGuiIntegration/Context.h>
#include <Magnum/Platform/ScreenedApplication.h>
#include <Magnum/Platform/Sdl2Application.h>
#include <SDL_timer.h>
using namespace Magnum;
class Application: public Platform::ScreenedApplication {
public:
explicit Application(const Arguments& args);
~Application();
Application(const Application&) = delete;
Application& operator=(const Application&) = delete;
Application(Application&&) = delete;
Application& operator=(Application&&) = delete;
private:
// Events
void globalBeforeDrawEvent() override;
void globalDrawEvent() override;
void globalViewportEvent(ViewportEvent& event) override;
void anyEvent(SDL_Event& event) override;
Timeline _timeline;
ImGuiIntegration::Context _imgui{NoCreate};
SDL_TimerID _gameCheckTimerId = 0;
};

View file

@ -33,6 +33,8 @@ add_subdirectory(UESaveFile EXCLUDE_FROM_ALL)
add_executable(MassBuilderSaveTool WIN32
main.cpp
Application/Application.h
Application/Application.cpp
SaveTool/SaveTool.h
SaveTool/SaveTool.cpp
SaveTool/SaveTool_drawAbout.cpp
@ -87,6 +89,8 @@ add_executable(MassBuilderSaveTool WIN32
Maps/WeaponTypes.hpp
ToastQueue/ToastQueue.h
ToastQueue/ToastQueue.cpp
UpdateChecker/UpdateChecker.h
UpdateChecker/UpdateChecker.cpp
Utilities/Crc32.h
FontAwesome/IconsFontAwesome5.h
FontAwesome/IconsFontAwesome5Brands.h

View file

@ -198,9 +198,10 @@ SaveTool::findGameDataDirectory() -> bool {
wchar_t* localappdata_path = nullptr;
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_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path);
if(result != S_OK)
{
_lastError = Utility::format("SHGetKnownFolderPath() failed with error code {}.", GetLastError());
_lastError = Utility::format("SHGetKnownFolderPath() failed with error code {}.", result);
LOG_ERROR(_lastError);
return false;
}

View file

@ -0,0 +1,31 @@
// 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 <curl/curl.h>
#include "../Logger/Logger.h"
#include "UpdateChecker.h"
UpdateChecker::UpdateChecker() {
LOG_INFO("Initialising update checker.");
curl_global_init(CURL_GLOBAL_DEFAULT);
}
UpdateChecker::~UpdateChecker() {
LOG_INFO("Shutting libcurl down.");
curl_global_cleanup();
}

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 <mutex>
class UpdateChecker {
public:
UpdateChecker();
~UpdateChecker();
void lock() {
_mutex.lock();
}
bool tryLock() {
return _mutex.try_lock();
}
void unlock() {
_mutex.unlock();
}
private:
std::mutex _mutex;
};