diff --git a/install_vr4life.py b/install_vr4life.py index 8d1536e..532f68a 100644 --- a/install_vr4life.py +++ b/install_vr4life.py @@ -1,22 +1,24 @@ import os from pymxs import runtime as rt -def configure_plugin(): +def force_menu_load(): try: - print("=== CONFIGURANDO COMPONENTES INTERNOS VR4LIFE ===") - - # 1. Define o caminho onde os scripts foram salvos (o diretório atual deste arquivo) - plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/") - - # 2. Adiciona a pasta do plugin ao PATH do Python do 3ds Max - # Isso permite que você dê 'import vr4life_engine' de qualquer lugar - import sys - if plugin_dir not in sys.path: - sys.path.append(plugin_dir) - print(f"Path adicionado ao Python: {plugin_dir}") + # 1. Caminho onde o arquivo foi copiado pelo script principal + pasta_macros = rt.pathConfig.getDir(rt.name("userMacros")) + pasta_enu = os.path.dirname(pasta_macros) + caminho_mnx = os.path.join(pasta_enu, "en-US", "UI", "vr4life.mnx") - # 3. Se você precisar registrar algum atalho de teclado ou MacroScript, faça aqui. - # Exemplo: Registrar o comando que o botão do menu vai chamar + if os.path.exists(caminho_mnx): + print(f"Carregando menu: {caminho_mnx}") + # Comando para carregar o arquivo de menu imediatamente + rt.menuMan.loadMenuFile(caminho_mnx) + rt.menuMan.updateMenuBar() + print("Menu VR4Life carregado com sucesso!") + else: + print("Arquivo .mnx ainda não encontrado no destino final.") + + # 2. Registrar a Macro (para o botão saber o que executar) + plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/") macro_script = f""" macroScript VR4Life_Launcher category:"VR4Life" @@ -26,18 +28,11 @@ tooltip:"Abrir VR4Life" ) """ rt.execute(macro_script) - print("MacroScript VR4Life_Launcher registrado com sucesso.") - - # 4. Forçar o 3ds Max a atualizar a interface para o menu aparecer - # (Opcional, às vezes o Max precisa reiniciar para ler o .mnx novo) - rt.menuMan.updateMenuBar() - - print("=== PLUGIN VR4LIFE PRONTO PARA USO ===") + return True - except Exception as e: - print(f"Erro na configuração final: {str(e)}") + print(f"Erro ao carregar menu: {str(e)}") return False if __name__ == "__main__": - configure_plugin() \ No newline at end of file + force_menu_load() \ No newline at end of file