git repos / blockattack-game

commit e19eddb8

sago007 · 2019-05-05 16:21
e19eddb86f965e3e083a824eed617776f6e07203 patch · browse files
parent f634c96f1af1e7baf1948c0fb6f456f0f3c2c0fe

Fix the Windows part

Changed files

M source/code/main.cpp before
M source/code/os.cpp before
M source/code/os.hpp before
diff --git a/source/code/main.cpp b/source/code/main.cpp index 473a2f7..86176a8 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -326,7 +326,12 @@ static ExplosionManager theExplosionManager;
#include "sago/platform_folders.h"
std::string pathToScreenShots() {
- return sago::getPicturesFolder() + "/blockattack";
+ Config::getInstance()->setDefault("screenshot_dir", _("Block Attack - Rise of the Blocks"));
+ std::string screenshot_dir = Config::getInstance()->getString("screenshot_dir");
+ if (OsPathIsRelative(screenshot_dir)) {
+ return sago::getPicturesFolder() + "/" + screenshot_dir;
+ }
+ return screenshot_dir;
}
//writeScreenShot saves the screen as a bmp file, it uses the time to get a unique filename
diff --git a/source/code/os.cpp b/source/code/os.cpp index 8e65df5..626c968 100644 --- a/source/code/os.cpp +++ b/source/code/os.cpp
@@ -55,6 +55,8 @@ void setPathToSaveFiles(const std::string& path) {
}
#if defined(_WIN32)
+#include "shlwapi.h"
+
static std::wstring win32_utf8_to_utf16(const char* str) {
std::wstring res;
// If the 6th parameter is 0 then WideCharToMultiByte returns the number of bytes needed to store the result.
@@ -101,9 +103,9 @@ std::string defaultPlayerName() {
return ret;
}
-static bool OsPathIsRelative(const std::string& path) {
+bool OsPathIsRelative(const std::string& path) {
#if defined(_WIN32)
- return PathIsRelativeW(win32_utf8_to_utf16(path.c_str()));
+ return PathIsRelativeW(win32_utf8_to_utf16(path.c_str()).c_str());
#else
return path[0] != '/';
#endif
diff --git a/source/code/os.hpp b/source/code/os.hpp index 94339d3..5a07131 100644 --- a/source/code/os.hpp +++ b/source/code/os.hpp
@@ -38,4 +38,6 @@ void setPathToSaveFiles(const std::string& path);
void OsCreateSaveFolder();
+bool OsPathIsRelative(const std::string& path);
+
void OsCreateFolder(const std::string& path);