Skip to content

Commit ab938a1

Browse files
committed
scan all available drives and find steam folder
1 parent 343f116 commit ab938a1

4 files changed

Lines changed: 95 additions & 19 deletions

File tree

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,3 @@ Creates a single `.exe` file with no external dependencies.
7979
- `generate_index.py`: Fetches Game IDs and Names from Steam APIs to generate `games_index.json`.
8080
- **`resources/`**: Icons and assets.
8181
82-
83-
## 📄 License
84-
85-
This project is open-source. Feel free to fork and contribute!

src/config.h

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#define CONFIG_H
33

44
#include <QString>
5+
#include <QStringList>
6+
#include <QDir>
7+
#include <QFileInfo>
58

69
namespace Config {
710
const QString APP_VERSION = "1.1.0";
@@ -16,9 +19,64 @@ namespace Config {
1619
return WEBSERVER_BASE_URL + "/lua/";
1720
}
1821

19-
// Steam paths
20-
const QString STEAM_PLUGIN_DIR = "C:/Program Files (x86)/Steam/config/stplug-in";
21-
const QString STEAM_EXE_PATH = "C:/Program Files (x86)/Steam/Steam.exe";
22+
// Steam paths - check all drives for Steam installation
23+
inline QStringList getAllSteamPluginDirs() {
24+
QStringList paths;
25+
26+
// Common Steam installation paths to check on each drive
27+
QStringList steamPaths = {
28+
":/Program Files (x86)/Steam/config/stplug-in",
29+
":/Program Files/Steam/config/stplug-in",
30+
":/Steam/config/stplug-in"
31+
};
32+
33+
// Check all drives from A to Z
34+
for (char drive = 'A'; drive <= 'Z'; drive++) {
35+
for (const QString& steamPath : steamPaths) {
36+
QString fullPath = QString(drive) + steamPath;
37+
QDir dir(fullPath);
38+
if (dir.exists()) {
39+
paths.append(fullPath);
40+
}
41+
}
42+
}
43+
44+
return paths;
45+
}
46+
47+
inline QString getSteamPluginDir() {
48+
QStringList paths = getAllSteamPluginDirs();
49+
return paths.isEmpty() ? "C:/Program Files (x86)/Steam/config/stplug-in" : paths.first();
50+
}
51+
52+
inline QStringList getAllSteamExePaths() {
53+
QStringList paths;
54+
55+
// Common Steam executable paths to check on each drive
56+
QStringList steamExePaths = {
57+
":/Program Files (x86)/Steam/Steam.exe",
58+
":/Program Files/Steam/Steam.exe",
59+
":/Steam/Steam.exe"
60+
};
61+
62+
// Check all drives from A to Z
63+
for (char drive = 'A'; drive <= 'Z'; drive++) {
64+
for (const QString& exePath : steamExePaths) {
65+
QString fullPath = QString(drive) + exePath;
66+
QFileInfo fileInfo(fullPath);
67+
if (fileInfo.exists() && fileInfo.isFile()) {
68+
paths.append(fullPath);
69+
}
70+
}
71+
}
72+
73+
return paths;
74+
}
75+
76+
inline QString getSteamExePath() {
77+
QStringList paths = getAllSteamExePaths();
78+
return paths.isEmpty() ? "C:/Program Files (x86)/Steam/Steam.exe" : paths.first();
79+
}
2280
}
2381

2482
#endif // CONFIG_H

src/mainwindow.cpp

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -513,18 +513,39 @@ void MainWindow::doPatch() {
513513

514514
void MainWindow::onPatchDone(QString path) {
515515
try {
516-
QString dest = QDir(Config::STEAM_PLUGIN_DIR)
517-
.filePath(m_selectedGame["appid"] + ".lua");
518-
519-
QDir dir;
520-
if (!dir.exists(Config::STEAM_PLUGIN_DIR)) {
521-
dir.mkpath(Config::STEAM_PLUGIN_DIR);
516+
QStringList targetDirs = Config::getAllSteamPluginDirs();
517+
if (targetDirs.isEmpty()) {
518+
targetDirs.append(Config::getSteamPluginDir());
522519
}
523-
524-
QFile::remove(dest);
525-
if (!QFile::copy(path, dest)) {
526-
throw std::runtime_error("Failed to copy patch file");
520+
521+
bool atLeastOneSuccess = false;
522+
QString lastError;
523+
524+
for (const QString& pluginDir : targetDirs) {
525+
QString dest = QDir(pluginDir).filePath(m_selectedGame["appid"] + ".lua");
526+
527+
QDir dir;
528+
if (!dir.exists(pluginDir)) {
529+
dir.mkpath(pluginDir);
530+
}
531+
532+
if (QFile::exists(dest)) {
533+
QFile::remove(dest);
534+
}
535+
536+
if (QFile::copy(path, dest)) {
537+
atLeastOneSuccess = true;
538+
} else {
539+
lastError = "Failed to copy patch file to " + pluginDir;
540+
}
527541
}
542+
543+
if (!atLeastOneSuccess) {
544+
throw std::runtime_error(lastError.toStdString());
545+
}
546+
547+
// Clean up the downloaded file after copying to all destinations
548+
QFile::remove(path);
528549

529550
m_progress->hide();
530551
m_btnPatch->setEnabled(true);

src/workers/restartworker.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ void RestartWorker::run() {
2020
QThread::sleep(2);
2121

2222
// Restart Steam
23-
if (QFile::exists(Config::STEAM_EXE_PATH)) {
24-
QProcess::startDetached(Config::STEAM_EXE_PATH, QStringList());
23+
QString steamExe = Config::getSteamExePath();
24+
if (QFile::exists(steamExe)) {
25+
QProcess::startDetached(steamExe, QStringList());
2526
emit finished("Steam launched!");
2627
} else {
2728
QProcess::startDetached("cmd", QStringList() << "/c" << "start" << "steam://open/main");

0 commit comments

Comments
 (0)