Compare commits
4 commits
c0943bd084
...
8668c59858
Author | SHA1 | Date | |
---|---|---|---|
8668c59858 | |||
da6aea3661 | |||
aff84ccc96 | |||
8177d61755 |
10 changed files with 411 additions and 256 deletions
|
@ -139,6 +139,8 @@ add_executable(MassBuilderSaveTool WIN32
|
||||||
SaveTool/SaveTool_MassViewer_Weapons.cpp
|
SaveTool/SaveTool_MassViewer_Weapons.cpp
|
||||||
SaveTool/SaveTool_ProfileManager.cpp
|
SaveTool/SaveTool_ProfileManager.cpp
|
||||||
SaveTool/SaveTool_UpdateChecker.cpp
|
SaveTool/SaveTool_UpdateChecker.cpp
|
||||||
|
Configuration/Configuration.h
|
||||||
|
Configuration/Configuration.cpp
|
||||||
ProfileManager/ProfileManager.h
|
ProfileManager/ProfileManager.h
|
||||||
ProfileManager/ProfileManager.cpp
|
ProfileManager/ProfileManager.cpp
|
||||||
Profile/Profile.h
|
Profile/Profile.h
|
||||||
|
|
152
src/Configuration/Configuration.cpp
Normal file
152
src/Configuration/Configuration.cpp
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
#include <Corrade/Containers/Optional.h>
|
||||||
|
#include <Corrade/Containers/Pair.h>
|
||||||
|
#include <Corrade/Utility/Path.h>
|
||||||
|
|
||||||
|
#include "Configuration.h"
|
||||||
|
|
||||||
|
Configuration::Configuration() {
|
||||||
|
Containers::String exe_path = Utility::Path::split(*Utility::Path::executableLocation()).first();
|
||||||
|
_conf = Utility::Configuration{Utility::Path::join(exe_path, "MassBuilderSaveTool.ini")};
|
||||||
|
|
||||||
|
if(_conf.hasValue("swap_interval")) {
|
||||||
|
_swapInterval = _conf.value<int>("swap_interval");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("swap_interval", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_conf.hasValue("frame_limit")) {
|
||||||
|
std::string frame_limit = _conf.value("frame_limit");
|
||||||
|
if(frame_limit == "half_vsync") {
|
||||||
|
_swapInterval = 2;
|
||||||
|
}
|
||||||
|
_conf.removeValue("frame_limit");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_conf.hasValue("fps_cap")) {
|
||||||
|
_fpsCap = _conf.value<float>("fps_cap");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("fps_cap", 60.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_conf.hasValue("cheat_mode")) {
|
||||||
|
_cheatMode = _conf.value<bool>("cheat_mode");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("cheat_mode", _cheatMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_conf.hasValue("advanced_mode")) {
|
||||||
|
_advancedMode = _conf.value<bool>("advanced_mode");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("advanced_mode", _advancedMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_conf.hasValue("startup_update_check")) {
|
||||||
|
_checkUpdatesOnStartup = _conf.value<bool>("startup_update_check");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_conf.hasValue("skip_disclaimer")) {
|
||||||
|
_skipDisclaimer = _conf.value<bool>("skip_disclaimer");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("skip_disclaimer", _skipDisclaimer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Configuration::~Configuration() {
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Configuration::save() {
|
||||||
|
_conf.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Configuration::swapInterval() const {
|
||||||
|
return _swapInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Configuration::setSwapInterval(int interval) {
|
||||||
|
_swapInterval = interval;
|
||||||
|
_conf.setValue("swap_interval", _swapInterval);
|
||||||
|
_conf.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
Configuration::fpsCap() const {
|
||||||
|
return _fpsCap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Configuration::setFpsCap(float cap) {
|
||||||
|
_fpsCap = cap;
|
||||||
|
_conf.setValue("fps_cap", _fpsCap);
|
||||||
|
_conf.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Configuration::cheatMode() const {
|
||||||
|
return _cheatMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Configuration::setCheatMode(bool enabled) {
|
||||||
|
_cheatMode = enabled;
|
||||||
|
_conf.setValue("cheat_mode", _cheatMode);
|
||||||
|
_conf.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Configuration::advancedMode() const {
|
||||||
|
return _advancedMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Configuration::setAdvancedMode(bool enabled) {
|
||||||
|
_advancedMode = enabled;
|
||||||
|
_conf.setValue("advanced_mode", _advancedMode);
|
||||||
|
_conf.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Configuration::checkUpdatesOnStartup() const {
|
||||||
|
return _checkUpdatesOnStartup;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Configuration::setCheckUpdatesOnStartup(bool mode) {
|
||||||
|
_checkUpdatesOnStartup = mode;
|
||||||
|
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
|
||||||
|
_conf.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Configuration::skipDisclaimer() const {
|
||||||
|
return _skipDisclaimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Configuration::setSkipDisclaimer(bool mode) {
|
||||||
|
_skipDisclaimer = mode;
|
||||||
|
_conf.setValue("skip_disclaimer", _skipDisclaimer);
|
||||||
|
_conf.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
Configuration&
|
||||||
|
Configuration::instance() {
|
||||||
|
static Configuration conf{};
|
||||||
|
return conf;
|
||||||
|
}
|
||||||
|
|
||||||
|
Configuration&
|
||||||
|
conf() {
|
||||||
|
return Configuration::instance();
|
||||||
|
}
|
46
src/Configuration/Configuration.h
Normal file
46
src/Configuration/Configuration.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Corrade/Utility/Configuration.h>
|
||||||
|
|
||||||
|
using namespace Corrade;
|
||||||
|
|
||||||
|
class Configuration {
|
||||||
|
public:
|
||||||
|
static Configuration& instance();
|
||||||
|
|
||||||
|
~Configuration();
|
||||||
|
|
||||||
|
void save();
|
||||||
|
|
||||||
|
int swapInterval() const;
|
||||||
|
void setSwapInterval(int interval);
|
||||||
|
|
||||||
|
float fpsCap() const;
|
||||||
|
void setFpsCap(float cap);
|
||||||
|
|
||||||
|
bool cheatMode() const;
|
||||||
|
void setCheatMode(bool enabled);
|
||||||
|
|
||||||
|
bool advancedMode() const;
|
||||||
|
void setAdvancedMode(bool enabled);
|
||||||
|
|
||||||
|
bool checkUpdatesOnStartup() const;
|
||||||
|
void setCheckUpdatesOnStartup(bool mode);
|
||||||
|
|
||||||
|
bool skipDisclaimer() const;
|
||||||
|
void setSkipDisclaimer(bool mode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit Configuration();
|
||||||
|
|
||||||
|
Utility::Configuration _conf;
|
||||||
|
|
||||||
|
int _swapInterval = 1;
|
||||||
|
float _fpsCap = 60.0f;
|
||||||
|
bool _cheatMode = false;
|
||||||
|
bool _advancedMode = false;
|
||||||
|
bool _checkUpdatesOnStartup = true;
|
||||||
|
bool _skipDisclaimer = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Configuration& conf();
|
|
@ -35,6 +35,7 @@
|
||||||
#include <wtsapi32.h>
|
#include <wtsapi32.h>
|
||||||
|
|
||||||
#include "../FontAwesome/IconsFontAwesome5.h"
|
#include "../FontAwesome/IconsFontAwesome5.h"
|
||||||
|
#include "../Configuration/Configuration.h"
|
||||||
#include "../Logger/Logger.h"
|
#include "../Logger/Logger.h"
|
||||||
|
|
||||||
using namespace Containers::Literals;
|
using namespace Containers::Literals;
|
||||||
|
@ -51,7 +52,7 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
.setSize({960, 720})}
|
.setSize({960, 720})}
|
||||||
{
|
{
|
||||||
#ifdef SAVETOOL_DEBUG_BUILD
|
#ifdef SAVETOOL_DEBUG_BUILD
|
||||||
tweak.enable(""_s, "../../"_s);
|
tweak.enable("", "../../");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOG_INFO("Configuring OpenGL renderer.");
|
LOG_INFO("Configuring OpenGL renderer.");
|
||||||
|
@ -130,7 +131,7 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
|
|
||||||
LOG_INFO("Initialising update checker.");
|
LOG_INFO("Initialising update checker.");
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
if(_checkUpdatesOnStartup) {
|
if(conf().checkUpdatesOnStartup()) {
|
||||||
_queue.addToast(Toast::Type::Default, "Checking for updates..."_s);
|
_queue.addToast(Toast::Type::Default, "Checking for updates..."_s);
|
||||||
_updateThread = std::thread{[this]{ checkForUpdates(); }};
|
_updateThread = std::thread{[this]{ checkForUpdates(); }};
|
||||||
}
|
}
|
||||||
|
@ -141,7 +142,7 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
GL::DebugOutput::setEnabled(GL::DebugOutput::Source::Api, GL::DebugOutput::Type::Other, {131185}, false);
|
GL::DebugOutput::setEnabled(GL::DebugOutput::Source::Api, GL::DebugOutput::Type::Other, {131185}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_skipDisclaimer) {
|
if(conf().skipDisclaimer()) {
|
||||||
_uiState = UiState::Initialising;
|
_uiState = UiState::Initialising;
|
||||||
_initThread = std::thread{[this]{ initialiseManager(); }};
|
_initThread = std::thread{[this]{ initialiseManager(); }};
|
||||||
}
|
}
|
||||||
|
@ -159,14 +160,7 @@ SaveTool::~SaveTool() {
|
||||||
|
|
||||||
LOG_INFO("Saving the configuration.");
|
LOG_INFO("Saving the configuration.");
|
||||||
|
|
||||||
_conf.setValue("cheat_mode"_s, _cheatMode);
|
conf().save();
|
||||||
_conf.setValue("advanced_mode"_s, _advancedMode);
|
|
||||||
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup);
|
|
||||||
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer);
|
|
||||||
_conf.setValue("swap_interval"_s, _swapInterval);
|
|
||||||
_conf.setValue("fps_cap"_s, _fpsCap);
|
|
||||||
|
|
||||||
_conf.save();
|
|
||||||
|
|
||||||
LOG_INFO("Exiting.");
|
LOG_INFO("Exiting.");
|
||||||
}
|
}
|
||||||
|
@ -182,8 +176,8 @@ void SaveTool::drawEvent() {
|
||||||
|
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
|
|
||||||
if(_swapInterval == 0 && _fpsCap < 301.0f) {
|
if(conf().swapInterval() == 0 && conf().fpsCap() < 301.0f) {
|
||||||
while(_timeline.currentFrameDuration() < (1.0f / _fpsCap));
|
while(_timeline.currentFrameDuration() < (1.0f / conf().fpsCap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw();
|
redraw();
|
||||||
|
@ -344,7 +338,9 @@ void SaveTool::drawDisclaimer() {
|
||||||
ImGui::Dummy({0.0f, 5.0f});
|
ImGui::Dummy({0.0f, 5.0f});
|
||||||
ImGui::Dummy({4.0f, 0.0f});
|
ImGui::Dummy({4.0f, 0.0f});
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Checkbox("Don't show next time", &_skipDisclaimer);
|
if(drawCheckbox("Don't show next time", conf().skipDisclaimer())) {
|
||||||
|
conf().setSkipDisclaimer(!conf().skipDisclaimer());
|
||||||
|
}
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {24.0f, 12.0f});
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {24.0f, 12.0f});
|
||||||
if(ImGui::Button("I understand the risks")) {
|
if(ImGui::Button("I understand the risks")) {
|
||||||
|
@ -412,6 +408,11 @@ void SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SaveTool::drawCheckbox(Containers::StringView label, bool value) {
|
||||||
|
return ImGui::Checkbox(label.data(), &value);
|
||||||
|
}
|
||||||
|
|
||||||
void SaveTool::openUri(Containers::StringView uri) {
|
void 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include <Corrade/Containers/Pointer.h>
|
#include <Corrade/Containers/Pointer.h>
|
||||||
#include <Corrade/Containers/String.h>
|
#include <Corrade/Containers/String.h>
|
||||||
#include <Corrade/Utility/Configuration.h>
|
|
||||||
#include <Corrade/Utility/Resource.h>
|
#include <Corrade/Utility/Resource.h>
|
||||||
#ifdef SAVETOOL_DEBUG_BUILD
|
#ifdef SAVETOOL_DEBUG_BUILD
|
||||||
#include <Corrade/Utility/Tweakable.h>
|
#include <Corrade/Utility/Tweakable.h>
|
||||||
|
@ -164,6 +163,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
// Convenience wrappers over ImGui stuff
|
// Convenience wrappers over ImGui stuff
|
||||||
void drawHelpMarker(Containers::StringView text, Float wrap_pos = 0.0f);
|
void drawHelpMarker(Containers::StringView text, Float wrap_pos = 0.0f);
|
||||||
void drawTooltip(Containers::StringView text, Float wrap_pos = 0.0f);
|
void drawTooltip(Containers::StringView text, Float wrap_pos = 0.0f);
|
||||||
|
bool drawCheckbox(Containers::StringView label, bool value);
|
||||||
|
|
||||||
template<typename Functor, typename... Args>
|
template<typename Functor, typename... Args>
|
||||||
auto drawUnsafeWidget(Functor func, Args... args) -> bool {
|
auto drawUnsafeWidget(Functor func, Args... args) -> bool {
|
||||||
|
@ -197,7 +197,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
|
|
||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
|
|
||||||
Utility::Configuration _conf{"MassBuilderSaveTool.ini"_s};
|
|
||||||
Utility::Resource _rs{"assets"_s};
|
Utility::Resource _rs{"assets"_s};
|
||||||
|
|
||||||
// GUI-related members
|
// GUI-related members
|
||||||
|
@ -262,12 +261,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
};
|
};
|
||||||
Containers::StaticArray<2, efsw::WatchID> _watchIDs;
|
Containers::StaticArray<2, efsw::WatchID> _watchIDs;
|
||||||
|
|
||||||
int _swapInterval = 1;
|
|
||||||
float _fpsCap = 60.0f;
|
|
||||||
|
|
||||||
bool _skipDisclaimer{false};
|
|
||||||
bool _checkUpdatesOnStartup{true};
|
|
||||||
|
|
||||||
bool _updateAvailable{false};
|
bool _updateAvailable{false};
|
||||||
Containers::String _latestVersion;
|
Containers::String _latestVersion;
|
||||||
Containers::String _releaseLink;
|
Containers::String _releaseLink;
|
||||||
|
@ -290,8 +283,5 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
bool _bLaunchersDirty{false};
|
bool _bLaunchersDirty{false};
|
||||||
bool _eLaunchersDirty{false};
|
bool _eLaunchersDirty{false};
|
||||||
|
|
||||||
bool _cheatMode{false};
|
|
||||||
bool _advancedMode{false};
|
|
||||||
|
|
||||||
Timeline _timeline;
|
Timeline _timeline;
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,7 +48,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
return;
|
return;
|
||||||
} // TODO: actually do something when config files will finally be handled
|
} // TODO: actually do something when config files will finally be handled
|
||||||
|
|
||||||
if(!Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) {
|
if(!Utility::String::endsWith(filename, Utility::format("Profile{}.sav", _currentProfile->account()).data())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,8 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::fileUpdateEvent(SDL_Event& event) {
|
void SaveTool::fileUpdateEvent(SDL_Event& event) {
|
||||||
Containers::String filename{static_cast<char*>(event.user.data1), std::strlen(static_cast<char*>(event.user.data1)), nullptr};
|
Containers::String filename{static_cast<char*>(event.user.data1),
|
||||||
|
std::strlen(static_cast<char*>(event.user.data1)), nullptr};
|
||||||
|
|
||||||
if((event.user.code & StagedUpdate) == StagedUpdate) {
|
if((event.user.code & StagedUpdate) == StagedUpdate) {
|
||||||
_massManager->refreshStagedMass(filename);
|
_massManager->refreshStagedMass(filename);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
|
||||||
|
#include "../Configuration/Configuration.h"
|
||||||
#include "../FontAwesome/IconsFontAwesome5.h"
|
#include "../FontAwesome/IconsFontAwesome5.h"
|
||||||
#include "../FontAwesome/IconsFontAwesome5Brands.h"
|
#include "../FontAwesome/IconsFontAwesome5Brands.h"
|
||||||
#include "../Logger/Logger.h"
|
#include "../Logger/Logger.h"
|
||||||
|
@ -51,64 +52,10 @@ void SaveTool::initEvent(SDL_Event& event) {
|
||||||
void SaveTool::initialiseConfiguration() {
|
void SaveTool::initialiseConfiguration() {
|
||||||
LOG_INFO("Reading configuration file.");
|
LOG_INFO("Reading configuration file.");
|
||||||
|
|
||||||
if(_conf.hasValue("cheat_mode"_s)) {
|
setSwapInterval(conf().swapInterval());
|
||||||
_cheatMode = _conf.value<bool>("cheat_mode"_s);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_conf.setValue("cheat_mode"_s, _cheatMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_conf.hasValue("advanced_mode"_s)) {
|
|
||||||
_advancedMode = _conf.value<bool>("advanced_mode"_s);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_conf.setValue("advanced_mode"_s, _advancedMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_conf.hasValue("startup_update_check"_s)) {
|
|
||||||
_checkUpdatesOnStartup = _conf.value<bool>("startup_update_check"_s);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_conf.hasValue("skip_disclaimer"_s)) {
|
|
||||||
_skipDisclaimer = _conf.value<bool>("skip_disclaimer"_s);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_conf.hasValue("swap_interval"_s)) {
|
|
||||||
_swapInterval = _conf.value<int>("swap_interval"_s);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_conf.setValue("swap_interval"_s, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_conf.hasValue("fps_cap"_s)) {
|
|
||||||
_fpsCap = _conf.value<float>("fps_cap");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_conf.setValue("fps_cap", 60.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_conf.hasValue("frame_limit"_s)) {
|
|
||||||
std::string frame_limit = _conf.value("frame_limit"_s);
|
|
||||||
if(frame_limit == "half_vsync"_s) {
|
|
||||||
_swapInterval = 2;
|
|
||||||
}
|
|
||||||
_conf.removeValue("frame_limit"_s);
|
|
||||||
}
|
|
||||||
|
|
||||||
setSwapInterval(_swapInterval);
|
|
||||||
if(_swapInterval == 0) {
|
|
||||||
setMinimalLoopPeriod(0);
|
setMinimalLoopPeriod(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_conf.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SaveTool::initialiseGui() {
|
void SaveTool::initialiseGui() {
|
||||||
LOG_INFO("Initialising Dear ImGui.");
|
LOG_INFO("Initialising Dear ImGui.");
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <SDL_messagebox.h>
|
#include <SDL_messagebox.h>
|
||||||
|
|
||||||
|
#include "../Configuration/Configuration.h"
|
||||||
#include "../FontAwesome/IconsFontAwesome5.h"
|
#include "../FontAwesome/IconsFontAwesome5.h"
|
||||||
#include "../Maps/LastMissionId.h"
|
#include "../Maps/LastMissionId.h"
|
||||||
#include "../Maps/StoryProgress.h"
|
#include "../Maps/StoryProgress.h"
|
||||||
|
@ -224,7 +225,7 @@ void SaveTool::drawGeneralInfo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_cheatMode) {
|
if(!conf().cheatMode()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +404,7 @@ void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter get
|
||||||
ImGui::TableSetColumnIndex(2);
|
ImGui::TableSetColumnIndex(2);
|
||||||
if(getter() != -1) {
|
if(getter() != -1) {
|
||||||
ImGui::Text("%i", getter());
|
ImGui::Text("%i", getter());
|
||||||
if(_cheatMode) {
|
if(conf().cheatMode()) {
|
||||||
ImGui::TableSetColumnIndex(3);
|
ImGui::TableSetColumnIndex(3);
|
||||||
ImGui::PushID(name.data());
|
ImGui::PushID(name.data());
|
||||||
static Int var = 0;
|
static Int var = 0;
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
#include <Magnum/ImGuiIntegration/Integration.h>
|
#include <Magnum/ImGuiIntegration/Integration.h>
|
||||||
|
|
||||||
|
#include "../Configuration/Configuration.h"
|
||||||
|
#include "../FontAwesome/IconsFontAwesome5.h"
|
||||||
#include "../Maps/Accessories.h"
|
#include "../Maps/Accessories.h"
|
||||||
#define STYLENAMES_DEFINITION
|
#define STYLENAMES_DEFINITION
|
||||||
#include "../Maps/StyleNames.h"
|
#include "../Maps/StyleNames.h"
|
||||||
|
|
||||||
#include "../FontAwesome/IconsFontAwesome5.h"
|
|
||||||
|
|
||||||
#include "SaveTool.h"
|
#include "SaveTool.h"
|
||||||
|
|
||||||
void SaveTool::drawMassViewer() {
|
void SaveTool::drawMassViewer() {
|
||||||
|
@ -394,10 +394,10 @@ auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult {
|
||||||
void SaveTool::drawDecalEditor(Decal& decal) {
|
void SaveTool::drawDecalEditor(Decal& decal) {
|
||||||
ImGui::Text("ID: %i", decal.id);
|
ImGui::Text("ID: %i", decal.id);
|
||||||
|
|
||||||
if(ImGui::BeginTable("##DecalTable", _advancedMode ? 2 : 1, ImGuiTableFlags_BordersInnerV)) {
|
if(ImGui::BeginTable("##DecalTable", conf().advancedMode() ? 2 : 1, ImGuiTableFlags_BordersInnerV)) {
|
||||||
ImGui::TableSetupColumn("##Normal", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("##Normal", ImGuiTableColumnFlags_WidthStretch);
|
||||||
|
|
||||||
if(_advancedMode) {
|
if(conf().advancedMode()) {
|
||||||
ImGui::TableSetupColumn("##Advanced", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("##Advanced", ImGuiTableColumnFlags_WidthStretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ void SaveTool::drawDecalEditor(Decal& decal) {
|
||||||
ImGui::Checkbox("##Wrap", &decal.wrap);
|
ImGui::Checkbox("##Wrap", &decal.wrap);
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
||||||
if(_advancedMode) {
|
if(conf().advancedMode()) {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
ImGui::TextColored(ImColor(255, 255, 0), ICON_FA_EXCLAMATION_TRIANGLE);
|
ImGui::TextColored(ImColor(255, 255, 0), ICON_FA_EXCLAMATION_TRIANGLE);
|
||||||
|
@ -636,11 +636,11 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
|
||||||
|
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
drawAlignedText("Styles:");
|
drawAlignedText("Styles:");
|
||||||
if(_advancedMode) {
|
if(conf().advancedMode()) {
|
||||||
drawAlignedText("Base position:");
|
drawAlignedText("Base position:");
|
||||||
}
|
}
|
||||||
drawAlignedText("Position offset:");
|
drawAlignedText("Position offset:");
|
||||||
if(_advancedMode) {
|
if(conf().advancedMode()) {
|
||||||
drawAlignedText("Base rotation:");
|
drawAlignedText("Base rotation:");
|
||||||
}
|
}
|
||||||
drawAlignedText("Rotation offset:");
|
drawAlignedText("Rotation offset:");
|
||||||
|
@ -673,7 +673,7 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
|
||||||
}
|
}
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
if(_advancedMode) {
|
if(conf().advancedMode()) {
|
||||||
ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth());
|
ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth());
|
||||||
ImGui::DragFloat("##PosX", &accessory.relativePosition.x(), 1.0f, -FLT_MAX, +FLT_MAX, "X: %.3f");
|
ImGui::DragFloat("##PosX", &accessory.relativePosition.x(), 1.0f, -FLT_MAX, +FLT_MAX, "X: %.3f");
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
@ -697,7 +697,7 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
drawHelpMarker("+/-500.0 = +/-250 in-game");
|
drawHelpMarker("+/-500.0 = +/-250 in-game");
|
||||||
|
|
||||||
if(_advancedMode) {
|
if(conf().advancedMode()) {
|
||||||
ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth());
|
ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth());
|
||||||
ImGui::DragFloat("##RotX", &accessory.relativeRotation.x(), 1.0f, -FLT_MAX, +FLT_MAX, "Roll: %.3f");
|
ImGui::DragFloat("##RotX", &accessory.relativeRotation.x(), 1.0f, -FLT_MAX, +FLT_MAX, "Roll: %.3f");
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
|
@ -14,15 +14,19 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "SaveTool.h"
|
|
||||||
|
|
||||||
#include <Corrade/Utility/Path.h>
|
#include <Corrade/Utility/Path.h>
|
||||||
|
|
||||||
|
#include "../Configuration/Configuration.h"
|
||||||
#include "../FontAwesome/IconsFontAwesome5.h"
|
#include "../FontAwesome/IconsFontAwesome5.h"
|
||||||
#include "../FontAwesome/IconsFontAwesome5Brands.h"
|
#include "../FontAwesome/IconsFontAwesome5Brands.h"
|
||||||
|
|
||||||
|
#include "SaveTool.h"
|
||||||
|
|
||||||
void SaveTool::drawMainMenu() {
|
void SaveTool::drawMainMenu() {
|
||||||
if(ImGui::BeginMainMenuBar()) {
|
if(!ImGui::BeginMainMenuBar()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(ImGui::BeginMenu("Save Tool##SaveToolMenu")) {
|
if(ImGui::BeginMenu("Save Tool##SaveToolMenu")) {
|
||||||
if(ImGui::BeginMenu(ICON_FA_FOLDER_OPEN " Open game data directory", Utility::Path::exists(_gameDataDir))) {
|
if(ImGui::BeginMenu(ICON_FA_FOLDER_OPEN " Open game data directory", Utility::Path::exists(_gameDataDir))) {
|
||||||
if(ImGui::MenuItem(ICON_FA_COG " Configuration", nullptr, false, Utility::Path::exists(_configDir))) {
|
if(ImGui::MenuItem(ICON_FA_COG " Configuration", nullptr, false, Utility::Path::exists(_configDir))) {
|
||||||
|
@ -57,7 +61,7 @@ void SaveTool::drawMainMenu() {
|
||||||
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
|
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
drawAlignedText("Vertical sync:");
|
drawAlignedText("Vertical sync:");
|
||||||
if(_swapInterval == 0) {
|
if(conf().swapInterval() == 0) {
|
||||||
drawAlignedText("FPS cap:");
|
drawAlignedText("FPS cap:");
|
||||||
}
|
}
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
@ -75,10 +79,10 @@ void SaveTool::drawMainMenu() {
|
||||||
|
|
||||||
ImGui::PushItemWidth(300.0f);
|
ImGui::PushItemWidth(300.0f);
|
||||||
|
|
||||||
if(ImGui::BeginCombo("##FrameLimit", framelimit_labels[_swapInterval])) {
|
if(ImGui::BeginCombo("##FrameLimit", framelimit_labels[conf().swapInterval()])) {
|
||||||
for(int i = 0; i <= 3; i++) {
|
for(int i = 0; i <= 3; i++) {
|
||||||
if(ImGui::Selectable(framelimit_labels[i], _swapInterval == i)) {
|
if(ImGui::Selectable(framelimit_labels[i], conf().swapInterval() == i)) {
|
||||||
_swapInterval = i;
|
conf().setSwapInterval(i);
|
||||||
setSwapInterval(i);
|
setSwapInterval(i);
|
||||||
if(i == 0) {
|
if(i == 0) {
|
||||||
setMinimalLoopPeriod(0);
|
setMinimalLoopPeriod(0);
|
||||||
|
@ -89,28 +93,38 @@ void SaveTool::drawMainMenu() {
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_swapInterval == 0) {
|
if(conf().swapInterval() == 0) {
|
||||||
ImGui::SliderFloat("##FpsCapSlider", &_fpsCap, 15.0f, 301.0f,
|
static float fps_cap = conf().fpsCap();
|
||||||
_fpsCap != 301.0f ? "%.0f" : "Uncapped", ImGuiSliderFlags_AlwaysClamp);
|
if(ImGui::SliderFloat("##FpsCapSlider", &fps_cap, 15.0f, 301.0f,
|
||||||
|
conf().fpsCap() != 301.0f ? "%.0f" : "Uncapped", ImGuiSliderFlags_AlwaysClamp))
|
||||||
|
{
|
||||||
|
conf().setFpsCap(fps_cap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
||||||
ImGui::Checkbox("Cheat mode", &_cheatMode);
|
if(drawCheckbox("Cheat mode", conf().cheatMode())) {
|
||||||
|
conf().setCheatMode(!conf().cheatMode());
|
||||||
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
drawHelpMarker("This gives access to save edition features that can be considered cheats.",
|
drawHelpMarker("This gives access to save edition features that can be considered cheats.",
|
||||||
Float(windowSize().x()) * 0.4f);
|
Float(windowSize().x()) * 0.4f);
|
||||||
|
|
||||||
ImGui::Checkbox("Advanced mode", &_advancedMode);
|
if(drawCheckbox("Advanced mode", conf().advancedMode())) {
|
||||||
|
conf().setAdvancedMode(!conf().advancedMode());
|
||||||
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
drawHelpMarker("This gives access to editing values that have unknown purposes or are undocumented.",
|
drawHelpMarker("This gives access to editing values that have unknown purposes or are undocumented.",
|
||||||
Float(windowSize().x()) * 0.4f);
|
Float(windowSize().x()) * 0.4f);
|
||||||
|
|
||||||
ImGui::Checkbox("Check for updates on startup", &_checkUpdatesOnStartup);
|
if(drawCheckbox("Check for updates on startup", conf().checkUpdatesOnStartup())) {
|
||||||
|
conf().setCheckUpdatesOnStartup(!conf().checkUpdatesOnStartup());
|
||||||
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) {
|
if(ImGui::Button(ICON_FA_SYNC_ALT " Check now")) {
|
||||||
_queue.addToast(Toast::Type::Default, "Checking for updates...");
|
_queue.addToast(Toast::Type::Default, "Checking for updates...");
|
||||||
|
@ -128,7 +142,9 @@ void SaveTool::drawMainMenu() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Checkbox("Skip disclaimer", &_skipDisclaimer);
|
if(drawCheckbox("Skip disclaimer", conf().skipDisclaimer())) {
|
||||||
|
conf().setSkipDisclaimer(!conf().skipDisclaimer());
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
@ -214,4 +230,3 @@ void SaveTool::drawMainMenu() {
|
||||||
|
|
||||||
ImGui::EndMainMenuBar();
|
ImGui::EndMainMenuBar();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue