Compare commits

..

2 Commits

Author SHA1 Message Date
henrique c64b72bfb5 aaa 2 months ago
henrique e4e54e5615 dwqdqw 2 months ago

@ -5,31 +5,28 @@ def auto_install_menu():
try: try:
# 1. PEGAR O CAMINHO DO PLUGIN (onde este script está) # 1. PEGAR O CAMINHO DO PLUGIN (onde este script está)
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/") 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 (CORRIGIDO: usando string bruta para evitar erro de escape)
# Usamos o comando 'getDir #userScripts' para montar o caminho dinamicamente no MaxScript # 2. REGISTRAR A ACTION (USANDO MÉTODO SEM CONFLITO DE STRING)
macro_cmd = f""" # Aqui, o MaxScript chama uma função Python global que NÓS vamos definir
macroScript VR4Life_Launcher macro_cmd = (
category:"Immerse Games" 'macroScript VR4Life_Launcher\n'
tooltip:"Abrir VR4Life" 'category:"Immerse Games"\n'
( 'tooltip:"Abrir VR4Life"\n'
on execute do ( '(\n'
local scriptPath = @{plugin_dir}/run_vr4life.py@ f' on execute do python.executeFile "{run_script}"\n'
if (doesFileExist scriptPath) then ( ')'
python.executeFile scriptPath
) else (
messageBox "Erro: run_vr4life.py nao encontrado."
) )
)
) # Limpeza radical de aspas para evitar o erro "expected C"
""" macro_cmd = macro_cmd.replace('\\', '/')
rt.execute(macro_cmd) rt.execute(macro_cmd)
# 3. CONFIGURAR O MENU NO TOPO # 3. CONFIGURAR O MENU NO TOPO
menu_manager = rt.menuMan menu_manager = rt.menuMan
main_bar = menu_manager.getMainMenuBar() main_bar = menu_manager.getMainMenuBar()
# Limpa menu antigo se existir para evitar duplicados # Limpa menu antigo se existir
existente = menu_manager.findMenu("VR4Life") existente = menu_manager.findMenu("VR4Life")
if existente: if existente:
menu_manager.unRegisterMenu(existente) menu_manager.unRegisterMenu(existente)
@ -37,25 +34,22 @@ tooltip:"Abrir VR4Life"
# Cria o novo menu # Cria o novo menu
new_menu = menu_manager.createMenu("VR4Life") new_menu = menu_manager.createMenu("VR4Life")
# Cria o item que aponta para o MacroScript "VR4Life_Launcher" # Cria o item que aponta para o MacroScript
launcher_item = menu_manager.createActionItem("VR4Life_Launcher", "Immerse Games") launcher_item = menu_manager.createActionItem("VR4Life_Launcher", "Immerse Games")
# Adiciona o botão no menu
new_menu.addItem(launcher_item, -1) new_menu.addItem(launcher_item, -1)
# 4. INJETAR NA BARRA PRINCIPAL # 4. INJETAR NA BARRA PRINCIPAL
sub_menu_item = menu_manager.createSubMenuItem("VR4Life", new_menu) 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()) main_bar.addItem(sub_menu_item, main_bar.numItems())
# ATUALIZA A INTERFACE # ATUALIZA A INTERFACE
menu_manager.updateMenuBar() menu_manager.updateMenuBar()
print("VR4Life: Instalacao concluida com sucesso!") print("VR4Life: Menu instalado com sucesso!")
return True return True
except Exception as e: 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)}") print(f"Erro no script de menu: {str(e)}")
return False return False

Loading…
Cancel
Save