fix(games): let the GUI Add-game dialog link a launcher & log folder
The "Add game…" button only prompted for a name (single-field QInputDialog), so a custom game couldn't be given its launch command or log dir from the GUI. Replace it with a proper dialog: name + an optional launch command/script (with a file browser) + an optional log folder (auto-detected from the script's folder when left blank). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -430,19 +430,78 @@ class GamesPage(QWidget):
|
|||||||
self._banner.hide()
|
self._banner.hide()
|
||||||
|
|
||||||
def _add_custom_game(self) -> None:
|
def _add_custom_game(self) -> None:
|
||||||
"""Manually add a game no launcher reports (e.g. SPT), then rescan to show it."""
|
"""Manually add a game no launcher reports (e.g. SPT): name + an optional launch
|
||||||
from PySide6.QtWidgets import QInputDialog
|
command/script (so it can be launched under crash-capture) and log folder."""
|
||||||
|
|
||||||
from ..core import customgames
|
from ..core import customgames
|
||||||
|
|
||||||
name, ok = QInputDialog.getText(
|
dlg = QDialog(self)
|
||||||
self, "Add game", "Game name (e.g. SPT) — for titles no launcher reports:")
|
dlg.setWindowTitle("Add game")
|
||||||
if not ok:
|
dlg.setMinimumWidth(560)
|
||||||
|
v = QVBoxLayout(dlg)
|
||||||
|
v.setContentsMargins(20, 18, 20, 16)
|
||||||
|
v.setSpacing(10)
|
||||||
|
|
||||||
|
intro = QLabel(
|
||||||
|
"Add a game no launcher reports — a standalone mod launcher like SPT, an itch.io "
|
||||||
|
"download, or any hand-installed game.")
|
||||||
|
intro.setWordWrap(True)
|
||||||
|
v.addWidget(intro)
|
||||||
|
|
||||||
|
name_edit = QLineEdit()
|
||||||
|
name_edit.setPlaceholderText("SPT")
|
||||||
|
v.addWidget(QLabel("Game name"))
|
||||||
|
v.addWidget(name_edit)
|
||||||
|
|
||||||
|
cmd_edit = QLineEdit()
|
||||||
|
cmd_edit.setPlaceholderText("e.g. /run/media/.../Escape-From-Tarkov/tarkov.sh")
|
||||||
|
cmd_row = QHBoxLayout()
|
||||||
|
cmd_row.addWidget(cmd_edit, 1)
|
||||||
|
cmd_browse = QPushButton("Browse…")
|
||||||
|
cmd_row.addWidget(cmd_browse, 0)
|
||||||
|
v.addWidget(QLabel("Launch command / script (optional — enables launch + auto-capture)"))
|
||||||
|
v.addLayout(cmd_row)
|
||||||
|
|
||||||
|
log_edit = QLineEdit()
|
||||||
|
log_edit.setPlaceholderText("auto-detected from the script's folder (its logs/ subfolder)")
|
||||||
|
log_row = QHBoxLayout()
|
||||||
|
log_row.addWidget(log_edit, 1)
|
||||||
|
log_browse = QPushButton("Browse…")
|
||||||
|
log_row.addWidget(log_browse, 0)
|
||||||
|
v.addWidget(QLabel("Log folder (optional — read into crash diagnostics)"))
|
||||||
|
v.addLayout(log_row)
|
||||||
|
|
||||||
|
def _pick_command() -> None:
|
||||||
|
path, _ = QFileDialog.getOpenFileName(dlg, "Select the launch script/executable")
|
||||||
|
if path:
|
||||||
|
cmd_edit.setText(path)
|
||||||
|
|
||||||
|
def _pick_logdir() -> None:
|
||||||
|
path = QFileDialog.getExistingDirectory(dlg, "Select the game's log folder")
|
||||||
|
if path:
|
||||||
|
log_edit.setText(path)
|
||||||
|
|
||||||
|
cmd_browse.clicked.connect(_pick_command)
|
||||||
|
log_browse.clicked.connect(_pick_logdir)
|
||||||
|
|
||||||
|
buttons = QHBoxLayout()
|
||||||
|
buttons.addStretch(1)
|
||||||
|
cancel = QPushButton("Cancel")
|
||||||
|
cancel.clicked.connect(dlg.reject)
|
||||||
|
buttons.addWidget(cancel)
|
||||||
|
add = QPushButton("Add")
|
||||||
|
add.setObjectName("PrimaryButton")
|
||||||
|
add.setDefault(True)
|
||||||
|
add.clicked.connect(dlg.accept)
|
||||||
|
buttons.addWidget(add)
|
||||||
|
v.addLayout(buttons)
|
||||||
|
|
||||||
|
if dlg.exec() != QDialog.DialogCode.Accepted:
|
||||||
return
|
return
|
||||||
name = name.strip()
|
name = name_edit.text().strip()
|
||||||
if not name:
|
if not name:
|
||||||
return
|
return
|
||||||
if customgames.add(name):
|
if customgames.add(name, command=cmd_edit.text().strip() or None,
|
||||||
|
logdir=log_edit.text().strip() or None):
|
||||||
self.refresh()
|
self.refresh()
|
||||||
else:
|
else:
|
||||||
QMessageBox.information(self, "Add game", f"'{name}' is already in your games.")
|
QMessageBox.information(self, "Add game", f"'{name}' is already in your games.")
|
||||||
|
|||||||
Reference in New Issue
Block a user