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.
63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
import os
|
|
import sys
|
|
from pymxs import runtime as rt
|
|
|
|
def install_plugin():
|
|
# Define os caminhos locais onde o instalador baixou os arquivos
|
|
user_scripts_dir = rt.getDir(rt.name("userScripts"))
|
|
plugin_dir = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
|
|
|
|
# Adiciona a pasta ao PATH do Python para evitar erros de 'ModuleNotFoundError'
|
|
if plugin_dir not in sys.path:
|
|
sys.path.append(plugin_dir)
|
|
|
|
run_script = os.path.join(plugin_dir, "run_vr4life.py").replace("\\", "/")
|
|
|
|
# 1. Registro de MacroScript (Funciona em TODAS as versões)
|
|
# Permite que o usuário crie botões em qualquer barra de ferramentas (Toolbar)
|
|
macro_name = "Zombisco_Launcher"
|
|
category = "Immerse Games"
|
|
|
|
macro_code = f'''
|
|
macroScript {macro_name}
|
|
category:"{category}"
|
|
buttonText:"Zombisco VR"
|
|
tooltip:"Abrir Painel Zombisco"
|
|
(
|
|
on execute do (
|
|
python.ExecuteFile @"{run_script}"
|
|
)
|
|
)
|
|
'''
|
|
rt.execute(macro_code)
|
|
|
|
# 2. Tentativa de criação de Menu (Legacy vs Modern CUI)
|
|
try:
|
|
# Tenta o método antigo (3ds Max 2024 e anteriores)
|
|
main_menu = rt.menuMan.getMainMenuBar()
|
|
menu_name = "Immerse Games"
|
|
|
|
# Limpa menu anterior se existir
|
|
existing_menu = rt.menuMan.findMenu(menu_name)
|
|
if existing_menu:
|
|
rt.menuMan.unRegisterMenu(existing_menu)
|
|
|
|
new_menu = rt.menuMan.createMenu(menu_name)
|
|
menu_item = rt.menuMan.createActionItem(macro_name, category)
|
|
new_menu.addItem(menu_item, -1)
|
|
|
|
sub_menu_item = rt.menuMan.createSubMenuItem(menu_name, new_menu)
|
|
main_menu.addItem(sub_menu_item, -1)
|
|
rt.menuMan.updateMenuBar()
|
|
|
|
except AttributeError:
|
|
# Detectado 3ds Max 2025 ou 2026 (menuMan não existe)
|
|
# Nestas versões, o usuário deve adicionar o botão manualmente via 'Customize User Interface'
|
|
# ou o script pode abrir a ferramenta automaticamente na primeira vez.
|
|
if os.path.exists(run_script):
|
|
rt.python.ExecuteFile(run_script)
|
|
|
|
rt.messageBox("Instalação concluída!\n\nNo 3ds Max 2025/2026, adicione o botão 'Zombisco' através do menu 'Customize > Hotkey Editor' procurando pela categoria 'Immerse Games'.", title="Immerse Games")
|
|
|
|
if __name__ == "__main__":
|
|
install_plugin() |