|
|
|
@ -1,68 +1,56 @@
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
|
|
|
|
|
|
|
|
def install_vr4life_babylon_final():
|
|
|
|
def install_vr4life_2026_fixed():
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# 1. DEFINIR CAMINHOS
|
|
|
|
# 1. CAMINHOS
|
|
|
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
|
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
|
|
startup_dir = rt.getDir(rt.name("userStartupScripts"))
|
|
|
|
|
|
|
|
loader_path = os.path.join(startup_dir, "CreateVr4LifeMenus.ms")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 2. O CONTEÚDO DO SCRIPT (Fiel ao repositório BabylonJS 2026)
|
|
|
|
# Onde o MNX foi copiado pelo seu instalador
|
|
|
|
# O segredo do 2026: usar interfaces dinâmicas e registrar no CUI
|
|
|
|
pasta_macros = rt.getDir(rt.name("userMacros"))
|
|
|
|
ms_content = f"""
|
|
|
|
pasta_enu = os.path.dirname(pasta_macros)
|
|
|
|
|
|
|
|
caminho_mnx = os.path.join(pasta_enu, "en-US", "UI", "vr4life.mnx").replace("\\", "/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 2. REGISTRAR AS MACROS (Obrigatorio para o MNX funcionar)
|
|
|
|
|
|
|
|
# Usamos exatamente a categoria "Immerse Games" que está no seu MNX
|
|
|
|
|
|
|
|
macro_cmd = f"""
|
|
|
|
|
|
|
|
macroScript VR4Life_Launcher
|
|
|
|
|
|
|
|
category:"Immerse Games"
|
|
|
|
|
|
|
|
tooltip:"Abrir VR4Life"
|
|
|
|
(
|
|
|
|
(
|
|
|
|
-- Função principal de criação (Abordagem Babylon)
|
|
|
|
on execute do python.executeFile "{plugin_dir}/run_vr4life.py"
|
|
|
|
fn CreateVr4LifeMenu = (
|
|
|
|
)
|
|
|
|
local menuMgr = maxUtils.getMainMenuManager()
|
|
|
|
|
|
|
|
if menuMgr == undefined do menuMgr = menuMan
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if menuMgr != undefined then (
|
|
|
|
|
|
|
|
local mainMenuBar = menuMgr.getMainMenuBar()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Remove duplicados para evitar poluição
|
|
|
|
|
|
|
|
local existingMenu = menuMgr.findMenu "Vr4Life"
|
|
|
|
|
|
|
|
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Cria o menu "Vr4Life"
|
|
|
|
|
|
|
|
local newMenu = menuMgr.createMenu "Vr4Life"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Cria os itens (Actions) - Usando a categoria Immerse Games do seu MNX
|
|
|
|
|
|
|
|
local actionLauncher = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games"
|
|
|
|
|
|
|
|
local actionUpdate = menuMgr.createActionItem "VR4Life_Update" "Immerse Games"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newMenu.addItem actionLauncher -1
|
|
|
|
|
|
|
|
newMenu.addItem actionUpdate -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Adiciona à barra principal (Posição final)
|
|
|
|
|
|
|
|
local subMenuItem = menuMgr.createSubMenuItem "Vr4Life" newMenu
|
|
|
|
|
|
|
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menuMgr.updateMenuBar()
|
|
|
|
|
|
|
|
format ">> VR4Life: Menu injetado via %\\n" (getSourceFileName())
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Registro das Macros (O motor por trás dos botões)
|
|
|
|
|
|
|
|
macroScript VR4Life_Launcher category:"Immerse Games" tooltip:"Abrir VR4Life" ( on execute do python.executeFile "{plugin_dir}/run_vr4life.py" )
|
|
|
|
|
|
|
|
macroScript VR4Life_Update category:"Immerse Games" tooltip:"Atualizar VR4Life" ( on execute do python.executeFile "{plugin_dir}/vr4life_updater.py" )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Gatilhos de execução (O Babylon usa múltiplos para garantir)
|
|
|
|
macroScript VR4Life_Update
|
|
|
|
CreateVr4LifeMenu()
|
|
|
|
category:"Immerse Games"
|
|
|
|
callbacks.removeScripts id:#VR4LifeMenuSetup
|
|
|
|
tooltip:"Atualizar VR4Life"
|
|
|
|
callbacks.addScript #cuiRegisterMenus "CreateVr4LifeMenu()" id:#VR4LifeMenuSetup
|
|
|
|
(
|
|
|
|
callbacks.addScript #filePostOpen "CreateVr4LifeMenu()" id:#VR4LifeMenuSetup
|
|
|
|
on execute do python.executeFile "{plugin_dir}/vr4life_updater.py"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# 3. GRAVAR O ARQUIVO NO DISCO (Persistência estilo Babylon)
|
|
|
|
rt.execute(macro_cmd)
|
|
|
|
with open(loader_path, "w", encoding="utf-8") as f:
|
|
|
|
|
|
|
|
f.write(ms_content)
|
|
|
|
# 3. CARREGAR O MNX VIA INTERFACE DE CONTEXTO (Abordagem Babylon 2026)
|
|
|
|
|
|
|
|
# Se o menuMan é undefined, usamos o carregamento de arquivo de configuração
|
|
|
|
# 4. EXECUTAR O ARQUIVO CRIADO
|
|
|
|
setup_script = f"""
|
|
|
|
rt.fileIn(loader_path)
|
|
|
|
(
|
|
|
|
|
|
|
|
local mnxPath = "{caminho_mnx}"
|
|
|
|
|
|
|
|
if (doesFileExist mnxPath) then (
|
|
|
|
|
|
|
|
-- No 2026, tentamos carregar o arquivo de menus diretamente
|
|
|
|
|
|
|
|
-- sem passar pelas propriedades de "getMainMenuBar"
|
|
|
|
|
|
|
|
try (
|
|
|
|
|
|
|
|
menuMan.loadMenuFile mnxPath
|
|
|
|
|
|
|
|
menuMan.updateMenuBar()
|
|
|
|
|
|
|
|
) catch (
|
|
|
|
|
|
|
|
-- Se falhar aqui, o Max carregará no próximo boot
|
|
|
|
|
|
|
|
-- pois o arquivo já está na pasta oficial de UI
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
rt.execute(setup_script)
|
|
|
|
|
|
|
|
|
|
|
|
print(f">> Arquivo gerado em: {loader_path}")
|
|
|
|
print(">> VR4Life: Macros registradas e MNX vinculado.")
|
|
|
|
print(">> Se o menu não aparecer agora, ele aparecerá ao abrir qualquer arquivo ou reiniciar.")
|
|
|
|
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
@ -70,4 +58,4 @@ def install_vr4life_babylon_final():
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
install_vr4life_babylon_final()
|
|
|
|
install_vr4life_2026_fixed()
|