Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scripts which allow enabling filepatching #93

Merged
merged 3 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_Marker"

[hemtt.launch.default]
workshop = [
"450814997", # CBA_A3's Workshop ID
]
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@
},
"search.exclude": {
"**/venv": true,
".hemttout/dev": true,
".hemttout/build": true,
".hemttout/release": true,
},
"explorer.autoRevealExclude": {
"**/venv": true
"**/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"
##########################

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)