diff --git a/install_vr4life.py b/install_vr4life.py index 9c3b871..cb1811a 100644 --- a/install_vr4life.py +++ b/install_vr4life.py @@ -2,22 +2,24 @@ import os import sys from pymxs import runtime as rt -# Definição da Versão -VERSION = "1.0.6" +# Definição da Versão para o Log +VERSION = "1.0.7" def log(msg): + # Log visível no Listener (F11) print(f"[VR4Life Install Log] {msg}") def install_plugin(): rt.clearListener() - log(f"=== INICIANDO INSTALAÇÃO VR4Life v{VERSION} ===") + log(f"=== INICIANDO INSTALAÇÃO v{VERSION} ===") - # 1. Configuração de Caminhos + # 1. REGISTRO DE CAMINHO (Resolve o erro 'ModuleNotFoundError' da Imagem 3) user_scripts_dir = rt.getDir(rt.name("userScripts")) plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/") if plugin_dir not in sys.path: sys.path.insert(0, plugin_dir) + log(f"Pasta registrada: {plugin_dir}") run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/") update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/") @@ -25,71 +27,60 @@ def install_plugin(): product_name = "VR4Life" category = "Immerse Games" - # 2. Registro das Macros + # 2. REGISTRO DAS MACROS (Garante que os botões existam no sistema) rt.execute(f''' macroScript VR4Life_Open category:"{category}" buttonText:"VR4Life Engine" ( on execute do ( python.ExecuteFile @"{run_script}" ) ) ''') - rt.execute(f''' macroScript VR4Life_Update category:"{category}" buttonText:"Atualizar Plugin" ( on execute do ( python.ExecuteFile @"{update_script}" ) ) ''') - # 3. Injeção no Menu Rendering (Para garantir visibilidade no 2026) + # 3. INJEÇÃO NO MENU 'RENDERING' (Evita os erros de 'menuMan' das Imagens 2, 4 e 5) try: - log("Buscando menu 'Rendering' para injeção...") + log("Tentando injetar no menu Rendering (Modo 2026)...") cui_mgr = rt.cui.getContentManager() main_menu_bar = cui_mgr.mainMenuBar - # Localiza o menu Rendering + # Localiza o menu Rendering de forma segura render_menu = None - target_name = "Rendering" # Em inglês, padrão do Max - for i in range(main_menu_bar.numItems): item = main_menu_bar.getItem(i) - # Verifica se é o menu Rendering (ou Renderização em PT) - if item.displayText == target_name or item.displayText == "&Rendering": + if item.displayText in ["Rendering", "&Rendering"]: render_menu = item break if render_menu: - log("Menu Rendering encontrado. Adicionando itens...") - # Verifica se já injetamos antes para não duplicar - # No CUI moderno, injetamos como ActionItems dentro do menu existente + # Adiciona os itens no final do menu Rendering render_menu.addActionItem("VR4Life_Open", category) render_menu.addActionItem("VR4Life_Update", category) - + # Comando para 'acordar' a interface cui_mgr.updateMainMenuBar() - log("Itens injetados no menu Rendering com sucesso.") + log("Injetado com sucesso no menu Rendering.") else: - log("AVISO: Menu Rendering não encontrado. Criando menu próprio no final...") - new_menu = cui_mgr.createCustomMenu(product_name) - new_menu.addActionItem("VR4Life_Open", category) - new_menu.addActionItem("VR4Life_Update", category) - main_menu_bar.addItem(new_menu, -1) - cui_mgr.updateMainMenuBar() + log("AVISO: Menu Rendering não localizado via CUI.") - except AttributeError: - # Lógica Legada (2024) - Injeta no Rendering via menuMan - main_menu = rt.menuMan.getMainMenuBar() - # Procura o menu Rendering (índice ou nome) - render_idx = rt.menuMan.findMenu("&Rendering") - if render_idx != -1: - r_menu = rt.menuMan.getMenu(render_idx) - r_menu.addItem(rt.menuMan.createSeparatorItem(), -1) - r_menu.addItem(rt.menuMan.createActionItem("VR4Life_Open", category), -1) - r_menu.addItem(rt.menuMan.createActionItem("VR4Life_Update", category), -1) - rt.menuMan.updateMenuBar() - log("Injetado no Rendering (Legacy).") + except Exception as e: + log(f"Erro ao usar CUI: {str(e)}. Tentando alternativa segura...") + # Fallback para versões antigas apenas se o comando existir + if hasattr(rt, "menuMan"): + render_idx = rt.menuMan.findMenu("&Rendering") + if render_idx != -1: + r_menu = rt.menuMan.getMenu(render_idx) + r_menu.addItem(rt.menuMan.createActionItem("VR4Life_Open", category), -1) + rt.menuMan.updateMenuBar() - # 4. EXECUTAR A JANELA + # 4. EXECUÇÃO E LOG FINAL if os.path.exists(run_script): - log(f"Abrindo interface v{VERSION}...") + log(f"Abrindo interface do plugin v{VERSION}...") rt.python.ExecuteFile(run_script) log(f"=== INSTALAÇÃO CONCLUÍDA v{VERSION} ===") - rt.messageBox(f"VR4Life v{VERSION} instalado!\n\nProcure as opções no final do menu 'Rendering'.", title=f"VR4Life v{VERSION}") + + # Mensagem clara para o usuário + msg = f"VR4Life v{VERSION} instalado!\n\nProcure as opções no final do menu 'Rendering'." + rt.messageBox(msg, title=f"VR4Life v{VERSION}") if __name__ == "__main__": install_plugin() \ No newline at end of file