2024-07-06 00:11:56 +02:00
|
|
|
import json
|
|
|
|
|
|
|
|
import dearpygui.dearpygui as dpg
|
|
|
|
|
2024-07-07 15:05:16 +02:00
|
|
|
from vrutil.utils import loaded, store
|
2024-07-06 00:11:56 +02:00
|
|
|
|
|
|
|
_STEAM_VR_SETTINGS_FILE = '{steam_dir}/config/steamvr.vrsettings'
|
|
|
|
|
|
|
|
|
|
|
|
class SteamVrSettings:
|
|
|
|
"""Steam VR related settings"""
|
|
|
|
|
|
|
|
def __init__(self, steam_dir):
|
|
|
|
self._settings_file_path = _STEAM_VR_SETTINGS_FILE.format(steam_dir=steam_dir)
|
|
|
|
self._enable_vulkan_async_item = None
|
|
|
|
|
|
|
|
def create_views(self):
|
|
|
|
with dpg.collapsing_header(label='Steam VR', default_open=True):
|
|
|
|
|
|
|
|
self._enable_vulkan_async_item = dpg.add_checkbox(
|
|
|
|
label='enableLinuxVulkanAsync',
|
|
|
|
default_value=self._is_vulkan_async_enabled(),
|
|
|
|
callback=self._enable_vulkan_async,
|
|
|
|
)
|
|
|
|
|
|
|
|
dpg.add_spacer(height=10)
|
|
|
|
|
2024-07-07 16:53:24 +02:00
|
|
|
def reload(self):
|
2024-07-06 00:11:56 +02:00
|
|
|
dpg.set_value(self._enable_vulkan_async_item, self._is_vulkan_async_enabled())
|
|
|
|
|
|
|
|
def _is_vulkan_async_enabled(self):
|
|
|
|
with open(self._settings_file_path, 'r') as f:
|
|
|
|
data_content = json.load(f)
|
|
|
|
enabled = data_content['steamvr']['enableLinuxVulkanAsync']
|
|
|
|
loaded('SteamVR enableLinuxVulkanAsync', enabled)
|
|
|
|
return enabled
|
|
|
|
|
|
|
|
def _enable_vulkan_async(self, _sender, enabled, _user_data):
|
|
|
|
store('SteamVR enableLinuxVulkanAsync', enabled)
|
|
|
|
with open(self._settings_file_path, 'r') as f:
|
|
|
|
data_content = json.load(f)
|
|
|
|
data_content['steamvr']['enableLinuxVulkanAsync'] = enabled
|
|
|
|
with open(self._settings_file_path, 'w') as f:
|
|
|
|
json.dump(data_content, f, indent=3, separators=(',', ' : '))
|
2024-07-07 16:53:24 +02:00
|
|
|
self.reload()
|