diff --git a/psychtobase/main.py b/psychtobase/main.py index dd442fd..f030203 100644 --- a/psychtobase/main.py +++ b/psychtobase/main.py @@ -22,6 +22,9 @@ # Main charts = [] +characterMap = { + # 'charactr': 'Name In English' +} vocalSplitMasterToggle = True def folderMake(folder_path): @@ -197,6 +200,10 @@ def convert(psych_mod_folder, result_folder, options): converted_char.convert() converted_char.save() + # For THOSE + fileBasename = converted_char.iconID.replace('icon-', '') + characterMap[fileBasename] = converted_char.characterName + logging.info(f'Saved {converted_char.characterName} to character map using their icon id: {fileBasename}.') else: logging.warn(f'{character} is a directory, or not a json! Skipped') @@ -225,17 +232,27 @@ def convert(psych_mod_folder, result_folder, options): destination = f'{result_folder}/{modFoldername}{bgCharacterAssets}{filename}' fileCopy(character, destination) - # Woah, freeplay icons - logging.getLogger('PIL').setLevel(logging.INFO) - with Image.open(character) as img: - # Get the winning/normal half of icons - normal_half = img.crop((0, 0, 150, 150)) - # Scale to 50x50, same size as BF and GF pixel icons - pixel_img = normal_half.resize((50, 50), Image.Resampling.NEAREST) - pixel_name = filename[5:-4] + 'pixel' + filename[-4:] - freeplay_destination = f'{result_folder}/{modFoldername}{freeplayDir}/{pixel_name}' - pixel_img.save(freeplay_destination) - logging.info(f'Saving converted freeplay icon to {freeplay_destination}') + keyForThisIcon = filename.replace('icon-', '').replace('.png', '') + logging.info('Checking if ' + keyForThisIcon + ' is in the characterMap') + + if characterMap.get(keyForThisIcon, None) != None: + try: + # Woah, freeplay icons + logging.getLogger('PIL').setLevel(logging.INFO) + with Image.open(character) as img: + # Get the winning/normal half of icons + normal_half = img.crop((0, 0, 150, 150)) + # Scale to 50x50, same size as BF and GF pixel icons + pixel_img = normal_half.resize((50, 50), Image.Resampling.NEAREST) + + + pixel_name = characterMap.get(keyForThisIcon) + 'pixel.png' + + freeplay_destination = f'{result_folder}/{modFoldername}{freeplayDir}/{pixel_name}' + pixel_img.save(freeplay_destination) + logging.info(f'Saving converted freeplay icon to {freeplay_destination}') + except Exception as ___exc: + logging.error(f"Failed to create character {keyForThisIcon}'s freeplay icon: {___exc}") except Exception as e: logging.error(f'Could not copy asset {character}: {e}') else: diff --git a/psychtobase/src/tools/CharacterTools.py b/psychtobase/src/tools/CharacterTools.py index 6ceaa6a..bc6f55a 100644 --- a/psychtobase/src/tools/CharacterTools.py +++ b/psychtobase/src/tools/CharacterTools.py @@ -14,6 +14,8 @@ def __init__(self, path: str, resultPath) -> None: self.character:dict = copy.deepcopy(Constants.CHARACTER) self.characterName:str = None + self.iconID:str = None + self.loadCharacter() def loadCharacter(self): @@ -34,6 +36,7 @@ def convert(self): # self.character['scale'] = char['scale'] self.character['isPixel'] = char['scale'] >= 6 self.character['healthIcon']['id'] = char['healthicon'] + self.iconID = char['healthicon'] self.character['healthIcon']['isPixel'] = char['scale'] >= 6 self.character['flipX'] = char.get('flip_x', False) diff --git a/psychtobase/src/window.py b/psychtobase/src/window.py index 1a99eed..df0c044 100644 --- a/psychtobase/src/window.py +++ b/psychtobase/src/window.py @@ -251,7 +251,9 @@ def __init__(self): self.icons = QCheckBox("Health Icons", self) self.icons.move(sSX, _currentYPos) - self.icons.setToolTip("Copies over all of your character icon .png files from the \"/images/icons/\" directory of your mod. This also generates Freeplay Icons.") + self.icons.setToolTip("Copies over all of your character icon .png files from the \"/images/icons/\" directory of your mod. This also generates Freeplay Icons (These require characters enabled).") + + _currentYPos += 20 self.jsons = QCheckBox(".json files", self) self.jsons.move(sSX, _currentYPos)