Skip to content

Commit 2f4487a

Browse files
committed
Add launcher path in Paths config; does not show in gamelist yet
1 parent c5ef578 commit 2f4487a

File tree

15 files changed

+117
-15
lines changed

15 files changed

+117
-15
lines changed
File renamed without changes.
File renamed without changes.

Source/Core/Common/CommonPaths.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
#define WIISDSYNC_DIR "WiiSDSync"
9595
#define ASSEMBLY_DIR "SavedAssembly"
9696
#define NETPLAY_SAVE_DIR "NetplaySave"
97+
#define LAUNCHER_DIR "Launcher"
9798

9899

99100
// This one is only used to remove it if it was present

Source/Core/Common/FileUtil.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
882882
s_user_paths[D_DYNAMICINPUT_IDX] = s_user_paths[D_LOAD_IDX] + DYNAMICINPUT_DIR DIR_SEP;
883883
s_user_paths[D_GRAPHICSMOD_IDX] = s_user_paths[D_LOAD_IDX] + GRAPHICSMOD_DIR DIR_SEP;
884884
s_user_paths[D_WIISDCARDSYNCFOLDER_IDX] = s_user_paths[D_LOAD_IDX] + WIISDSYNC_DIR DIR_SEP;
885+
s_user_paths[D_LAUNCHERS_IDX] = s_user_paths[D_USER_IDX] + LAUNCHER_DIR DIR_SEP;
885886
s_user_paths[F_DOLPHINCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DOLPHIN_CONFIG;
886887
s_user_paths[F_GCPADCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + GCPAD_CONFIG;
887888
s_user_paths[F_WIIPADCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + WIIPAD_CONFIG;

Source/Core/Common/FileUtil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ enum
7676
D_GPU_DRIVERS_HOOKS,
7777
D_GPU_DRIVERS_FILE_REDIRECT,
7878
D_ASM_ROOT_IDX,
79+
D_LAUNCHERS_IDX,
7980
FIRST_FILE_USER_PATH_IDX,
8081
F_DOLPHINCONFIG_IDX = FIRST_FILE_USER_PATH_IDX,
8182
F_GCPADCONFIG_IDX,

Source/Core/Core/Config/MainSettings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ bool ShouldUseDPL2Decoder()
311311

312312
const Info<std::string> MAIN_DUMP_PATH{{System::Main, "General", "DumpPath"}, ""};
313313
const Info<std::string> MAIN_LOAD_PATH{{System::Main, "General", "LoadPath"}, ""};
314+
const Info<std::string> MAIN_LAUNCHER_PATH{{System::Main, "General", "LauncherPath"}, ""};
314315
const Info<std::string> MAIN_RESOURCEPACK_PATH{{System::Main, "General", "ResourcePackPath"}, ""};
315316
const Info<std::string> MAIN_FS_PATH{{System::Main, "General", "NANDRootPath"}, ""};
316317
const Info<std::string> MAIN_WII_SD_CARD_IMAGE_PATH{{System::Main, "General", "WiiSDCardPath"}, ""};
@@ -344,6 +345,7 @@ std::vector<std::string> GetIsoPaths()
344345
if (!iso_path.empty())
345346
paths.emplace_back(std::move(iso_path));
346347
}
348+
347349
return paths;
348350
}
349351

Source/Core/Core/Config/MainSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ extern const Info<bool> MAIN_TIME_TRACKING;
197197

198198
extern const Info<std::string> MAIN_DUMP_PATH;
199199
extern const Info<std::string> MAIN_LOAD_PATH;
200+
extern const Info<std::string> MAIN_LAUNCHER_PATH;
200201
extern const Info<std::string> MAIN_RESOURCEPACK_PATH;
201202
extern const Info<std::string> MAIN_FS_PATH;
202203
extern const Info<std::string> MAIN_WII_SD_CARD_IMAGE_PATH;

Source/Core/DolphinQt/GameList/GameTracker.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent)
4343
connect(this, &QFileSystemWatcher::fileChanged, this, &GameTracker::UpdateFile);
4444
connect(&Settings::Instance(), &Settings::AutoRefreshToggled, this, [] {
4545
const auto paths = Settings::Instance().GetPaths();
46+
const auto launcher = File::GetUserPath(D_LAUNCHERS_IDX);
4647

4748
for (const auto& path : paths)
4849
{
@@ -232,6 +233,18 @@ void GameTracker::UpdateFile(const QString& dir)
232233
m_load_thread.EmplaceItem(Command{CommandType::UpdateFile, dir});
233234
}
234235

236+
void GameTracker::AddLauncherDirectory(const QString& dir)
237+
{
238+
if (!QFileInfo(dir).exists())
239+
return;
240+
for (const QString& dir : Settings::Instance().GetLauncherPath())
241+
{
242+
m_load_thread.EmplaceItem(Command{CommandType::RemoveDirectory, dir});
243+
m_load_thread.EmplaceItem(Command{CommandType::AddDirectory, dir});
244+
}
245+
UpdateLauncherDirectory(dir);
246+
}
247+
235248
void GameTracker::AddDirectoryInternal(const QString& dir)
236249
{
237250
if (!QFileInfo(dir).exists())
@@ -307,6 +320,44 @@ void GameTracker::UpdateDirectoryInternal(const QString& dir)
307320
}
308321
}
309322

323+
void GameTracker::UpdateLauncherDirectory(const QString& dir)
324+
{
325+
auto it = GetIterator(dir);
326+
while (it->hasNext() && !m_processing_halted)
327+
{
328+
QString path = QFileInfo(it->next()).canonicalFilePath();
329+
330+
if (m_tracked_files.contains(path))
331+
{
332+
auto& tracked_file = m_tracked_files[path];
333+
if (!tracked_file.contains(dir))
334+
tracked_file.insert(dir);
335+
}
336+
else
337+
{
338+
AddPath(path);
339+
m_tracked_files[path] = QSet<QString>{dir};
340+
LoadGame(path);
341+
}
342+
}
343+
344+
for (const auto& missing : FindMissingFiles(dir))
345+
{
346+
if (m_processing_halted)
347+
break;
348+
349+
auto& tracked_file = m_tracked_files[missing];
350+
351+
tracked_file.remove(dir);
352+
if (tracked_file.empty())
353+
{
354+
m_tracked_files.remove(missing);
355+
if (m_started)
356+
GameRemoved(missing.toStdString());
357+
}
358+
}
359+
}
360+
310361
void GameTracker::UpdateFileInternal(const QString& file)
311362
{
312363
if (QFileInfo(file).exists())

Source/Core/DolphinQt/GameList/GameTracker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ class GameTracker final : public QFileSystemWatcher
5454
void UpdateDirectory(const QString& dir);
5555
void UpdateFile(const QString& path);
5656
void AddDirectoryInternal(const QString& dir);
57+
void AddLauncherDirectory(const QString& dir);
5758
void RemoveDirectoryInternal(const QString& dir);
5859
void UpdateDirectoryInternal(const QString& dir);
60+
void UpdateLauncherDirectory(const QString& dir);
5961
void UpdateFileInternal(const QString& path);
6062
QSet<QString> FindMissingFiles(const QString& dir);
6163
void LoadGame(const QString& path);

0 commit comments

Comments
 (0)