Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
Guillaume Jacquemin | 7b64d78b5b | |
Guillaume Jacquemin | 59aa006611 | |
Guillaume Jacquemin | 81b35476a0 | |
Guillaume Jacquemin | b909f0ac13 | |
Guillaume Jacquemin | aff84ccc96 | |
Guillaume Jacquemin | 8177d61755 | |
Guillaume Jacquemin | c0943bd084 | |
Guillaume Jacquemin | 6fa21128ab |
|
@ -18,7 +18,7 @@ set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
set(SAVETOOL_PROJECT_VERSION 1.4.0)
|
set(SAVETOOL_PROJECT_VERSION 1.4.3)
|
||||||
|
|
||||||
find_package(Corrade REQUIRED Main Containers Utility)
|
find_package(Corrade REQUIRED Main Containers Utility)
|
||||||
find_package(Magnum REQUIRED GL Sdl2Application)
|
find_package(Magnum REQUIRED GL Sdl2Application)
|
||||||
|
|
|
@ -458,6 +458,7 @@ auto Profile::setResource(Containers::StringView container, MaterialID id, Int a
|
||||||
if(!mats_prop) {
|
if(!mats_prop) {
|
||||||
mats_prop = new ArrayProperty;
|
mats_prop = new ArrayProperty;
|
||||||
mats_prop->name.emplace(container);
|
mats_prop->name.emplace(container);
|
||||||
|
mats_prop->itemType = "StructProperty";
|
||||||
_profile.appendProperty(ArrayProperty::ptr{mats_prop});
|
_profile.appendProperty(ArrayProperty::ptr{mats_prop});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,6 +472,9 @@ auto Profile::setResource(Containers::StringView container, MaterialID id, Int a
|
||||||
ResourceItemValue* res_prop;
|
ResourceItemValue* res_prop;
|
||||||
if(it == mats_prop->items.end()) {
|
if(it == mats_prop->items.end()) {
|
||||||
res_prop = new ResourceItemValue;
|
res_prop = new ResourceItemValue;
|
||||||
|
if(mats_prop->items.isEmpty()) {
|
||||||
|
res_prop->name.emplace(container);
|
||||||
|
}
|
||||||
res_prop->id = id;
|
res_prop->id = id;
|
||||||
ResourceItemValue::ptr prop{res_prop};
|
ResourceItemValue::ptr prop{res_prop};
|
||||||
arrayAppend(mats_prop->items, std::move(prop));
|
arrayAppend(mats_prop->items, std::move(prop));
|
||||||
|
|
|
@ -51,7 +51,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.");
|
||||||
|
@ -128,15 +128,6 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
|
|
||||||
initialiseConfiguration();
|
initialiseConfiguration();
|
||||||
|
|
||||||
switch(_framelimit) {
|
|
||||||
case Framelimit::Vsync:
|
|
||||||
setSwapInterval(1);
|
|
||||||
break;
|
|
||||||
case Framelimit::HalfVsync:
|
|
||||||
setSwapInterval(2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(_checkUpdatesOnStartup) {
|
||||||
|
@ -154,6 +145,8 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
_uiState = UiState::Initialising;
|
_uiState = UiState::Initialising;
|
||||||
_initThread = std::thread{[this]{ initialiseManager(); }};
|
_initThread = std::thread{[this]{ initialiseManager(); }};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_timeline.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveTool::~SaveTool() {
|
SaveTool::~SaveTool() {
|
||||||
|
@ -170,17 +163,8 @@ SaveTool::~SaveTool() {
|
||||||
_conf.setValue("advanced_mode"_s, _advancedMode);
|
_conf.setValue("advanced_mode"_s, _advancedMode);
|
||||||
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup);
|
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup);
|
||||||
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer);
|
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer);
|
||||||
|
_conf.setValue("swap_interval"_s, _swapInterval);
|
||||||
switch(_framelimit) {
|
_conf.setValue("fps_cap"_s, _fpsCap);
|
||||||
case Framelimit::Vsync:
|
|
||||||
_conf.setValue("frame_limit"_s, "vsync"_s);
|
|
||||||
break;
|
|
||||||
case Framelimit::HalfVsync:
|
|
||||||
_conf.setValue("frame_limit"_s, "half_vsync"_s);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_conf.setValue("frame_limit"_s, "vsync"_s);
|
|
||||||
}
|
|
||||||
|
|
||||||
_conf.save();
|
_conf.save();
|
||||||
|
|
||||||
|
@ -197,7 +181,14 @@ void SaveTool::drawEvent() {
|
||||||
drawImGui();
|
drawImGui();
|
||||||
|
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
|
|
||||||
|
if(_swapInterval == 0 && _fpsCap < 301.0f) {
|
||||||
|
while(_timeline.currentFrameDuration() < (1.0f / _fpsCap));
|
||||||
|
}
|
||||||
|
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
|
_timeline.nextFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::viewportEvent(ViewportEvent& event) {
|
void SaveTool::viewportEvent(ViewportEvent& event) {
|
||||||
|
|
|
@ -23,7 +23,11 @@
|
||||||
#include <Corrade/Containers/String.h>
|
#include <Corrade/Containers/String.h>
|
||||||
#include <Corrade/Utility/Configuration.h>
|
#include <Corrade/Utility/Configuration.h>
|
||||||
#include <Corrade/Utility/Resource.h>
|
#include <Corrade/Utility/Resource.h>
|
||||||
|
#ifdef SAVETOOL_DEBUG_BUILD
|
||||||
|
#include <Corrade/Utility/Tweakable.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Magnum/Timeline.h>
|
||||||
#include <Magnum/Platform/Sdl2Application.h>
|
#include <Magnum/Platform/Sdl2Application.h>
|
||||||
#include <Magnum/ImGuiIntegration/Context.h>
|
#include <Magnum/ImGuiIntegration/Context.h>
|
||||||
|
|
||||||
|
@ -39,8 +43,6 @@
|
||||||
#include "../ToastQueue/ToastQueue.h"
|
#include "../ToastQueue/ToastQueue.h"
|
||||||
|
|
||||||
#ifdef SAVETOOL_DEBUG_BUILD
|
#ifdef SAVETOOL_DEBUG_BUILD
|
||||||
#include <Corrade/Utility/Tweakable.h>
|
|
||||||
|
|
||||||
#define tw CORRADE_TWEAKABLE
|
#define tw CORRADE_TWEAKABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -174,7 +176,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
// Also, func should be a lambda if there are any default arguments, like ImGui::Button(), etc...
|
// Also, func should be a lambda if there are any default arguments, like ImGui::Button(), etc...
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void drawUnsafeText(Containers::StringView text, Args... args) { // Alternative to the above, for ImGui::Text*() variants.
|
void drawUnsafeText(const char* text, Args... args) { // Alternative to the above, for ImGui::Text*() variants.
|
||||||
if(_gameState != GameState::NotRunning) {
|
if(_gameState != GameState::NotRunning) {
|
||||||
ImGui::TextDisabled(text, std::forward<Args>(args)...);
|
ImGui::TextDisabled(text, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
@ -260,10 +262,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
};
|
};
|
||||||
Containers::StaticArray<2, efsw::WatchID> _watchIDs;
|
Containers::StaticArray<2, efsw::WatchID> _watchIDs;
|
||||||
|
|
||||||
enum class Framelimit: UnsignedByte {
|
int _swapInterval = 1;
|
||||||
Vsync,
|
float _fpsCap = 60.0f;
|
||||||
HalfVsync
|
|
||||||
} _framelimit{Framelimit::Vsync};
|
|
||||||
|
|
||||||
bool _skipDisclaimer{false};
|
bool _skipDisclaimer{false};
|
||||||
bool _checkUpdatesOnStartup{true};
|
bool _checkUpdatesOnStartup{true};
|
||||||
|
@ -292,4 +292,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
|
|
||||||
bool _cheatMode{false};
|
bool _cheatMode{false};
|
||||||
bool _advancedMode{false};
|
bool _advancedMode{false};
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
|
@ -79,17 +79,31 @@ void SaveTool::initialiseConfiguration() {
|
||||||
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer);
|
_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)) {
|
if(_conf.hasValue("frame_limit"_s)) {
|
||||||
std::string frame_limit = _conf.value("frame_limit"_s);
|
std::string frame_limit = _conf.value("frame_limit"_s);
|
||||||
if(frame_limit == "half_vsync"_s) {
|
if(frame_limit == "half_vsync"_s) {
|
||||||
_framelimit = Framelimit::HalfVsync;
|
_swapInterval = 2;
|
||||||
}
|
}
|
||||||
else {
|
_conf.removeValue("frame_limit"_s);
|
||||||
_framelimit = Framelimit::Vsync;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
setSwapInterval(_swapInterval);
|
||||||
_conf.setValue("frame_limit"_s, "vsync"_s);
|
if(_swapInterval == 0) {
|
||||||
|
setMinimalLoopPeriod(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_conf.save();
|
_conf.save();
|
||||||
|
|
|
@ -19,12 +19,11 @@
|
||||||
|
|
||||||
#include <Magnum/ImGuiIntegration/Integration.h>
|
#include <Magnum/ImGuiIntegration/Integration.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() {
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
// 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 "../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()) {
|
||||||
if(ImGui::BeginMenu("Save Tool##SaveToolMenu")) {
|
if(ImGui::BeginMenu("Save Tool##SaveToolMenu")) {
|
||||||
|
@ -55,31 +55,49 @@ void SaveTool::drawMainMenu() {
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
|
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
|
||||||
drawAlignedText("Frame limiter:");
|
ImGui::BeginGroup();
|
||||||
|
drawAlignedText("Vertical sync:");
|
||||||
|
if(_swapInterval == 0) {
|
||||||
|
drawAlignedText("FPS cap:");
|
||||||
|
}
|
||||||
|
ImGui::EndGroup();
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
static auto selection = static_cast<UnsignedByte>(_framelimit);
|
ImGui::BeginGroup();
|
||||||
static const char* framelimit_labels[2] = {
|
|
||||||
"V-sync",
|
static const char* framelimit_labels[] = {
|
||||||
"Half V-sync"
|
"Off",
|
||||||
|
"Every VBLANK",
|
||||||
|
"Every second VBLANK",
|
||||||
|
"Every third VBLANK",
|
||||||
};
|
};
|
||||||
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
ImGui::PushItemWidth(300.0f);
|
||||||
if(ImGui::BeginCombo("##FrameLimit", framelimit_labels[selection])) {
|
|
||||||
if(ImGui::Selectable(framelimit_labels[0], _framelimit == Framelimit::Vsync)) {
|
if(ImGui::BeginCombo("##FrameLimit", framelimit_labels[_swapInterval])) {
|
||||||
selection = 0;
|
for(int i = 0; i <= 3; i++) {
|
||||||
_framelimit = Framelimit::Vsync;
|
if(ImGui::Selectable(framelimit_labels[i], _swapInterval == i)) {
|
||||||
setSwapInterval(1);
|
_swapInterval = i;
|
||||||
|
setSwapInterval(i);
|
||||||
|
if(i == 0) {
|
||||||
|
setMinimalLoopPeriod(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(ImGui::Selectable(framelimit_labels[1], _framelimit == Framelimit::HalfVsync)) {
|
|
||||||
selection = 1;
|
|
||||||
_framelimit = Framelimit::HalfVsync;
|
|
||||||
setSwapInterval(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_swapInterval == 0) {
|
||||||
|
ImGui::SliderFloat("##FpsCapSlider", &_fpsCap, 15.0f, 301.0f,
|
||||||
|
_fpsCap != 301.0f ? "%.0f" : "Uncapped", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
ImGui::EndGroup();
|
||||||
|
|
||||||
ImGui::Checkbox("Cheat mode", &_cheatMode);
|
ImGui::Checkbox("Cheat mode", &_cheatMode);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
|
|
Loading…
Reference in New Issue