|
|
|
|
@ -1,59 +1,68 @@
|
|
|
|
|
import os
|
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
|
|
|
|
|
|
def install_vr4life_clean():
|
|
|
|
|
def install_vr4life_babylon_style():
|
|
|
|
|
try:
|
|
|
|
|
# 1. PEGAR CAMINHOS
|
|
|
|
|
plugin_dir = os.path.dirname(os.path.realpath(__file__)).replace("\\", "/")
|
|
|
|
|
|
|
|
|
|
# 2. REGISTRAR AS MACROS COM AS CATEGORIAS VISTAS NO SEU PRINT
|
|
|
|
|
# Usamos "Immerse Games" para bater com o que já existe no seu Menu Editor
|
|
|
|
|
startup_dir = rt.getDir(rt.name("userStartupScripts"))
|
|
|
|
|
loader_ms = os.path.join(startup_dir, "VR4Life_Menu_Loader.ms")
|
|
|
|
|
|
|
|
|
|
# 2. CRIAR O SCRIPT DE INICIALIZAÇÃO (O "Segredo" do Babylon)
|
|
|
|
|
# Este arquivo ficará na pasta Startup e rodará sempre que o Max abrir
|
|
|
|
|
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)
|
|
|
|
|
macro_cmd = f"""
|
|
|
|
|
macroScript VR4Life_Launcher
|
|
|
|
|
category:"Immerse Games"
|
|
|
|
|
tooltip:"Abrir VR4Life"
|
|
|
|
|
internalId:647394
|
|
|
|
|
(
|
|
|
|
|
on execute do python.executeFile "{plugin_dir}/run_vr4life.py"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
macroScript VR4Life_Update
|
|
|
|
|
category:"Immerse Games"
|
|
|
|
|
tooltip:"Atualizar VR4Life"
|
|
|
|
|
internalId:647394
|
|
|
|
|
(
|
|
|
|
|
on execute do python.executeFile "{plugin_dir}/vr4life_updater.py"
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
rt.execute(macro_cmd)
|
|
|
|
|
|
|
|
|
|
# 3. CONSTRUÇÃO DO MENU (Lógica Babylon/Direct UI)
|
|
|
|
|
setup_script = """
|
|
|
|
|
(
|
|
|
|
|
local menuMgr = menuMan
|
|
|
|
|
local mainMenuBar = menuMgr.getMainMenuBar()
|
|
|
|
|
|
|
|
|
|
-- Limpar se já existir para não duplicar
|
|
|
|
|
local existingMenu = menuMgr.findMenu "VR4Life"
|
|
|
|
|
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu
|
|
|
|
|
|
|
|
|
|
-- Criar o novo menu "VR4Life"
|
|
|
|
|
local newMenu = menuMgr.createMenu "VR4Life"
|
|
|
|
|
|
|
|
|
|
-- Adicionar os itens usando o nome da macro e a categoria exata
|
|
|
|
|
local itemLauncher = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games"
|
|
|
|
|
local itemUpdate = menuMgr.createActionItem "VR4Life_Update" "Immerse Games"
|
|
|
|
|
|
|
|
|
|
newMenu.addItem itemLauncher -1
|
|
|
|
|
newMenu.addItem itemUpdate -1
|
|
|
|
|
|
|
|
|
|
-- Injetar na barra principal antes do Help
|
|
|
|
|
local subMenuItem = menuMgr.createSubMenuItem "VR4Life" newMenu
|
|
|
|
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
|
|
|
|
|
|
|
|
|
menuMgr.updateMenuBar()
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
rt.execute(setup_script)
|
|
|
|
|
print(">> VR4Life: Menu instalado com sucesso via Script Direto.")
|
|
|
|
|
|
|
|
|
|
# Executa o loader agora mesmo para tentar criar o menu sem reiniciar
|
|
|
|
|
rt.fileIn(loader_ms)
|
|
|
|
|
|
|
|
|
|
print(f">> VR4Life: Loader criado em {loader_ms}. Verifique o menu no topo.")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
@ -61,4 +70,4 @@ tooltip:"Atualizar VR4Life"
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
install_vr4life_clean()
|
|
|
|
|
install_vr4life_babylon_style()
|