From 142c2a6b4886c08241cc3b3a1210fbcd1da02439 Mon Sep 17 00:00:00 2001 From: henrique Date: Mon, 23 Feb 2026 16:31:46 -0300 Subject: [PATCH] b --- install_vr4life.py | 103 ++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 61 deletions(-) diff --git a/install_vr4life.py b/install_vr4life.py index cb1811a..b9090cf 100644 --- a/install_vr4life.py +++ b/install_vr4life.py @@ -2,85 +2,66 @@ import os import sys from pymxs import runtime as rt -# 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}") +# Versão de Teste Direto +VERSION = "1.0.8-DEBUG" def install_plugin(): + # Limpa o console para você ler com clareza rt.clearListener() - log(f"=== INICIANDO INSTALAÇÃO v{VERSION} ===") - - # 1. REGISTRO DE CAMINHO (Resolve o erro 'ModuleNotFoundError' da Imagem 3) + + print(f"--- DEBUG INICIADO v{VERSION} ---") + + # 1. SETUP DE PASTAS 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("\\", "/") - product_name = "VR4Life" - category = "Immerse Games" - - # 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}" ) ) - ''') + print(f"Pasta do Plugin: {plugin_dir}") + + # 2. REGISTRO DE MACROS + print("Registrando Macros...") + rt.execute(f'macroScript VR4Life_Open category:"Immerse" buttonText:"VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}")') + rt.execute(f'macroScript VR4Life_Update category:"Immerse" buttonText:"Atualizar VR4Life" (on execute do python.ExecuteFile @"{update_script}")') - # 3. INJEÇÃO NO MENU 'RENDERING' (Evita os erros de 'menuMan' das Imagens 2, 4 e 5) - try: - log("Tentando injetar no menu Rendering (Modo 2026)...") - cui_mgr = rt.cui.getContentManager() - main_menu_bar = cui_mgr.mainMenuBar - - # Localiza o menu Rendering de forma segura - render_menu = None - for i in range(main_menu_bar.numItems): - item = main_menu_bar.getItem(i) - if item.displayText in ["Rendering", "&Rendering"]: - render_menu = item - break + # 3. TENTATIVA DE INJEÇÃO NO MENU RENDERING (SEM SUPRESSÃO DE ERRO) + print("Localizando CUI Content Manager...") + cui_mgr = rt.cui.getContentManager() + main_menu_bar = cui_mgr.mainMenuBar + + render_menu = None + # No Max 2026 o nome pode variar entre "Rendering" e "&Rendering" + for i in range(main_menu_bar.numItems): + item = main_menu_bar.getItem(i) + if "Rendering" in item.displayText: + render_menu = item + print(f"Menu Rendering encontrado no índice: {i}") + break + + if render_menu: + print("Adicionando itens ao menu Rendering...") + # Adiciona separador e itens + render_menu.addActionItem("VR4Life_Open", "Immerse") + render_menu.addActionItem("VR4Life_Update", "Immerse") - if render_menu: - # 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("Injetado com sucesso no menu Rendering.") - else: - log("AVISO: Menu Rendering não localizado via CUI.") + print("Forçando atualização da barra de menus...") + cui_mgr.updateMainMenuBar() + else: + print("ERRO: Não foi possível localizar o menu Rendering na barra principal!") - 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. EXECUÇÃO E LOG FINAL + # 4. EXECUÇÃO DA JANELA if os.path.exists(run_script): - log(f"Abrindo interface do plugin v{VERSION}...") + print("Executando janela principal...") rt.python.ExecuteFile(run_script) + else: + print(f"ERRO: Arquivo {run_script} não encontrado!") - log(f"=== INSTALAÇÃO CONCLUÍDA 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}") + print(f"--- DEBUG FINALIZADO v{VERSION} ---") + rt.messageBox(f"Instalação v{VERSION} finalizada.\nCheque o log (F11) para ver se houve erros no console.", title="VR4Life Debug") if __name__ == "__main__": install_plugin() \ No newline at end of file