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