FransBouma / ShaderToggler

Reshade 5+ addin to toggle shaders on/off in groups based on a key press. It allows you to configure these groups from within the addin as well.
MIT License
100 stars 28 forks source link

Fix loading/storing ini file in a wrong directory #17

Closed liuxd17thu closed 1 year ago

liuxd17thu commented 1 year ago

When using shader toggler in some games with a launcher, the ini file goes into the directory of launcher, instead of the same directory as the addon itself. I made a easy fix, generally the same way as what REST did.

FransBouma commented 1 year ago

Thanks for the fix! I inlined the variable usage which are used once in DllMain() pre-merge :)

blackwind commented 1 year ago

Note that crosire himself recommends using get_reshade_base_path() for this.

FransBouma commented 1 year ago

Hmm that would have been a better choice indeed. Will add a comment to the code. It's not a big deal as the code merged is copied from reshade it seems (and uses win32 to get the file path) but it's more code than this call would have been.

blackwind commented 1 year ago

Just found a real-world use case for get_reshade_base_path(): I tried centralizing my add-ons in one folder using the folder selector at the top of the add-ons tab so I don't have to go around and replace all copies of all add-ons for each game when a new version is released. In this configuration and with this PR, ShaderToggler.ini predictably ends up in the centralized add-ons folder, meaning you can't have separate profiles for each game. The correct logic would be to store ShaderToggler.ini next to ReShade.ini wherever that's located, which get_reshade_base_path() should accomplish.

FransBouma commented 1 year ago

I didn't realize there was a way to have all addons in a central place! that's great, because I have all my shaders in a central place but the addons are copied around to each game.

Good point!

FransBouma commented 1 year ago

@blackwind See #18 I can't use the api method as in DllMain the runtime object isn't available and the ini file has to be read at startup. However using the host exe's path works fine with a central location of the addons: the ini file is stored at the right location, where the dxgi file is located as well (or the exe file, in case of vulkan with centralized storage of the reshade dll)

blackwind commented 1 year ago

Note, though, that the RESHADE_BASE_PATH_OVERRIDE environment variable exists. This is how Special K makes ReShade dump its files into Special K's per-game profile folder, and that's where I expect add-on data to be stored as well. If the API can't be used, perhaps the environment variable itself could be checked for an override instead?

FransBouma commented 1 year ago

How nice I get info fed one info bit at a time so I can fix a fix on a fix. :(

Will think about it

(edit) The ini file for shadertoggler is stored in the exe's folder, where it normally would reside, using special K or not. So I think that's enough for now.