Trying to port a ultility and have some questions

More
5 years 3 months ago #1 by CodeManJames Trying to port a ultility and have some questions was created by CodeManJames
So there's this utility for Witcher 3 that changes the ReShade/SweetFX preset automatically when you move form zone to zone. This was accomplished in the old Reshade by writing to the current config file that ReShade has loaded. On this new ReShade I can't seem to find where it write its configs to compared to the old one. In the old one it would use this:

string presetCurrentReShade[5] = { "ReShade\\BasicFX.cfg", "ReShade\\CustomFX.cfg", "ReShade\\GemFX.cfg", "ReShade\\McFX.cfg", "ReShade\\SweetFX.cfg" };

But now I can't seem to figure out the folder structure for the new one. Can anyone help?
The following user(s) said Thank You: jminternelia

Please Log in or Create an account to join the conversation.

More
5 years 3 months ago - 5 years 3 months ago #2 by Evan20xx Replied by Evan20xx on topic Trying to port a ultility and have some questions
With ReShade 3.0, once you create a preset the .ini should be created along side to where you installed the .dll



PUBG_Enhancer_v1_1.ini being the presets config file.

I hope this is what you were looking for.
Last edit: 5 years 3 months ago by Evan20xx.

Please Log in or Create an account to join the conversation.

More
4 years 8 months ago - 4 years 8 months ago #3 by jminternelia Replied by jminternelia on topic Trying to port a ultility and have some questions
I started trying to figure this out. I am a total novice at this stuff, but Insofar as I can tell, he has it set up to point to Reshade Preset locations:
////////////////////// ReShade Presets locations //////////////////////

presetDefaultReShade[0] = "LocationPresets\\ReShade\\default\\BasicFX.cfg";
presetDefaultReShade[1] = "LocationPresets\\ReShade\\default\\CustomFX.cfg";
presetDefaultReShade[2] = "LocationPresets\\ReShade\\default\\GemFX.cfg";
presetDefaultReShade[3] = "LocationPresets\\ReShade\\default\\McFX.cfg";
presetDefaultReShade[4] = "LocationPresets\\ReShade\\default\\SweetFX.cfg";

presetCastleReShade[0] = "LocationPresets\\ReShade\\preset_wyzima_castle\\BasicFX.cfg";
presetCastleReShade[1] = "LocationPresets\\ReShade\\preset_wyzima_castle\\CustomFX.cfg";
presetCastleReShade[2] = "LocationPresets\\ReShade\\preset_wyzima_castle\\GemFX.cfg";
presetCastleReShade[3] = "LocationPresets\\ReShade\\preset_wyzima_castle\\McFX.cfg";
presetCastleReShade[4] = "LocationPresets\\ReShade\\preset_wyzima_castle\\SweetFX.cfg";

presetNovigradReShade[0] = "LocationPresets\\ReShade\\preset_novigrad(velen, oxenfurt)\\BasicFX.cfg";
presetNovigradReShade[1] = "LocationPresets\\ReShade\\preset_novigrad(velen, oxenfurt)\\CustomFX.cfg";
presetNovigradReShade[2] = "LocationPresets\\ReShade\\preset_novigrad(velen, oxenfurt)\\GemFX.cfg";
presetNovigradReShade[3] = "LocationPresets\\ReShade\\preset_novigrad(velen, oxenfurt)\\McFX.cfg";
presetNovigradReShade[4] = "LocationPresets\\ReShade\\preset_novigrad(velen, oxenfurt)\\SweetFX.cfg";

presetSkelligeReShade[0] = "LocationPresets\\ReShade\\preset_skellige\\BasicFX.cfg";
presetSkelligeReShade[1] = "LocationPresets\\ReShade\\preset_skellige\\CustomFX.cfg";
presetSkelligeReShade[2] = "LocationPresets\\ReShade\\preset_skellige\\GemFX.cfg";
presetSkelligeReShade[3] = "LocationPresets\\ReShade\\preset_skellige\\McFX.cfg";
presetSkelligeReShade[4] = "LocationPresets\\ReShade\\preset_skellige\\SweetFX.cfg";

presetKMReShade[0] = "LocationPresets\\ReShade\\preset_kaer_morhen\\BasicFX.cfg";
presetKMReShade[1] = "LocationPresets\\ReShade\\preset_kaer_morhen\\CustomFX.cfg";
presetKMReShade[2] = "LocationPresets\\ReShade\\preset_kaer_morhen\\GemFX.cfg";
presetKMReShade[3] = "LocationPresets\\ReShade\\preset_kaer_morhen\\McFX.cfg";
presetKMReShade[4] = "LocationPresets\\ReShade\\preset_kaer_morhen\\SweetFX.cfg";

presetWOReShade[0] = "LocationPresets\\ReShade\\preset_whiteorchard\\BasicFX.cfg";
presetWOReShade[1] = "LocationPresets\\ReShade\\preset_whiteorchard\\CustomFX.cfg";
presetWOReShade[2] = "LocationPresets\\ReShade\\preset_whiteorchard\\GemFX.cfg";
presetWOReShade[3] = "LocationPresets\\ReShade\\preset_whiteorchard\\McFX.cfg";
presetWOReShade[4] = "LocationPresets\\ReShade\\preset_whiteorchard\\SweetFX.cfg";

presetToussaintReShade[0] = "LocationPresets\\ReShade\\preset_toussaint\\BasicFX.cfg";
presetToussaintReShade[1] = "LocationPresets\\ReShade\\preset_toussaint\\CustomFX.cfg";
presetToussaintReShade[2] = "LocationPresets\\ReShade\\preset_toussaint\\GemFX.cfg";
presetToussaintReShade[3] = "LocationPresets\\ReShade\\preset_toussaint\\McFX.cfg";
presetToussaintReShade[4] = "LocationPresets\\ReShade\\preset_toussaint\\SweetFX.cfg";


With ReShade 3, the presets aren't stored in individual config files like older versions. The entire preset is in a single .ini file. Also, Reshade's shaders now store the individual default values for each shader in the shader itself, making pointing to each shader's configuration moot. So, in acknowledgement of that, wouldn't it be coded as below?

////////////////////// ReShade Presets locations //////////////////////

presetDefaultReShade[0] = "1.ini";
presetCastleReShade[0] = "2.ini";
presetNovigradReShade[0] = "3.ini";
presetSkelligeReShade[0] = "4.ini";
presetKMReShade[0] = "5.ini";
presetWOReShade[0] = "6.ini";
presetToussaintReShade[0] = "7.ini";


If so, then where I am getting stumped is where the individual .cfg files are interpreted as below. In essence, from what it looks like, he is reading each config file within each preset to get the values for the shaders. I included a snippet of his code to show what I am referring to (lines 483-924 of the source code .cpp):

//////////////////////////////////////////// ReShade Files ////////////////////////////////////////////

////////////////////// Default Preset ///////////////////

////////// BasicFX.cfg /////////

ifstream fileDefaultReShade0;
fileDefaultReShade0.open(presetDefaultReShade[0]);

strStream << fileDefaultReShade0.rdbuf();
presetDefaultReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileDefaultReShade0.close();

////////// CustomFX.cfg /////////

ifstream fileDefaultReShade1;
fileDefaultReShade1.open(presetDefaultReShade[1]);

strStream << fileDefaultReShade1.rdbuf();
presetDefaultReShadeLoaded[1] = strStream.str();

strStream.str(string());
strStream.clear();
fileDefaultReShade1.close();

////////// GemFX.cfg /////////

ifstream fileDefaultReShade2;
fileDefaultReShade2.open(presetDefaultReShade[2]);

strStream << fileDefaultReShade2.rdbuf();
presetDefaultReShadeLoaded[2] = strStream.str();

strStream.str(string());
strStream.clear();
fileDefaultReShade2.close();

////////// McFX.cfg /////////

ifstream fileDefaultReShade3;
fileDefaultReShade3.open(presetDefaultReShade[3]);

strStream << fileDefaultReShade3.rdbuf();
presetDefaultReShadeLoaded[3] = strStream.str();

strStream.str(string());
strStream.clear();
fileDefaultReShade3.close();

////////// SweetFX.cfg /////////


ifstream fileDefaultReShade4;
fileDefaultReShade4.open(presetDefaultReShade[4]);

strStream << fileDefaultReShade4.rdbuf();
presetDefaultReShadeLoaded[4] = strStream.str();

strStream.str(string());
strStream.clear();
fileDefaultReShade4.close();

////////////////////// Castle Preset ///////////////////

////////// BasicFX.cfg /////////

ifstream fileCastleReShade0;
fileCastleReShade0.open(presetCastleReShade[0]);

strStream << fileCastleReShade0.rdbuf();
presetCastleReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileCastleReShade0.close();

////////// CustomFX.cfg /////////

ifstream fileCastleReShade1;
fileCastleReShade1.open(presetCastleReShade[1]);

strStream << fileCastleReShade1.rdbuf();
presetCastleReShadeLoaded[1] = strStream.str();

strStream.str(string());
strStream.clear();
fileCastleReShade1.close();

////////// GemFX.cfg /////////

ifstream fileCastleReShade2;
fileCastleReShade0.open(presetCastleReShade[2]);

strStream << fileCastleReShade2.rdbuf();
presetCastleReShadeLoaded[2] = strStream.str();

strStream.str(string());
strStream.clear();
fileCastleReShade2.close();

////////// McFX.cfg /////////

ifstream fileCastleReShade3;
fileCastleReShade3.open(presetCastleReShade[3]);

strStream << fileCastleReShade3.rdbuf();
presetCastleReShadeLoaded[3] = strStream.str();

strStream.str(string());
strStream.clear();
fileCastleReShade3.close();

////////// SweetFX.cfg /////////


ifstream fileCastleReShade4;
fileCastleReShade4.open(presetCastleReShade[4]);

strStream << fileCastleReShade4.rdbuf();
presetCastleReShadeLoaded[4] = strStream.str();

strStream.str(string());
strStream.clear();
fileCastleReShade4.close();

////////////////////// Novigrad Preset ///////////////////

////////// BasicFX.cfg /////////

ifstream fileNovigradReShade0;
fileNovigradReShade0.open(presetNovigradReShade[0]);

strStream << fileNovigradReShade0.rdbuf();
presetNovigradReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileNovigradReShade0.close();

////////// CustomFX.cfg /////////

ifstream fileNovigradReShade1;
fileNovigradReShade1.open(presetNovigradReShade[1]);

strStream << fileNovigradReShade1.rdbuf();
presetNovigradReShadeLoaded[1] = strStream.str();

strStream.str(string());
strStream.clear();
fileNovigradReShade1.close();

////////// GemFX.cfg /////////

ifstream fileNovigradReShade2;
fileNovigradReShade2.open(presetNovigradReShade[2]);

strStream << fileNovigradReShade2.rdbuf();
presetNovigradReShadeLoaded[2] = strStream.str();

strStream.str(string());
strStream.clear();
fileNovigradReShade2.close();

////////// McFX.cfg /////////

ifstream fileNovigradReShade3;
fileNovigradReShade3.open(presetNovigradReShade[3]);

strStream << fileNovigradReShade3.rdbuf();
presetNovigradReShadeLoaded[3] = strStream.str();

strStream.str(string());
strStream.clear();
fileNovigradReShade3.close();

////////// SweetFX.cfg /////////


ifstream fileNovigradReShade4;
fileNovigradReShade4.open(presetNovigradReShade[4]);

strStream << fileNovigradReShade4.rdbuf();
presetNovigradReShadeLoaded[4] = strStream.str();

strStream.str(string());
strStream.clear();
fileNovigradReShade4.close();

////////////////////// Skellige Preset ///////////////////

////////// BasicFX.cfg /////////

ifstream fileSkelligeReShade0;
fileSkelligeReShade0.open(presetSkelligeReShade[0]);

strStream << fileSkelligeReShade0.rdbuf();
presetSkelligeReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileSkelligeReShade0.close();

////////// CustomFX.cfg /////////

ifstream fileSkelligeReShade1;
fileSkelligeReShade1.open(presetSkelligeReShade[1]);

strStream << fileSkelligeReShade1.rdbuf();
presetSkelligeReShadeLoaded[1] = strStream.str();

strStream.str(string());
strStream.clear();
fileSkelligeReShade1.close();

////////// GemFX.cfg /////////

ifstream fileSkelligeReShade2;
fileSkelligeReShade2.open(presetSkelligeReShade[2]);

strStream << fileSkelligeReShade2.rdbuf();
presetSkelligeReShadeLoaded[2] = strStream.str();

strStream.str(string());
strStream.clear();
fileSkelligeReShade2.close();

////////// McFX.cfg /////////

ifstream fileSkelligeReShade3;
fileSkelligeReShade3.open(presetSkelligeReShade[3]);

strStream << fileSkelligeReShade3.rdbuf();
presetSkelligeReShadeLoaded[3] = strStream.str();

strStream.str(string());
strStream.clear();
fileSkelligeReShade3.close();

////////// SweetFX.cfg /////////


ifstream fileSkelligeReShade4;
fileSkelligeReShade4.open(presetSkelligeReShade[4]);

strStream << fileSkelligeReShade4.rdbuf();
presetSkelligeReShadeLoaded[4] = strStream.str();

strStream.str(string());
strStream.clear();
fileSkelligeReShade4.close();

////////////////////// Kaer Morhen Preset ///////////////////

////////// BasicFX.cfg /////////

ifstream fileKMReShade0;
fileKMReShade0.open(presetKMReShade[0]);

strStream << fileKMReShade0.rdbuf();
presetKMReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileKMReShade0.close();

////////// CustomFX.cfg /////////

ifstream fileKMReShade1;
fileKMReShade1.open(presetKMReShade[1]);

strStream << fileKMReShade1.rdbuf();
presetKMReShadeLoaded[1] = strStream.str();

strStream.str(string());
strStream.clear();
fileKMReShade1.close();

////////// GemFX.cfg /////////

ifstream fileKMReShade2;
fileKMReShade2.open(presetKMReShade[2]);

strStream << fileKMReShade2.rdbuf();
presetKMReShadeLoaded[2] = strStream.str();

strStream.str(string());
strStream.clear();
fileKMReShade2.close();

////////// McFX.cfg /////////

ifstream fileKMReShade3;
fileKMReShade3.open(presetKMReShade[3]);

strStream << fileKMReShade3.rdbuf();
presetKMReShadeLoaded[3] = strStream.str();

strStream.str(string());
strStream.clear();
fileKMReShade3.close();

////////// SweetFX.cfg /////////


ifstream fileKMReShade4;
fileKMReShade4.open(presetKMReShade[4]);

strStream << fileKMReShade4.rdbuf();
presetKMReShadeLoaded[4] = strStream.str();

strStream.str(string());
strStream.clear();
fileKMReShade4.close();

////////////////////// White Orchard Preset ///////////////////

////////// BasicFX.cfg /////////

ifstream fileWOReShade0;
fileWOReShade0.open(presetWOReShade[0]);

strStream << fileWOReShade0.rdbuf();
presetWOReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileWOReShade0.close();

////////// CustomFX.cfg /////////

ifstream fileWOReShade1;
fileWOReShade1.open(presetWOReShade[1]);

strStream << fileWOReShade1.rdbuf();
presetWOReShadeLoaded[1] = strStream.str();

strStream.str(string());
strStream.clear();
fileWOReShade1.close();

////////// GemFX.cfg /////////

ifstream fileWOReShade2;
fileWOReShade2.open(presetWOReShade[2]);

strStream << fileWOReShade2.rdbuf();
presetWOReShadeLoaded[2] = strStream.str();

strStream.str(string());
strStream.clear();
fileWOReShade2.close();

////////// McFX.cfg /////////

ifstream fileWOReShade3;
fileWOReShade3.open(presetWOReShade[3]);

strStream << fileWOReShade3.rdbuf();
presetWOReShadeLoaded[3] = strStream.str();

strStream.str(string());
strStream.clear();
fileWOReShade3.close();

////////// SweetFX.cfg /////////


ifstream fileWOReShade4;
fileWOReShade4.open(presetWOReShade[4]);

strStream << fileWOReShade4.rdbuf();
presetWOReShadeLoaded[4] = strStream.str();

strStream.str(string());
strStream.clear();
fileWOReShade4.close();

////////////////////// Toussaint Preset ///////////////////

////////// BasicFX.cfg /////////

ifstream fileToussaintReShade0;
fileToussaintReShade0.open(presetToussaintReShade[0]);

strStream << fileToussaintReShade0.rdbuf();
presetToussaintReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileToussaintReShade0.close();

////////// CustomFX.cfg /////////

ifstream fileToussaintReShade1;
fileToussaintReShade1.open(presetToussaintReShade[1]);

strStream << fileToussaintReShade1.rdbuf();
presetToussaintReShadeLoaded[1] = strStream.str();

strStream.str(string());
strStream.clear();
fileToussaintReShade1.close();

////////// GemFX.cfg /////////

ifstream fileToussaintReShade2;
fileToussaintReShade2.open(presetToussaintReShade[2]);

strStream << fileToussaintReShade2.rdbuf();
presetToussaintReShadeLoaded[2] = strStream.str();

strStream.str(string());
strStream.clear();
fileToussaintReShade2.close();

////////// McFX.cfg /////////

ifstream fileToussaintReShade3;
fileToussaintReShade3.open(presetToussaintReShade[3]);

strStream << fileToussaintReShade3.rdbuf();
presetToussaintReShadeLoaded[3] = strStream.str();

strStream.str(string());
strStream.clear();
fileToussaintReShade3.close();

////////// SweetFX.cfg /////////


ifstream fileToussaintReShade4;
fileToussaintReShade4.open(presetToussaintReShade[4]);

strStream << fileToussaintReShade4.rdbuf();
presetToussaintReShadeLoaded[4] = strStream.str();

strStream.str(string());
strStream.clear();
fileToussaintReShade4.close();


Instead of having separate "pointers" to each .cfg file (that no longer exist for ReShade 3), wouldn't having a single "pointer" for each preset work, or can this be eliminated altogether since we already pointed to the preset? (My guess is no, since he isn't reading the preset values in fields 351-393). If my assumption is correct, would the following be likely the correct solution?

//////////////////////////////////////////// ReShade Files ////////////////////////////////////////////

////////////////////// Default Preset ///////////////////

ifstream fileDefaultReShade0;
fileDefaultReShade0.open(presetDefaultReShade[0]);

strStream << fileDefaultReShade0.rdbuf();
presetDefaultReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileDefaultReShade0.close();

////////////////////// Castle Preset ///////////////////

ifstream fileCastleReShade0;
fileCastleReShade0.open(presetCastleReShade[0]);

strStream << fileCastleReShade0.rdbuf();
presetCastleReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileCastleReShade0.close();

////////////////////// Novigrad Preset ///////////////////

ifstream fileNovigradReShade0;
fileNovigradReShade0.open(presetNovigradReShade[0]);

strStream << fileNovigradReShade0.rdbuf();
presetNovigradReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileNovigradReShade0.close();

////////////////////// Skellige Preset ///////////////////

ifstream fileSkelligeReShade0;
fileSkelligeReShade0.open(presetSkelligeReShade[0]);

strStream << fileSkelligeReShade0.rdbuf();
presetSkelligeReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileSkelligeReShade0.close();

////////////////////// Kaer Morhen Preset ///////////////////

ifstream fileKMReShade0;
fileKMReShade0.open(presetKMReShade[0]);

strStream << fileKMReShade0.rdbuf();
presetKMReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileKMReShade0.close();

////////////////////// White Orchard Preset ///////////////////

ifstream fileWOReShade0;
fileWOReShade0.open(presetWOReShade[0]);

strStream << fileWOReShade0.rdbuf();
presetWOReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileWOReShade0.close();

////////////////////// Toussaint Preset ///////////////////

ifstream fileToussaintReShade0;
fileToussaintReShade0.open(presetToussaintReShade[0]);

strStream << fileToussaintReShade0.rdbuf();
presetToussaintReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileToussaintReShade0.close();


If I am correct, then all that needs done is for someone to compile this, but I am probably not right. In any case, here's what the .cpp would look like if I am correct:

#define _CRT_SECURE_NO_WARNINGS 1
#pragma comment(lib, "Shlwapi.lib")

#include "Shlwapi.h"
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <Shlobj.h>
#include <sstream>


using namespace std;

string GetMyDocumentsPath(); //get path to my documents for accessing user.settings
string GetCurrentLocation(); //get current location in game from user.settings (there is custom option "Location" that scripts change after location change and save load/new game start in game)
string GetReShadeOrSFX(); //checks if SweetFX or ReShade is used, simply checks if "ReShade" or "SweetFX" folders exist in bin\x64

int loadedPreset = 6; //default

bool GetGameExe();
bool IsLocationChanged(); //check if location was changed by reading "LocationChanged" value in user.settings

void ShowStartMessage(); //show text message at the start in console
void SaveUserSettings(); //rewrite user.settings with values from temp file
void ChangePreset(string sfxOrReShade, string type); //copy and overwrite specific preset settings file to sweetfx_settings so sweetfx will automatically detect changes and reload
//type - "default" or "location change", default loads default preset, "location change" checks current location in user.settings and loads appriopriate preset
void LoadPresetsToMemory(); // to reduce drive reads
void ClearLoadedPresets(); // to reduce drive reads
void SavePreset(string SFXOrReShade, string location);
void LoadUserSettings();
void ChangeLoadedUserSettingsLine(string option, string value);


string presetCastleSFX, presetNovigradSFX, presetSkelligeSFX, presetKMSFX, presetWOSFX, presetToussaintSFX;
string presetDefaultSFX;
string presetCastleReShade[5], presetNovigradReShade[5], presetSkelligeReShade[5], presetKMReShade[5], presetWOReShade[5], presetToussaintReShade[5];
string presetDefaultReShade[5];

string presetCastleSFXLoaded, presetNovigradSFXLoaded, presetSkelligeSFXLoaded, presetKMSFXLoaded, presetWOSFXLoaded, presetToussaintSFXLoaded;
string presetDefaultSFXLoaded;
string presetCastleReShadeLoaded[5], presetNovigradReShadeLoaded[5], presetSkelligeReShadeLoaded[5], presetKMReShadeLoaded[5], presetWOReShadeLoaded[5], presetToussaintReShadeLoaded[5];
string presetDefaultReShadeLoaded[5];
string userSettingsLoaded;

string presetCurrentSFX = "SweetFX\\SweetFX_settings.txt";
string presetCurrentReShade[5] = { "ReShade\\BasicFX.cfg", "ReShade\\CustomFX.cfg", "ReShade\\GemFX.cfg", "ReShade\\McFX.cfg", "ReShade\\SweetFX.cfg" };

string myDocuments = GetMyDocumentsPath();
string userSettings = myDocuments + "\\The Witcher 3\\user.settings";

int main()
{
ShowStartMessage();
if (GetReShadeOrSFX() != "")
cout << "Using: " << GetReShadeOrSFX() << endl << endl;
else
{
cout << "ReShade or SweetFX not found.\n\n";
}
if (GetGameExe())
cout << "witcher3.exe detected." << endl << endl;
else
{
cout << "witcher3.exe not found.\n\n";
}
if ((GetReShadeOrSFX() == "") || (!GetGameExe()))
{
cin.get();
cin.get();
return 1;
}
if (GetMyDocumentsPath() == "")
{
cout << "Could not find My Documents\n";
cin.get();
cin.get();
return 1;
}
LoadUserSettings();
if (userSettingsLoaded.length() < 1)
{
cout << "Could not load user.settings\n";
cin.get();
cin.get();
return 1;
}

cout << "Loading presets...\n";
LoadPresetsToMemory();
ChangeLoadedUserSettingsLine("Location", "6");
SaveUserSettings();
userSettingsLoaded.clear();

cout << "Loading default preset.\n\n\n";

ChangePreset(GetReShadeOrSFX(), "default"); //load default preset at program start
userSettingsLoaded.clear();


while (true)
{
Sleep(2000); //no need to check for location change too often and use cpu too much,
//because after location change in game, "LocationChanged" in user.settings is set to true through scripts even before location is finished loading in game
if (IsLocationChanged())
{
ChangePreset(GetReShadeOrSFX(), "location change");
}
}

return 0;
}
string GetMyDocumentsPath()
{
wchar_t Folder[1024];
HRESULT hr = SHGetFolderPath(0, CSIDL_MYDOCUMENTS, 0, 0, Folder);
if (SUCCEEDED(hr))
{
char str[1024];
wcstombs(str, Folder, 1023);
return str;
}
else
return "";
}
bool IsLocationChanged()
{
int savedLocation;
ifstream input(myDocuments + "\\The Witcher 3\\user.settings");
for (string line; getline(input, line); )
{
if (line == "Location=0")
{
savedLocation = 0;
break;
}
else if (line == "Location=1")
{
savedLocation = 1;
break;
}
else if (line == "Location=2")
{
savedLocation = 2;
break;
}
else if (line == "Location=3")
{
savedLocation = 3;
break;
}
else if (line == "Location=4")
{
savedLocation = 4;
break;
}
else if (line == "Location=5")
{
savedLocation = 5;
break;
}
else if (line == "Location=6")
{
savedLocation = 6;
break;
}
}

if (savedLocation != loadedPreset)
return true;
else
return false;
}
void ChangeLoadedUserSettingsLine(string option, string value)
{
size_t start_pos, max_pos;
string lineToReplace, replacingLine, optionValues[7];
bool setToFalse, found;
found = false;
start_pos = 0;
max_pos = userSettingsLoaded.length();

if (option == "LocationChanged")
{
setToFalse = false;
start_pos = userSettingsLoaded.find("LocationChanged=true");
lineToReplace = "LocationChanged=true";
if (start_pos > max_pos)
{
setToFalse = true;
}
if (!setToFalse)
{
replacingLine = option + "=" + "false";
userSettingsLoaded.replace(start_pos, lineToReplace.length(), replacingLine);
}
}
else if (option == "Location")
{
optionValues[0] = "Location=0";
optionValues[1] = "Location=1";
optionValues[2] = "Location=2";
optionValues[3] = "Location=3";
optionValues[4] = "Location=4";
optionValues[5] = "Location=5";
optionValues[6] = "Location=6";

for (int i = 0; i < 7; i++)
{
start_pos = userSettingsLoaded.find(optionValues);
if (start_pos < max_pos)
{
lineToReplace = optionValues;
found = true;
break;
}

}
if (found)
{
replacingLine = option + "=" + value;
start_pos = userSettingsLoaded.find(lineToReplace);
userSettingsLoaded.replace(start_pos, lineToReplace.length(), replacingLine);
}
}


}
void SaveUserSettings()
{
ofstream fileout(userSettings);
fileout << userSettingsLoaded;
fileout.close();
}
void LoadUserSettings()
{
stringstream strStream;

ifstream filein;
filein.open(userSettings);
strStream << filein.rdbuf();
userSettingsLoaded = strStream.str();

strStream.str(string());
strStream.clear();
filein.close();
}
void ChangePreset(string sfxOrReShade, string type)
{
if (sfxOrReShade == "SweetFX" && type == "location change")
{
SavePreset("SweetFX", GetCurrentLocation());
}
else if (sfxOrReShade == "ReShade" && type == "location change")
{
SavePreset("ReShade", GetCurrentLocation());
}


if (sfxOrReShade == "SweetFX" && type == "default")
{
SavePreset("SweetFX", "default");
}
else if (sfxOrReShade == "ReShade" && type == "default")
{
SavePreset("ReShade", "default");
}
if (type == "location change")
cout << "Location changed.\nCurrentlocation in game: " << GetCurrentLocation() << "\nChanging preset.\n\n";
}
string GetCurrentLocation()
{
ifstream input(myDocuments + "\\The Witcher 3\\user.settings");
for (string line; getline(input, line); )
{
if (line == "Location=0")
return "Wyzima Castle";
else if(line == "Location=1")
return "Novigrad";
else if (line == "Location=2")
return "Skellige";
else if (line == "Location=3")
return "Kaer Morhen";
else if (line == "Location=4")
return "White Orchard";
else if (line == "Location=5")
return "Toussaint";
else if (line == "Location=6")
return "default";
}
return "";
}
void ShowStartMessage()
{

cout
<< "

\n"
<< "
Different SFX Presets for Witcher 3
\n"
<< "
\n"
<< "
By Murzinio
\n\n";
}
string GetReShadeOrSFX()
{
if (PathFileExists(L"reshade-shaders"))
return "ReShade";
else if (PathFileExists(L"SweetFX"))
return "SweetFX";
else
return "";
}
bool GetGameExe()
{
if (PathFileExists(L"witcher3.exe"))
return true;
else
return false;
}
void ClearLoadedPresets()
{
presetCastleSFXLoaded.clear();
presetNovigradSFXLoaded.clear();
presetSkelligeSFXLoaded.clear();
presetKMSFXLoaded.clear();
presetWOSFXLoaded.clear();
presetToussaintSFXLoaded.clear();
presetDefaultSFXLoaded.clear();
for (int i = 0; i < 5; i++)
{
presetCastleReShadeLoaded.clear();
presetNovigradReShadeLoaded.clear();
presetSkelligeReShadeLoaded.clear();
presetKMReShadeLoaded.clear();
presetWOReShadeLoaded.clear();
presetToussaintReShadeLoaded.clear();
presetDefaultReShadeLoaded.clear();
}
}
void LoadPresetsToMemory()
{
////////////////////// SweetFX Presets Locations //////////////////////

presetDefaultSFX = "LocationPresets\\SweetFX\\SweetFX_default.txt";

presetCastleSFX = "LocationPresets\\SweetFX\\preset_wyzima_castle.txt";
presetNovigradSFX = "LocationPresets\\SweetFX\\preset_novigrad(velen, oxenfurt).txt";
presetSkelligeSFX = "LocationPresets\\SweetFX\\preset_skellige.txt";
presetKMSFX = "LocationPresets\\SweetFX\\preset_kaer_morhen.txt";
presetWOSFX = "LocationPresets\\SweetFX\\preset_whiteorchard.txt";
presetToussaintSFX = "LocationPresets\\SweetFX\\preset_toussaint.txt";

////////////////////// ReShade Presets locations //////////////////////

presetDefaultReShade[0] = "1.ini";

presetCastleReShade[0] = "2.ini";

presetNovigradReShade[0] = "3.ini";

presetSkelligeReShade[0] = "4.ini";

presetKMReShade[0] = "5.ini";

presetWOReShade[0] = "6.ini";

presetToussaintReShade[0] = "7.ini";

//////////////////////////////////////////// SweetFX Files ////////////////////////////////////////////

stringstream strStream;

////////////////////// Default Preset //////////////////////

ifstream fileDefaultSFX;
fileDefaultSFX.open(presetDefaultSFX);

strStream << fileDefaultSFX.rdbuf();
presetDefaultSFXLoaded = strStream.str();

strStream.str(string());
strStream.clear();
fileDefaultSFX.close();

////////////////////// Vizima Preset //////////////////////

ifstream fileCastleSFX;
fileCastleSFX.open(presetCastleSFX);

strStream << fileCastleSFX.rdbuf();
presetCastleSFXLoaded = strStream.str();

strStream.str(string());
strStream.clear();
fileCastleSFX.close();

////////////////////// Novigrad Preset //////////////////////

ifstream fileNovigradSFX;
fileNovigradSFX.open(presetNovigradSFX);

strStream << fileNovigradSFX.rdbuf();
presetNovigradSFXLoaded = strStream.str();

strStream.str(string());
strStream.clear();
fileNovigradSFX.close();

////////////////////// Skellige Preset //////////////////////

ifstream fileSkelligeSFX;
fileSkelligeSFX.open(presetNovigradSFX);

strStream << fileSkelligeSFX.rdbuf();
presetSkelligeSFXLoaded = strStream.str();

strStream.str(string());
strStream.clear();
fileSkelligeSFX.close();

////////////////////// Kaer Morhen Preset ///////////////////

ifstream fileKMSFX;
fileKMSFX.open(presetKMSFX);

strStream << fileKMSFX.rdbuf();
presetKMSFXLoaded = strStream.str();

strStream.str(string());
strStream.clear();
fileKMSFX.close();

////////////////////// White Orchard Preset /////////////////

ifstream fileWOSFX;
fileWOSFX.open(presetWOSFX);

strStream << fileWOSFX.rdbuf();
presetWOSFXLoaded = strStream.str();

strStream.str(string());
strStream.clear();
fileWOSFX.close();

////////////////////// Toussaint Preset ///////////////////

ifstream fileToussaintSFXX;
fileToussaintSFXX.open(presetToussaintSFX);

strStream << fileToussaintSFXX.rdbuf();
presetToussaintSFXLoaded = strStream.str();

strStream.str(string());
strStream.clear();
fileToussaintSFXX.close();

//////////////////////////////////////////// ReShade Files ////////////////////////////////////////////

////////////////////// Default Preset ///////////////////

ifstream fileDefaultReShade0;
fileDefaultReShade0.open(presetDefaultReShade[0]);

strStream << fileDefaultReShade0.rdbuf();
presetDefaultReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileDefaultReShade0.close();

////////////////////// Castle Preset ///////////////////

ifstream fileCastleReShade0;
fileCastleReShade0.open(presetCastleReShade[0]);

strStream << fileCastleReShade0.rdbuf();
presetCastleReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileCastleReShade0.close();

////////////////////// Novigrad Preset ///////////////////

ifstream fileNovigradReShade0;
fileNovigradReShade0.open(presetNovigradReShade[0]);

strStream << fileNovigradReShade0.rdbuf();
presetNovigradReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileNovigradReShade0.close();

////////////////////// Skellige Preset ///////////////////

ifstream fileSkelligeReShade0;
fileSkelligeReShade0.open(presetSkelligeReShade[0]);

strStream << fileSkelligeReShade0.rdbuf();
presetSkelligeReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileSkelligeReShade0.close();

////////////////////// Kaer Morhen Preset ///////////////////

ifstream fileKMReShade0;
fileKMReShade0.open(presetKMReShade[0]);

strStream << fileKMReShade0.rdbuf();
presetKMReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileKMReShade0.close();

////////////////////// White Orchard Preset ///////////////////

ifstream fileWOReShade0;
fileWOReShade0.open(presetWOReShade[0]);

strStream << fileWOReShade0.rdbuf();
presetWOReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileWOReShade0.close();

////////////////////// Toussaint Preset ///////////////////

ifstream fileToussaintReShade0;
fileToussaintReShade0.open(presetToussaintReShade[0]);

strStream << fileToussaintReShade0.rdbuf();
presetToussaintReShadeLoaded[0] = strStream.str();

strStream.str(string());
strStream.clear();
fileToussaintReShade0.close();

}
void SavePreset(string SFXOrReShade, string location)
{
if (SFXOrReShade == "SweetFX")
{
ofstream fileout(presetCurrentSFX);
if (location == "default")
{
fileout << presetDefaultSFXLoaded;
loadedPreset = 6;
}
else if (location == "Wyzima Castle")
{
fileout << presetCastleSFXLoaded;
loadedPreset = 0;
}
else if (location == "Novigrad")
{
fileout << presetNovigradSFXLoaded;
loadedPreset = 1;
}
else if (location == "Skellige")
{
fileout << presetSkelligeSFXLoaded;
loadedPreset = 2;
}
else if (location == "Kaer Morhen")
{
fileout << presetKMSFXLoaded;
loadedPreset = 3;
}
else if (location == "White Orchard")
{
fileout << presetWOSFXLoaded;
loadedPreset = 4;
}
else if (location == "Toussaint")
{
fileout << presetToussaintSFXLoaded;
loadedPreset = 5;
}
fileout.close();
}
else if (SFXOrReShade == "ReShade")
{
ofstream fileout;
if (location == "default")
{
loadedPreset = 6;
for (int i = 0; i < 5; i++)
{
fileout.open(presetCurrentReShade);
fileout << presetDefaultReShadeLoaded;
fileout.close();
}
}
else if (location == "Wyzima Castle")
{
loadedPreset = 0;
for (int i = 0; i < 5; i++)
{
fileout.open(presetCurrentReShade);
fileout << presetCastleReShadeLoaded;
fileout.close();
}
}
else if (location == "Novigrad")
{
loadedPreset = 1;
for (int i = 0; i < 5; i++)
{
loadedPreset = 1;
fileout.open(presetCurrentReShade);
fileout << presetNovigradReShadeLoaded;
fileout.close();
}
}
else if (location == "Skellige")
{
loadedPreset = 2;
for (int i = 0; i < 5; i++)
{
fileout.open(presetCurrentReShade);
fileout << presetSkelligeReShadeLoaded;
fileout.close();
}
}
else if (location == "Kaer Morhen")
{
loadedPreset = 3;
for (int i = 0; i < 5; i++)
{
fileout.open(presetCurrentReShade);
fileout << presetKMReShadeLoaded;
fileout.close();
}
}
else if (location == "White Orchard")
{
loadedPreset = 4;
for (int i = 0; i < 5; i++)
{
fileout.open(presetCurrentReShade);
fileout << presetWOReShadeLoaded;
fileout.close();
}
}
else if (location == "Toussaint")
{
loadedPreset = 5;
for (int i = 0; i < 5; i++)
{
fileout.open(presetCurrentReShade);
fileout << presetToussaintReShadeLoaded;
fileout.close();
}
}
}
}
Last edit: 4 years 8 months ago by jminternelia.

Please Log in or Create an account to join the conversation.

More
4 years 8 months ago #4 by Chavolatra Replied by Chavolatra on topic Trying to port a ultility and have some questions
and this works ?

Please Log in or Create an account to join the conversation.

More
4 years 8 months ago #5 by JTLB Replied by JTLB on topic Trying to port a ultility and have some questions
GW2Hook a version of ReShade built for GuildWars2, has this function. Maybe try and contact him.

04348.github.io/Gw2Hook/index.html

Please Log in or Create an account to join the conversation.

More
3 years 5 months ago #6 by Neo_Bambi Replied by Neo_Bambi on topic Trying to port a ultility and have some questions
Been trying to get Different SFX or ReShade Presets For Each Location working on reshade v3+ and I've seen your solution and I want to try it but I have no idea where to put the .cpp file. Does anybody know where?

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #7 by vinkrogel Replied by vinkrogel on topic Trying to port a ultility and have some questions
I was working on this last night. Unfortunately, it seems ReShade no longer detects changes to ini or shader files and auto reloads. I've asked for clarification here:
reshade.me/forum/general-discussion/5064...of-reshade-gui#34696

Please Log in or Create an account to join the conversation.

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.