main
henrique 2 months ago
parent 68a58634d6
commit d3172d1dce

@ -1,59 +1,75 @@
import os import os
from pymxs import runtime as rt from pymxs import runtime as rt
def install_vr4life_clean(): def install_vr4life_final():
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"
update_script = f"{plugin_dir}/vr4life_updater.py"
# 2. REGISTRAR AS MACROS COM AS CATEGORIAS VISTAS NO SEU PRINT # 2. REGISTRAR AS MACROS (Isso não depende da UI, então funciona direto)
# Usamos "Immerse Games" para bater com o que já existe no seu Menu Editor # Usamos 647394 como ID fixo para bater com seu arquivo .mnx
macro_cmd = f""" macro_cmd = f"""
macroScript VR4Life_Launcher macroScript VR4Life_Launcher
category:"Immerse Games" category:"Immerse Games"
internalId:647394
tooltip:"Abrir VR4Life" tooltip:"Abrir VR4Life"
( (
on execute do python.executeFile "{plugin_dir}/run_vr4life.py" on execute do python.executeFile "{run_script}"
) )
macroScript VR4Life_Update macroScript VR4Life_Update
category:"Immerse Games" category:"Immerse Games"
internalId:647394
tooltip:"Atualizar VR4Life" tooltip:"Atualizar VR4Life"
( (
on execute do python.executeFile "{plugin_dir}/vr4life_updater.py" on execute do python.executeFile "{update_script}"
) )
""" """
rt.execute(macro_cmd) rt.execute(macro_cmd)
# 3. CONSTRUÇÃO DO MENU (Lógica Babylon/Direct UI) # 3. O "ESPERADOR" (TIMER) - Resolve o erro de 'undefined'
setup_script = """ # Ele vai tentar 10 vezes, a cada 1 segundo, até o menuMan aparecer
setup_ui_ms = """
( (
local menuMgr = menuMan global _vr_timer = dotNetObject "System.Windows.Forms.Timer"
local mainMenuBar = menuMgr.getMainMenuBar() _vr_timer.interval = 1000
global _vr_tries = 0
-- Limpar se existir para não duplicar dotNet.addEventHandler _vr_timer "Tick" (fn onTick s e = (
local existingMenu = menuMgr.findMenu "VR4Life" _vr_tries += 1
if existingMenu != undefined do menuMgr.unRegisterMenu existingMenu if menuMan != undefined and menuMan.getMainMenuBar() != undefined then (
-- Se o menuMan acordou, a gente mata o erro 'undefined' aqui
-- Criar o novo menu "VR4Life" local mainBar = menuMan.getMainMenuBar()
local newMenu = menuMgr.createMenu "VR4Life" local existing = menuMan.findMenu "VR4Life"
if existing != undefined do menuMan.unRegisterMenu existing
-- Adicionar os itens usando o nome da macro e a categoria exata
local itemLauncher = menuMgr.createActionItem "VR4Life_Launcher" "Immerse Games" local vMenu = menuMan.createMenu "VR4Life"
local itemUpdate = menuMgr.createActionItem "VR4Life_Update" "Immerse Games" local item1 = menuMan.createActionItem "VR4Life_Launcher" "Immerse Games"
local item2 = menuMan.createActionItem "VR4Life_Update" "Immerse Games"
newMenu.addItem itemLauncher -1
newMenu.addItem itemUpdate -1 vMenu.addItem item1 -1
vMenu.addItem item2 -1
-- Injetar na barra principal antes do Help
local subMenuItem = menuMgr.createSubMenuItem "VR4Life" newMenu local subM = menuMan.createSubMenuItem "VR4Life" vMenu
mainMenuBar.addItem subMenuItem (mainMenuBar.numItems()) mainBar.addItem subM (mainBar.numItems())
menuMan.updateMenuBar()
menuMgr.updateMenuBar()
s.stop()
s.dispose()
format ">> VR4Life: Interface carregada com sucesso!\\n"
) else if _vr_tries > 10 do (
s.stop()
s.dispose()
format ">> VR4Life Erro: Timeout aguardando interface.\\n"
)
))
_vr_timer.start()
) )
""" """
rt.execute(setup_script) rt.execute(setup_ui_ms)
print(">> VR4Life: Menu instalado com sucesso via Script Direto.") print(">> VR4Life: Scripts registrados. Aguardando interface aparecer...")
return True return True
except Exception as e: except Exception as e:
@ -61,4 +77,4 @@ tooltip:"Atualizar VR4Life"
return False return False
if __name__ == "__main__": if __name__ == "__main__":
install_vr4life_clean() install_vr4life_final()
Loading…
Cancel
Save