|
|
|
|
@ -7,69 +7,73 @@ def log(msg):
|
|
|
|
|
|
|
|
|
|
def install_plugin():
|
|
|
|
|
rt.clearListener()
|
|
|
|
|
log("=== INICIANDO INSTALAÇÃO BLINDADA (VR4Life) ===")
|
|
|
|
|
log("=== FORÇANDO ATUALIZAÇÃO DE MENU (VR4Life) ===")
|
|
|
|
|
|
|
|
|
|
# 1. FORÇAR O REGISTRO DA PASTA NO PYTHON (Resolve Imagem 3)
|
|
|
|
|
# 1. Configuração de Caminhos
|
|
|
|
|
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) # Insere no topo para ter prioridade
|
|
|
|
|
log(f"Pasta registrada no Python: {plugin_dir}")
|
|
|
|
|
sys.path.insert(0, 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"
|
|
|
|
|
macro_name = "VR4Life_Launcher"
|
|
|
|
|
|
|
|
|
|
# 2. REGISTRO DA MACRO
|
|
|
|
|
macro_code = f'''
|
|
|
|
|
macroScript {macro_name}
|
|
|
|
|
category:"{category}"
|
|
|
|
|
buttonText:"{product_name}"
|
|
|
|
|
# 2. Registro das Macros (Garante que os comandos existam)
|
|
|
|
|
rt.execute(f'''
|
|
|
|
|
macroScript VR4Life_Open category:"{category}" buttonText:"VR4Life Engine"
|
|
|
|
|
( on execute do ( python.ExecuteFile @"{run_script}" ) )
|
|
|
|
|
'''
|
|
|
|
|
rt.execute(macro_code)
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
rt.execute(f'''
|
|
|
|
|
macroScript VR4Life_Update category:"{category}" buttonText:"Atualizar Plugin"
|
|
|
|
|
( on execute do ( python.ExecuteFile @"{update_script}" ) )
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
# 3. LÓGICA DE MENU COM ESCUDO ANTI-ERRO (Resolve Imagens 2, 4, 5)
|
|
|
|
|
# 3. Lógica para 3ds Max 2025/2026 (CUI)
|
|
|
|
|
try:
|
|
|
|
|
# Tenta o modo moderno do 2026 primeiro
|
|
|
|
|
log("Acessando CUI Content Manager...")
|
|
|
|
|
cui_mgr = rt.cui.getContentManager()
|
|
|
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
|
|
|
|
|
|
# Limpa qualquer resquício para evitar o "vai e vem"
|
|
|
|
|
# REMOÇÃO AGRESSIVA: Procura por qualquer variação do nome para limpar
|
|
|
|
|
for i in range(main_menu_bar.numItems - 1, -1, -1):
|
|
|
|
|
item = main_menu_bar.getItem(i)
|
|
|
|
|
if item.displayText in [product_name, "1-VR4Life"]:
|
|
|
|
|
if item.displayText in [product_name, "1-VR4Life", "vr4life"]:
|
|
|
|
|
main_menu_bar.removeItem(item)
|
|
|
|
|
log(f"Limpando resquício: {item.displayText}")
|
|
|
|
|
|
|
|
|
|
log("Criando menu moderno...")
|
|
|
|
|
# CRIAÇÃO DO MENU
|
|
|
|
|
new_menu = cui_mgr.createCustomMenu(product_name)
|
|
|
|
|
new_menu.addActionItem(macro_name, category)
|
|
|
|
|
main_menu_bar.addItem(new_menu, -1) # Adiciona no final como solicitado
|
|
|
|
|
new_menu.addActionItem("VR4Life_Open", category)
|
|
|
|
|
new_menu.addActionItem("VR4Life_Update", category)
|
|
|
|
|
|
|
|
|
|
# Adiciona ao final (-1)
|
|
|
|
|
main_menu_bar.addItem(new_menu, -1)
|
|
|
|
|
|
|
|
|
|
# REFRESH TOTAL: Força o Max a reescrever o arquivo de menu no disco
|
|
|
|
|
rt.execute("cui.getContentManager().updateMainMenuBar()")
|
|
|
|
|
log("Menu injetado e interface atualizada.")
|
|
|
|
|
|
|
|
|
|
except AttributeError:
|
|
|
|
|
# Lógica Legada (2024 e anteriores)
|
|
|
|
|
if hasattr(rt, "menuMan"):
|
|
|
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
|
|
|
existing = rt.menuMan.findMenu(product_name)
|
|
|
|
|
if existing: rt.menuMan.unRegisterMenu(existing)
|
|
|
|
|
new_menu = rt.menuMan.createMenu(product_name)
|
|
|
|
|
new_menu.addItem(rt.menuMan.createActionItem("VR4Life_Open", category), -1)
|
|
|
|
|
new_menu.addItem(rt.menuMan.createActionItem("VR4Life_Update", category), -1)
|
|
|
|
|
sub_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
|
|
|
|
|
main_menu.addItem(sub_item, -1)
|
|
|
|
|
rt.menuMan.updateMenuBar()
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
# Se falhar (versões antigas), tenta o menuMan de forma segura
|
|
|
|
|
log("Tentando modo legado com segurança...")
|
|
|
|
|
try:
|
|
|
|
|
# Usamos hasattr para evitar que o script 'estoure' o erro de atributo
|
|
|
|
|
if hasattr(rt, "menuMan"):
|
|
|
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
|
|
|
existing = rt.menuMan.findMenu(product_name)
|
|
|
|
|
if existing: rt.menuMan.unRegisterMenu(existing)
|
|
|
|
|
|
|
|
|
|
new_menu = rt.menuMan.createMenu(product_name)
|
|
|
|
|
new_menu.addItem(rt.menuMan.createActionItem(macro_name, category), -1)
|
|
|
|
|
sub_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
|
|
|
|
|
main_menu.addItem(sub_item, -1)
|
|
|
|
|
rt.menuMan.updateMenuBar()
|
|
|
|
|
except:
|
|
|
|
|
log("Aviso: Não foi possível criar o menu superior, use o 'Customize User Interface'.")
|
|
|
|
|
|
|
|
|
|
# 4. EXECUÇÃO FINAL
|
|
|
|
|
# 4. EXECUTAR A JANELA
|
|
|
|
|
if os.path.exists(run_script):
|
|
|
|
|
log("Executando motor...")
|
|
|
|
|
log("Abrindo janela do plugin...")
|
|
|
|
|
rt.python.ExecuteFile(run_script)
|
|
|
|
|
|
|
|
|
|
log("=== INSTALAÇÃO CONCLUÍDA ===")
|
|
|
|
|
|