diff --git a/install_vr4life.py b/install_vr4life.py index 9bb5188..df9b7b2 100644 --- a/install_vr4life.py +++ b/install_vr4life.py @@ -5,31 +5,25 @@ def auto_install_menu(): try: # 1. PEGAR O CAMINHO DO PLUGIN (onde este script está) plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/") - - # 2. REGISTRAR A ACTION (CORRIGIDO: usando string bruta para evitar erro de escape) - # Usamos o comando 'getDir #userScripts' para montar o caminho dinamicamente no MaxScript - macro_cmd = f""" -macroScript VR4Life_Launcher -category:"Immerse Games" -tooltip:"Abrir VR4Life" -( - on execute do ( - local scriptPath = @{plugin_dir}/run_vr4life.py@ - if (doesFileExist scriptPath) then ( - python.executeFile scriptPath - ) else ( - messageBox "Erro: run_vr4life.py nao encontrado." + run_script = f"{plugin_dir}/run_vr4life.py" + + # 2. REGISTRAR A ACTION (Usando string format para evitar conflito de arrobas) + # Usamos o comando python.executeFile direto com o path formatado + macro_cmd = ( + 'macroScript VR4Life_Launcher\n' + 'category:"Immerse Games"\n' + 'tooltip:"Abrir VR4Life"\n' + '(\n' + f' on execute do python.executeFile "{run_script}"\n' + ')' ) - ) -) -""" rt.execute(macro_cmd) # 3. CONFIGURAR O MENU NO TOPO menu_manager = rt.menuMan main_bar = menu_manager.getMainMenuBar() - # Limpa menu antigo se existir para evitar duplicados + # Limpa menu antigo se existir para evitar duplicidade existente = menu_manager.findMenu("VR4Life") if existente: menu_manager.unRegisterMenu(existente) @@ -38,6 +32,7 @@ tooltip:"Abrir VR4Life" new_menu = menu_manager.createMenu("VR4Life") # Cria o item que aponta para o MacroScript "VR4Life_Launcher" + # O nome da categoria deve ser igual ao definido no macro_cmd launcher_item = menu_manager.createActionItem("VR4Life_Launcher", "Immerse Games") # Adiciona o botão no menu @@ -46,13 +41,13 @@ tooltip:"Abrir VR4Life" # 4. INJETAR NA BARRA PRINCIPAL sub_menu_item = menu_manager.createSubMenuItem("VR4Life", new_menu) - # Adiciona antes do menu Help (que costuma ser o último) + # Adiciona no final da barra (antes do Help) main_bar.addItem(sub_menu_item, main_bar.numItems()) # ATUALIZA A INTERFACE menu_manager.updateMenuBar() - print("VR4Life: Instalacao concluida com sucesso!") + print("VR4Life: Menu instalado e registrado com sucesso!") return True except Exception as e: