henrique 2 months ago
parent bdd867733f
commit b4f1827970

@ -2,8 +2,8 @@ import os
import sys import sys
from pymxs import runtime as rt from pymxs import runtime as rt
# Versão v1.1.0 - Correção Definitiva para o 3ds Max 2026 # Versão v1.1.1 - Acesso Universal 2026
VERSION = "1.1.0" VERSION = "1.1.1"
def log(msg): def log(msg):
print(f"[VR4Life Install Log] {msg}") print(f"[VR4Life Install Log] {msg}")
@ -12,7 +12,7 @@ def install_plugin():
rt.clearListener() rt.clearListener()
log(f"=== INICIANDO INSTALAÇÃO v{VERSION} ===") log(f"=== INICIANDO INSTALAÇÃO v{VERSION} ===")
# 1. SETUP DE PASTAS # 1. SETUP DE PASTAS E PATH
user_scripts_dir = rt.getDir(rt.name("userScripts")) user_scripts_dir = rt.getDir(rt.name("userScripts"))
plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/") plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
@ -22,69 +22,78 @@ def install_plugin():
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/") run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/") update_script = os.path.join(plugin_dir, "vr4life_updater.py").replace("\\", "/")
# 2. REGISTRO DE MACROS (Comandos que o Max entende) # 2. REGISTRO DE MACROS (Sempre funciona)
log("Registrando Comandos VR4Life...") log("Registrando Comandos...")
# Criamos a categoria 'Immerse Games' que aparecerá no Customize User Interface mxs_macros = f'''
mxs_macro = f'''
( (
macroScript VR4Life_Open category:"Immerse Games" buttonText:"VR4Life Engine" macroScript VR4Life_Open category:"Immerse Games" buttonText:"VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}")
( on execute do python.ExecuteFile @"{run_script}" ) macroScript VR4Life_Update category:"Immerse Games" buttonText:"Atualizar VR4Life" (on execute do python.ExecuteFile @"{update_script}")
macroScript VR4Life_Update category:"Immerse Games" buttonText:"Atualizar VR4Life"
( on execute do python.ExecuteFile @"{update_script}" )
) )
''' '''
rt.execute(mxs_macro) rt.execute(mxs_macros)
# 3. CRIAÇÃO DO MENU (Método Seguro para o 2026) # 3. INJEÇÃO NO MENU 'RENDERING' (Lógica Multi-Versão para 2026)
# Como o getContentManager está falhando, vamos usar o menuMan de forma condicional log("Injetando no menu de Renderização...")
# e injetar no menu 'Rendering' apenas se as funções básicas existirem.
log("Injetando no menu Rendering de forma segura...")
safe_menu_script = ''' # Este bloco tenta acessar o novo Gerenciador de Interface (CUI)
# sem causar erro de 'undefined' ou 'unknown property'
mxs_ui_fix = '''
( (
-- Tenta o método clássico de MenuManager que ainda funciona para submenus local manager = undefined
local mainMenuBar = menuMan.getMainMenuBar()
local renderMenuIdx = menuMan.findMenu "&Rendering"
if renderMenuIdx != -1 then ( -- Tentativa 1: Novo padrão 2025/2026
local renderMenu = menuMan.getMenu renderMenuIdx 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
-- Verifica se existe um item chamado VR4Life para não duplicar -- Busca o menu Rendering pelo nome técnico
local exists = false for i = 0 to mainBar.numItems - 1 do (
for i = 1 to renderMenu.numItems() do ( local item = mainBar.getItem i
local item = renderMenu.getItem i if (matchPattern item.displayText pattern:"*Rendering*") then (
if item != undefined and (matchPattern (item.getTitle()) pattern:"*VR4Life*") then exists = true renderMenu = item
exit
)
) )
if not exists then ( if renderMenu != undefined then (
local sep = menuMan.createSeparatorItem() renderMenu.addActionItem "VR4Life_Open" "Immerse Games"
renderMenu.addItem sep -1 renderMenu.addActionItem "VR4Life_Update" "Immerse Games"
manager.updateMainMenuBar()
local openItem = menuMan.createActionItem "VR4Life_Open" "Immerse Games" "Sucesso no CUI"
renderMenu.addItem openItem -1 ) else ( "Menu Rendering não achado" )
) else (
local updateItem = menuMan.createActionItem "VR4Life_Update" "Immerse Games" -- Tentativa 3: Fallback para MenuMan (Max 2024 ou inferior)
renderMenu.addItem updateItem -1 if menuMan != undefined then (
local mBar = menuMan.getMainMenuBar()
menuMan.updateMenuBar() local rIdx = menuMan.findMenu "&Rendering"
true if rIdx != -1 then (
) else ( "Menu já existe." ) local rMenu = menuMan.getMenu rIdx
) else ( false ) rMenu.addItem (menuMan.createActionItem "VR4Life_Open" "Immerse Games") -1
menuMan.updateMenuBar()
"Sucesso no MenuMan"
) else ( "MenuMan falhou" )
) else ( "Todos os sistemas de menu falharam" )
)
) )
''' '''
menu_result = rt.execute(safe_menu_script) ui_result = rt.execute(mxs_ui_fix)
log(f"Resultado da criação do menu: {menu_result}") log(f"Resultado da Interface: {ui_result}")
# 4. EXECUÇÃO DA JANELA (O que você já confirmou que funciona) # 4. EXECUÇÃO DA JANELA
if os.path.exists(run_script): if os.path.exists(run_script):
log(f"Abrindo v{VERSION}...") log(f"Executando v{VERSION}...")
rt.python.ExecuteFile(run_script) rt.python.ExecuteFile(run_script)
log(f"=== INSTALAÇÃO FINALIZADA v{VERSION} ===") log(f"=== INSTALAÇÃO CONCLUÍDA v{VERSION} ===")
rt.messageBox(f"VR4Life v{VERSION} instalado!\n\nSe o menu não aparecer em 'Rendering', você pode adicionar manualmente em: Customize > Customize User Interface > Menus.", title="VR4Life") rt.messageBox(f"VR4Life v{VERSION} Instalado!\nResultado: {ui_result}", title="VR4Life")
if __name__ == "__main__": if __name__ == "__main__":
install_plugin() install_plugin()
Loading…
Cancel
Save