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.
89 lines
3.4 KiB
Python
89 lines
3.4 KiB
Python
import os
|
|
import sys
|
|
from pymxs import runtime as rt
|
|
|
|
def log(msg):
|
|
"""Log detalhado no Listener (F11)"""
|
|
print(f"[VR4Life Install Log] {msg}")
|
|
|
|
def install_plugin():
|
|
rt.clearListener()
|
|
log("=== CONFIGURANDO MENU VR4Life (INSTALAÇÃO NO FINAL) ===")
|
|
|
|
# 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.append(plugin_dir)
|
|
|
|
engine_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
|
|
log("Registrando Macros no sistema...")
|
|
rt.execute(f'''
|
|
macroScript VR4Life_Open category:"{category}" buttonText:"VR4Life Engine"
|
|
( on execute do ( python.ExecuteFile @"{engine_script}" ) )
|
|
''')
|
|
|
|
rt.execute(f'''
|
|
macroScript VR4Life_Update category:"{category}" buttonText:"Atualizar Plugin"
|
|
( on execute do ( python.ExecuteFile @"{update_script}" ) )
|
|
''')
|
|
|
|
# 3. Lógica de Menu para 3ds Max 2025/2026 (CUI)
|
|
try:
|
|
log("Gerenciando interface via CUI Manager (2025+)...")
|
|
cui_mgr = rt.cui.getContentManager()
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
# Limpeza de versões anteriores
|
|
for i in range(main_menu_bar.numItems - 1, -1, -1):
|
|
item = main_menu_bar.getItem(i)
|
|
if item.displayText == product_name or item.displayText == "1-VR4Life":
|
|
main_menu_bar.removeItem(item)
|
|
log(f"Limpando menu antigo: {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)
|
|
|
|
# addItem sem o segundo parâmetro ou com -1 coloca no FINAL da lista
|
|
main_menu_bar.addItem(new_menu, -1)
|
|
|
|
rt.execute("cui.getContentManager().updateMainMenuBar()")
|
|
log("Menu VR4Life adicionado ao final da barra principal.")
|
|
|
|
except AttributeError:
|
|
# 4. Lógica Legada (2024 e anteriores)
|
|
log("Usando menuMan (Modo Legado)...")
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
existing_menu = rt.menuMan.findMenu(product_name)
|
|
if existing_menu: rt.menuMan.unRegisterMenu(existing_menu)
|
|
|
|
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_menu_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
|
|
|
|
# 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. Execução Automática
|
|
if os.path.exists(engine_script):
|
|
log("Executando interface do plugin...")
|
|
rt.python.ExecuteFile(engine_script)
|
|
|
|
log("=== PROCESSO FINALIZADO COM LOGS ATIVOS ===")
|
|
rt.messageBox(f"Instalação do '{product_name}' concluída no final do menu!", title=product_name)
|
|
|
|
if __name__ == "__main__":
|
|
install_plugin() |