From 0029d83bb0d4833f44fc2b3af4c3bc0d55a6bf95 Mon Sep 17 00:00:00 2001 From: VocalFan <45863583+VocalFan@users.noreply.github.com> Date: Thu, 23 May 2024 06:07:28 -0400 Subject: [PATCH] Maybe, pls? --- psychtobase/main.py | 4 +++- psychtobase/src/tools/WeekTools.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/psychtobase/main.py b/psychtobase/main.py index 2dbafe2..3f450af 100644 --- a/psychtobase/main.py +++ b/psychtobase/main.py @@ -336,7 +336,9 @@ def convert(psych_mod_folder, result_folder, options): logging.info(f'Loading {week} into the converter...') weekJSON = json.loads(open(week, 'r').read()) - open(f'{result_folder}/{modFoldername}{baseLevels}{os.path.basename(week)}', 'w').write(json.dumps(WeekTools.convert(weekJSON, modName), indent=4)) + week_filename = os.path.basename(week) + converted_week = WeekTools.convert(weekJSON, modName, week_filename) + open(f'{result_folder}/{modFoldername}{baseLevels}{week_filename}', 'w').write(json.dumps(converted_week, indent=4)) if weekCOptions['props']: logging.info('Copying prop assets...') diff --git a/psychtobase/src/tools/WeekTools.py b/psychtobase/src/tools/WeekTools.py index 020b70b..3617552 100644 --- a/psychtobase/src/tools/WeekTools.py +++ b/psychtobase/src/tools/WeekTools.py @@ -3,7 +3,7 @@ import logging import psychtobase.src.Constants as Constants -def convert(weekJSON, modfolder): +def convert(weekJSON, modfolder, week_filename): level = deepcopy(Constants.LEVEL) level['name'] = weekJSON['storyName'] @@ -45,11 +45,15 @@ def convert(weekJSON, modfolder): level['props'].append(propTemplate) - level['background'] = '#FFFFFF' # Change!! + if 'freeplayColor' in weekJSON: + r, g, b = weekJSON['freeplayColor'] + level['background'] = f'#{r:02X}{g:02X}{b:02X}' + else: + level['background'] = '#FFFFFF' - level['titleAsset'] = Constants.FILE_LOCS.get('WEEKIMAGE_WEEKJSON')[1] + weekJSON['weekName'] + level['titleAsset'] = Constants.FILE_LOCS.get('WEEKIMAGE_WEEKJSON')[1] + week_filename return level def defaultProp(propName): - return Constants.LEVEL_PROP_DEFAULTS.get(propName, None) \ No newline at end of file + return Constants.LEVEL_PROP_DEFAULTS.get(propName, None)