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.
55 lines
1.9 KiB
Python
55 lines
1.9 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("\\", "/")
|
|
|
|
# 2. REGISTAR A ACTION (O QUE O BOTÃO FAZ)
|
|
macro_cmd = f"""
|
|
macroScript VR4Life_Launcher
|
|
category:"Immerse Games"
|
|
tooltip:"Abrir VR4Life"
|
|
(
|
|
python.executeFile @{plugin_dir}/run_vr4life.py@
|
|
)
|
|
"""
|
|
rt.execute(macro_cmd)
|
|
|
|
# 3. CRIAR O MENU NO TOPO
|
|
menu_manager = rt.menuMan
|
|
main_bar = menu_manager.getMainMenuBar()
|
|
|
|
# Verifica se o menu já existe para não duplicar toda vez que rodar
|
|
for i in range(1, main_bar.numItems() + 1):
|
|
if main_bar.getItem(i).getTitle() == "VR4Life":
|
|
menu_manager.unRegisterMenu(menu_manager.findMenu("VR4Life"))
|
|
|
|
# Cria um novo menu chamado VR4Life
|
|
new_menu = menu_manager.createMenu("VR4Life")
|
|
|
|
# Cria o item de clique que chama a Action que registamos acima
|
|
# O nome tem de ser igual ao do macroScript: "VR4Life_Launcher"
|
|
launcher_item = menu_manager.createActionItem("VR4Life_Launcher", "Immerse Games")
|
|
|
|
# Adiciona o botão dentro do menu
|
|
new_menu.addItem(launcher_item, -1)
|
|
|
|
# 4. INJETAR NA BARRA PRINCIPAL (Main Menu Bar)
|
|
# Cria o "SubMenu" e coloca ele antes do 'Help' (último item)
|
|
sub_menu_item = menu_manager.createSubMenuItem("VR4Life", new_menu)
|
|
main_bar.addItem(sub_menu_item, main_bar.numItems())
|
|
|
|
# ATUALIZA A INTERFACE NA HORA
|
|
menu_manager.updateMenuBar()
|
|
|
|
print("VR4Life: Menu instalado via script 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() |