From b4f182797052dedf3dbee09f6783df4cb0deecd6 Mon Sep 17 00:00:00 2001 From: henrique Date: Mon, 23 Feb 2026 16:44:18 -0300 Subject: [PATCH] fr --- install_vr4life.py | 107 ++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 49 deletions(-) diff --git a/install_vr4life.py b/install_vr4life.py index 5d9effc..fab59e1 100644 --- a/install_vr4life.py +++ b/install_vr4life.py @@ -2,8 +2,8 @@ import os import sys from pymxs import runtime as rt -# Versão v1.1.0 - Correção Definitiva para o 3ds Max 2026 -VERSION = "1.1.0" +# Versão v1.1.1 - Acesso Universal 2026 +VERSION = "1.1.1" def log(msg): print(f"[VR4Life Install Log] {msg}") @@ -12,7 +12,7 @@ def install_plugin(): rt.clearListener() log(f"=== INICIANDO INSTALAÇÃO v{VERSION} ===") - # 1. SETUP DE PASTAS + # 1. SETUP DE PASTAS E PATH user_scripts_dir = rt.getDir(rt.name("userScripts")) plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/") @@ -22,69 +22,78 @@ def install_plugin(): run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/") update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/") - # 2. REGISTRO DE MACROS (Comandos que o Max entende) - log("Registrando Comandos VR4Life...") - # Criamos a categoria 'Immerse Games' que aparecerá no Customize User Interface - mxs_macro = f''' + # 2. REGISTRO DE MACROS (Sempre funciona) + log("Registrando Comandos...") + mxs_macros = f''' ( - macroScript VR4Life_Open category:"Immerse Games" buttonText:"VR4Life Engine" - ( on execute do python.ExecuteFile @"{run_script}" ) - - macroScript VR4Life_Update category:"Immerse Games" buttonText:"Atualizar VR4Life" - ( on execute do python.ExecuteFile @"{update_script}" ) + macroScript VR4Life_Open category:"Immerse Games" buttonText:"VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}") + macroScript VR4Life_Update category:"Immerse Games" buttonText:"Atualizar VR4Life" (on execute do python.ExecuteFile @"{update_script}") ) ''' - rt.execute(mxs_macro) + rt.execute(mxs_macros) - # 3. CRIAÇÃO DO MENU (Método Seguro para o 2026) - # Como o getContentManager está falhando, vamos usar o menuMan de forma condicional - # e injetar no menu 'Rendering' apenas se as funções básicas existirem. - - log("Injetando no menu Rendering de forma segura...") + # 3. INJEÇÃO NO MENU 'RENDERING' (Lógica Multi-Versão para 2026) + log("Injetando no menu de Renderização...") - safe_menu_script = ''' + # Este bloco tenta acessar o novo Gerenciador de Interface (CUI) + # sem causar erro de 'undefined' ou 'unknown property' + mxs_ui_fix = ''' ( - -- Tenta o método clássico de MenuManager que ainda funciona para submenus - local mainMenuBar = menuMan.getMainMenuBar() - local renderMenuIdx = menuMan.findMenu "&Rendering" + local manager = undefined - if renderMenuIdx != -1 then ( - local renderMenu = menuMan.getMenu renderMenuIdx + -- Tentativa 1: Novo padrão 2025/2026 + try ( manager = cui.getContentManager() ) catch () + + -- Tentativa 2: Interface Global (se a primeira falhar) + if manager == undefined then ( + try ( manager = (maxOps.GetICuiContentManager()) ) catch () + ) + + if manager != undefined then ( + local mainBar = manager.mainMenuBar + local renderMenu = undefined - -- Verifica se já existe um item chamado VR4Life para não duplicar - local exists = false - for i = 1 to renderMenu.numItems() do ( - local item = renderMenu.getItem i - if item != undefined and (matchPattern (item.getTitle()) pattern:"*VR4Life*") then exists = true + -- Busca o menu Rendering pelo nome técnico + for i = 0 to mainBar.numItems - 1 do ( + local item = mainBar.getItem i + if (matchPattern item.displayText pattern:"*Rendering*") then ( + renderMenu = item + exit + ) ) - if not exists then ( - local sep = menuMan.createSeparatorItem() - renderMenu.addItem sep -1 - - local openItem = menuMan.createActionItem "VR4Life_Open" "Immerse Games" - renderMenu.addItem openItem -1 - - local updateItem = menuMan.createActionItem "VR4Life_Update" "Immerse Games" - renderMenu.addItem updateItem -1 - - menuMan.updateMenuBar() - true - ) else ( "Menu já existe." ) - ) else ( false ) + if renderMenu != undefined then ( + renderMenu.addActionItem "VR4Life_Open" "Immerse Games" + renderMenu.addActionItem "VR4Life_Update" "Immerse Games" + manager.updateMainMenuBar() + "Sucesso no CUI" + ) else ( "Menu Rendering não achado" ) + ) else ( + -- Tentativa 3: Fallback para MenuMan (Max 2024 ou inferior) + if menuMan != undefined then ( + local mBar = menuMan.getMainMenuBar() + local rIdx = menuMan.findMenu "&Rendering" + if rIdx != -1 then ( + local rMenu = menuMan.getMenu rIdx + rMenu.addItem (menuMan.createActionItem "VR4Life_Open" "Immerse Games") -1 + menuMan.updateMenuBar() + "Sucesso no MenuMan" + ) else ( "MenuMan falhou" ) + ) else ( "Todos os sistemas de menu falharam" ) + ) ) ''' - menu_result = rt.execute(safe_menu_script) - log(f"Resultado da criação do menu: {menu_result}") + ui_result = rt.execute(mxs_ui_fix) + log(f"Resultado da Interface: {ui_result}") - # 4. EXECUÇÃO DA JANELA (O que você já confirmou que funciona) + # 4. EXECUÇÃO DA JANELA if os.path.exists(run_script): - log(f"Abrindo v{VERSION}...") + log(f"Executando v{VERSION}...") rt.python.ExecuteFile(run_script) - log(f"=== INSTALAÇÃO FINALIZADA v{VERSION} ===") - rt.messageBox(f"VR4Life v{VERSION} instalado!\n\nSe o menu não aparecer em 'Rendering', você pode adicionar manualmente em: Customize > Customize User Interface > Menus.", title="VR4Life") + log(f"=== INSTALAÇÃO CONCLUÍDA v{VERSION} ===") + rt.messageBox(f"VR4Life v{VERSION} Instalado!\nResultado: {ui_result}", title="VR4Life") if __name__ == "__main__": install_plugin() \ No newline at end of file