henrique 2 months ago
parent aa2d17ae85
commit f4d802e8cf

@ -2,22 +2,24 @@ import os
import sys import sys
from pymxs import runtime as rt from pymxs import runtime as rt
# Definição da Versão # Definição da Versão para o Log
VERSION = "1.0.6" VERSION = "1.0.7"
def log(msg): def log(msg):
# Log visível no Listener (F11)
print(f"[VR4Life Install Log] {msg}") print(f"[VR4Life Install Log] {msg}")
def install_plugin(): def install_plugin():
rt.clearListener() 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")) user_scripts_dir = rt.getDir(rt.name("userScripts"))
plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/") plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
if plugin_dir not in sys.path: if plugin_dir not in sys.path:
sys.path.insert(0, plugin_dir) sys.path.insert(0, plugin_dir)
log(f"Pasta registrada: {plugin_dir}")
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/") run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/") update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/")
@ -25,71 +27,60 @@ def install_plugin():
product_name = "VR4Life" product_name = "VR4Life"
category = "Immerse Games" category = "Immerse Games"
# 2. Registro das Macros # 2. REGISTRO DAS MACROS (Garante que os botões existam no sistema)
rt.execute(f''' rt.execute(f'''
macroScript VR4Life_Open category:"{category}" buttonText:"VR4Life Engine" macroScript VR4Life_Open category:"{category}" buttonText:"VR4Life Engine"
( on execute do ( python.ExecuteFile @"{run_script}" ) ) ( on execute do ( python.ExecuteFile @"{run_script}" ) )
''') ''')
rt.execute(f''' rt.execute(f'''
macroScript VR4Life_Update category:"{category}" buttonText:"Atualizar Plugin" macroScript VR4Life_Update category:"{category}" buttonText:"Atualizar Plugin"
( on execute do ( python.ExecuteFile @"{update_script}" ) ) ( 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: try:
log("Buscando menu 'Rendering' para injeção...") log("Tentando injetar no menu Rendering (Modo 2026)...")
cui_mgr = rt.cui.getContentManager() cui_mgr = rt.cui.getContentManager()
main_menu_bar = cui_mgr.mainMenuBar main_menu_bar = cui_mgr.mainMenuBar
# Localiza o menu Rendering # Localiza o menu Rendering de forma segura
render_menu = None render_menu = None
target_name = "Rendering" # Em inglês, padrão do Max
for i in range(main_menu_bar.numItems): for i in range(main_menu_bar.numItems):
item = main_menu_bar.getItem(i) item = main_menu_bar.getItem(i)
# Verifica se é o menu Rendering (ou Renderização em PT) if item.displayText in ["Rendering", "&Rendering"]:
if item.displayText == target_name or item.displayText == "&Rendering":
render_menu = item render_menu = item
break break
if render_menu: if render_menu:
log("Menu Rendering encontrado. Adicionando itens...") # Adiciona os itens no final do menu Rendering
# Verifica se já injetamos antes para não duplicar
# No CUI moderno, injetamos como ActionItems dentro do menu existente
render_menu.addActionItem("VR4Life_Open", category) render_menu.addActionItem("VR4Life_Open", category)
render_menu.addActionItem("VR4Life_Update", category) render_menu.addActionItem("VR4Life_Update", category)
# Comando para 'acordar' a interface
cui_mgr.updateMainMenuBar() cui_mgr.updateMainMenuBar()
log("Itens injetados no menu Rendering com sucesso.") log("Injetado com sucesso no menu Rendering.")
else: else:
log("AVISO: Menu Rendering não encontrado. Criando menu próprio no final...") log("AVISO: Menu Rendering não localizado via CUI.")
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()
except AttributeError: except Exception as e:
# Lógica Legada (2024) - Injeta no Rendering via menuMan log(f"Erro ao usar CUI: {str(e)}. Tentando alternativa segura...")
main_menu = rt.menuMan.getMainMenuBar() # Fallback para versões antigas apenas se o comando existir
# Procura o menu Rendering (índice ou nome) if hasattr(rt, "menuMan"):
render_idx = rt.menuMan.findMenu("&Rendering") render_idx = rt.menuMan.findMenu("&Rendering")
if render_idx != -1: if render_idx != -1:
r_menu = rt.menuMan.getMenu(render_idx) 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_Open", category), -1) rt.menuMan.updateMenuBar()
r_menu.addItem(rt.menuMan.createActionItem("VR4Life_Update", category), -1)
rt.menuMan.updateMenuBar()
log("Injetado no Rendering (Legacy).")
# 4. EXECUTAR A JANELA # 4. EXECUÇÃO E LOG FINAL
if os.path.exists(run_script): 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) rt.python.ExecuteFile(run_script)
log(f"=== INSTALAÇÃO CONCLUÍDA v{VERSION} ===") 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__": if __name__ == "__main__":
install_plugin() install_plugin()
Loading…
Cancel
Save