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.3 KiB
Python
63 lines
2.3 KiB
Python
import os
|
|
from pymxs import runtime as rt
|
|
|
|
def install_vr4life_menu_official():
|
|
try:
|
|
# 1. PEGAR CAMINHOS
|
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
run_script = f"{plugin_dir}/run_vr4life.py"
|
|
|
|
# 2. REGISTRAR MACRO (Necessário para o botão funcionar)
|
|
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. O SEGREDO DO BABYLON: Pegar a Interface de Menu corretamente
|
|
setup_script = """
|
|
(
|
|
-- Em vez de menuMan direto, usamos a interface de sistema
|
|
local menuMgr = maxUtils.getMainMenuManager()
|
|
|
|
if menuMgr == undefined then (
|
|
-- Se ainda for undefined, tentamos a forma global com fallback
|
|
menuMgr = menuMan
|
|
)
|
|
|
|
if menuMgr != undefined then (
|
|
local mainMenuBar = menuMgr.getMainMenuBar()
|
|
|
|
-- Limpar duplicados
|
|
local existingMenu = menuMgr.findMenu "VR4Life"
|
|
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu
|
|
|
|
-- Criar o menu
|
|
local newMenu = menuMgr.createMenu "VR4Life"
|
|
local actionItem = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games"
|
|
newMenu.addItem actionItem -1
|
|
|
|
-- Adicionar na barra principal
|
|
local subMenuItem = menuMgr.createSubMenuItem "VR4Life" newMenu
|
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
|
|
|
menuMgr.updateMenuBar()
|
|
format ">> VR4Life: Menu instalado com sucesso via MainMenuManager.\\n"
|
|
) else (
|
|
format ">> VR4Life Erro: Nao foi possivel obter o Menu Manager.\\n"
|
|
)
|
|
)
|
|
"""
|
|
rt.execute(setup_script)
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"Erro na instalacao: {str(e)}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
install_vr4life_menu_official() |