🚧 [WIP/TEST] Model : Overlayの処理を起動したらしっぱなしにするように変更

This commit is contained in:
misyaguziya
2024-05-04 17:25:39 +09:00
parent a5962f699b
commit 313682cbbd
2 changed files with 25 additions and 28 deletions

View File

@@ -427,12 +427,11 @@ def callbackToggleTranscriptionReceive(is_turned_on):
view.changeTranscriptionDisplayStatus("SPEAKER_OFF")
if config.ENABLE_TRANSCRIPTION_RECEIVE is True and config.ENABLE_OVERLAY_SMALL_LOG is True:
if model.overlay.initialized is False:
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
model.startOverlay()
print("model.startOverlay()")
elif config.ENABLE_TRANSCRIPTION_RECEIVE is False:
model.shutdownOverlay()
print("model.shutdownOverlay()")
pass
def callbackToggleForeground(is_turned_on):
config.ENABLE_FOREGROUND = is_turned_on
@@ -882,12 +881,11 @@ def callbackSetEnableOverlaySmallLog(value):
config.ENABLE_OVERLAY_SMALL_LOG = value
if config.ENABLE_OVERLAY_SMALL_LOG is True and config.ENABLE_TRANSCRIPTION_RECEIVE is True:
if model.overlay.initialized is False:
if model.overlay.initialized is False and model.overlay.checkSteamvrRunning() is True:
model.startOverlay()
print("model.startOverlay()")
elif config.ENABLE_OVERLAY_SMALL_LOG is False:
model.shutdownOverlay()
print("model.shutdownOverlay()")
pass
def callbackSetOverlaySmallLogSettings(value, set_type:str):
print("callbackSetOverlaySmallLogSettings", value, set_type)

View File

@@ -1,5 +1,6 @@
import os
import ctypes
import psutil
from psutil import process_iter
# from os import path as os_path
import ctypes
import time
@@ -8,12 +9,6 @@ from PIL import Image
# from queue import Queue
from threading import Thread
def checkSteamvrRunning() -> bool:
for proc in psutil.process_iter():
if "vrserver.exe" == proc.name().lower():
return True
return False
def mat34Id():
arr = openvr.HmdMatrix34_t()
arr[0][0] = 1
@@ -44,22 +39,21 @@ class Overlay:
def init(self):
try:
if checkSteamvrRunning() is True:
self.system = openvr.init(openvr.VRApplication_Background)
self.overlay = openvr.IVROverlay()
self.handle = self.overlay.createOverlay("Overlay_Speaker2log", "SOverlay_Speaker2log_UI")
self.system = openvr.init(openvr.VRApplication_Background)
self.overlay = openvr.IVROverlay()
self.handle = self.overlay.createOverlay("Overlay_Speaker2log", "SOverlay_Speaker2log_UI")
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)))
self.setColor(self.settings['Color'])
self.updateColor()
self.setTransparency(self.settings['Transparency'])
self.updateTransparency()
self.setUiScaling(self.settings['Ui_scaling'])
self.updateUiScaling()
self.setPosition((self.settings["Normalized_icon_X_position"], self.settings["Normalized_icon_Y_position"]))
self.updatePosition()
self.overlay.showOverlay(self.handle)
self.initialized = True
self.updateImage(Image.new("RGBA", (1, 1), (0, 0, 0, 0)))
self.setColor(self.settings['Color'])
self.updateColor()
self.setTransparency(self.settings['Transparency'])
self.updateTransparency()
self.setUiScaling(self.settings['Ui_scaling'])
self.updateUiScaling()
self.setPosition((self.settings["Normalized_icon_X_position"], self.settings["Normalized_icon_Y_position"]))
self.updatePosition()
self.overlay.showOverlay(self.handle)
self.initialized = True
except Exception as e:
print("Could not initialise OpenVR", e)
@@ -195,6 +189,11 @@ class Overlay:
self.system = None
self.initialized = False
@staticmethod
def checkSteamvrRunning() -> bool:
_proc_name = "vrmonitor.exe" if os.name == 'nt' else "vrmonitor"
return _proc_name in (p.name() for p in process_iter())
if __name__ == '__main__':
from overlay_image import OverlayImage
overlay_image = OverlayImage()