You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
3.0 KiB
Python
78 lines
3.0 KiB
Python
import os
|
|
import sys
|
|
from pymxs import runtime as rt
|
|
|
|
def log(msg):
|
|
print(f"[VR4Life Install Log] {msg}")
|
|
|
|
def install_plugin():
|
|
rt.clearListener()
|
|
log("=== INICIANDO INSTALAÇÃO BLINDADA (VR4Life) ===")
|
|
|
|
# 1. FORÇAR O REGISTRO DA PASTA NO PYTHON (Resolve Imagem 3)
|
|
user_scripts_dir = rt.getDir(rt.name("userScripts"))
|
|
plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
|
|
|
|
if plugin_dir not in sys.path:
|
|
sys.path.insert(0, plugin_dir) # Insere no topo para ter prioridade
|
|
log(f"Pasta registrada no Python: {plugin_dir}")
|
|
|
|
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
|
|
product_name = "VR4Life"
|
|
category = "Immerse Games"
|
|
macro_name = "VR4Life_Launcher"
|
|
|
|
# 2. REGISTRO DA MACRO
|
|
macro_code = f'''
|
|
macroScript {macro_name}
|
|
category:"{category}"
|
|
buttonText:"{product_name}"
|
|
( on execute do ( python.ExecuteFile @"{run_script}" ) )
|
|
'''
|
|
rt.execute(macro_code)
|
|
|
|
# 3. LÓGICA DE MENU COM ESCUDO ANTI-ERRO (Resolve Imagens 2, 4, 5)
|
|
try:
|
|
# Tenta o modo moderno do 2026 primeiro
|
|
cui_mgr = rt.cui.getContentManager()
|
|
main_menu_bar = cui_mgr.mainMenuBar
|
|
|
|
# Limpa qualquer resquício para evitar o "vai e vem"
|
|
for i in range(main_menu_bar.numItems - 1, -1, -1):
|
|
item = main_menu_bar.getItem(i)
|
|
if item.displayText in [product_name, "1-VR4Life"]:
|
|
main_menu_bar.removeItem(item)
|
|
|
|
log("Criando menu moderno...")
|
|
new_menu = cui_mgr.createCustomMenu(product_name)
|
|
new_menu.addActionItem(macro_name, category)
|
|
main_menu_bar.addItem(new_menu, -1) # Adiciona no final como solicitado
|
|
rt.execute("cui.getContentManager().updateMainMenuBar()")
|
|
|
|
except Exception as e:
|
|
# Se falhar (versões antigas), tenta o menuMan de forma segura
|
|
log("Tentando modo legado com segurança...")
|
|
try:
|
|
# Usamos hasattr para evitar que o script 'estoure' o erro de atributo
|
|
if hasattr(rt, "menuMan"):
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
existing = rt.menuMan.findMenu(product_name)
|
|
if existing: rt.menuMan.unRegisterMenu(existing)
|
|
|
|
new_menu = rt.menuMan.createMenu(product_name)
|
|
new_menu.addItem(rt.menuMan.createActionItem(macro_name, category), -1)
|
|
sub_item = rt.menuMan.createSubMenuItem(product_name, new_menu)
|
|
main_menu.addItem(sub_item, -1)
|
|
rt.menuMan.updateMenuBar()
|
|
except:
|
|
log("Aviso: Não foi possível criar o menu superior, use o 'Customize User Interface'.")
|
|
|
|
# 4. EXECUÇÃO FINAL
|
|
if os.path.exists(run_script):
|
|
log("Executando motor...")
|
|
rt.python.ExecuteFile(run_script)
|
|
|
|
log("=== INSTALAÇÃO CONCLUÍDA ===")
|
|
|
|
if __name__ == "__main__":
|
|
install_plugin() |