|
|
|
|
@ -3,7 +3,7 @@ import sys
|
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
|
|
|
|
|
|
def install_plugin():
|
|
|
|
|
# Caminhos e nomes
|
|
|
|
|
# Configurações de Caminho
|
|
|
|
|
user_scripts_dir = rt.getDir(rt.name("userScripts"))
|
|
|
|
|
plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
|
|
|
|
|
|
|
|
|
|
@ -12,13 +12,14 @@ def install_plugin():
|
|
|
|
|
|
|
|
|
|
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
|
|
|
|
|
|
|
|
|
|
# Nome com "1-" para forçar o topo da lista
|
|
|
|
|
# Nome solicitado: "1-VR4Life" para o topo
|
|
|
|
|
product_name = "1-VR4Life"
|
|
|
|
|
category = "Immerse Games"
|
|
|
|
|
macro_name = "VR4Life_Launcher"
|
|
|
|
|
|
|
|
|
|
# 1. Cria a Action (MacroScript) - Base para qualquer versão
|
|
|
|
|
# 1. Registo da Macro (Essencial para o 2026 "enxergar" o comando)
|
|
|
|
|
macro_code = f'''
|
|
|
|
|
macroScript VR4LifeLauncher
|
|
|
|
|
macroScript {macro_name}
|
|
|
|
|
category:"{category}"
|
|
|
|
|
buttonText:"{product_name}"
|
|
|
|
|
tooltip:"Abrir {product_name}"
|
|
|
|
|
@ -28,49 +29,51 @@ def install_plugin():
|
|
|
|
|
'''
|
|
|
|
|
rt.execute(macro_code)
|
|
|
|
|
|
|
|
|
|
# 2. Tenta o método moderno (3ds Max 2025/2026+)
|
|
|
|
|
# 2. Lógica para 3ds Max 2025 e 2026 (Sistema CUI Moderno)
|
|
|
|
|
try:
|
|
|
|
|
# No 2025+, usamos o CuiContentManager
|
|
|
|
|
# Tenta aceder ao Gestor de Conteúdo Moderno
|
|
|
|
|
cui_mgr = rt.cui.getContentManager()
|
|
|
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
|
|
|
|
|
|
# Verifica se o menu já existe para não duplicar
|
|
|
|
|
exists = False
|
|
|
|
|
# Verifica se já existe para não duplicar no 2026
|
|
|
|
|
menu_exists = False
|
|
|
|
|
for i in range(main_menu_bar.numItems):
|
|
|
|
|
if main_menu_bar.getItem(i).displayText == product_name:
|
|
|
|
|
exists = True
|
|
|
|
|
menu_exists = True
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if not exists:
|
|
|
|
|
# Cria um novo menu customizado
|
|
|
|
|
if not menu_exists:
|
|
|
|
|
# No 2026, criamos um menu customizado e forçamos a atualização do ficheiro MNX
|
|
|
|
|
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')
|
|
|
|
|
new_menu.addActionItem(macro_name, category)
|
|
|
|
|
|
|
|
|
|
# Posição 1 coloca-o logo após o menu "File"
|
|
|
|
|
main_menu_bar.addItem(new_menu, 1)
|
|
|
|
|
print(f"[LOG] Menu '{product_name}' instalado via CUI (Max 2025+)")
|
|
|
|
|
|
|
|
|
|
print(f"[LOG] {product_name} instalado com sucesso via CUI (2025/2026).")
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
# 3. Lógica para 3ds Max 2024 e anteriores (Sistema menuMan)
|
|
|
|
|
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(macro_name, category)
|
|
|
|
|
new_menu.addItem(menu_item, -1)
|
|
|
|
|
|
|
|
|
|
sub_menu_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
|
|
|
|
|
main_menu.addItem(sub_menu_item, 1)
|
|
|
|
|
rt.menuMan.updateMenuBar()
|
|
|
|
|
print(f"[LOG] {product_name} instalado com sucesso via menuMan (Legacy).")
|
|
|
|
|
|
|
|
|
|
# Força a abertura da ferramenta na primeira instalação para o artista já começar a trabalhar no Zombisco
|
|
|
|
|
if os.path.exists(run_script):
|
|
|
|
|
rt.python.ExecuteFile(run_script)
|
|
|
|
|
|
|
|
|
|
rt.messageBox(f"O menu '{product_name}' foi adicionado com sucesso!", title=product_name)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
install_plugin()
|