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.
58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
import os
|
|
from pymxs import runtime as rt
|
|
|
|
def carregar_menu_mnx():
|
|
print("\n" + "="*50)
|
|
print("AGENDANDO CARREGAMENTO - VR4LIFE (MODO SEGURO)")
|
|
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
|
|
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. TIMER COM EXECUÇÃO TARDIA (Late Bound)
|
|
# Usamos execute dentro do timer para o compilador não travar no 'menuMan' agora
|
|
timer_cmd = f"""
|
|
(
|
|
global _vr4life_timer = dotNetObject "System.Windows.Forms.Timer"
|
|
_vr4life_timer.interval = 3000 -- 3 segundos para garantir
|
|
|
|
dotNet.addEventHandler _vr4life_timer "Tick" (fn onTick s e = (
|
|
-- Só tentamos acessar o menuMan aqui dentro, após o tempo passar
|
|
if (execute "menuMan") != undefined then (
|
|
execute "menuMan.loadMenuFile \\"{caminho_mnx}\\""
|
|
execute "menuMan.updateMenuBar()"
|
|
format ">> VR4Life: Menu carregado com sucesso apos espera.\\n"
|
|
s.stop()
|
|
s.dispose()
|
|
) else (
|
|
format ">> VR4Life: Interface ainda carregando...\\n"
|
|
)
|
|
))
|
|
|
|
_vr4life_timer.start()
|
|
format "[*] Aguardando 3 segundos para injetar o menu...\\n"
|
|
)
|
|
"""
|
|
rt.execute(timer_cmd)
|
|
|
|
except Exception as e:
|
|
print(f"\n[EXCEPTION] Falha no agendamento:\n{str(e)}")
|
|
|
|
if __name__ == "__main__":
|
|
carregar_menu_mnx() |