You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.1 KiB
Python

import os
from pymxs import runtime as rt
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("\\", "/")
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
# 2. REGISTRAR A ACTION (USANDO MÉTODO SEM CONFLITO DE STRING)
# Aqui, o MaxScript chama uma função Python global que NÓS vamos definir
macro_cmd = (
'macroScript VR4Life_Launcher\n'
'category:"Immerse Games"\n'
'tooltip:"Abrir VR4Life"\n'
'(\n'
f' on execute do python.executeFile "{run_script}"\n'
')'
)
# Limpeza radical de aspas para evitar o erro "expected C"
macro_cmd = macro_cmd.replace('\\', '/')
rt.execute(macro_cmd)
# 3. CONFIGURAR O MENU NO TOPO
menu_manager = rt.menuMan
main_bar = menu_manager.getMainMenuBar()
# Limpa menu antigo se existir
existente = menu_manager.findMenu("VR4Life")
if existente:
menu_manager.unRegisterMenu(existente)
# Cria o novo menu
new_menu = menu_manager.createMenu("VR4Life")
# Cria o item que aponta para o MacroScript
launcher_item = menu_manager.createActionItem("VR4Life_Launcher", "Immerse Games")
new_menu.addItem(launcher_item, -1)
# 4. INJETAR NA BARRA PRINCIPAL
sub_menu_item = menu_manager.createSubMenuItem("VR4Life", new_menu)
main_bar.addItem(sub_menu_item, main_bar.numItems())
# ATUALIZA A INTERFACE
menu_manager.updateMenuBar()
print("VR4Life: Menu instalado com sucesso!")
return True
except Exception as e:
# Se falhar, vamos imprimir EXATAMENTE o que o MaxScript recebeu para debug
print(f"Erro no script de menu: {str(e)}")
return False
if __name__ == "__main__":
auto_install_menu()