|
|
|
@ -3,110 +3,87 @@ import sys
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
|
|
|
|
|
|
|
|
def log(msg):
|
|
|
|
def log(msg):
|
|
|
|
"""Função para imprimir no Listener (F11) com prefixo identificável"""
|
|
|
|
"""Log detalhado 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("=== INICIANDO FASE DE CONFIGURAÇÃO DE INTERFACE (UNIVERSAL) ===")
|
|
|
|
log("=== CONFIGURANDO MENU VR4Life (INSTALAÇÃO NO FINAL) ===")
|
|
|
|
|
|
|
|
|
|
|
|
# 1. Configuração de Caminhos Locais
|
|
|
|
# 1. Configuração de Caminhos
|
|
|
|
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.append(plugin_dir)
|
|
|
|
sys.path.append(plugin_dir)
|
|
|
|
log(f"Path Python atualizado: {plugin_dir}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
|
|
|
|
engine_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
|
|
|
|
log(f"Caminho do script de execução detectado: {run_script}")
|
|
|
|
update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/")
|
|
|
|
|
|
|
|
|
|
|
|
# Definições do Produto
|
|
|
|
product_name = "VR4Life"
|
|
|
|
product_name = "1-VR4Life"
|
|
|
|
|
|
|
|
category = "Immerse Games"
|
|
|
|
category = "Immerse Games"
|
|
|
|
macro_name = "VR4Life_Launcher"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 2. Registro do MacroScript (Obrigatório para o comando existir no sistema)
|
|
|
|
# 2. Registro das Macros
|
|
|
|
log(f"Registando MacroScript '{macro_name}'...")
|
|
|
|
log("Registrando Macros no sistema...")
|
|
|
|
macro_code = f'''
|
|
|
|
rt.execute(f'''
|
|
|
|
macroScript {macro_name}
|
|
|
|
macroScript VR4Life_Open category:"{category}" buttonText:"VR4Life Engine"
|
|
|
|
category:"{category}"
|
|
|
|
( on execute do ( python.ExecuteFile @"{engine_script}" ) )
|
|
|
|
buttonText:"{product_name}"
|
|
|
|
''')
|
|
|
|
tooltip:"Abrir {product_name}"
|
|
|
|
|
|
|
|
(
|
|
|
|
rt.execute(f'''
|
|
|
|
on execute do ( python.ExecuteFile @"{run_script}" )
|
|
|
|
macroScript VR4Life_Update category:"{category}" buttonText:"Atualizar Plugin"
|
|
|
|
)
|
|
|
|
( on execute do ( python.ExecuteFile @"{update_script}" ) )
|
|
|
|
'''
|
|
|
|
''')
|
|
|
|
try:
|
|
|
|
|
|
|
|
rt.execute(macro_code)
|
|
|
|
|
|
|
|
log("MacroScript registado com sucesso.")
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
log(f"ERRO ao registar MacroScript: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 3. Lógica de Menu para 3ds Max 2025/2026 (CUI Content Manager)
|
|
|
|
# 3. Lógica de Menu para 3ds Max 2025/2026 (CUI)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
log("Tentando configurar via CUI Content Manager (3ds Max 2025+)...")
|
|
|
|
log("Gerenciando interface via CUI Manager (2025+)...")
|
|
|
|
cui_mgr = rt.cui.getContentManager()
|
|
|
|
cui_mgr = rt.cui.getContentManager()
|
|
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
|
|
|
|
|
|
|
|
# Verificar e remover duplicados para evitar menus 'fantasmas'
|
|
|
|
# Limpeza de versões anteriores
|
|
|
|
existing_item = None
|
|
|
|
for i in range(main_menu_bar.numItems - 1, -1, -1):
|
|
|
|
for i in range(main_menu_bar.numItems):
|
|
|
|
|
|
|
|
item = main_menu_bar.getItem(i)
|
|
|
|
item = main_menu_bar.getItem(i)
|
|
|
|
if item.displayText == product_name:
|
|
|
|
if item.displayText == product_name or item.displayText == "1-VR4Life":
|
|
|
|
existing_item = item
|
|
|
|
main_menu_bar.removeItem(item)
|
|
|
|
log("Menu já existente detectado. Removendo para reinstalação limpa...")
|
|
|
|
log(f"Limpando menu antigo: {item.displayText}")
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if existing_item:
|
|
|
|
|
|
|
|
main_menu_bar.removeItem(existing_item)
|
|
|
|
|
|
|
|
log("Menu antigo removido da barra CUI.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Criação do Menu Moderno
|
|
|
|
# Criação do Menu
|
|
|
|
log(f"Criando novo menu '{product_name}'...")
|
|
|
|
|
|
|
|
new_menu = cui_mgr.createCustomMenu(product_name)
|
|
|
|
new_menu = cui_mgr.createCustomMenu(product_name)
|
|
|
|
new_menu.addActionItem(macro_name, category)
|
|
|
|
new_menu.addActionItem("VR4Life_Open", category)
|
|
|
|
|
|
|
|
new_menu.addActionItem("VR4Life_Update", category)
|
|
|
|
|
|
|
|
|
|
|
|
# Insere na posição 1 (logo após o 'File')
|
|
|
|
# addItem sem o segundo parâmetro ou com -1 coloca no FINAL da lista
|
|
|
|
main_menu_bar.addItem(new_menu, 1)
|
|
|
|
main_menu_bar.addItem(new_menu, -1)
|
|
|
|
log(f"Menu '{product_name}' adicionado à barra principal.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Forçar o 3ds Max a redesenhar a barra de menus (Crucial para o 2026)
|
|
|
|
rt.execute("cui.getContentManager().updateMainMenuBar()")
|
|
|
|
log("Solicitando atualização forçada da barra de menus...")
|
|
|
|
log("Menu VR4Life adicionado ao final da barra principal.")
|
|
|
|
rt.execute("cui.getContentManager().updateMainMenuBar()")
|
|
|
|
|
|
|
|
log("Comando 'updateMainMenuBar' enviado.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except AttributeError:
|
|
|
|
except AttributeError:
|
|
|
|
# 4. Lógica Legada (3ds Max 2024 e anteriores)
|
|
|
|
# 4. Lógica Legada (2024 e anteriores)
|
|
|
|
log("CUI Manager não disponível. Usando modo legado 'menuMan'...")
|
|
|
|
log("Usando menuMan (Modo Legado)...")
|
|
|
|
try:
|
|
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
|
|
existing_menu = rt.menuMan.findMenu(product_name)
|
|
|
|
existing_menu = rt.menuMan.findMenu(product_name)
|
|
|
|
if existing_menu: rt.menuMan.unRegisterMenu(existing_menu)
|
|
|
|
|
|
|
|
|
|
|
|
if existing_menu:
|
|
|
|
|
|
|
|
rt.menuMan.unRegisterMenu(existing_menu)
|
|
|
|
|
|
|
|
log("Menu legado antigo removido.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new_menu = rt.menuMan.createMenu(product_name)
|
|
|
|
|
|
|
|
menu_item = rt.menuMan.createActionItem(macro_name, category)
|
|
|
|
|
|
|
|
new_menu.addItem(menu_item, -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub_menu_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
|
|
|
|
new_menu = rt.menuMan.createMenu(product_name)
|
|
|
|
main_menu.addItem(sub_menu_item, 1)
|
|
|
|
new_menu.addItem(rt.menuMan.createActionItem("VR4Life_Open", category), -1)
|
|
|
|
rt.menuMan.updateMenuBar()
|
|
|
|
new_menu.addItem(rt.menuMan.createActionItem("VR4Life_Update", category), -1)
|
|
|
|
log("Menu legado criado e atualizado com sucesso.")
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
sub_menu_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
|
|
|
|
log(f"ERRO na criação de menu legado: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
# No menuMan, -1 também adiciona ao final
|
|
|
|
|
|
|
|
main_menu.addItem(sub_menu_item, -1)
|
|
|
|
|
|
|
|
rt.menuMan.updateMenuBar()
|
|
|
|
|
|
|
|
log("Menu legado adicionado ao final.")
|
|
|
|
|
|
|
|
|
|
|
|
# 5. Inicialização pós-instalação
|
|
|
|
# 5. Execução Automática
|
|
|
|
if os.path.exists(run_script):
|
|
|
|
if os.path.exists(engine_script):
|
|
|
|
log("Abrindo interface VR4Life para teste imediato...")
|
|
|
|
log("Executando interface do plugin...")
|
|
|
|
rt.python.ExecuteFile(run_script)
|
|
|
|
rt.python.ExecuteFile(engine_script)
|
|
|
|
else:
|
|
|
|
|
|
|
|
log(f"AVISO: Arquivo de execução não encontrado em: {run_script}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log("=== PROCESSO DE INSTALAÇÃO FINALIZADO ===")
|
|
|
|
log("=== PROCESSO FINALIZADO COM LOGS ATIVOS ===")
|
|
|
|
rt.messageBox(f"Instalação do '{product_name}' concluída!\nSe o menu não aparecer imediatamente, verifique o Listener (F11).", title=product_name)
|
|
|
|
rt.messageBox(f"Instalação do '{product_name}' concluída no final do menu!", title=product_name)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
install_plugin()
|
|
|
|
install_plugin()
|