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.
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
import os
|
|
from pymxs import runtime as rt
|
|
|
|
def auto_install_menu():
|
|
try:
|
|
# 1. PEGAR O CAMINHO DO PLUGIN
|
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
run_script = f"{plugin_dir}/run_vr4life.py"
|
|
|
|
# 2. REGISTRAR A ACTION (MacroScript)
|
|
# Usamos o rt.execute para garantir que o MaxScript entenda o comando
|
|
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 (Via MaxScript para evitar erro de atributo)
|
|
# Como o pymxs às vezes falha ao mapear o menuMan, o rt.execute é 100% seguro
|
|
setup_menu_cmd = """
|
|
(
|
|
local mainMenuBar = menuMan.getMainMenuBar()
|
|
local existingMenu = menuMan.findMenu "VR4Life"
|
|
if existingMenu != undefined do menuMan.unRegisterMenu existingMenu
|
|
|
|
local newMenu = menuMan.createMenu "VR4Life"
|
|
local launcherItem = menuMan.createActionItem "VR4Life_Launcher" "Immerse Games"
|
|
newMenu.addItem launcherItem -1
|
|
|
|
local subMenuItem = menuMan.createSubMenuItem "VR4Life" newMenu
|
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
|
menuMan.updateMenuBar()
|
|
)
|
|
"""
|
|
rt.execute(setup_menu_cmd)
|
|
|
|
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() |