forked from gta-reversed/gta-reversed-modern
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
253 changed files
with
6,436 additions
and
2,411 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
[submodule "libs/vorbis"] | ||
path = libs/vorbis | ||
url = https://github.com/xiph/vorbis | ||
url = https://github.com/xiph/vorbis.git | ||
[submodule "libs/ogg"] | ||
path = libs/ogg | ||
url = https://github.com/xiph/ogg | ||
url = https://github.com/xiph/ogg.git | ||
[submodule "libs/imgui"] | ||
path = libs/imgui | ||
url = ../../ocornut/imgui.git | ||
url = https://github.com/ocornut/imgui.git | ||
branch = docking | ||
[submodule "libs/spdlog"] | ||
path = libs/spdlog | ||
url = https://github.com/gabime/spdlog.git | ||
[submodule "libs/tracy"] | ||
path = libs/tracy | ||
url = https://github.com/wolfpld/tracy.git | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
""" | ||
Python script to format garbage RwRenderStateSet calls to be nice | ||
Make sure to copy the garbage looking code to the clipboard, then run the program | ||
And the output will be set on the clipboard. | ||
When pasting to VS make sure to press CTRL Z once, because it automatically gets formatted incorrectly | ||
""" | ||
|
||
import pyperclip as pyc # If the program fails here, please run `pip install pyperclip` | ||
from typing import Type | ||
import re | ||
from enum import Enum | ||
|
||
def cint(val : str): # C-style int | ||
return int(val.rstrip('u')) | ||
|
||
def cenum(enum_type : Type[Enum]): # enum cast | ||
return lambda val: enum_type(cint(val)).name | ||
|
||
def cbool(val : str): # c-style capitalized bool [TRUE, FALSE] | ||
return str(bool(val)).upper() | ||
|
||
# | ||
# RW renderstate enums | ||
# | ||
|
||
class RwTextureAddressMode(Enum): | ||
rwTEXTUREADDRESSNATEXTUREADDRESS = 0 | ||
rwTEXTUREADDRESSWRAP = 1 | ||
rwTEXTUREADDRESSMIRROR = 2 | ||
rwTEXTUREADDRESSCLAMP = 3 | ||
rwTEXTUREADDRESSBORDER = 4 | ||
|
||
class RwBlendFunction(Enum): | ||
rwBLENDNABLEND = 0 | ||
rwBLENDZERO = 1 | ||
rwBLENDONE = 2 | ||
rwBLENDSRCCOLOR = 3 | ||
rwBLENDINVSRCCOLOR = 4 | ||
rwBLENDSRCALPHA = 5 | ||
rwBLENDINVSRCALPHA = 6 | ||
rwBLENDDESTALPHA = 7 | ||
rwBLENDINVDESTALPHA = 8 | ||
rwBLENDDESTCOLOR = 9 | ||
rwBLENDINVDESTCOLOR = 10 | ||
rwBLENDSRCALPHASAT = 11 | ||
|
||
class RwAlphaTestFunction(Enum): | ||
rwALPHATESTFUNCTIONNAALPHATESTFUNCTION = 0 | ||
rwALPHATESTFUNCTIONNEVER = 1 | ||
rwALPHATESTFUNCTIONLESS = 2 | ||
rwALPHATESTFUNCTIONEQUAL = 3 | ||
rwALPHATESTFUNCTIONLESSEQUAL = 4 | ||
rwALPHATESTFUNCTIONGREATER = 5 | ||
rwALPHATESTFUNCTIONNOTEQUAL = 6 | ||
rwALPHATESTFUNCTIONGREATEREQUAL = 7 | ||
rwALPHATESTFUNCTIONALWAYS = 8 | ||
|
||
|
||
# Render state to type mapping | ||
RwRenderState_To_Type = { | ||
# None - Not yet implemented | ||
# Any other type means that the value has to be of that type | ||
|
||
'rwRENDERSTATENARENDERSTATE': cint, | ||
'rwRENDERSTATETEXTURERASTER': str, # pointer in reality | ||
'rwRENDERSTATETEXTUREADDRESS': cenum(RwTextureAddressMode), | ||
'rwRENDERSTATETEXTUREADDRESSU': cenum(RwTextureAddressMode), | ||
'rwRENDERSTATETEXTUREADDRESSV': cenum(RwTextureAddressMode), | ||
'rwRENDERSTATETEXTUREPERSPECTIVE': None, | ||
'rwRENDERSTATEZTESTENABLE': cbool, | ||
'rwRENDERSTATESHADEMODE': None, | ||
'rwRENDERSTATEZWRITEENABLE': cbool, | ||
'rwRENDERSTATETEXTUREFILTER': None, | ||
'rwRENDERSTATESRCBLEND': cenum(RwBlendFunction), | ||
'rwRENDERSTATEDESTBLEND': cenum(RwBlendFunction), | ||
'rwRENDERSTATEVERTEXALPHAENABLE': cbool, | ||
'rwRENDERSTATEBORDERCOLOR': cint, | ||
'rwRENDERSTATEFOGENABLE': cbool, | ||
'rwRENDERSTATEFOGCOLOR': cbool, | ||
'rwRENDERSTATEFOGTYPE': None, | ||
'rwRENDERSTATEFOGDENSITY': int, | ||
'rwRENDERSTATECULLMODE': None, | ||
'rwRENDERSTATESTENCILENABLE': cbool, | ||
'rwRENDERSTATESTENCILFAIL': None, | ||
'rwRENDERSTATESTENCILZFAIL': None, | ||
'rwRENDERSTATESTENCILPASS': None, | ||
'rwRENDERSTATESTENCILFUNCTION': None, | ||
'rwRENDERSTATESTENCILFUNCTIONREF': str, | ||
'rwRENDERSTATESTENCILFUNCTIONMASK': None, | ||
'rwRENDERSTATESTENCILFUNCTIONWRITEMASK': None, | ||
'rwRENDERSTATEALPHATESTFUNCTION': cenum(RwAlphaTestFunction), | ||
'rwRENDERSTATEALPHATESTFUNCTIONREF': None, | ||
} | ||
|
||
input("Make sure to have copied the code to the clipboard!") | ||
|
||
# Example user input | ||
# RwEngineInstance->dOpenDevice.fpRenderStateSet(rwRENDERSTATEZWRITEENABLE, 0); | ||
# RwEngineInstance->dOpenDevice.fpRenderStateSet(rwRENDERSTATEZTESTENABLE, 1u); | ||
# RwEngineInstance->dOpenDevice.fpRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, 1u); | ||
# RwEngineInstance->dOpenDevice.fpRenderStateSet(rwRENDERSTATEFOGENABLE, 0); | ||
# RwEngineInstance->dOpenDevice.fpRenderStateSet(rwRENDERSTATESRCBLEND, 5u); | ||
# RwEngineInstance->dOpenDevice.fpRenderStateSet(rwRENDERSTATEDESTBLEND, 6u); | ||
# RwEngineInstance->dOpenDevice.fpRenderStateSet(rwRENDERSTATETEXTURERASTER, (unsigned int)gpCloudMaskTex->raster); | ||
|
||
# Tuples of (state_name, state_value); [Ex.: ("rwRENDERSTATEZWRITEENABLE", "0")] | ||
input_values : list[tuple[str, str]] = [ | ||
re.search(r'\((\w+), (.+)\)', line).groups() | ||
for line in pyc.paste().splitlines() | ||
] | ||
|
||
# Find longest name | ||
longest = max(len(n) for (n, v) in input_values) | ||
|
||
# Format it | ||
output = [] | ||
for n, v in input_values: | ||
value_type = RwRenderState_To_Type[n] | ||
if value_type is None: | ||
raise NotImplementedError(f'Value type for state {n} is not yet implemented!') | ||
output.append( | ||
f'RwRenderStateSet({n}, {" " * (longest - len(n))}RWRSTATE({value_type(v)}));' | ||
) | ||
pyc.copy('\n'.join(output)) |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import tkinter as tk | ||
import os | ||
import subprocess | ||
from tkinter import filedialog as tkFileDialog | ||
from pathlib import Path | ||
import zipfile | ||
|
||
def main(): | ||
git_repo_root = Path.cwd() | ||
|
||
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 | ||
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!') | ||
|
||
if __name__ == "__main__": | ||
main() |
Binary file not shown.
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
Oops, something went wrong.