2022-10-23 13:43:51 +00:00
|
|
|
import re
|
|
|
|
import argparse
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
_LITERAL_REPLACEMENTS = [
|
|
|
|
("std::string_view", "const rstl::string&"),
|
|
|
|
("std::vector", "rstl::vector"),
|
|
|
|
("std::list", "rstl::list"),
|
|
|
|
("std::pair", "rstl::pair"),
|
|
|
|
("std::optional", "rstl::optional_object"),
|
|
|
|
("std::nullopt", "rstl::optional_object_null()"),
|
|
|
|
|
|
|
|
("zeus::CTransform", "CTransform4f"),
|
|
|
|
("zeus::skZero2f", "CVector2f(0.f, 0.f)"),
|
|
|
|
("zeus::skZero3f", "CVector3f::Zero()"),
|
|
|
|
("zeus::skPurple", "CColor::Purple()"),
|
|
|
|
("zeus::skWhite", "CColor::White()"),
|
|
|
|
("zeus::CFrustum", "CFrustumPlanes"),
|
|
|
|
("zeus::lookAt", "CTransform4f::LookAt"),
|
2022-10-24 23:29:11 +00:00
|
|
|
("zeus::radToDeg", "CMath::Rad2Deg"),
|
|
|
|
("zeus::degToRad", "CMath::Deg2Rad"),
|
2022-10-23 13:43:51 +00:00
|
|
|
("zeus::", ""),
|
|
|
|
("u32 ", "uint "),
|
|
|
|
("s32 ", "int "),
|
|
|
|
("std::min(", "rstl::min_val("),
|
|
|
|
("std::max(", "rstl::max_val("),
|
|
|
|
|
|
|
|
("DEFINE_ENTITY", ""),
|
|
|
|
("visitor.Visit(this)", "visitor.Visit(*this)"),
|
|
|
|
|
|
|
|
("g_SimplePool", "gpSimplePool"),
|
|
|
|
("g_Renderer", "gpRender"),
|
|
|
|
|
|
|
|
# Vector
|
|
|
|
(".magnitude()", ".Magnitude()"),
|
|
|
|
(".normalized()", ".AsNormalized()"),
|
|
|
|
# Transform
|
|
|
|
(".frontVector()", ".GetForward()"),
|
|
|
|
|
2022-11-29 17:17:12 +00:00
|
|
|
# CStateManager
|
|
|
|
(".GetActiveRandom()", ".Random()"),
|
|
|
|
|
2022-10-23 13:43:51 +00:00
|
|
|
# Enums
|
|
|
|
("EMaterialTypes::", "kMT_"),
|
2022-11-29 17:17:12 +00:00
|
|
|
("EScriptObjectState::", "kSS_"),
|
|
|
|
("EScriptObjectMessage::", "kSM_"),
|
2022-10-23 13:43:51 +00:00
|
|
|
("CPlayer::EPlayerOrbitState::", "CPlayer::kOS_"),
|
|
|
|
("CPlayer::ESurfaceRestraints::", "CPlayer::kSR_"),
|
|
|
|
("CPlayer::EPlayerCameraState::", "CPlayer::kCS_"),
|
|
|
|
("CPlayer::EPlayerMorphBallState::", "CPlayer::kMS_"),
|
|
|
|
("CPlayer::EPlayerOrbitType::", "CPlayer::kOT_"),
|
|
|
|
("CPlayer::EPlayerOrbitRequest::", "CPlayer::kOR_"),
|
|
|
|
("CPlayer::EPlayerZoneInfo::", "CPlayer::kZI_"),
|
|
|
|
("CPlayer::EPlayerZoneType::", "CPlayer::kZT_"),
|
|
|
|
("CPlayer::EPlayerScanState::", "CPlayer::kSS_"),
|
|
|
|
("CPlayer::EGrappleState::", "CPlayer::kGS_"),
|
|
|
|
("CPlayer::EFootstepSfx::", "CPlayer::kFS_"),
|
|
|
|
("CPlayer::EGunHolsterState::", "CPlayer::kGH_"),
|
|
|
|
("CPlayerState::EPlayerVisor::", "CPlayerState::kPV_"),
|
|
|
|
("CPlayerState::EPlayerSuit::", "CPlayerState::kPS_"),
|
|
|
|
("CPlayerState::EBeamId::", "CPlayerState::kBI_"),
|
|
|
|
("CPlayerState::EItemType::", "CPlayerState::kIT_"),
|
|
|
|
]
|
|
|
|
_RE_REPLACEMENTS = [
|
|
|
|
(re.compile(r"SObjectTag{FOURCC\('(.*)'\),\s*(.*)}"), r"SObjectTag('\1', \2)"),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("file", type=Path)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
contents: str = args.file.read_text()
|
|
|
|
|
|
|
|
for sub, replacement in _LITERAL_REPLACEMENTS:
|
|
|
|
contents = contents.replace(sub, replacement)
|
|
|
|
|
|
|
|
for re_obj, replacement in _RE_REPLACEMENTS:
|
|
|
|
contents = re_obj.sub(replacement, contents)
|
|
|
|
|
|
|
|
args.file.write_text(contents)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|