You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
import os
|
|
from pymxs import runtime as rt
|
|
|
|
def carregar_menu_mnx():
|
|
print("\n" + "="*50)
|
|
print("AGENDANDO CARREGAMENTO DE INTERFACE - VR4LIFE")
|
|
print("="*50)
|
|
|
|
try:
|
|
# 1. Definir caminhos
|
|
pasta_macros = rt.getDir(rt.name("userMacros"))
|
|
pasta_enu = os.path.dirname(pasta_macros)
|
|
caminho_mnx = os.path.join(pasta_enu, "en-US", "UI", "vr4life.mnx").replace("\\", "/")
|
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
run_script = f"{plugin_dir}/run_vr4life.py"
|
|
|
|
# 2. Registrar MacroScript (Isso pode ser feito agora, não depende de UI)
|
|
macro_cmd = (
|
|
'macroScript VR4Life_Launcher\n'
|
|
'category:"Immerse Games"\n'
|
|
'tooltip:"Abrir VR4Life"\n'
|
|
'(\n'
|
|
f' on execute do python.executeFile "{run_script}"\n'
|
|
')'
|
|
)
|
|
rt.execute(macro_cmd)
|
|
|
|
# 3. AGENDAMENTO (O Timer de 2 segundos)
|
|
# Criamos um timer que espera o menuMan acordar para carregar o seu MNX
|
|
timer_cmd = f"""
|
|
(
|
|
fn tryLoadVRMenu = (
|
|
if menuMan != undefined then (
|
|
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)
|
|
local theTimer = dotNetObject "System.Windows.Forms.Timer"
|
|
theTimer.interval = 2000
|
|
|
|
dotNet.addEventHandler theTimer "Tick" (fn onTick s e = (
|
|
if (tryLoadVRMenu()) do (
|
|
s.stop()
|
|
s.dispose()
|
|
)
|
|
))
|
|
|
|
theTimer.start()
|
|
)
|
|
"""
|
|
rt.execute(timer_cmd)
|
|
print("[*] Timer iniciado. O menu aparecera em 2 segundos.")
|
|
|
|
except Exception as e:
|
|
print(f"\n[EXCEPTION] Falha no agendamento:\n{str(e)}")
|
|
|
|
if __name__ == "__main__":
|
|
carregar_menu_mnx() |