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.
58 lines
2.1 KiB
Python
58 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 = 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 duplicidade
|
|
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 "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
|
|
new_menu.addItem(launcher_item, -1)
|
|
|
|
# 4. INJETAR NA BARRA PRINCIPAL
|
|
sub_menu_item = menu_manager.createSubMenuItem("VR4Life", new_menu)
|
|
|
|
# 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: Menu instalado e registrado com sucesso!")
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"Erro no script de menu: {str(e)}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
auto_install_menu() |