henrique 2 months ago
parent f5a7f3172c
commit bdd867733f

@ -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.0.9 - Correção de Wrapper CUI # Versão v1.1.0 - Correção Definitiva para o 3ds Max 2026
VERSION = "1.0.9" VERSION = "1.1.0"
def log(msg): def log(msg):
print(f"[VR4Life Install Log] {msg}") print(f"[VR4Life Install Log] {msg}")
@ -22,57 +22,69 @@ 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 # 2. REGISTRO DE MACROS (Comandos que o Max entende)
log("Registrando Macros...") log("Registrando Comandos VR4Life...")
rt.execute(f'macroScript VR4Life_Open category:"Immerse" buttonText:"VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}")') # Criamos a categoria 'Immerse Games' que aparecerá no Customize User Interface
rt.execute(f'macroScript VR4Life_Update category:"Immerse" buttonText:"Atualizar VR4Life" (on execute do python.ExecuteFile @"{update_script}")') mxs_macro = 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_macro)
# 3. INJEÇÃO NO MENU RENDERING VIA MAXSCRIPT (Para evitar erro de Wrapper no Python) # 3. CRIAÇÃO DO MENU (Método Seguro para o 2026)
log("Injetando itens no menu Rendering...") # Como o getContentManager está falhando, vamos usar o menuMan de forma condicional
# e injetar no menu 'Rendering' apenas se as funções básicas existirem.
mxs_command = ''' log("Injetando no menu Rendering de forma segura...")
safe_menu_script = '''
( (
local cuiMgr = cui.getContentManager() -- Tenta o método clássico de MenuManager que ainda funciona para submenus
local mainMenuBar = cuiMgr.mainMenuBar local mainMenuBar = menuMan.getMainMenuBar()
local renderMenu = undefined local renderMenuIdx = menuMan.findMenu "&Rendering"
-- Procura o menu Rendering if renderMenuIdx != -1 then (
for i = 0 to mainMenuBar.numItems - 1 do ( local renderMenu = menuMan.getMenu renderMenuIdx
local item = mainMenuBar.getItem i
if (matchPattern item.displayText pattern:"*Rendering*") then ( -- Verifica se existe um item chamado VR4Life para não duplicar
renderMenu = item local exists = false
exit for i = 1 to renderMenu.numItems() do (
local item = renderMenu.getItem i
if item != undefined and (matchPattern (item.getTitle()) pattern:"*VR4Life*") then exists = true
) )
)
if not exists then (
if render_menu != undefined then ( local sep = menuMan.createSeparatorItem()
-- Adiciona os itens no final do menu Rendering renderMenu.addItem sep -1
renderMenu.addActionItem "VR4Life_Open" "Immerse"
renderMenu.addActionItem "VR4Life_Update" "Immerse" local openItem = menuMan.createActionItem "VR4Life_Open" "Immerse Games"
cuiMgr.updateMainMenuBar() renderMenu.addItem openItem -1
true
) else ( local updateItem = menuMan.createActionItem "VR4Life_Update" "Immerse Games"
false renderMenu.addItem updateItem -1
)
menuMan.updateMenuBar()
true
) else ( "Menu já existe." )
) else ( false )
) )
''' '''
success = rt.execute(mxs_command) menu_result = rt.execute(safe_menu_script)
log(f"Resultado da criação do menu: {menu_result}")
if success:
log("Sucesso: Itens adicionados ao menu Rendering.")
else:
log("ERRO: Menu Rendering não encontrado. Criando menu no final da barra...")
# Fallback: Cria menu novo se o Rendering falhar
rt.execute('local m = (cui.getContentManager()).createCustomMenu "VR4Life"; m.addActionItem "VR4Life_Open" "Immerse"; m.addActionItem "VR4Life_Update" "Immerse"; (cui.getContentManager()).mainMenuBar.addItem m -1; (cui.getContentManager()).updateMainMenuBar()')
# 4. EXECUÇÃO DA JANELA # 4. EXECUÇÃO DA JANELA (O que você já confirmou que funciona)
if os.path.exists(run_script): if os.path.exists(run_script):
log(f"Abrindo v{VERSION}...") log(f"Abrindo v{VERSION}...")
rt.python.ExecuteFile(run_script) rt.python.ExecuteFile(run_script)
log(f"=== INSTALAÇÃO FINALIZADA v{VERSION} ===") log(f"=== INSTALAÇÃO FINALIZADA v{VERSION} ===")
rt.messageBox(f"VR4Life v{VERSION} instalado!\n\nConfira o final do menu Rendering.", title="VR4Life") 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")
if __name__ == "__main__": if __name__ == "__main__":
install_plugin() install_plugin()
Loading…
Cancel
Save