ProtonSettings: Move proton search function into utils/proton.py
This commit is contained in:
parent
616df235cd
commit
1f34ad4b13
|
@ -9,37 +9,13 @@ from PyQt5.QtWidgets import QGroupBox, QFileDialog
|
|||
from rare.components.tabs.settings import LinuxSettings
|
||||
from rare.shared import LegendaryCoreSingleton
|
||||
from rare.ui.components.tabs.settings.proton import Ui_ProtonSettings
|
||||
from rare.utils import config_helper
|
||||
from rare.utils import config_helper, proton
|
||||
from rare.widgets.indicator_edit import PathEdit, IndicatorReasonsCommon
|
||||
from .wrapper import WrapperSettings
|
||||
|
||||
logger = getLogger("Proton")
|
||||
|
||||
|
||||
def find_proton_combos():
|
||||
possible_proton_combos = []
|
||||
compatibilitytools_dirs = [
|
||||
os.path.expanduser("~/.steam/steam/steamapps/common"),
|
||||
"/usr/share/steam/compatibilitytools.d",
|
||||
os.path.expanduser("~/.steam/compatibilitytools.d"),
|
||||
os.path.expanduser("~/.steam/root/compatibilitytools.d"),
|
||||
]
|
||||
for c in compatibilitytools_dirs:
|
||||
if os.path.exists(c):
|
||||
for i in os.listdir(c):
|
||||
proton = os.path.join(c, i, "proton")
|
||||
compatibilitytool = os.path.join(c, i, "compatibilitytool.vdf")
|
||||
toolmanifest = os.path.join(c, i, "toolmanifest.vdf")
|
||||
if os.path.exists(proton) and (
|
||||
os.path.exists(compatibilitytool) or os.path.exists(toolmanifest)
|
||||
):
|
||||
wrapper = f'"{proton}" run'
|
||||
possible_proton_combos.append(wrapper)
|
||||
if not possible_proton_combos:
|
||||
logger.warning("Unable to find any Proton version")
|
||||
return possible_proton_combos
|
||||
|
||||
|
||||
class ProtonSettings(QGroupBox):
|
||||
# str: option key
|
||||
environ_changed = pyqtSignal(str)
|
||||
|
@ -53,7 +29,7 @@ class ProtonSettings(QGroupBox):
|
|||
self._linux_settings = linux_settings
|
||||
self._wrapper_settings = wrapper_settings
|
||||
self.core = LegendaryCoreSingleton()
|
||||
self.possible_proton_combos = find_proton_combos()
|
||||
self.possible_proton_combos = proton.find_proton_combos()
|
||||
|
||||
self.ui.proton_combo.addItems(self.possible_proton_combos)
|
||||
self.ui.proton_combo.currentIndexChanged.connect(self.change_proton)
|
||||
|
|
28
rare/utils/proton.py
Normal file
28
rare/utils/proton.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import os
|
||||
from logging import getLogger
|
||||
|
||||
logger = getLogger("Proton")
|
||||
|
||||
|
||||
def find_proton_combos():
|
||||
possible_proton_combos = []
|
||||
compatibilitytools_dirs = [
|
||||
os.path.expanduser("~/.steam/steam/steamapps/common"),
|
||||
"/usr/share/steam/compatibilitytools.d",
|
||||
os.path.expanduser("~/.steam/compatibilitytools.d"),
|
||||
os.path.expanduser("~/.steam/root/compatibilitytools.d"),
|
||||
]
|
||||
for c in compatibilitytools_dirs:
|
||||
if os.path.exists(c):
|
||||
for i in os.listdir(c):
|
||||
proton = os.path.join(c, i, "proton")
|
||||
compatibilitytool = os.path.join(c, i, "compatibilitytool.vdf")
|
||||
toolmanifest = os.path.join(c, i, "toolmanifest.vdf")
|
||||
if os.path.exists(proton) and (
|
||||
os.path.exists(compatibilitytool) or os.path.exists(toolmanifest)
|
||||
):
|
||||
wrapper = f'"{proton}" run'
|
||||
possible_proton_combos.append(wrapper)
|
||||
if not possible_proton_combos:
|
||||
logger.warning("Unable to find any Proton version")
|
||||
return possible_proton_combos
|
Loading…
Reference in a new issue