From e634a6f396fd0abea59ffa5e31b6ed3b5819537d Mon Sep 17 00:00:00 2001 From: henrique Date: Sun, 22 Feb 2026 23:58:14 -0300 Subject: [PATCH] a --- install_vr4life.py | 79 +++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/install_vr4life.py b/install_vr4life.py index 5c5d5f0..7e657b9 100644 --- a/install_vr4life.py +++ b/install_vr4life.py @@ -3,61 +3,74 @@ import sys from pymxs import runtime as rt def install_plugin(): - # Define os caminhos locais onde o instalador baixou os arquivos + # Caminhos e nomes user_scripts_dir = rt.getDir(rt.name("userScripts")) 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: sys.path.append(plugin_dir) run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/") - # 1. Registro de MacroScript (Funciona em TODAS as versões) - # Permite que o usuário crie botões em qualquer barra de ferramentas (Toolbar) - macro_name = "Zombisco_Launcher" + # 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 {macro_name} + macroScript VR4LifeLauncher category:"{category}" - buttonText:"Zombisco VR" - tooltip:"Abrir Painel Zombisco" + buttonText:"{product_name}" + tooltip:"Abrir {product_name}" ( - on execute do ( - python.ExecuteFile @"{run_script}" - ) + on execute do ( python.ExecuteFile @"{run_script}" ) ) ''' 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: - # Tenta o método antigo (3ds Max 2024 e anteriores) - main_menu = rt.menuMan.getMainMenuBar() - menu_name = "Immerse Games" + # No 2025+, usamos o CuiContentManager + cui_mgr = rt.cui.getContentManager() + main_menu_bar = cui_mgr.mainMenuBar - # Limpa menu anterior se existir - existing_menu = rt.menuMan.findMenu(menu_name) - if existing_menu: - rt.menuMan.unRegisterMenu(existing_menu) - - new_menu = rt.menuMan.createMenu(menu_name) - 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() + # 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: - # Detectado 3ds Max 2025 ou 2026 (menuMan não existe) - # Nestas versões, o usuário deve adicionar o botão manualmente via 'Customize User Interface' - # ou o script pode abrir a ferramenta automaticamente na primeira vez. - if os.path.exists(run_script): - rt.python.ExecuteFile(run_script) + # 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) - 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__": install_plugin() \ No newline at end of file