62 lines
2 KiB
C++
62 lines
2 KiB
C++
// 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 "SaveTool/SaveTool.h"
|
|
|
|
#ifndef SAVETOOL_DEBUG_BUILD
|
|
#include <fstream>
|
|
#endif
|
|
|
|
#include <errhandlingapi.h>
|
|
#include <synchapi.h>
|
|
#include <winerror.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
#ifndef SAVETOOL_DEBUG_BUILD
|
|
std::ofstream output{"SaveToolLog.txt", std::ios::trunc|std::ios::out};
|
|
|
|
Utility::Debug d{&output};
|
|
Utility::Warning w{&output};
|
|
Utility::Error e{&output};
|
|
#else
|
|
Utility::Warning w{Utility::Debug::defaultOutput()};
|
|
Utility::Error e{Utility::Debug::defaultOutput()};
|
|
#endif
|
|
|
|
Utility::Debug{} << "===M.A.S.S. Builder Save Tool version " SAVETOOL_VERSION "===";
|
|
|
|
auto mutex_handle = CreateMutexW(nullptr, 0, L"MassBuilderSaveTool");
|
|
|
|
if(!mutex_handle) {
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app",
|
|
"There was an error initialising the mutex.",nullptr);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
if(GetLastError() == ERROR_ALREADY_EXISTS) {
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app",
|
|
"There can be only one running instance of the application.",nullptr);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
Utility::Debug{} << "===Initialising OpenGL renderer===";
|
|
SaveTool app({argc, argv});
|
|
Int result = app.exec();
|
|
|
|
ReleaseMutex(mutex_handle);
|
|
|
|
return result;
|
|
}
|