This commit is contained in:
@@ -21,7 +21,7 @@ Keybinds::Keybinds(int layoutNumber) :
|
||||
}
|
||||
|
||||
void Keybinds::loadKeybindsFromFile() {
|
||||
std::ifstream layoutFile(AssetManager::getResourcePath("data/config/keybinds/layout" + std::to_string(this->layoutNumber) + ".bin"), std::ios::binary);
|
||||
std::ifstream layoutFile(AssetManager::getConfigPath("data/config/keybinds/layout" + std::to_string(this->layoutNumber) + ".bin"), std::ios::binary);
|
||||
|
||||
for (Action action : ACTION_LIST_IN_ORDER) {
|
||||
this->keybinds.at(action).clear();
|
||||
@@ -48,7 +48,7 @@ void Keybinds::loadKeybindsFromFile() {
|
||||
void Keybinds::saveKeybindsToFile() const {
|
||||
if (!this->modifiable) return;
|
||||
|
||||
std::ofstream layoutFile(AssetManager::getResourcePath("data/config/keybinds/layout" + std::to_string(this->layoutNumber) + ".bin"), std::ios::trunc | std::ios::binary);
|
||||
std::ofstream layoutFile(AssetManager::getConfigPath("data/config/keybinds/layout" + std::to_string(this->layoutNumber) + ".bin"), std::ios::trunc | std::ios::binary);
|
||||
|
||||
char byte;
|
||||
for (Action action : ACTION_LIST_IN_ORDER) {
|
||||
|
||||
@@ -50,7 +50,7 @@ void Settings::loadPieces(int loadablePiecesSizeRequest) {
|
||||
}
|
||||
|
||||
void Settings::loadSettingsFromFile(bool loadPieces, std::optional<int> loadablePiecesSizeRequest) {
|
||||
std::ifstream settingsFile(AssetManager::getResourcePath("data/config/settings.bin"), std::ios::binary);
|
||||
std::ifstream settingsFile(AssetManager::getConfigPath("data/config/settings.bin"), std::ios::binary);
|
||||
char byte;
|
||||
|
||||
// file format version
|
||||
@@ -159,7 +159,7 @@ void Settings::saveSettingsToFile() const {
|
||||
|
||||
this->keybinds.at(CUSTOMIZABLE_KEYBINDS).saveKeybindsToFile();
|
||||
|
||||
std::ofstream settingsFile(AssetManager::getResourcePath("data/config/settings.bin"), std::ios::trunc | std::ios::binary);
|
||||
std::ofstream settingsFile(AssetManager::getConfigPath("data/config/settings.bin"), std::ios::trunc | std::ios::binary);
|
||||
char byte;
|
||||
|
||||
// file format version
|
||||
|
||||
@@ -59,19 +59,19 @@ int main() {
|
||||
|
||||
// CHECK CONFIG FILES
|
||||
|
||||
if (!std::filesystem::exists(AssetManager::getResourcePath("data/config/settings.bin"))) {
|
||||
if (!std::filesystem::exists(AssetManager::getConfigPath("data/config/settings.bin"))) {
|
||||
std::cout << "INFO: Settings file not found, generating..." << std::endl;
|
||||
everythingIsOK &= resetSettingsFile();
|
||||
|
||||
for (int i = 0; i < NUMBER_OF_KEYBINDS; i++) {
|
||||
if (!std::filesystem::exists(AssetManager::getResourcePath("data/config/keybinds/layout" + std::to_string(i) + ".bin"))) {
|
||||
if (!std::filesystem::exists(AssetManager::getConfigPath("data/config/keybinds/layout" + std::to_string(i) + ".bin"))) {
|
||||
std::cout << "INFO: Keybind file number " << (i + 1) << "/" << NUMBER_OF_KEYBINDS << " not found, generating..." << std::endl;
|
||||
everythingIsOK &= resetKeybindFile(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::ifstream settingsFile(AssetManager::getResourcePath("data/config/settings.bin"), std::ios::binary);
|
||||
std::ifstream settingsFile(AssetManager::getConfigPath("data/config/settings.bin"), std::ios::binary);
|
||||
char byte;
|
||||
|
||||
settingsFile.get(byte);
|
||||
@@ -101,11 +101,11 @@ int main() {
|
||||
|
||||
|
||||
bool resetSettingsFile() {
|
||||
if (!std::filesystem::exists(AssetManager::getResourcePath("data/config"))) {
|
||||
std::filesystem::create_directories(AssetManager::getResourcePath("data/config"));
|
||||
if (!std::filesystem::exists(AssetManager::getConfigPath("data/config"))) {
|
||||
std::filesystem::create_directories(AssetManager::getConfigPath("data/config"));
|
||||
}
|
||||
|
||||
auto filePath = AssetManager::getResourcePath("data/config/settings.bin");
|
||||
auto filePath = AssetManager::getConfigPath("data/config/settings.bin");
|
||||
std::ofstream settingsFile(filePath, std::ios::trunc | std::ios::binary);
|
||||
if (!settingsFile.good()) {
|
||||
std::cerr << "ERROR: Could not open file " << filePath << std::endl;
|
||||
@@ -182,11 +182,11 @@ bool resetKeybindFile(int layout) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!std::filesystem::exists(AssetManager::getResourcePath("data/config/keybinds"))) {
|
||||
std::filesystem::create_directories(AssetManager::getResourcePath("data/config/keybinds"));
|
||||
if (!std::filesystem::exists(AssetManager::getConfigPath("data/config/keybinds"))) {
|
||||
std::filesystem::create_directories(AssetManager::getConfigPath("data/config/keybinds"));
|
||||
}
|
||||
|
||||
auto filePath = AssetManager::getResourcePath("data/config/keybinds/layout" + std::to_string(layout) + ".bin");
|
||||
auto filePath = AssetManager::getConfigPath("data/config/keybinds/layout" + std::to_string(layout) + ".bin");
|
||||
std::ofstream layoutFile(filePath, std::ios::trunc | std::ios::binary);
|
||||
if (!layoutFile.good()) {
|
||||
std::cerr << "ERROR: Could not open file " << filePath << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user