pokeemerald/migration_scripts/1.15/update_IsTextPrinterActive.py
hedara90 c9c85f1584
Sprite text printing improvements (#8345)
Co-authored-by: Hedara <hedara90@gmail.com>
2026-01-07 21:38:26 +01:00

39 lines
1.1 KiB
Python

import glob
import re
import os
from pathlib import Path
# All existing calls to IsTextPrinterActive targets a window
# so all function calls can be assumed to be FALSE
if not os.path.exists("Makefile"):
print("Please run this script from your root folder.")
quit()
def find_close_paren(string, index):
while not string[index] == ")":
index += 1
return index
def update_function(fileInput):
fileTest = Path(fileInput)
if not fileTest.is_file():
return False
allLines = list()
with open(fileInput, 'r', encoding='UTF-8') as file:
while line:=file.readline():
if "bool32 IsTextPrinterActiveOn" in line:
allLines.append(line)
elif "IsTextPrinterActive" in line:
line = line.replace("IsTextPrinterActive(", "IsTextPrinterActiveOnWindow(")
allLines.append(line)
else:
allLines.append(line)
with open(fileInput, 'w', encoding='UTF-8') as file:
for line in allLines:
file.write(line)
for file in glob.glob("src/**/*.c", recursive=True):
update_function(file)