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.
59 lines
2.2 KiB
Python
59 lines
2.2 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 MACROS (O padrão que o Babylon usa)
|
|
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. CONSTRUÇÃO DO MENU (Lógica idêntica ao CreateBabylonMenus.ms)
|
|
# Usamos um bloco MaxScript puro para garantir acesso às interfaces core
|
|
setup_script = """
|
|
(
|
|
-- 1. Acessar o Menu Manager
|
|
local menuMgr = menuMan
|
|
local mainMenuBar = menuMgr.getMainMenuBar()
|
|
|
|
-- 2. Limpar se já existir (evita duplicados)
|
|
local existingMenu = menuMgr.findMenu "VR4Life"
|
|
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu
|
|
|
|
-- 3. Criar o novo menu
|
|
local newMenu = menuMgr.createMenu "VR4Life"
|
|
|
|
-- 4. Criar o item da Action (vinculado à categoria Immerse Games)
|
|
local actionItem = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games"
|
|
newMenu.addItem actionItem -1
|
|
|
|
-- 5. Criar o SubMenu na Barra Principal
|
|
local subMenuItem = menuMgr.createSubMenuItem "VR4Life" newMenu
|
|
|
|
-- 6. Inserir antes do Help (ou no final)
|
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
|
|
|
-- 7. Forçar atualização visual
|
|
menuMgr.updateMenuBar()
|
|
format ">> VR4Life: Menu instalado seguindo padrao BabylonJS.\\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() |