Added force extension to saving files
This commit is contained in:
parent
1d134e5d39
commit
fc16d78bb8
4 changed files with 17 additions and 1 deletions
|
|
@ -24,6 +24,7 @@
|
||||||
#include "Helpers/SCollision.hpp"
|
#include "Helpers/SCollision.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <include/core/SkPathBuilder.h>
|
#include <include/core/SkPathBuilder.h>
|
||||||
|
#include "../../FileHelpers.hpp"
|
||||||
|
|
||||||
#include "../../GridManager.hpp"
|
#include "../../GridManager.hpp"
|
||||||
|
|
||||||
|
|
@ -111,6 +112,10 @@ void ScreenshotTool::gui_toolbox(Toolbar& t) {
|
||||||
auto world = w.lock();
|
auto world = w.lock();
|
||||||
if(world && world->drawProg.drawTool->get_type() == DrawingProgramToolType::SCREENSHOT) {
|
if(world && world->drawProg.drawTool->get_type() == DrawingProgramToolType::SCREENSHOT) {
|
||||||
ScreenshotTool* screenshotTool = static_cast<ScreenshotTool*>(world->drawProg.drawTool.get());
|
ScreenshotTool* screenshotTool = static_cast<ScreenshotTool*>(world->drawProg.drawTool.get());
|
||||||
|
if(world->main.conf.forceExtensionOnPath)
|
||||||
|
screenshotTool->controls.screenshotSavePath = force_extension_on_path(p, setExtensionFilter.extensions);
|
||||||
|
else
|
||||||
|
screenshotTool->controls.screenshotSavePath = p;
|
||||||
screenshotTool->controls.screenshotSavePath = p;
|
screenshotTool->controls.screenshotSavePath = p;
|
||||||
screenshotTool->controls.screenshotSaveType = world->main.toolConfig.screenshot.selectedType;
|
screenshotTool->controls.screenshotSaveType = world->main.toolConfig.screenshot.selectedType;
|
||||||
screenshotTool->controls.setToTakeScreenshot = true;
|
screenshotTool->controls.setToTakeScreenshot = true;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@ class GlobalConfig {
|
||||||
float guiScale = 1.0f;
|
float guiScale = 1.0f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__EMSCRIPTEN__) || defined(_WIN32)
|
||||||
|
bool forceExtensionOnPath = true;
|
||||||
|
#else
|
||||||
|
bool forceExtensionOnPath = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
double dragZoomSpeed = 0.02;
|
double dragZoomSpeed = 0.02;
|
||||||
double scrollZoomSpeed = 0.4;
|
double scrollZoomSpeed = 0.4;
|
||||||
float jumpTransitionTime = 0.5f;
|
float jumpTransitionTime = 0.5f;
|
||||||
|
|
|
||||||
|
|
@ -1545,6 +1545,7 @@ void Toolbar::general_settings_inner_gui() {
|
||||||
main.set_vsync_value(main.conf.vsyncValue);
|
main.set_vsync_value(main.conf.vsyncValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
checkbox_boolean_field(gui, "force extension on path", "Force extension on path when saving files", &main.conf.forceExtensionOnPath);
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
checkbox_boolean_field(gui, "apply display scale", "Apply display scale", &main.conf.applyDisplayScale);
|
checkbox_boolean_field(gui, "apply display scale", "Apply display scale", &main.conf.applyDisplayScale);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@
|
||||||
#include "CanvasComponents/CanvasComponentContainer.hpp"
|
#include "CanvasComponents/CanvasComponentContainer.hpp"
|
||||||
#include "CanvasComponents/CanvasComponentAllocator.hpp"
|
#include "CanvasComponents/CanvasComponentAllocator.hpp"
|
||||||
#include "WorldScreenshot.hpp"
|
#include "WorldScreenshot.hpp"
|
||||||
|
#include "FileHelpers.hpp"
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#include <EmscriptenHelpers/emscripten_browser_file.h>
|
#include <EmscriptenHelpers/emscripten_browser_file.h>
|
||||||
|
|
@ -478,7 +479,10 @@ void World::autosave_to_directory(const std::filesystem::path& directoryToSaveAt
|
||||||
|
|
||||||
void World::save_to_file(const std::filesystem::path& filePathToSaveAt) {
|
void World::save_to_file(const std::filesystem::path& filePathToSaveAt) {
|
||||||
try {
|
try {
|
||||||
filePath = filePathToSaveAt;
|
if(main.conf.forceExtensionOnPath)
|
||||||
|
filePath = force_extension_on_path(filePathToSaveAt, FILE_EXTENSION);
|
||||||
|
else
|
||||||
|
filePath = filePathToSaveAt;
|
||||||
|
|
||||||
std::stringstream f;
|
std::stringstream f;
|
||||||
f.write(VersionConstants::CURRENT_SAVEFILE_HEADER.c_str(), VersionConstants::SAVEFILE_HEADER_LEN);
|
f.write(VersionConstants::CURRENT_SAVEFILE_HEADER.c_str(), VersionConstants::SAVEFILE_HEADER_LEN);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue