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.
63 lines
2.1 KiB
Python
63 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("\\", "/")
|
|
|
|
# 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."
|
|
)
|
|
)
|
|
)
|
|
"""
|
|
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
|
|
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"
|
|
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 antes do menu Help (que costuma ser o último)
|
|
main_bar.addItem(sub_menu_item, main_bar.numItems())
|
|
|
|
# ATUALIZA A INTERFACE
|
|
menu_manager.updateMenuBar()
|
|
|
|
print("VR4Life: Instalacao concluida 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() |