from pathlib import Path import dearpygui.dearpygui as dpg from vrutil.dialogs import Dialogs from vrutil.geproton import GeProtonSettings from vrutil.gpu import GpuSettings from vrutil.steamvr import SteamVrSettings from vrutil.valveindex import ValeIndexSettings _NO_STEAM_FOUND = 'No Steam installation found!' def get_steam_dir(): possible_paths = [ '.local/share/Steam', '.steam/steam', '.steam/root' ] for path in possible_paths: candidate = (Path.home() / Path(path)).resolve() if candidate.exists(): return str(candidate) return None class MainWindow: """Main class managing the main application window""" def __init__(self): self._steam_dir = get_steam_dir() self._dialogs = Dialogs() self._gpu_settings = GpuSettings() self._steamvr_settings = SteamVrSettings(self._steam_dir) self._geproton_settings = GeProtonSettings(self._steam_dir, self._dialogs) self._valveindex_settings = ValeIndexSettings() self._steam_dir_item = None def create_window(self): self._dialogs.create_dialogs() with dpg.window() as main_window: with dpg.menu_bar(): dpg.add_menu_item(label='Reload all', callback=self.reload_all) dpg.add_menu_item(label='About', callback=self._dialogs.show_about) dpg.add_text('Current Steam dir:') self._steam_dir_item = dpg.add_text(self._steam_dir or _NO_STEAM_FOUND) dpg.add_spacer(height=10) if self._steam_dir is not None: self._gpu_settings.create_views() self._steamvr_settings.create_views() self._geproton_settings.create_views() self._valveindex_settings.create_views() return main_window def reload_all(self): self._steam_dir = get_steam_dir() dpg.set_value(self._steam_dir_item, self._steam_dir or _NO_STEAM_FOUND) if self._steam_dir is None: self._dialogs.show_alert( title='Still no Steam found!', message='TODO: Allow custom location.', on_confirm=self._dialogs.hide, ) else: self._gpu_settings.reload() self._steamvr_settings.reload(self._steam_dir) self._geproton_settings.reload_installed(self._steam_dir) self._geproton_settings.reload_available() self._valveindex_settings.reload()