|
|
|
@ -1,19 +1,20 @@
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
from pymxs import runtime as rt
|
|
|
|
|
|
|
|
|
|
|
|
def install_vr4life_official_style():
|
|
|
|
def install_vr4life_babylon_style():
|
|
|
|
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"))
|
|
|
|
startup_dir = rt.getDir(rt.name("userStartupScripts"))
|
|
|
|
loader_script_path = os.path.join(startup_dir, "VR4Life_Loader.ms")
|
|
|
|
loader_script_path = os.path.join(startup_dir, "VR4Life_Loader.ms")
|
|
|
|
|
|
|
|
|
|
|
|
# 2. CRIAR O SCRIPT DE CARREGAMENTO (Igual ao CreateBabylonMenus.ms)
|
|
|
|
# 2. O SCRIPT DE CARREGAMENTO (Com Callback de Interface)
|
|
|
|
# Este arquivo vai rodar toda vez que o Max abrir, garantindo que o menu exista
|
|
|
|
# O segredo do Babylon: #filePostOpen ou #systemStartup
|
|
|
|
loader_content = f"""
|
|
|
|
loader_content = f"""
|
|
|
|
(
|
|
|
|
(
|
|
|
|
fn installVR4LifeMenu = (
|
|
|
|
fn installVR4LifeMenu = (
|
|
|
|
if menuMan != undefined then (
|
|
|
|
-- Verifica se o menuMan existe E se a barra principal está pronta
|
|
|
|
|
|
|
|
if menuMan != undefined and menuMan.getMainMenuBar() != undefined then (
|
|
|
|
local mainMenuBar = menuMan.getMainMenuBar()
|
|
|
|
local mainMenuBar = menuMan.getMainMenuBar()
|
|
|
|
local existingMenu = menuMan.findMenu "VR4Life"
|
|
|
|
local existingMenu = menuMan.findMenu "VR4Life"
|
|
|
|
if existingMenu != undefined do menuMan.unRegisterMenu existingMenu
|
|
|
|
if existingMenu != undefined do menuMan.unRegisterMenu existingMenu
|
|
|
|
@ -25,16 +26,26 @@ def install_vr4life_official_style():
|
|
|
|
local subMenuItem = menuMan.createSubMenuItem "VR4Life" newMenu
|
|
|
|
local subMenuItem = menuMan.createSubMenuItem "VR4Life" newMenu
|
|
|
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
|
|
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
|
|
|
menuMan.updateMenuBar()
|
|
|
|
menuMan.updateMenuBar()
|
|
|
|
|
|
|
|
return true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
return false
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Tenta agora
|
|
|
|
installVR4LifeMenu()
|
|
|
|
installVR4LifeMenu()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- O SEGREDO: Se falhar ou se o Max resetar, tenta de novo quando a UI estiver "viva"
|
|
|
|
|
|
|
|
callbacks.removeScripts id:#VR4LifeMenuSetup
|
|
|
|
|
|
|
|
callbacks.addScript #filePostOpen "installVR4LifeMenu()" id:#VR4LifeMenuSetup
|
|
|
|
|
|
|
|
callbacks.addScript #systemStartup "installVR4LifeMenu()" id:#VR4LifeMenuSetup
|
|
|
|
|
|
|
|
callbacks.addScript #cueConfigured "installVR4LifeMenu()" id:#VR4LifeMenuSetup
|
|
|
|
)
|
|
|
|
)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# Escreve o arquivo na pasta Startup
|
|
|
|
# Salva o loader na pasta Startup
|
|
|
|
with open(loader_script_path, "w", encoding="utf-8") as f:
|
|
|
|
with open(loader_script_path, "w", encoding="utf-8") as f:
|
|
|
|
f.write(loader_content)
|
|
|
|
f.write(loader_content)
|
|
|
|
|
|
|
|
|
|
|
|
# 3. REGISTRAR O MACROSCRIPT (Para o botão funcionar)
|
|
|
|
# 3. REGISTRAR O MACROSCRIPT
|
|
|
|
macro_cmd = (
|
|
|
|
macro_cmd = (
|
|
|
|
'macroScript VR4Life_Launcher\n'
|
|
|
|
'macroScript VR4Life_Launcher\n'
|
|
|
|
'category:"Immerse Games"\n'
|
|
|
|
'category:"Immerse Games"\n'
|
|
|
|
@ -45,10 +56,10 @@ def install_vr4life_official_style():
|
|
|
|
)
|
|
|
|
)
|
|
|
|
rt.execute(macro_cmd)
|
|
|
|
rt.execute(macro_cmd)
|
|
|
|
|
|
|
|
|
|
|
|
# 4. EXECUTAR AGORA (Tentar carregar o menu imediatamente)
|
|
|
|
# Tenta disparar uma vez agora mesmo
|
|
|
|
rt.fileIn(loader_script_path)
|
|
|
|
rt.fileIn(loader_script_path)
|
|
|
|
|
|
|
|
|
|
|
|
print(f">> VR4Life: Loader instalado em {loader_script_path}")
|
|
|
|
print(f">> VR4Life: Loader configurado com Callbacks em {loader_script_path}")
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
@ -56,4 +67,4 @@ def install_vr4life_official_style():
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
install_vr4life_official_style()
|
|
|
|
install_vr4life_babylon_style()
|