Skip to content
This repository was archived by the owner on Jun 12, 2025. It is now read-only.

Commit 530ef67

Browse files
committed
fix up freeplay icons
1 parent ac53ca7 commit 530ef67

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

psychtobase/main.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
# Main
2323

2424
charts = []
25+
characterMap = {
26+
# 'charactr': 'Name In English'
27+
}
2528
vocalSplitMasterToggle = True
2629

2730
def folderMake(folder_path):
@@ -197,6 +200,10 @@ def convert(psych_mod_folder, result_folder, options):
197200

198201
converted_char.convert()
199202
converted_char.save()
203+
# For THOSE
204+
fileBasename = converted_char.iconID.replace('icon-', '')
205+
characterMap[fileBasename] = converted_char.characterName
206+
logging.info(f'Saved {converted_char.characterName} to character map using their icon id: {fileBasename}.')
200207
else:
201208
logging.warn(f'{character} is a directory, or not a json! Skipped')
202209

@@ -225,17 +232,27 @@ def convert(psych_mod_folder, result_folder, options):
225232

226233
destination = f'{result_folder}/{modFoldername}{bgCharacterAssets}{filename}'
227234
fileCopy(character, destination)
228-
# Woah, freeplay icons
229-
logging.getLogger('PIL').setLevel(logging.INFO)
230-
with Image.open(character) as img:
231-
# Get the winning/normal half of icons
232-
normal_half = img.crop((0, 0, 150, 150))
233-
# Scale to 50x50, same size as BF and GF pixel icons
234-
pixel_img = normal_half.resize((50, 50), Image.Resampling.NEAREST)
235-
pixel_name = filename[5:-4] + 'pixel' + filename[-4:]
236-
freeplay_destination = f'{result_folder}/{modFoldername}{freeplayDir}/{pixel_name}'
237-
pixel_img.save(freeplay_destination)
238-
logging.info(f'Saving converted freeplay icon to {freeplay_destination}')
235+
keyForThisIcon = filename.replace('icon-', '').replace('.png', '')
236+
logging.info('Checking if ' + keyForThisIcon + ' is in the characterMap')
237+
238+
if characterMap.get(keyForThisIcon, None) != None:
239+
try:
240+
# Woah, freeplay icons
241+
logging.getLogger('PIL').setLevel(logging.INFO)
242+
with Image.open(character) as img:
243+
# Get the winning/normal half of icons
244+
normal_half = img.crop((0, 0, 150, 150))
245+
# Scale to 50x50, same size as BF and GF pixel icons
246+
pixel_img = normal_half.resize((50, 50), Image.Resampling.NEAREST)
247+
248+
249+
pixel_name = characterMap.get(keyForThisIcon) + 'pixel.png'
250+
251+
freeplay_destination = f'{result_folder}/{modFoldername}{freeplayDir}/{pixel_name}'
252+
pixel_img.save(freeplay_destination)
253+
logging.info(f'Saving converted freeplay icon to {freeplay_destination}')
254+
except Exception as ___exc:
255+
logging.error(f"Failed to create character {keyForThisIcon}'s freeplay icon: {___exc}")
239256
except Exception as e:
240257
logging.error(f'Could not copy asset {character}: {e}')
241258
else:

psychtobase/src/tools/CharacterTools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def __init__(self, path: str, resultPath) -> None:
1414
self.character:dict = copy.deepcopy(Constants.CHARACTER)
1515
self.characterName:str = None
1616

17+
self.iconID:str = None
18+
1719
self.loadCharacter()
1820

1921
def loadCharacter(self):
@@ -34,6 +36,7 @@ def convert(self):
3436
# self.character['scale'] = char['scale']
3537
self.character['isPixel'] = char['scale'] >= 6
3638
self.character['healthIcon']['id'] = char['healthicon']
39+
self.iconID = char['healthicon']
3740
self.character['healthIcon']['isPixel'] = char['scale'] >= 6
3841
self.character['flipX'] = char.get('flip_x', False)
3942

psychtobase/src/window.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ def __init__(self):
251251

252252
self.icons = QCheckBox("Health Icons", self)
253253
self.icons.move(sSX, _currentYPos)
254-
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.")
254+
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).")
255+
256+
_currentYPos += 20
255257

256258
self.jsons = QCheckBox(".json files", self)
257259
self.jsons.move(sSX, _currentYPos)

0 commit comments

Comments
 (0)