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.

99 lines
3.7 KiB
Python

import os
import sys
from pymxs import runtime as rt
# Versão v1.1.1 - Acesso Universal 2026
VERSION = "1.1.1"
def log(msg):
print(f"[VR4Life Install Log] {msg}")
def install_plugin():
rt.clearListener()
log(f"=== INICIANDO INSTALAÇÃO v{VERSION} ===")
# 1. SETUP DE PASTAS E PATH
user_scripts_dir = rt.getDir(rt.name("userScripts"))
plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
if plugin_dir not in sys.path:
sys.path.insert(0, plugin_dir)
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/")
# 2. REGISTRO DE MACROS (Sempre funciona)
log("Registrando Comandos...")
mxs_macros = f'''
(
macroScript VR4Life_Open category:"Immerse Games" buttonText:"VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}")
macroScript VR4Life_Update category:"Immerse Games" buttonText:"Atualizar VR4Life" (on execute do python.ExecuteFile @"{update_script}")
)
'''
rt.execute(mxs_macros)
# 3. INJEÇÃO NO MENU 'RENDERING' (Lógica Multi-Versão para 2026)
log("Injetando no menu de Renderização...")
# Este bloco tenta acessar o novo Gerenciador de Interface (CUI)
# sem causar erro de 'undefined' ou 'unknown property'
mxs_ui_fix = '''
(
local manager = undefined
-- Tentativa 1: Novo padrão 2025/2026
try ( manager = cui.getContentManager() ) catch ()
-- Tentativa 2: Interface Global (se a primeira falhar)
if manager == undefined then (
try ( manager = (maxOps.GetICuiContentManager()) ) catch ()
)
if manager != undefined then (
local mainBar = manager.mainMenuBar
local renderMenu = undefined
-- Busca o menu Rendering pelo nome técnico
for i = 0 to mainBar.numItems - 1 do (
local item = mainBar.getItem i
if (matchPattern item.displayText pattern:"*Rendering*") then (
renderMenu = item
exit
)
)
if renderMenu != undefined then (
renderMenu.addActionItem "VR4Life_Open" "Immerse Games"
renderMenu.addActionItem "VR4Life_Update" "Immerse Games"
manager.updateMainMenuBar()
"Sucesso no CUI"
) else ( "Menu Rendering não achado" )
) else (
-- Tentativa 3: Fallback para MenuMan (Max 2024 ou inferior)
if menuMan != undefined then (
local mBar = menuMan.getMainMenuBar()
local rIdx = menuMan.findMenu "&Rendering"
if rIdx != -1 then (
local rMenu = menuMan.getMenu rIdx
rMenu.addItem (menuMan.createActionItem "VR4Life_Open" "Immerse Games") -1
menuMan.updateMenuBar()
"Sucesso no MenuMan"
) else ( "MenuMan falhou" )
) else ( "Todos os sistemas de menu falharam" )
)
)
'''
ui_result = rt.execute(mxs_ui_fix)
log(f"Resultado da Interface: {ui_result}")
# 4. EXECUÇÃO DA JANELA
if os.path.exists(run_script):
log(f"Executando v{VERSION}...")
rt.python.ExecuteFile(run_script)
log(f"=== INSTALAÇÃO CONCLUÍDA v{VERSION} ===")
rt.messageBox(f"VR4Life v{VERSION} Instalado!\nResultado: {ui_result}", title="VR4Life")
if __name__ == "__main__":
install_plugin()