dwdw
parent
681b5b2fe3
commit
0bb150da42
@ -1,55 +1,73 @@
|
||||
import os
|
||||
from pymxs import runtime as rt
|
||||
|
||||
def install_vr4life_mnx_only():
|
||||
def gerar_loader_estilo_babylon():
|
||||
try:
|
||||
# 1. PEGAR CAMINHOS
|
||||
# 1. DEFINIR CAMINHOS
|
||||
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
||||
# Pasta Startup oficial do 3ds Max
|
||||
startup_dir = rt.getDir(rt.name("userStartupScripts"))
|
||||
loader_path = os.path.join(startup_dir, "CreateVr4LifeMenus.ms")
|
||||
|
||||
# Caminho onde o instalador principal já copiou o seu MNX
|
||||
pasta_macros = rt.getDir(rt.name("userMacros"))
|
||||
pasta_enu = os.path.dirname(pasta_macros)
|
||||
caminho_mnx = os.path.join(pasta_enu, "en-US", "UI", "vr4life.mnx").replace("\\", "/")
|
||||
|
||||
# 2. REGISTRAR AS MACROS (Sem parâmetros inválidos)
|
||||
# Importante: A categoria deve ser "Immerse Games" para bater com seu MNX
|
||||
macro_cmd = f"""
|
||||
macroScript VR4Life_Launcher
|
||||
category:"Immerse Games"
|
||||
tooltip:"Abrir VR4Life"
|
||||
# 2. O CONTEÚDO DO .MS (Baseado no BabylonJS Exporters 2026)
|
||||
# Este código em MaxScript puro é o que o Max vai rodar no boot
|
||||
ms_content = f"""
|
||||
(
|
||||
on execute do python.executeFile "{plugin_dir}/run_vr4life.py"
|
||||
)
|
||||
-- Função principal para criar o menu
|
||||
fn CreateVr4LifeMenu = (
|
||||
-- No 2026, usamos a Interface Core para evitar 'undefined'
|
||||
local menuMgr = maxUtils.getMainMenuManager()
|
||||
if menuMgr == undefined do menuMgr = menuMan
|
||||
|
||||
macroScript VR4Life_Update
|
||||
category:"Immerse Games"
|
||||
tooltip:"Atualizar VR4Life"
|
||||
(
|
||||
on execute do python.executeFile "{plugin_dir}/vr4life_updater.py"
|
||||
)
|
||||
"""
|
||||
rt.execute(macro_cmd)
|
||||
|
||||
# 3. FORÇAR O CARREGAMENTO DO MNX
|
||||
# Em vez de criar o menu, mandamos o Max ler o arquivo que você copiou
|
||||
if os.path.exists(caminho_mnx):
|
||||
load_cmd = f"""
|
||||
(
|
||||
if menuMan != undefined then (
|
||||
menuMan.loadMenuFile "{caminho_mnx}"
|
||||
menuMan.updateMenuBar()
|
||||
format ">> VR4Life: Arquivo MNX carregado com sucesso.\\n"
|
||||
if menuMgr != undefined then (
|
||||
local mainMenuBar = menuMgr.getMainMenuBar()
|
||||
|
||||
-- Remove duplicados
|
||||
local existingMenu = menuMgr.findMenu "Vr4Life"
|
||||
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu
|
||||
|
||||
-- Cria o menu "Vr4Life"
|
||||
local newMenu = menuMgr.createMenu "Vr4Life"
|
||||
|
||||
-- Cria os itens (Actions) - Categoria Immerse Games conforme seu .mnx
|
||||
local actionLauncher = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games"
|
||||
local actionUpdate = menuMgr.createActionItem "VR4Life_Update" "Immerse Games"
|
||||
|
||||
newMenu.addItem actionLauncher -1
|
||||
newMenu.addItem actionUpdate -1
|
||||
|
||||
-- Adiciona à barra principal (antes do Help)
|
||||
local subMenuItem = menuMgr.createSubMenuItem "Vr4Life" newMenu
|
||||
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
||||
|
||||
menuMgr.updateMenuBar()
|
||||
format ">> VR4Life: Menu injetado com sucesso via Startup Script.\\n"
|
||||
)
|
||||
)
|
||||
"""
|
||||
rt.execute(load_cmd)
|
||||
|
||||
print(">> VR4Life: Instalacao concluida. Se o menu nao aparecer, use 'File > Reset'.")
|
||||
-- Registro das Macros (Garante que os comandos existam para o Menu)
|
||||
macroScript VR4Life_Launcher category:"Immerse Games" tooltip:"Abrir VR4Life" ( on execute do python.executeFile "{plugin_dir}/run_vr4life.py" )
|
||||
macroScript VR4Life_Update category:"Immerse Games" tooltip:"Atualizar VR4Life" ( on execute do python.executeFile "{plugin_dir}/vr4life_updater.py" )
|
||||
|
||||
-- Execução imediata e via Callback (Padrão Babylon)
|
||||
CreateVr4LifeMenu()
|
||||
callbacks.removeScripts id:#VR4LifeMenuSetup
|
||||
callbacks.addScript #filePostOpen "CreateVr4LifeMenu()" id:#VR4LifeMenuSetup
|
||||
)
|
||||
"""
|
||||
# 3. GRAVAR O ARQUIVO NO DISCO
|
||||
with open(loader_path, "w", encoding="utf-8") as f:
|
||||
f.write(ms_content)
|
||||
|
||||
# 4. EXECUTAR O ARQUIVO CRIADO AGORA
|
||||
rt.fileIn(loader_path)
|
||||
|
||||
print(f">> Sucesso: {loader_path} gerado e executado.")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"Erro na instalacao: {str(e)}")
|
||||
print(f"Erro ao gerar loader: {str(e)}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
install_vr4life_mnx_only()
|
||||
gerar_loader_estilo_babylon()
|
||||
Loading…
Reference in New Issue