henrique 2 months ago
parent b3e6f7e8c3
commit d577713243

@ -3,7 +3,7 @@ from pymxs import runtime as rt
def carregar_menu_mnx(): def carregar_menu_mnx():
print("\n" + "="*50) print("\n" + "="*50)
print("AGENDANDO CARREGAMENTO DE INTERFACE - VR4LIFE") print("AGENDANDO CARREGAMENTO - VR4LIFE (MODO SEGURO)")
print("="*50) print("="*50)
try: try:
@ -14,7 +14,7 @@ def carregar_menu_mnx():
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/") plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
run_script = f"{plugin_dir}/run_vr4life.py" run_script = f"{plugin_dir}/run_vr4life.py"
# 2. Registrar MacroScript (Isso pode ser feito agora, não depende de UI) # 2. Registrar MacroScript
macro_cmd = ( macro_cmd = (
'macroScript VR4Life_Launcher\n' 'macroScript VR4Life_Launcher\n'
'category:"Immerse Games"\n' 'category:"Immerse Games"\n'
@ -25,38 +25,31 @@ def carregar_menu_mnx():
) )
rt.execute(macro_cmd) rt.execute(macro_cmd)
# 3. AGENDAMENTO (O Timer de 2 segundos) # 3. TIMER COM EXECUÇÃO TARDIA (Late Bound)
# Criamos um timer que espera o menuMan acordar para carregar o seu MNX # Usamos execute dentro do timer para o compilador não travar no 'menuMan' agora
timer_cmd = f""" timer_cmd = f"""
( (
fn tryLoadVRMenu = ( global _vr4life_timer = dotNetObject "System.Windows.Forms.Timer"
if menuMan != undefined then ( _vr4life_timer.interval = 3000 -- 3 segundos para garantir
menuMan.loadMenuFile "{caminho_mnx}"
menuMan.updateMenuBar()
format ">> VR4Life: Menu carregado via Timer com sucesso.\\n"
return true
) else (
format ">> VR4Life: Aguardando interface...\\n"
return false
)
)
-- Cria um timer de 2000ms (2 segundos) dotNet.addEventHandler _vr4life_timer "Tick" (fn onTick s e = (
local theTimer = dotNetObject "System.Windows.Forms.Timer" -- tentamos acessar o menuMan aqui dentro, após o tempo passar
theTimer.interval = 2000 if (execute "menuMan") != undefined then (
execute "menuMan.loadMenuFile \\"{caminho_mnx}\\""
dotNet.addEventHandler theTimer "Tick" (fn onTick s e = ( execute "menuMan.updateMenuBar()"
if (tryLoadVRMenu()) do ( format ">> VR4Life: Menu carregado com sucesso apos espera.\\n"
s.stop() s.stop()
s.dispose() s.dispose()
) else (
format ">> VR4Life: Interface ainda carregando...\\n"
) )
)) ))
theTimer.start() _vr4life_timer.start()
format "[*] Aguardando 3 segundos para injetar o menu...\\n"
) )
""" """
rt.execute(timer_cmd) rt.execute(timer_cmd)
print("[*] Timer iniciado. O menu aparecera em 2 segundos.")
except Exception as e: except Exception as e:
print(f"\n[EXCEPTION] Falha no agendamento:\n{str(e)}") print(f"\n[EXCEPTION] Falha no agendamento:\n{str(e)}")

Loading…
Cancel
Save