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.
89 lines
3.3 KiB
Python
89 lines
3.3 KiB
Python
import os
|
|
import sys
|
|
from pymxs import runtime as rt
|
|
|
|
# Definição da Versão
|
|
VERSION = "1.0.5"
|
|
|
|
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. Lógica para 3ds Max 2025/2026 (CUI)
|
|
try:
|
|
log("Tentando injetar menu no sistema CUI...")
|
|
cui_mgr = rt.cui.getContentManager()
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
# Limpa qualquer rastro anterior
|
|
for i in range(main_menu_bar.numItems - 1, -1, -1):
|
|
item = main_menu_bar.getItem(i)
|
|
if item.displayText in [product_name, "1-VR4Life"]:
|
|
main_menu_bar.removeItem(item)
|
|
|
|
# Criação do Menu
|
|
new_menu = cui_mgr.createCustomMenu(product_name)
|
|
new_menu.addActionItem("VR4Life_Open", category)
|
|
new_menu.addActionItem("VR4Life_Update", category)
|
|
|
|
# -1 coloca no final da lista
|
|
main_menu_bar.addItem(new_menu, -1)
|
|
|
|
# FORÇAR REFRESH E SALVAMENTO (Crucial para o 2026)
|
|
cui_mgr.updateMainMenuBar()
|
|
log("Interface CUI atualizada.")
|
|
|
|
except AttributeError:
|
|
# Lógica Legada (2024)
|
|
if hasattr(rt, "menuMan"):
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
existing = rt.menuMan.findMenu(product_name)
|
|
if existing: rt.menuMan.unRegisterMenu(existing)
|
|
new_menu = rt.menuMan.createMenu(product_name)
|
|
new_menu.addItem(rt.menuMan.createActionItem("VR4Life_Open", category), -1)
|
|
new_menu.addItem(rt.menuMan.createActionItem("VR4Life_Update", category), -1)
|
|
sub_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
|
|
main_menu.addItem(sub_item, -1)
|
|
rt.menuMan.updateMenuBar()
|
|
log("Interface Legacy atualizada.")
|
|
|
|
# 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} ===")
|
|
|
|
# Mensagem final com versão para o usuário
|
|
msg = f"VR4Life v{VERSION} instalado com sucesso!\n\nO menu deve aparecer ao final da lista superior.\nCaso não veja, reinicie o 3ds Max ou troque o Workspace."
|
|
rt.messageBox(msg, title=f"VR4Life v{VERSION}")
|
|
|
|
if __name__ == "__main__":
|
|
install_plugin() |