Skip to content

Commit

Permalink
Enable Steam library auto-refresh
Browse files Browse the repository at this point in the history
And prevent repopulating the libraries while the
worker thread is running in the background
  • Loading branch information
Aemony committed Nov 13, 2023
1 parent 92f96b5 commit 3a066fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/SKIF.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const UINT_PTR IDT_REFRESH_TOOLTIP = 1341;
const UINT_PTR IDT_REFRESH_UPDATER = 1342;
const UINT_PTR IDT_REFRESH_NOTIFY = 1343;
const UINT_PTR IDT_REFRESH_DIR_ROOT = 1344; // Used by the directory watch for the root folder
//const UINT_PTR IDT_REFRESH_STEAM_LIB = 1983-1999; // Used by the directory watch for Steam libraries

// Desktop notification types
constexpr UINT SKIF_NTOAST_UPDATE = 0; // Appears always
Expand Down
22 changes: 18 additions & 4 deletions src/tabs/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ bool tryingToLoadCover = false;
std::atomic<bool> gameCoverLoading = false;
std::atomic<bool> modDownloading = false;
std::atomic<bool> modInstalling = false;
std::atomic<bool> gameWorkerRunning = false;
std::atomic<uint32_t> modAppId = 0;

static bool clickedGameLaunch,
Expand Down Expand Up @@ -1435,8 +1436,8 @@ SKIF_UI_Tab_DrawLibrary (void)
{
// Temporarily disabled since this gets triggered on game launch/shutdown as well...
// And generally also breaks SKIF's library view on occasion
//if (SKIF_Steam_isLibrariesSignaled ())
// RepopulateGames = true;
if (_registry.bLibrarySteam && SKIF_Steam_isLibrariesSignaled ())
RepopulateGames = true;

if (_registry.bLibraryEpic && SKIF_Epic_ManifestWatch.isSignaled (SKIF_Epic_AppDataPath, true))
RepopulateGames = true;
Expand All @@ -1454,9 +1455,11 @@ SKIF_UI_Tab_DrawLibrary (void)
RepopulateGames = true;
}

if (RepopulateGames)
// We cannot manipulate the apps array while the game worker thread is running
if (RepopulateGames && ! gameWorkerRunning.load())
{
RepopulateGames = false;
gameWorkerRunning.store(true);

// Clear cached lists
apps.clear ();
Expand All @@ -1479,7 +1482,7 @@ SKIF_UI_Tab_DrawLibrary (void)
//InterlockedExchange (&icon_thread, 1);

PLOG_INFO << "Populating library list...";

apps = SKIF_Steam_GetInstalledAppIDs ();

// Refresh the current Steam user
Expand Down Expand Up @@ -1580,6 +1583,16 @@ SKIF_UI_Tab_DrawLibrary (void)
continue;
}

/*
if (app.second.launch_configs.size() == 0)
{
PLOG_DEBUG << "App ID " << app.second.id << " (" << app.second.store_utf8 << ") has no launch config; ignoring!";
app.second.id = 0;
continue;
}
*/

std::string original_name = app.first;

// Some games use weird Unicode character combos that ImGui can't handle,
Expand Down Expand Up @@ -1737,6 +1750,7 @@ SKIF_UI_Tab_DrawLibrary (void)
PLOG_INFO << "Finished streaming game icons asynchronously...";

//InterlockedExchange (&icon_thread, 0);
gameWorkerRunning.store(false);

// Force a refresh when the game icons have finished being streamed
PostMessage (SKIF_Notify_hWnd, WM_SKIF_ICON, 0x0, 0x0);
Expand Down
2 changes: 1 addition & 1 deletion src/utility/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ SKIF_Util_SaveExtractExeIcon (std::wstring exePath, std::wstring targetPath)
{
bool ret = PathFileExists (targetPath.c_str());

if (! ret)
if (! ret && PathFileExists (exePath.c_str()))
{
std::filesystem::path target = targetPath;

Expand Down

0 comments on commit 3a066fb

Please sign in to comment.