aasa
parent
7dd179e366
commit
2702c584a6
@ -1,63 +1,59 @@
|
|||||||
import os
|
import os
|
||||||
from pymxs import runtime as rt
|
from pymxs import runtime as rt
|
||||||
|
|
||||||
def install_vr4life_menu_official():
|
def install_vr4life_official_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("\\", "/")
|
||||||
run_script = f"{plugin_dir}/run_vr4life.py"
|
startup_dir = rt.getDir(rt.name("userStartupScripts"))
|
||||||
|
loader_script_path = os.path.join(startup_dir, "VR4Life_Loader.ms")
|
||||||
|
|
||||||
# 2. REGISTRAR MACRO (Necessário para o botão funcionar)
|
# 2. CRIAR O SCRIPT DE CARREGAMENTO (Igual ao CreateBabylonMenus.ms)
|
||||||
|
# Este arquivo vai rodar toda vez que o Max abrir, garantindo que o menu exista
|
||||||
|
loader_content = f"""
|
||||||
|
(
|
||||||
|
fn installVR4LifeMenu = (
|
||||||
|
if menuMan != undefined then (
|
||||||
|
local mainMenuBar = menuMan.getMainMenuBar()
|
||||||
|
local existingMenu = menuMan.findMenu "VR4Life"
|
||||||
|
if existingMenu != undefined do menuMan.unRegisterMenu existingMenu
|
||||||
|
|
||||||
|
local newMenu = menuMan.createMenu "VR4Life"
|
||||||
|
local actionItem = menuMan.createActionItem "VR4Life_Launcher" "Immerse Games"
|
||||||
|
newMenu.addItem actionItem -1
|
||||||
|
|
||||||
|
local subMenuItem = menuMan.createSubMenuItem "VR4Life" newMenu
|
||||||
|
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
||||||
|
menuMan.updateMenuBar()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
installVR4LifeMenu()
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
# Escreve o arquivo na pasta Startup
|
||||||
|
with open(loader_script_path, "w", encoding="utf-8") as f:
|
||||||
|
f.write(loader_content)
|
||||||
|
|
||||||
|
# 3. REGISTRAR O MACROSCRIPT (Para o botão funcionar)
|
||||||
macro_cmd = (
|
macro_cmd = (
|
||||||
'macroScript VR4Life_Launcher\n'
|
'macroScript VR4Life_Launcher\n'
|
||||||
'category:"Immerse Games"\n'
|
'category:"Immerse Games"\n'
|
||||||
'tooltip:"Abrir VR4Life"\n'
|
'tooltip:"Abrir VR4Life"\n'
|
||||||
'(\n'
|
'(\n'
|
||||||
f' on execute do python.executeFile "{run_script}"\n'
|
f' on execute do python.executeFile "{plugin_dir}/run_vr4life.py"\n'
|
||||||
')'
|
')'
|
||||||
)
|
)
|
||||||
rt.execute(macro_cmd)
|
rt.execute(macro_cmd)
|
||||||
|
|
||||||
# 3. O SEGREDO DO BABYLON: Pegar a Interface de Menu corretamente
|
# 4. EXECUTAR AGORA (Tentar carregar o menu imediatamente)
|
||||||
setup_script = """
|
rt.fileIn(loader_script_path)
|
||||||
(
|
|
||||||
-- Em vez de menuMan direto, usamos a interface de sistema
|
print(f">> VR4Life: Loader instalado em {loader_script_path}")
|
||||||
local menuMgr = maxUtils.getMainMenuManager()
|
|
||||||
|
|
||||||
if menuMgr == undefined then (
|
|
||||||
-- Se ainda for undefined, tentamos a forma global com fallback
|
|
||||||
menuMgr = menuMan
|
|
||||||
)
|
|
||||||
|
|
||||||
if menuMgr != undefined then (
|
|
||||||
local mainMenuBar = menuMgr.getMainMenuBar()
|
|
||||||
|
|
||||||
-- Limpar duplicados
|
|
||||||
local existingMenu = menuMgr.findMenu "VR4Life"
|
|
||||||
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu
|
|
||||||
|
|
||||||
-- Criar o menu
|
|
||||||
local newMenu = menuMgr.createMenu "VR4Life"
|
|
||||||
local actionItem = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games"
|
|
||||||
newMenu.addItem actionItem -1
|
|
||||||
|
|
||||||
-- Adicionar na barra principal
|
|
||||||
local subMenuItem = menuMgr.createSubMenuItem "VR4Life" newMenu
|
|
||||||
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems())
|
|
||||||
|
|
||||||
menuMgr.updateMenuBar()
|
|
||||||
format ">> VR4Life: Menu instalado com sucesso via MainMenuManager.\\n"
|
|
||||||
) else (
|
|
||||||
format ">> VR4Life Erro: Nao foi possivel obter o Menu Manager.\\n"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
"""
|
|
||||||
rt.execute(setup_script)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Erro na instalacao: {str(e)}")
|
print(f"Erro no estilo Babylon: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
install_vr4life_menu_official()
|
install_vr4life_official_style()
|
||||||
Loading…
Reference in New Issue