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.
95 lines
3.7 KiB
Python
95 lines
3.7 KiB
Python
import os
|
|
import sys
|
|
from pymxs import runtime as rt
|
|
|
|
# Definição da Versão
|
|
VERSION = "1.0.6"
|
|
|
|
def log(msg):
|
|
print(f"[VR4Life Install Log] {msg}")
|
|
|
|
def install_plugin():
|
|
rt.clearListener()
|
|
log(f"=== INICIANDO INSTALAÇÃO VR4Life v{VERSION} ===")
|
|
|
|
# 1. Configuração de Caminhos
|
|
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("\\", "/")
|
|
|
|
product_name = "VR4Life"
|
|
category = "Immerse Games"
|
|
|
|
# 2. Registro das Macros
|
|
rt.execute(f'''
|
|
macroScript VR4Life_Open category:"{category}" buttonText:"VR4Life Engine"
|
|
( on execute do ( python.ExecuteFile @"{run_script}" ) )
|
|
''')
|
|
|
|
rt.execute(f'''
|
|
macroScript VR4Life_Update category:"{category}" buttonText:"Atualizar Plugin"
|
|
( on execute do ( python.ExecuteFile @"{update_script}" ) )
|
|
''')
|
|
|
|
# 3. Injeção no Menu Rendering (Para garantir visibilidade no 2026)
|
|
try:
|
|
log("Buscando menu 'Rendering' para injeção...")
|
|
cui_mgr = rt.cui.getContentManager()
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
# Localiza o menu Rendering
|
|
render_menu = None
|
|
target_name = "Rendering" # Em inglês, padrão do Max
|
|
|
|
for i in range(main_menu_bar.numItems):
|
|
item = main_menu_bar.getItem(i)
|
|
# Verifica se é o menu Rendering (ou Renderização em PT)
|
|
if item.displayText == target_name or item.displayText == "&Rendering":
|
|
render_menu = item
|
|
break
|
|
|
|
if render_menu:
|
|
log("Menu Rendering encontrado. Adicionando itens...")
|
|
# Verifica se já injetamos antes para não duplicar
|
|
# No CUI moderno, injetamos como ActionItems dentro do menu existente
|
|
render_menu.addActionItem("VR4Life_Open", category)
|
|
render_menu.addActionItem("VR4Life_Update", category)
|
|
|
|
cui_mgr.updateMainMenuBar()
|
|
log("Itens injetados no menu Rendering com sucesso.")
|
|
else:
|
|
log("AVISO: Menu Rendering não encontrado. Criando menu próprio no final...")
|
|
new_menu = cui_mgr.createCustomMenu(product_name)
|
|
new_menu.addActionItem("VR4Life_Open", category)
|
|
new_menu.addActionItem("VR4Life_Update", category)
|
|
main_menu_bar.addItem(new_menu, -1)
|
|
cui_mgr.updateMainMenuBar()
|
|
|
|
except AttributeError:
|
|
# Lógica Legada (2024) - Injeta no Rendering via menuMan
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
# Procura o menu Rendering (índice ou nome)
|
|
render_idx = rt.menuMan.findMenu("&Rendering")
|
|
if render_idx != -1:
|
|
r_menu = rt.menuMan.getMenu(render_idx)
|
|
r_menu.addItem(rt.menuMan.createSeparatorItem(), -1)
|
|
r_menu.addItem(rt.menuMan.createActionItem("VR4Life_Open", category), -1)
|
|
r_menu.addItem(rt.menuMan.createActionItem("VR4Life_Update", category), -1)
|
|
rt.menuMan.updateMenuBar()
|
|
log("Injetado no Rendering (Legacy).")
|
|
|
|
# 4. EXECUTAR A JANELA
|
|
if os.path.exists(run_script):
|
|
log(f"Abrindo interface v{VERSION}...")
|
|
rt.python.ExecuteFile(run_script)
|
|
|
|
log(f"=== INSTALAÇÃO CONCLUÍDA v{VERSION} ===")
|
|
rt.messageBox(f"VR4Life v{VERSION} instalado!\n\nProcure as opções no final do menu 'Rendering'.", title=f"VR4Life v{VERSION}")
|
|
|
|
if __name__ == "__main__":
|
|
install_plugin() |