|
|
|
@ -1,68 +1,50 @@
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
|
|
|
|
|
|
|
|
def install_vr4life_babylon_style():
|
|
|
|
def install_vr4life_mnx_only():
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# 1. PEGAR CAMINHOS
|
|
|
|
# 1. PEGAR CAMINHOS
|
|
|
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
|
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
|
|
startup_dir = rt.getDir(rt.name("userStartupScripts"))
|
|
|
|
|
|
|
|
loader_ms = os.path.join(startup_dir, "VR4Life_Menu_Loader.ms")
|
|
|
|
# Caminho onde o instalador principal já copiou o seu MNX
|
|
|
|
|
|
|
|
pasta_macros = rt.getDir(rt.name("userMacros"))
|
|
|
|
# 2. CRIAR O SCRIPT DE INICIALIZAÇÃO (O "Segredo" do Babylon)
|
|
|
|
pasta_enu = os.path.dirname(pasta_macros)
|
|
|
|
# Este arquivo ficará na pasta Startup e rodará sempre que o Max abrir
|
|
|
|
caminho_mnx = os.path.join(pasta_enu, "en-US", "UI", "vr4life.mnx").replace("\\", "/")
|
|
|
|
ms_code = f"""
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
fn setupVR4LifeMenu = (
|
|
|
|
|
|
|
|
if menuMan != undefined and menuMan.getMainMenuBar() != undefined then (
|
|
|
|
|
|
|
|
local mainBar = menuMan.getMainMenuBar()
|
|
|
|
|
|
|
|
local existing = menuMan.findMenu "VR4Life"
|
|
|
|
|
|
|
|
if existing != undefined do menuMan.unRegisterMenu existing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local vMenu = menuMan.createMenu "VR4Life"
|
|
|
|
|
|
|
|
-- Usamos os IDs e Nomes que estao no seu arquivo .mnx
|
|
|
|
|
|
|
|
local item1 = menuMan.createActionItem "VR4Life_Launcher" "Immerse Games"
|
|
|
|
|
|
|
|
local item2 = menuMan.createActionItem "VR4Life_Update" "Immerse Games"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vMenu.addItem item1 -1
|
|
|
|
|
|
|
|
vMenu.addItem item2 -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local subM = menuMan.createSubMenuItem "VR4Life" vMenu
|
|
|
|
|
|
|
|
mainBar.addItem subM (mainBar.numItems())
|
|
|
|
|
|
|
|
menuMan.updateMenuBar()
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
-- Tenta executar agora e deixa um gatilho para o startup
|
|
|
|
|
|
|
|
setupVR4LifeMenu()
|
|
|
|
|
|
|
|
callbacks.addScript #systemStartup "setupVR4LifeMenu()" id:#VR4LifeMenu
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
with open(loader_ms, "w", encoding="utf-8") as f:
|
|
|
|
|
|
|
|
f.write(ms_code)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 3. REGISTRAR AS MACROS (Para os botões funcionarem)
|
|
|
|
# 2. REGISTRAR AS MACROS (Sem parâmetros inválidos)
|
|
|
|
|
|
|
|
# Importante: A categoria deve ser "Immerse Games" para bater com seu MNX
|
|
|
|
macro_cmd = f"""
|
|
|
|
macro_cmd = f"""
|
|
|
|
macroScript VR4Life_Launcher
|
|
|
|
macroScript VR4Life_Launcher
|
|
|
|
category:"Immerse Games"
|
|
|
|
category:"Immerse Games"
|
|
|
|
internalId:647394
|
|
|
|
tooltip:"Abrir VR4Life"
|
|
|
|
(
|
|
|
|
(
|
|
|
|
on execute do python.executeFile "{plugin_dir}/run_vr4life.py"
|
|
|
|
on execute do python.executeFile "{plugin_dir}/run_vr4life.py"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
macroScript VR4Life_Update
|
|
|
|
macroScript VR4Life_Update
|
|
|
|
category:"Immerse Games"
|
|
|
|
category:"Immerse Games"
|
|
|
|
internalId:647394
|
|
|
|
tooltip:"Atualizar VR4Life"
|
|
|
|
(
|
|
|
|
(
|
|
|
|
on execute do python.executeFile "{plugin_dir}/vr4life_updater.py"
|
|
|
|
on execute do python.executeFile "{plugin_dir}/vr4life_updater.py"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
rt.execute(macro_cmd)
|
|
|
|
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"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
rt.execute(load_cmd)
|
|
|
|
|
|
|
|
|
|
|
|
# Executa o loader agora mesmo para tentar criar o menu sem reiniciar
|
|
|
|
print(">> VR4Life: Instalacao concluida. Se o menu nao aparecer, use 'File > Reset'.")
|
|
|
|
rt.fileIn(loader_ms)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f">> VR4Life: Loader criado em {loader_ms}. Verifique o menu no topo.")
|
|
|
|
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
@ -70,4 +52,4 @@ internalId:647394
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
install_vr4life_babylon_style()
|
|
|
|
install_vr4life_mnx_only()
|