Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
fix datetime issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dallmeyer authored Aug 28, 2024
1 parent b23b755 commit f1dc803
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions scripts/mod-bundler/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,31 +182,29 @@ def override_binaries_and_assets(args, out_folder, executable_extensions=True):

def patch_mod_timestamp_and_version_info(args, out_folder):
try:
path = os.path.join(args["outputDir"], "windows", "data", "goal_src", "jak1", "engine", "mods", "mod-settings.gc")

file = open(path, "r")
file_data = file.read()
file.close()

# Check if the placeholder string is present in the file
if "%MODVERSIONPLACEHOLDER%" in file_data:
# Replace the placeholder string with the version and date string
version_str = (
args["versionName"]
+ " "
+ datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d %H:%M:%S")
)
file_data = file_data.replace("%MODVERSIONPLACEHOLDER%", version_str)

# Write the updated content back to the mod-settings
file = open(path, "w")
file.write(file_data)
mod_settings_files = glob.glob(f"{args['outputDir']}/{out_folder}/data/goal_src/**/mod-settings.gc", recursive=True)
for settings_file_path in mod_settings_files:
file = open(settings_file_path, "r")
file_data = file.read()
file.close()
print(
f"String %MODVERSIONPLACEHOLDER% replaced with '{version_str}' in the file."
)
else:
print(f"Couldn't find %MODVERSIONPLACEHOLDER% in the file.")
# Check if the placeholder string is present in the file
if "%MODVERSIONPLACEHOLDER%" in file_data:
# Replace the placeholder string with the version and date string
version_str = (
args["versionName"]
+ " "
+ datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
)
file_data = file_data.replace("%MODVERSIONPLACEHOLDER%", version_str)
# Write the updated content back to the mod-settings
file = open(settings_file_path, "w")
file.write(file_data)
file.close()
print(
f"String %MODVERSIONPLACEHOLDER% replaced with '{version_str}' in the file."
)
else:
print(f"Couldn't find %MODVERSIONPLACEHOLDER% in the file.")
except Exception as e:
print(
f"Something went wrong trying to replace placeholder text with mod version info:"
Expand Down

0 comments on commit f1dc803

Please sign in to comment.