dadsa
parent
bb8c20be81
commit
68a58634d6
@ -1,70 +1,64 @@
|
|||||||
import os
|
import os
|
||||||
from pymxs import runtime as rt
|
from pymxs import runtime as rt
|
||||||
|
|
||||||
def install_vr4life_babylon_style():
|
def install_vr4life_clean():
|
||||||
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_script_path = os.path.join(startup_dir, "VR4Life_Loader.ms")
|
# 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
|
||||||
# 2. O SCRIPT DE CARREGAMENTO (Com Callback de Interface)
|
macro_cmd = f"""
|
||||||
# O segredo do Babylon: #filePostOpen ou #systemStartup
|
macroScript VR4Life_Launcher
|
||||||
loader_content = f"""
|
category:"Immerse Games"
|
||||||
|
tooltip:"Abrir VR4Life"
|
||||||
(
|
(
|
||||||
fn installVR4LifeMenu = (
|
on execute do python.executeFile "{plugin_dir}/run_vr4life.py"
|
||||||
-- 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 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()
|
|
||||||
return true
|
|
||||||
)
|
|
||||||
return false
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Tenta agora
|
|
||||||
installVR4LifeMenu()
|
|
||||||
|
|
||||||
-- O SEGREDO: Se falhar ou se o Max resetar, tenta de novo quando a UI estiver "viva"
|
macroScript VR4Life_Update
|
||||||
callbacks.removeScripts id:#VR4LifeMenuSetup
|
category:"Immerse Games"
|
||||||
callbacks.addScript #filePostOpen "installVR4LifeMenu()" id:#VR4LifeMenuSetup
|
tooltip:"Atualizar VR4Life"
|
||||||
callbacks.addScript #systemStartup "installVR4LifeMenu()" id:#VR4LifeMenuSetup
|
(
|
||||||
callbacks.addScript #cueConfigured "installVR4LifeMenu()" id:#VR4LifeMenuSetup
|
on execute do python.executeFile "{plugin_dir}/vr4life_updater.py"
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
# Salva o loader na pasta Startup
|
|
||||||
with open(loader_script_path, "w", encoding="utf-8") as f:
|
|
||||||
f.write(loader_content)
|
|
||||||
|
|
||||||
# 3. REGISTRAR O MACROSCRIPT
|
|
||||||
macro_cmd = (
|
|
||||||
'macroScript VR4Life_Launcher\n'
|
|
||||||
'category:"Immerse Games"\n'
|
|
||||||
'tooltip:"Abrir VR4Life"\n'
|
|
||||||
'(\n'
|
|
||||||
f' on execute do python.executeFile "{plugin_dir}/run_vr4life.py"\n'
|
|
||||||
')'
|
|
||||||
)
|
|
||||||
rt.execute(macro_cmd)
|
rt.execute(macro_cmd)
|
||||||
|
|
||||||
# Tenta disparar uma vez agora mesmo
|
# 3. CONSTRUÇÃO DO MENU (Lógica Babylon/Direct UI)
|
||||||
rt.fileIn(loader_script_path)
|
setup_script = """
|
||||||
|
(
|
||||||
print(f">> VR4Life: Loader configurado com Callbacks em {loader_script_path}")
|
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.")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Erro no estilo Babylon: {str(e)}")
|
print(f"Erro na instalacao: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
install_vr4life_babylon_style()
|
install_vr4life_clean()
|
||||||
Loading…
Reference in New Issue