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.
78 lines
2.9 KiB
Python
78 lines
2.9 KiB
Python
import os
|
|
import sys
|
|
from pymxs import runtime as rt
|
|
|
|
# Versão v1.0.9 - Correção de Wrapper CUI
|
|
VERSION = "1.0.9"
|
|
|
|
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
|
|
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
|
|
log("Registrando Macros...")
|
|
rt.execute(f'macroScript VR4Life_Open category:"Immerse" buttonText:"VR4Life Engine" (on execute do python.ExecuteFile @"{run_script}")')
|
|
rt.execute(f'macroScript VR4Life_Update category:"Immerse" buttonText:"Atualizar VR4Life" (on execute do python.ExecuteFile @"{update_script}")')
|
|
|
|
# 3. INJEÇÃO NO MENU RENDERING VIA MAXSCRIPT (Para evitar erro de Wrapper no Python)
|
|
log("Injetando itens no menu Rendering...")
|
|
|
|
mxs_command = '''
|
|
(
|
|
local cuiMgr = cui.getContentManager()
|
|
local mainMenuBar = cuiMgr.mainMenuBar
|
|
local renderMenu = undefined
|
|
|
|
-- Procura o menu Rendering
|
|
for i = 0 to mainMenuBar.numItems - 1 do (
|
|
local item = mainMenuBar.getItem i
|
|
if (matchPattern item.displayText pattern:"*Rendering*") then (
|
|
renderMenu = item
|
|
exit
|
|
)
|
|
)
|
|
|
|
if render_menu != undefined then (
|
|
-- Adiciona os itens no final do menu Rendering
|
|
renderMenu.addActionItem "VR4Life_Open" "Immerse"
|
|
renderMenu.addActionItem "VR4Life_Update" "Immerse"
|
|
cuiMgr.updateMainMenuBar()
|
|
true
|
|
) else (
|
|
false
|
|
)
|
|
)
|
|
'''
|
|
|
|
success = rt.execute(mxs_command)
|
|
|
|
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
|
|
if os.path.exists(run_script):
|
|
log(f"Abrindo v{VERSION}...")
|
|
rt.python.ExecuteFile(run_script)
|
|
|
|
log(f"=== INSTALAÇÃO FINALIZADA v{VERSION} ===")
|
|
rt.messageBox(f"VR4Life v{VERSION} instalado!\n\nConfira o final do menu Rendering.", title="VR4Life")
|
|
|
|
if __name__ == "__main__":
|
|
install_plugin() |