Skip to content

Commit

Permalink
Fix scripts which allow enabling filepatching (#13)
Browse files Browse the repository at this point in the history
Add script to create links to the addons needed for file patching
  • Loading branch information
Timi007 authored Dec 30, 2023
1 parent 5dd25e9 commit 75854fd
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 128 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
release/*
*.cache
*.pbo
texHeaders.bin
Expand All @@ -9,10 +8,11 @@ Thumbs.db
*.sqfc
*.exe

## Added by HEMTT
#### HEMTT
hemtt
hemtt.exe
releases/*
keys/*
release/
releases/
keys/
.hemttout/
####
5 changes: 5 additions & 0 deletions .hemtt/project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ preset = "Hemtt"

[hemtt.release]
folder = "Metis_Presentation"

[hemtt.launch.default]
workshop = [
"450814997", # CBA_A3's Workshop ID
]
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"**/*.exe": true,
"**/keys": true,
"**/release": true,
"**/__pycache__": true,
},
"files.associations": {
"**/*.hpp": "ext",
Expand All @@ -21,10 +20,14 @@
"init*.hpp": "sqf",
},
"search.exclude": {
"**/venv": true,
".hemttout/dev": true,
".hemttout/build": true,
".hemttout/release": true,
},
"explorer.autoRevealExclude": {
"**/venv": true
".hemttout/dev": true,
".hemttout/build": true,
".hemttout/release": true,
},
"sqf.enableACE3": false,
"sqf.enableCBA": true,
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"detail": "Build Arma addon with HEMTT in debug mode.",
"type": "process",
"command": "hemtt",
"args": ["build"],
"args": ["dev"],
"group": "build",
"presentation": {
"close": true,
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off
hemtt build
hemtt dev
pause
119 changes: 0 additions & 119 deletions tools/setup.py

This file was deleted.

94 changes: 94 additions & 0 deletions tools/setup_filepatching_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python3

########################
# Metis Setup Script #
########################

import os
import sys
import winreg
import _winapi

######## GLOBALS #########
MAINDIR = "z"
PROJECTDIR = "mts_presentation"
##########################

def main():
FULLDIR = f"{MAINDIR}\\{PROJECTDIR}"
print(f"""
#######################################
# Metis Development Environment Setup #
#######################################
This script will create your Metis dev environment for you.
Before you run this, you should already have:
- The Arma 3 Tools installed properly via Steam
- A properly set up P-drive
If you have not done those things yet, please abort this script in the next step and do so first.
This script will create two hard links on your system, both pointing to your Metis project folder:
[Arma 3 installation directory]\\{FULLDIR} => Metis project HEMTT dev build folder
P:\\{FULLDIR} => Metis project HEMTT dev build folder""")
print("\n")

try:
reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
key = winreg.OpenKey(reg, r"SOFTWARE\Wow6432Node\bohemia interactive\arma 3")
armapath = winreg.EnumValue(key,1)[1]
except:
print("Failed to determine Arma 3 Path.")
return 2

if not os.path.exists("P:\\"):
print("No P-drive detected.")
return 3

scriptpath = os.path.realpath(__file__)
projectpath = os.path.dirname(os.path.dirname(scriptpath))
devpath = os.path.join(projectpath, '.hemttout', 'dev')

print("# Detected Paths:")
print(f" Arma path: {armapath}")
print(f" Project path: {projectpath}")
print(f" HEMTT dev build path: {devpath}")

repl = input("\nAre these correct? (y/n): ")
if repl.lower() != "y":
return 4

print("\n# Creating links ...")
try:
os.makedirs(devpath, exist_ok=True)

if not os.path.exists(os.path.join("P:", MAINDIR, PROJECTDIR)):
os.makedirs(os.path.join("P:", MAINDIR), exist_ok=True)
_winapi.CreateJunction(devpath, os.path.join("P:", MAINDIR, PROJECTDIR))
else:
print("Link on P: already exists. Skipping it.")

if not os.path.exists(os.path.join(armapath, MAINDIR, PROJECTDIR)):
os.makedirs(os.path.join(armapath, MAINDIR), exist_ok=True)
_winapi.CreateJunction(devpath, os.path.join(armapath, MAINDIR, PROJECTDIR))
else:
print("Link in Arma directory already exists. Skipping it.")
except:
print("Something went wrong during the link creation. Please finish the setup manually.")
raise

print("# Links created successfully.")

return 0


if __name__ == "__main__":
exitcode = main()

if exitcode > 0:
print("\nSomething went wrong during the setup. If these issues persist, please follow the instructions on the Metis wiki to perform the setup manually.")
else:
print("\nSetup successfully completed.")

sys.exit(exitcode)

0 comments on commit 75854fd

Please sign in to comment.