import os from pymxs import runtime as rt def install_vr4life_2026_fixed(): try: # 1. CAMINHOS plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/") # Onde o MNX foi copiado pelo seu instalador 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("\\", "/") # 2. REGISTRAR AS MACROS (Obrigatorio para o MNX funcionar) # Usamos exatamente a categoria "Immerse Games" que está no seu MNX macro_cmd = f""" macroScript VR4Life_Launcher category:"Immerse Games" tooltip:"Abrir VR4Life" ( on execute do python.executeFile "{plugin_dir}/run_vr4life.py" ) macroScript VR4Life_Update category:"Immerse Games" tooltip:"Atualizar VR4Life" ( on execute do python.executeFile "{plugin_dir}/vr4life_updater.py" ) """ rt.execute(macro_cmd) # 3. CARREGAR O MNX VIA INTERFACE DE CONTEXTO (Abordagem Babylon 2026) # Se o menuMan é undefined, usamos o carregamento de arquivo de configuração setup_script = f""" ( local mnxPath = "{caminho_mnx}" if (doesFileExist mnxPath) then ( -- No 2026, tentamos carregar o arquivo de menus diretamente -- sem passar pelas propriedades de "getMainMenuBar" try ( menuMan.loadMenuFile mnxPath menuMan.updateMenuBar() ) catch ( -- Se falhar aqui, o Max carregará no próximo boot -- pois o arquivo já está na pasta oficial de UI ) ) ) """ rt.execute(setup_script) print(">> VR4Life: Macros registradas e MNX vinculado.") return True except Exception as e: print(f"Erro na instalação: {str(e)}") return False if __name__ == "__main__": install_vr4life_2026_fixed()