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.

58 lines
2.1 KiB
Python

import os
import urllib.request
from pymxs import runtime as rt
# ==========================================
# CONFIGURAÇÕES DO GITEA - IMMERSE GAMES
# ==========================================
GITEA_RAW_URL = "https://git.immersegame.com/immersegame/vr4life-3dmax-plugin/raw/branch/main/"
GITEA_TOKEN = "efebcde14ce96a2b80d0b3f207991bc155018ab8"
# Descobre a pasta segura de Scripts do Usuário do próprio 3ds Max
user_scripts_dir = rt.getDir(rt.name("userScripts"))
PLUGIN_DIR = os.path.join(user_scripts_dir, "VR4Life_Plugin").replace("\\", "/")
FILES_TO_DOWNLOAD = [
"vr4life_ui.py",
"vr4life_engine.py",
"vr4life_cloud.py",
"run_vr4life.py",
"vr4life_updater.py",
"install_vr4life.py",
"version.txt"
]
def install_from_cloud():
rt.clearListener()
print("=== INICIANDO INSTALAÇÃO ONLINE VR4LIFE ===")
if not os.path.exists(PLUGIN_DIR):
os.makedirs(PLUGIN_DIR)
try:
for file_name in FILES_TO_DOWNLOAD:
remote_url = GITEA_RAW_URL + file_name
local_path = os.path.join(PLUGIN_DIR, file_name).replace("\\", "/")
print(f"Baixando: {file_name}...")
req = urllib.request.Request(remote_url)
req.add_header("Authorization", f"token {GITEA_TOKEN}")
response = urllib.request.urlopen(req)
remote_code = response.read().decode('utf-8')
with open(local_path, "w", encoding="utf-8") as f:
f.write(remote_code)
print("Download concluído! Configurando menu do 3ds Max...")
install_script = os.path.join(PLUGIN_DIR, "install_vr4life.py").replace("\\", "/")
rt.python.ExecuteFile(install_script)
except Exception as e:
msg = f"Erro ao baixar os arquivos do Gitea.\nVerifique a internet, URL ou o Token de acesso.\n\nDetalhe técnico: {str(e)}"
rt.messageBox(msg, title="Erro de Instalação")
print(msg)
if __name__ == "__main__":
install_from_cloud()