dwdw
parent
0bb150da42
commit
9aa3acc3b4
@ -1,73 +1,73 @@
|
|||||||
import os
|
import os
|
||||||
from pymxs import runtime as rt
|
from pymxs import runtime as rt
|
||||||
|
|
||||||
def gerar_loader_estilo_babylon():
|
def install_vr4life_babylon_final():
|
||||||
try:
|
try:
|
||||||
# 1. DEFINIR CAMINHOS
|
# 1. DEFINIR CAMINHOS
|
||||||
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
||||||
# Pasta Startup oficial do 3ds Max
|
|
||||||
startup_dir = rt.getDir(rt.name("userStartupScripts"))
|
startup_dir = rt.getDir(rt.name("userStartupScripts"))
|
||||||
loader_path = os.path.join(startup_dir, "CreateVr4LifeMenus.ms")
|
loader_path = os.path.join(startup_dir, "CreateVr4LifeMenus.ms")
|
||||||
|
|
||||||
# 2. O CONTEÚDO DO .MS (Baseado no BabylonJS Exporters 2026)
|
# 2. O CONTEÚDO DO SCRIPT (Fiel ao repositório BabylonJS 2026)
|
||||||
# Este código em MaxScript puro é o que o Max vai rodar no boot
|
# O segredo do 2026: usar interfaces dinâmicas e registrar no CUI
|
||||||
ms_content = f"""
|
ms_content = f"""
|
||||||
(
|
(
|
||||||
-- Função principal para criar o menu
|
-- Função principal de criação (Abordagem Babylon)
|
||||||
fn CreateVr4LifeMenu = (
|
fn CreateVr4LifeMenu = (
|
||||||
-- No 2026, usamos a Interface Core para evitar 'undefined'
|
|
||||||
local menuMgr = maxUtils.getMainMenuManager()
|
local menuMgr = maxUtils.getMainMenuManager()
|
||||||
if menuMgr == undefined do menuMgr = menuMan
|
if menuMgr == undefined do menuMgr = menuMan
|
||||||
|
|
||||||
if menuMgr != undefined then (
|
if menuMgr != undefined then (
|
||||||
local mainMenuBar = menuMgr.getMainMenuBar()
|
local mainMenuBar = menuMgr.getMainMenuBar()
|
||||||
|
|
||||||
-- Remove duplicados
|
-- Remove duplicados para evitar poluição
|
||||||
local existingMenu = menuMgr.findMenu "Vr4Life"
|
local existingMenu = menuMgr.findMenu "Vr4Life"
|
||||||
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu
|
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu
|
||||||
|
|
||||||
-- Cria o menu "Vr4Life"
|
-- Cria o menu "Vr4Life"
|
||||||
local newMenu = menuMgr.createMenu "Vr4Life"
|
local newMenu = menuMgr.createMenu "Vr4Life"
|
||||||
|
|
||||||
-- Cria os itens (Actions) - Categoria Immerse Games conforme seu .mnx
|
-- Cria os itens (Actions) - Usando a categoria Immerse Games do seu MNX
|
||||||
local actionLauncher = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games"
|
local actionLauncher = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games"
|
||||||
local actionUpdate = menuMgr.createActionItem "VR4Life_Update" "Immerse Games"
|
local actionUpdate = menuMgr.createActionItem "VR4Life_Update" "Immerse Games"
|
||||||
|
|
||||||
newMenu.addItem actionLauncher -1
|
newMenu.addItem actionLauncher -1
|
||||||
newMenu.addItem actionUpdate -1
|
newMenu.addItem actionUpdate -1
|
||||||
|
|
||||||
-- Adiciona à barra principal (antes do Help)
|
-- Adiciona à barra principal (Posição final)
|
||||||
local subMenuItem = menuMgr.createSubMenuItem "Vr4Life" newMenu
|
local subMenuItem = menuMgr.createSubMenuItem "Vr4Life" newMenu
|
||||||
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
||||||
|
|
||||||
menuMgr.updateMenuBar()
|
menuMgr.updateMenuBar()
|
||||||
format ">> VR4Life: Menu injetado com sucesso via Startup Script.\\n"
|
format ">> VR4Life: Menu injetado via %\\n" (getSourceFileName())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Registro das Macros (Garante que os comandos existam para o Menu)
|
-- Registro das Macros (O motor por trás dos botões)
|
||||||
macroScript VR4Life_Launcher category:"Immerse Games" tooltip:"Abrir VR4Life" ( on execute do python.executeFile "{plugin_dir}/run_vr4life.py" )
|
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" )
|
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)
|
-- Gatilhos de execução (O Babylon usa múltiplos para garantir)
|
||||||
CreateVr4LifeMenu()
|
CreateVr4LifeMenu()
|
||||||
callbacks.removeScripts id:#VR4LifeMenuSetup
|
callbacks.removeScripts id:#VR4LifeMenuSetup
|
||||||
|
callbacks.addScript #cuiRegisterMenus "CreateVr4LifeMenu()" id:#VR4LifeMenuSetup
|
||||||
callbacks.addScript #filePostOpen "CreateVr4LifeMenu()" id:#VR4LifeMenuSetup
|
callbacks.addScript #filePostOpen "CreateVr4LifeMenu()" id:#VR4LifeMenuSetup
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
# 3. GRAVAR O ARQUIVO NO DISCO
|
# 3. GRAVAR O ARQUIVO NO DISCO (Persistência estilo Babylon)
|
||||||
with open(loader_path, "w", encoding="utf-8") as f:
|
with open(loader_path, "w", encoding="utf-8") as f:
|
||||||
f.write(ms_content)
|
f.write(ms_content)
|
||||||
|
|
||||||
# 4. EXECUTAR O ARQUIVO CRIADO AGORA
|
# 4. EXECUTAR O ARQUIVO CRIADO
|
||||||
rt.fileIn(loader_path)
|
rt.fileIn(loader_path)
|
||||||
|
|
||||||
print(f">> Sucesso: {loader_path} gerado e executado.")
|
print(f">> Arquivo gerado em: {loader_path}")
|
||||||
|
print(">> Se o menu não aparecer agora, ele aparecerá ao abrir qualquer arquivo ou reiniciar.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Erro ao gerar loader: {str(e)}")
|
print(f"Erro na instalação: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
gerar_loader_estilo_babylon()
|
install_vr4life_babylon_final()
|
||||||
Loading…
Reference in New Issue