From 00a789c410ac3800279c7b5e1efedfc859103239 Mon Sep 17 00:00:00 2001 From: henrique Date: Mon, 23 Feb 2026 22:29:50 -0300 Subject: [PATCH] dwdw --- install_vr4life.py | 96 ++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/install_vr4life.py b/install_vr4life.py index 9a45058..3761179 100644 --- a/install_vr4life.py +++ b/install_vr4life.py @@ -1,68 +1,56 @@ import os from pymxs import runtime as rt -def install_vr4life_babylon_final(): +def install_vr4life_2026_fixed(): try: - # 1. DEFINIR CAMINHOS + # 1. CAMINHOS plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/") - startup_dir = rt.getDir(rt.name("userStartupScripts")) - loader_path = os.path.join(startup_dir, "CreateVr4LifeMenus.ms") - - # 2. O CONTEÚDO DO SCRIPT (Fiel ao repositório BabylonJS 2026) - # O segredo do 2026: usar interfaces dinâmicas e registrar no CUI - ms_content = f""" -( - -- Função principal de criação (Abordagem Babylon) - fn CreateVr4LifeMenu = ( - local menuMgr = maxUtils.getMainMenuManager() - if menuMgr == undefined do menuMgr = menuMan - if menuMgr != undefined then ( - local mainMenuBar = menuMgr.getMainMenuBar() - - -- Remove duplicados para evitar poluição - local existingMenu = menuMgr.findMenu "Vr4Life" - if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu - - -- Cria o menu "Vr4Life" - local newMenu = menuMgr.createMenu "Vr4Life" - - -- Cria os itens (Actions) - Usando a categoria Immerse Games do seu MNX - local actionLauncher = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games" - local actionUpdate = menuMgr.createActionItem "VR4Life_Update" "Immerse Games" - - newMenu.addItem actionLauncher -1 - newMenu.addItem actionUpdate -1 - - -- Adiciona à barra principal (Posição final) - local subMenuItem = menuMgr.createSubMenuItem "Vr4Life" newMenu - mainMenuBar.addItem subMenuItem (mainMenuBar.numItems()) - - menuMgr.updateMenuBar() - format ">> VR4Life: Menu injetado via %\\n" (getSourceFileName()) - ) - ) + # 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("\\", "/") - -- Registro das Macros (O motor por trás dos botões) - 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" ) + # 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" +) - -- Gatilhos de execução (O Babylon usa múltiplos para garantir) - CreateVr4LifeMenu() - callbacks.removeScripts id:#VR4LifeMenuSetup - callbacks.addScript #cuiRegisterMenus "CreateVr4LifeMenu()" id:#VR4LifeMenuSetup - callbacks.addScript #filePostOpen "CreateVr4LifeMenu()" id:#VR4LifeMenuSetup +macroScript VR4Life_Update +category:"Immerse Games" +tooltip:"Atualizar VR4Life" +( + on execute do python.executeFile "{plugin_dir}/vr4life_updater.py" ) """ - # 3. GRAVAR O ARQUIVO NO DISCO (Persistência estilo Babylon) - with open(loader_path, "w", encoding="utf-8") as f: - f.write(ms_content) + rt.execute(macro_cmd) - # 4. EXECUTAR O ARQUIVO CRIADO - rt.fileIn(loader_path) + # 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(f">> Arquivo gerado em: {loader_path}") - print(">> Se o menu não aparecer agora, ele aparecerá ao abrir qualquer arquivo ou reiniciar.") + print(">> VR4Life: Macros registradas e MNX vinculado.") return True except Exception as e: @@ -70,4 +58,4 @@ def install_vr4life_babylon_final(): return False if __name__ == "__main__": - install_vr4life_babylon_final() \ No newline at end of file + install_vr4life_2026_fixed() \ No newline at end of file