Add optional doom_flags.txt so you can add flags for all games. This is experimental and may be removed.
This commit is contained in:
parent
21e933ab53
commit
6a8f866943
@ -1678,6 +1678,38 @@ class DoomLauncher(QMainWindow):
|
|||||||
process.wait() # Wait for the game to finish
|
process.wait() # Wait for the game to finish
|
||||||
QApplication.instance().quit() # Quit the application
|
QApplication.instance().quit() # Quit the application
|
||||||
|
|
||||||
|
def get_flags_from_file(self) -> List[str]:
|
||||||
|
"""Read additional launch flags from doom_flags.txt"""
|
||||||
|
flags = []
|
||||||
|
|
||||||
|
# Check multiple possible locations for the flags file
|
||||||
|
flag_file_locations = [
|
||||||
|
Path.cwd() / "doom_flags.txt", # Current directory
|
||||||
|
self.gamePath / "doom_flags.txt", # Game path
|
||||||
|
Path.home() / "doom_flags.txt", # User's home directory
|
||||||
|
Path.home() / ".local/doom/doom_flags.txt", # ~/.local/doom directory
|
||||||
|
Path.home() / ".local/share/doom/doom_flags.txt" # ~/.local/share/doom directory
|
||||||
|
]
|
||||||
|
|
||||||
|
for flag_file in flag_file_locations:
|
||||||
|
if flag_file.exists():
|
||||||
|
try:
|
||||||
|
with open(flag_file, 'r') as f:
|
||||||
|
# Read all lines, strip whitespace, and filter out empty lines
|
||||||
|
lines = [line.strip() for line in f.readlines()]
|
||||||
|
lines = [line for line in lines if line and not line.startswith('#')]
|
||||||
|
|
||||||
|
# Split each line by whitespace to get individual flags
|
||||||
|
for line in lines:
|
||||||
|
flags.extend(line.split())
|
||||||
|
|
||||||
|
print(f"Loaded {len(flags)} flags from {flag_file}")
|
||||||
|
break # Use the first file found
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error reading flags file {flag_file}: {e}", file=sys.stderr)
|
||||||
|
|
||||||
|
return flags
|
||||||
|
|
||||||
def launch_game(self, gameFiles: List[str], gameFlags: List[str] = None):
|
def launch_game(self, gameFiles: List[str], gameFlags: List[str] = None):
|
||||||
"""Launch game with speech processing"""
|
"""Launch game with speech processing"""
|
||||||
if not gameFiles:
|
if not gameFiles:
|
||||||
@ -1696,6 +1728,15 @@ class DoomLauncher(QMainWindow):
|
|||||||
|
|
||||||
iwadPath = self.iwadCombo.itemData(iwadIndex)
|
iwadPath = self.iwadCombo.itemData(iwadIndex)
|
||||||
|
|
||||||
|
# Initialize gameFlags if None
|
||||||
|
if gameFlags is None:
|
||||||
|
gameFlags = []
|
||||||
|
|
||||||
|
# Get additional flags from doom_flags.txt
|
||||||
|
additionalFlags = self.get_flags_from_file()
|
||||||
|
if additionalFlags:
|
||||||
|
gameFlags.extend(additionalFlags)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
configFile = Path.cwd() / 'TobyConfig.ini'
|
configFile = Path.cwd() / 'TobyConfig.ini'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user