-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making it easier to get to know the project (#725)
- Loading branch information
1 parent
fbec0fe
commit 70ba56d
Showing
11 changed files
with
58 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,58 @@ | ||
import tkinter as tk | ||
import os | ||
import subprocess | ||
import winreg | ||
from tkinter import filedialog as tkFileDialog | ||
from pathlib import Path | ||
import zipfile | ||
import ctypes | ||
import sys | ||
|
||
def set_env_var(name, value): | ||
try: | ||
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Environment', 0, winreg.KEY_ALL_ACCESS) | ||
except WindowsError: | ||
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, 'Environment') | ||
winreg.SetValueEx(key, name, 0, winreg.REG_SZ, str(value)) | ||
winreg.CloseKey(key) | ||
|
||
def main(): | ||
if not ctypes.windll.shell32.IsUserAnAdmin(): | ||
print('Allow the launch as an administrator!') | ||
return ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1) | ||
|
||
git_repo_root = Path.cwd() | ||
if git_repo_root.parts[-1] == 'contrib': | ||
git_repo_root = git_repo_root.parent | ||
|
||
select = tkFileDialog.askopenfilename( | ||
title='Select the executable file from the GTA:SA installation directory', | ||
filetypes=[("GTA:SA", ".exe")], initialdir=os.environ['GTA_SA_DIR'] if 'GTA_SA_DIR' in os.environ else '' | ||
) | ||
if not select: | ||
return input('You have not selected a file, we are leaving. Press Enter...') | ||
|
||
gta_sa_file = Path(select) | ||
gta_root_dir = gta_sa_file.parent.resolve() | ||
|
||
gta_root_dir = Path(tkFileDialog.askdirectory( | ||
title='Select GTA:SA install directory' | ||
)) | ||
gta_scripts_dir = gta_root_dir / 'scripts' | ||
|
||
# Unpack zip into gta dir | ||
print("Unpacking `plugins.zip` into GTA:SA root directory...") | ||
with zipfile.ZipFile(git_repo_root / 'contrib' / 'plugins.zip') as plugins_zip: | ||
plugins_zip.extractall(gta_root_dir) | ||
|
||
# Create symlinks | ||
config_name = input("Choose configuration to link (debug/release, default: debug): ") or 'debug' | ||
print(f"Creating the symlinks for `{config_name}` configuration...") | ||
config_bin_dir = git_repo_root / 'bin' / Path(config_name) | ||
print(f'{config_bin_dir=}') | ||
for filename in ('gta_reversed.pdb', 'gta_reversed.asi',): | ||
dst = gta_scripts_dir / filename | ||
for filename in ('gta_reversed.pdb', 'gta_reversed.asi'): | ||
dst = gta_root_dir / 'scripts' / filename | ||
dst.unlink(missing_ok=True) # Delete symlink if it already exists | ||
# This fails [WinError 1314] if the script isn't run with admin rights [softlinks require it] | ||
# To run as admin just open an admin cmd, and type `python ./install.py` in the repo root dir | ||
os.symlink(config_bin_dir / filename, dst) | ||
|
||
print('Done!') | ||
print("The Env variables are changing... If VS is open with the Modern solution, restart VS") | ||
set_env_var('GTA_SA_EXE', gta_sa_file) | ||
set_env_var('GTA_SA_DIR', gta_root_dir) | ||
input('Done! Press Enter...') | ||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters