You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.1 KiB
Python
82 lines
3.1 KiB
Python
import os
|
|
import sys
|
|
from pymxs import runtime as rt
|
|
|
|
def log(msg):
|
|
print(f"[VR4Life Install Log] {msg}")
|
|
|
|
def install_plugin():
|
|
rt.clearListener()
|
|
log("=== FORÇANDO ATUALIZAÇÃO DE MENU (VR4Life) ===")
|
|
|
|
# 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)
|
|
|
|
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 comandos existam)
|
|
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. Lógica para 3ds Max 2025/2026 (CUI)
|
|
try:
|
|
log("Acessando CUI Content Manager...")
|
|
cui_mgr = rt.cui.getContentManager()
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
# 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", "vr4life"]:
|
|
main_menu_bar.removeItem(item)
|
|
log(f"Limpando resquício: {item.displayText}")
|
|
|
|
# CRIAÇÃO DO MENU
|
|
new_menu = cui_mgr.createCustomMenu(product_name)
|
|
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()
|
|
|
|
# 4. EXECUTAR A JANELA
|
|
if os.path.exists(run_script):
|
|
log("Abrindo janela do plugin...")
|
|
rt.python.ExecuteFile(run_script)
|
|
|
|
log("=== INSTALAÇÃO CONCLUÍDA ===")
|
|
|
|
if __name__ == "__main__":
|
|
install_plugin() |