100 lines
3.2 KiB
Diff
100 lines
3.2 KiB
Diff
|
diff --git a/src/SSVOpenHexagon/Core/main.cpp b/src/SSVOpenHexagon/Core/main.cpp
|
||
|
index 7e3448f4..0c3a3f1e 100755
|
||
|
--- a/src/SSVOpenHexagon/Core/main.cpp
|
||
|
+++ b/src/SSVOpenHexagon/Core/main.cpp
|
||
|
@@ -4,6 +4,9 @@
|
||
|
|
||
|
#include <vector>
|
||
|
#include <string>
|
||
|
+#include <cstring>
|
||
|
+#include <cstdlib>
|
||
|
+#include <iostream>
|
||
|
#include <SSVUtils/SSVUtils.h>
|
||
|
#include <SSVStart/SSVStart.h>
|
||
|
#include "SSVOpenHexagon/Online/Online.h"
|
||
|
@@ -18,12 +21,24 @@ using namespace ssvu;
|
||
|
using namespace ssvu::FileSystem;
|
||
|
using namespace hg;
|
||
|
|
||
|
+static
|
||
|
+const char* getProfileFolder() {
|
||
|
+ char* path = new char[256];
|
||
|
+ strcpy(path, std::getenv("HOME"));
|
||
|
+ strcat(path, "/.config/OpenHexagon/Profiles/");
|
||
|
+ return path;
|
||
|
+}
|
||
|
+
|
||
|
void createProfilesFolder()
|
||
|
{
|
||
|
- if(exists("Profiles/")) return;
|
||
|
+ const char* profileFolder = getProfileFolder();
|
||
|
+ std::cout << "Profile folder: " << profileFolder << std::endl;
|
||
|
+ if(exists(profileFolder)) return;
|
||
|
|
||
|
log("Profiles folder does not exist, creating", "CreateProfilesFolder");
|
||
|
- createFolder("Profiles/");
|
||
|
+ char command[512];
|
||
|
+ sprintf(command, "mkdir -p \"%s\"", profileFolder);
|
||
|
+ system(command);
|
||
|
}
|
||
|
|
||
|
int main(int argc, char* argv[])
|
||
|
diff --git a/src/SSVOpenHexagon/Global/Assets.cpp b/src/SSVOpenHexagon/Global/Assets.cpp
|
||
|
index e008024d..340c74fe 100755
|
||
|
--- a/src/SSVOpenHexagon/Global/Assets.cpp
|
||
|
+++ b/src/SSVOpenHexagon/Global/Assets.cpp
|
||
|
@@ -4,6 +4,8 @@
|
||
|
|
||
|
#include <iostream>
|
||
|
#include <fstream>
|
||
|
+#include <cstdlib>
|
||
|
+#include <cstring>
|
||
|
#include <map>
|
||
|
#include <SFML/Graphics.hpp>
|
||
|
#include <SSVJsonCpp/SSVJsonCpp.h>
|
||
|
@@ -24,9 +26,17 @@ using namespace ssvu;
|
||
|
using namespace ssvuj;
|
||
|
using namespace ssvu::FileSystem;
|
||
|
|
||
|
+static
|
||
|
+const char* getProfileFolder() {
|
||
|
+ char* path = new char[256];
|
||
|
+ strcpy(path, std::getenv("HOME"));
|
||
|
+ strcat(path, "/.config/OpenHexagon/Profiles/");
|
||
|
+ return path;
|
||
|
+}
|
||
|
+
|
||
|
namespace hg
|
||
|
{
|
||
|
- AssetManager assetManager;
|
||
|
+ AssetManager assetManager;
|
||
|
map<string, MusicData> musicDataMap;
|
||
|
map<string, StyleData> styleDataMap;
|
||
|
map<string, LevelData> levelDataMap;
|
||
|
@@ -130,9 +140,10 @@ namespace hg
|
||
|
}
|
||
|
void loadProfiles()
|
||
|
{
|
||
|
- for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>("Profiles/", ".json"))
|
||
|
+ const char* profileFolder = getProfileFolder();
|
||
|
+ for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(profileFolder, ".json"))
|
||
|
{
|
||
|
- string fileName{getNameFromPath(filePath, "Profiles/", ".json")};
|
||
|
+ string fileName{getNameFromPath(filePath, profileFolder, ".json")};
|
||
|
|
||
|
ProfileData profileData{loadProfileFromJson(getRootFromFile(filePath))};
|
||
|
profileDataMap.insert(make_pair(profileData.getName(), profileData));
|
||
|
@@ -234,10 +245,10 @@ namespace hg
|
||
|
|
||
|
void setCurrentProfile(const string& mName) { currentProfilePtr = &profileDataMap.find(mName)->second; }
|
||
|
ProfileData& getCurrentProfile() { return *currentProfilePtr; }
|
||
|
- string getCurrentProfileFilePath() { return "Profiles/" + currentProfilePtr->getName() + ".json"; }
|
||
|
+ string getCurrentProfileFilePath() { return getProfileFolder() + currentProfilePtr->getName() + ".json"; }
|
||
|
void createProfile(const string& mName)
|
||
|
{
|
||
|
- ofstream o{"Profiles/" + mName + ".json"};
|
||
|
+ ofstream o{getProfileFolder() + mName + ".json"};
|
||
|
Json::Value root;
|
||
|
Json::StyledStreamWriter writer;
|
||
|
|