Skip to content

Commit 7a5d841

Browse files
committed
Populate a list of Path-to-AppID mappings in the registry for platforms that may not have a manifest that Special K can parse (e.g. Epic)
1 parent 4358daf commit 7a5d841

2 files changed

Lines changed: 42 additions & 13 deletions

File tree

src/tabs/library.cpp

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5249,8 +5249,14 @@ SKIF_UI_Tab_DrawLibrary (void)
52495249
pre = SKIF_Util_timeGetTime1 ( );
52505250

52515251
bool newCategories = true;
5252-
HKEY hKey;
5253-
LSTATUS lsKey = RegCreateKeyW (HKEY_CURRENT_USER, LR"(SOFTWARE\Kaldaien\Special K\Profiles)", &hKey);
5252+
HKEY hProfilesKey = 0;
5253+
HKEY hAppIdsKey = 0;
5254+
LSTATUS lsKey = RegCreateKeyW (HKEY_CURRENT_USER, LR"(SOFTWARE\Kaldaien\Special K\Profiles)", &hProfilesKey);
5255+
5256+
if (lsKey == ERROR_SUCCESS)
5257+
lsKey = RegCreateKeyW (HKEY_CURRENT_USER, LR"(SOFTWARE\Kaldaien\Special K\AppIds)", &hAppIdsKey);
5258+
else if ( hProfilesKey != 0)
5259+
RegCloseKey (hProfilesKey);
52545260

52555261
// UNIX timestamp for new arrivals
52565262
time_t ltime;
@@ -5529,22 +5535,43 @@ SKIF_UI_Tab_DrawLibrary (void)
55295535
// Ensure the Profiles registry key is populated properly, but only write it once to ensure
55305536
// profile folders are not randomly renamed if a game gets renamed on the storefront
55315537
if (ERROR_SUCCESS == lsKey &&
5532-
ERROR_FILE_NOT_FOUND == RegQueryValueExW (hKey, app.second.install_dir.c_str(), NULL, NULL, NULL, NULL))
5538+
ERROR_FILE_NOT_FOUND == RegQueryValueExW (hProfilesKey, app.second.install_dir.c_str(), NULL, NULL, NULL, NULL))
55335539
{
5534-
if (ERROR_SUCCESS != RegSetValueExW (hKey, app.second.install_dir.c_str(), 0, REG_SZ, (LPBYTE)wsName.data(), (DWORD)wsName.length() * sizeof(wchar_t)))
5540+
if (ERROR_SUCCESS != RegSetValueExW (hProfilesKey, app.second.install_dir.c_str(), 0, REG_SZ, (LPBYTE)wsName.data(), (DWORD)wsName.length() * sizeof(wchar_t)))
55355541
PLOG_ERROR << "Failed adding profile name (" << wsName << ") to registry value: " << app.second.install_dir;
55365542
}
55375543

5544+
// Populate a list of Path-to-AppID mappings in the registry for platforms that may not have a manifest that Special K can parse (e.g. Epic)
5545+
if (ERROR_SUCCESS == lsKey)
5546+
{
5547+
switch (app.second.store)
5548+
{
5549+
case app_record_s::Store::Epic:
5550+
{
5551+
if (! app.second.epic.name_app.empty ())
5552+
{
5553+
std::wstring wsAppId =
5554+
SK_UTF8ToWideChar (app.second.epic.name_app);
5555+
5556+
if (ERROR_SUCCESS != RegSetValueExW (hAppIdsKey, app.second.install_dir.c_str(), 0, REG_SZ, (LPBYTE)wsAppId.data (), (DWORD)wsAppId.length() * sizeof(wchar_t)))
5557+
PLOG_ERROR << "Failed adding appid mapping (" << wsAppId << ") to registry value : " << app.second.epic.name_app;
5558+
}
5559+
} break;
5560+
default:
5561+
break;
5562+
}
5563+
}
5564+
55385565
// Register profile mappings for all launch configs
55395566
for (auto& lc : app.second.launch_configs)
55405567
{
55415568
auto& exe_path =
55425569
lc.second.executable_path;
55435570

55445571
if (ERROR_SUCCESS == lsKey &&
5545-
ERROR_FILE_NOT_FOUND == RegQueryValueExW (hKey, exe_path.c_str (), NULL, NULL, NULL, NULL))
5572+
ERROR_FILE_NOT_FOUND == RegQueryValueExW (hProfilesKey, exe_path.c_str (), NULL, NULL, NULL, NULL))
55465573
{
5547-
if (ERROR_SUCCESS != RegSetValueExW (hKey, exe_path.c_str (), 0, REG_SZ, (LPBYTE)wsName.data(), (DWORD)wsName.length() * sizeof(wchar_t)))
5574+
if (ERROR_SUCCESS != RegSetValueExW (hProfilesKey, exe_path.c_str (), 0, REG_SZ, (LPBYTE)wsName.data(), (DWORD)wsName.length() * sizeof(wchar_t)))
55485575
PLOG_ERROR << "Failed adding profile name (" << wsName << ") to registry value: " << exe_path;
55495576
}
55505577
}
@@ -5553,21 +5580,23 @@ SKIF_UI_Tab_DrawLibrary (void)
55535580
if (app.second.store == app_record_s::Store::Xbox)
55545581
{
55555582
if ( ERROR_SUCCESS == lsKey &&
5556-
(ERROR_FILE_NOT_FOUND == RegQueryValueExW (hKey, app.second.xbox.directory_app.c_str(), NULL, NULL, NULL, NULL) ||
5557-
ERROR_FILE_NOT_FOUND == RegQueryValueExW (hKey, app.second.xbox.directory_program_files.c_str(), NULL, NULL, NULL, NULL)) )
5583+
(ERROR_FILE_NOT_FOUND == RegQueryValueExW (hProfilesKey, app.second.xbox.directory_app.c_str(), NULL, NULL, NULL, NULL) ||
5584+
ERROR_FILE_NOT_FOUND == RegQueryValueExW (hProfilesKey, app.second.xbox.directory_program_files.c_str(), NULL, NULL, NULL, NULL)) )
55585585
{
5559-
if (ERROR_SUCCESS != RegSetValueExW (hKey, app.second.xbox.directory_app.c_str(), 0, REG_SZ, (LPBYTE)wsName.data(), (DWORD)wsName.length() * sizeof(wchar_t)))
5586+
if (ERROR_SUCCESS != RegSetValueExW (hProfilesKey, app.second.xbox.directory_app.c_str(), 0, REG_SZ, (LPBYTE)wsName.data(), (DWORD)wsName.length() * sizeof(wchar_t)))
55605587
PLOG_ERROR << "Failed adding profile name (" << wsName << ") to registry value: " << app.second.xbox.directory_app;
55615588

5562-
if (ERROR_SUCCESS != RegSetValueExW (hKey, app.second.xbox.directory_program_files.c_str(), 0, REG_SZ, (LPBYTE)wsName.data(), (DWORD)wsName.length() * sizeof(wchar_t)))
5589+
if (ERROR_SUCCESS != RegSetValueExW (hProfilesKey, app.second.xbox.directory_program_files.c_str(), 0, REG_SZ, (LPBYTE)wsName.data(), (DWORD)wsName.length() * sizeof(wchar_t)))
55635590
PLOG_ERROR << "Failed adding profile name (" << wsName << ") to registry value: " << app.second.xbox.directory_program_files;
55645591
}
55655592
}
55665593
}
55675594
}
55685595

5569-
if (ERROR_SUCCESS == lsKey)
5570-
RegCloseKey (hKey);
5596+
if (ERROR_SUCCESS == lsKey) {
5597+
RegCloseKey (hProfilesKey);
5598+
RegCloseKey (hAppIdsKey);
5599+
}
55715600

55725601
// Update the db.json file with any additions and whatnot
55735602
JsonDB_WriteFile ( );

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#define SKIF_MAJOR 1
2828
#define SKIF_MINOR 3
29-
#define SKIF_BUILD 17
29+
#define SKIF_BUILD 18
3030
#define SKIF_REV 0
3131

3232

0 commit comments

Comments
 (0)