aaa
parent
5f16aa23ef
commit
4643bd8a3a
@ -1,49 +1,54 @@
|
||||
import os
|
||||
from pymxs import runtime as rt
|
||||
|
||||
def auto_install_menu():
|
||||
def carregar_menu_mnx():
|
||||
rt.clearListener()
|
||||
print("\n" + "="*50)
|
||||
print("LOG DE INSTALAÇÃO DE INTERFACE - VR4LIFE")
|
||||
print("="*50)
|
||||
|
||||
try:
|
||||
# 1. PEGAR O CAMINHO DO PLUGIN
|
||||
# 1. Definir caminhos
|
||||
pasta_macros = rt.pathConfig.getDir(rt.name("userMacros"))
|
||||
pasta_enu = os.path.dirname(pasta_macros)
|
||||
caminho_mnx = os.path.join(pasta_enu, "en-US", "UI", "vr4life.mnx").replace("\\", "/")
|
||||
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
||||
run_script = f"{plugin_dir}/run_vr4life.py"
|
||||
|
||||
# 2. REGISTRAR A ACTION (MacroScript)
|
||||
# Usamos o rt.execute para garantir que o MaxScript entenda o comando
|
||||
macro_cmd = (
|
||||
'macroScript VR4Life_Launcher\n'
|
||||
'category:"Immerse Games"\n'
|
||||
'tooltip:"Abrir VR4Life"\n'
|
||||
'(\n'
|
||||
f' on execute do python.executeFile "{run_script}"\n'
|
||||
')'
|
||||
)
|
||||
|
||||
print(f"[*] Pasta do Plugin: {plugin_dir}")
|
||||
print(f"[*] Caminho do MNX: {caminho_mnx}")
|
||||
|
||||
# 2. Registrar MacroScript
|
||||
print("[*] Registrando MacroScript VR4Life_Launcher...")
|
||||
macro_cmd = f'macroScript VR4Life_Launcher category:"Immerse Games" tooltip:"Abrir VR4Life" (on execute do python.executeFile "{run_script}")'
|
||||
rt.execute(macro_cmd)
|
||||
|
||||
# 3. CONFIGURAR O MENU NO TOPO (Via MaxScript para evitar erro de atributo)
|
||||
# Como o pymxs às vezes falha ao mapear o menuMan, o rt.execute é 100% seguro
|
||||
setup_menu_cmd = """
|
||||
(
|
||||
local mainMenuBar = menuMan.getMainMenuBar()
|
||||
local existingMenu = menuMan.findMenu "VR4Life"
|
||||
if existingMenu != undefined do menuMan.unRegisterMenu existingMenu
|
||||
# 3. Carregar MNX
|
||||
if os.path.exists(caminho_mnx):
|
||||
print(f"[!] Arquivo MNX encontrado. Solicitando carregamento ao 3ds Max...")
|
||||
|
||||
local newMenu = menuMan.createMenu "VR4Life"
|
||||
local launcherItem = menuMan.createActionItem "VR4Life_Launcher" "Immerse Games"
|
||||
newMenu.addItem launcherItem -1
|
||||
|
||||
local subMenuItem = menuMan.createSubMenuItem "VR4Life" newMenu
|
||||
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
||||
menuMan.updateMenuBar()
|
||||
)
|
||||
"""
|
||||
rt.execute(setup_menu_cmd)
|
||||
|
||||
print("VR4Life: Menu instalado e registrado com sucesso!")
|
||||
return True
|
||||
# Comando com verificação interna do MaxScript
|
||||
cmd_load = f"""
|
||||
(
|
||||
if menuMan != undefined then (
|
||||
local result = menuMan.loadMenuFile @{caminho_mnx}@
|
||||
menuMan.updateMenuBar()
|
||||
format ">> MaxScript: loadMenuFile result: %\\n" result
|
||||
) else (
|
||||
format ">> MaxScript Erro: menuMan ainda e undefined\\n"
|
||||
)
|
||||
)
|
||||
"""
|
||||
rt.execute(cmd_load)
|
||||
else:
|
||||
print(f"[X] ERRO: Arquivo {caminho_mnx} NAO existe no disco.")
|
||||
|
||||
print("="*50)
|
||||
print("FIM DO LOG DE INSTALAÇÃO")
|
||||
print("="*50 + "\n")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Erro no script de menu: {str(e)}")
|
||||
return False
|
||||
print(f"\n[EXCEPTION] Ocorreu uma falha grave:\n{str(e)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
auto_install_menu()
|
||||
carregar_menu_mnx()
|
||||
Loading…
Reference in New Issue