henrique 2 months ago
parent ad48022aaf
commit e634a6f396

@ -3,61 +3,74 @@ import sys
from pymxs import runtime as rt from pymxs import runtime as rt
def install_plugin(): def install_plugin():
# Define os caminhos locais onde o instalador baixou os arquivos # Caminhos e nomes
user_scripts_dir = rt.getDir(rt.name("userScripts")) user_scripts_dir = rt.getDir(rt.name("userScripts"))
plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/") plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
# Adiciona a pasta ao PATH do Python para evitar erros de 'ModuleNotFoundError'
if plugin_dir not in sys.path: if plugin_dir not in sys.path:
sys.path.append(plugin_dir) sys.path.append(plugin_dir)
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/") run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
# 1. Registro de MacroScript (Funciona em TODAS as versões) # Nome com "1-" para forçar o topo da lista
# Permite que o usuário crie botões em qualquer barra de ferramentas (Toolbar) product_name = "1-VR4Life"
macro_name = "Zombisco_Launcher"
category = "Immerse Games" category = "Immerse Games"
# 1. Cria a Action (MacroScript) - Base para qualquer versão
macro_code = f''' macro_code = f'''
macroScript {macro_name} macroScript VR4LifeLauncher
category:"{category}" category:"{category}"
buttonText:"Zombisco VR" buttonText:"{product_name}"
tooltip:"Abrir Painel Zombisco" tooltip:"Abrir {product_name}"
( (
on execute do ( on execute do ( python.ExecuteFile @"{run_script}" )
python.ExecuteFile @"{run_script}"
)
) )
''' '''
rt.execute(macro_code) rt.execute(macro_code)
# 2. Tentativa de criação de Menu (Legacy vs Modern CUI) # 2. Tenta o método moderno (3ds Max 2025/2026+)
try: try:
# Tenta o método antigo (3ds Max 2024 e anteriores) # No 2025+, usamos o CuiContentManager
main_menu = rt.menuMan.getMainMenuBar() cui_mgr = rt.cui.getContentManager()
menu_name = "Immerse Games" main_menu_bar = cui_mgr.mainMenuBar
# Limpa menu anterior se existir # Verifica se o menu já existe para não duplicar
existing_menu = rt.menuMan.findMenu(menu_name) exists = False
if existing_menu: for i in range(main_menu_bar.numItems):
rt.menuMan.unRegisterMenu(existing_menu) if main_menu_bar.getItem(i).displayText == product_name:
exists = True
new_menu = rt.menuMan.createMenu(menu_name) break
menu_item = rt.menuMan.createActionItem(macro_name, category)
new_menu.addItem(menu_item, -1)
sub_menu_item = rt.menuMan.createSubMenuItem(menu_name, new_menu)
main_menu.addItem(sub_menu_item, -1)
rt.menuMan.updateMenuBar()
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: except AttributeError:
# Detectado 3ds Max 2025 ou 2026 (menuMan não existe) # 3. Método Legado (3ds Max 2024 e anteriores)
# Nestas versões, o usuário deve adicionar o botão manualmente via 'Customize User Interface' try:
# ou o script pode abrir a ferramenta automaticamente na primeira vez. main_menu = rt.menuMan.getMainMenuBar()
if os.path.exists(run_script): existing_menu = rt.menuMan.findMenu(product_name)
rt.python.ExecuteFile(run_script) 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)
rt.messageBox("Instalação concluída!\n\nNo 3ds Max 2025/2026, adicione o botão 'Zombisco' através do menu 'Customize > Hotkey Editor' procurando pela categoria 'Immerse Games'.", title="Immerse Games") 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__": if __name__ == "__main__":
install_plugin() install_plugin()
Loading…
Cancel
Save