@@ -80,6 +80,8 @@ class SettingsTab
8080 ImGui::SameLine ();
8181 ImGui::HelpMarker (" Hides the program in recordings and screenshots" );
8282
83+ ImGui::Checkbox (" Notify about prereleases" , &S.checkPrerelease );
84+
8385 ImGui::Checkbox (" Launch client without admin" , &S.noAdmin );
8486
8587 if (ImGui::Checkbox (" Register debugger IFEO" , &S.debugger ))
@@ -155,11 +157,51 @@ class SettingsTab
155157 ImGui::InputText (" ##leaguePath" , bufLeaguePath, MAX_PATH);
156158 S.leaguePath = bufLeaguePath;
157159
158- /* if (ImGui::Button("Save Settings"))
160+ ImGui::SameLine ();
161+
162+ if (ImGui::Button (" Try to auto detect path" ))
163+ {
164+ using tSHGetFolderPathW = HRESULT (WINAPI*)(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
165+ const auto SHGetFolderPathW = reinterpret_cast <tSHGetFolderPathW>(GetProcAddress (LoadLibraryW (L" shell32.dll" ), " SHGetFolderPathW" ));
166+
167+ TCHAR szPath[MAX_PATH];
168+ if (SUCCEEDED (SHGetFolderPathW (NULL , 0x23 /* CSIDL_COMMON_APPDATA*/ , NULL , 0 , szPath)))
159169 {
160- CSettings::Save();
161- result = "Saved";
162- }*/
170+ std::filesystem::path programData (szPath);
171+ auto productSettingPath = programData / " Riot Games\\ Metadata\\ league_of_legends.live\\ league_of_legends.live.product_settings.yaml" ;
172+ if (std::filesystem::exists (productSettingPath))
173+ {
174+ std::ifstream fileStream (productSettingPath);
175+ if (fileStream.is_open ())
176+ {
177+ std::string line;
178+ while (std::getline (fileStream, line))
179+ {
180+ if (line.contains (" product_install_full_path: " ))
181+ {
182+ if (std::size_t pos = line.find (" :" ); pos != std::string::npos)
183+ {
184+ std::string value = line.substr (pos + 2 );
185+ value.erase (std::remove (value.begin (), value.end (), ' \" ' ), value.end ());
186+ size_t found;
187+ while ((found = value.find (" \\\\ " )) != std::string::npos)
188+ {
189+ value.replace (found, 2 , " /" );
190+ }
191+ if (value.back () != ' /' )
192+ value += ' /' ;
193+ S.leaguePath = value;
194+ std::fill (bufLeaguePath, bufLeaguePath + MAX_PATH, 0 );
195+ std::ranges::copy (S.leaguePath , bufLeaguePath);
196+ }
197+ }
198+ }
199+
200+ fileStream.close ();
201+ }
202+ }
203+ }
204+ }
163205
164206 ImGui::Separator ();
165207
0 commit comments