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.

76 lines
2.8 KiB
Python

import os
import sys
from pymxs import runtime as rt
def install_plugin():
# Caminhos e nomes
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)
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
# Nome com "1-" para forçar o topo da lista
product_name = "1-VR4Life"
category = "Immerse Games"
# 1. Cria a Action (MacroScript) - Base para qualquer versão
macro_code = f'''
macroScript VR4LifeLauncher
category:"{category}"
buttonText:"{product_name}"
tooltip:"Abrir {product_name}"
(
on execute do ( python.ExecuteFile @"{run_script}" )
)
'''
rt.execute(macro_code)
# 2. Tenta o método moderno (3ds Max 2025/2026+)
try:
# No 2025+, usamos o CuiContentManager
cui_mgr = rt.cui.getContentManager()
main_menu_bar = cui_mgr.mainMenuBar
# Verifica se o menu já existe para não duplicar
exists = False
for i in range(main_menu_bar.numItems):
if main_menu_bar.getItem(i).displayText == product_name:
exists = True
break
if not exists:
# Cria um novo menu customizado
new_menu = cui_mgr.createCustomMenu(product_name)
# Adiciona a Action que criamos acima ao menu
new_menu.addActionItem("VR4LifeLauncher", category)
# Insere o menu na barra principal (índice 1 para ficar logo após o 'File')
main_menu_bar.addItem(new_menu, 1)
print(f"[LOG] Menu '{product_name}' instalado via CUI (Max 2025+)")
except AttributeError:
# 3. Método Legado (3ds Max 2024 e anteriores)
try:
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)
menu_item = rt.menuMan.createActionItem("VR4LifeLauncher", category)
new_menu.addItem(menu_item, -1)
sub_menu_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
# Insere na posição 1 (logo após o File)
main_menu.addItem(sub_menu_item, 1)
rt.menuMan.updateMenuBar()
print(f"[LOG] Menu '{product_name}' instalado via menuMan (Legacy)")
except:
print("[ERRO] Não foi possível criar o menu automaticamente.")
rt.messageBox(f"Instalação do {product_name} concluída!", title=product_name)
if __name__ == "__main__":
install_plugin()