Skip to content

Commit

Permalink
Add freeplay icons and fix stuff-
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffyOMC committed May 25, 2024
1 parent 380823e commit 91ac88a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller numpy pydub luaparser pyqt6
pip install pyinstaller numpy pydub luaparser pyqt6 pillow
- name: Build with PyInstaller
run: |
pyinstaller --onefile setup.py --icon=${{ matrix.icon }} --noconsole -n "FNF Porter PR-${{ github.event.pull_request.number }}"
pyinstaller --onefile psychtobase/main.py --icon=${{ matrix.icon }} --noconsole -n "FNF Porter PR-${{ github.event.pull_request.number }}"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller numpy pydub luaparser pyqt6
pip install pyinstaller numpy pydub luaparser pyqt6 pillow
- name: Build with PyInstaller
run: |
pyinstaller --onefile main.py --icon=${{ matrix.icon }} --noconsole -n "FNF Porter dev-${{ github.run_number }}"
pyinstaller --onefile psychtobase/main.py --icon=${{ matrix.icon }} --noconsole -n "FNF Porter dev-${{ github.run_number }}"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pyinstaller --onefile --icon=icon.ico -n "FNF Porter" setup.py
pyinstaller --onefile --icon=icon.ico -n "FNF Porter" psychtobase/main.py
cd dist
"FNF Porter.exe"
3 changes: 2 additions & 1 deletion dependency-install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pip install pyinstaller
pip install numpy
pip install pydub
pip install luaparser
pip install pyqt6
pip install pyqt6
pip install pillow
21 changes: 20 additions & 1 deletion psychtobase/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import time
from pathlib import Path
from PIL import Image
from src import Constants, log, Paths, Utils, files, window
from src.tools import ModConvertTools as ModTools
import threading
Expand Down Expand Up @@ -207,14 +208,32 @@ def convert(psych_mod_folder, result_folder, options):
dir = Constants.FILE_LOCS.get('CHARACTERICON')
psychCharacterAssets = modName + dir[0]
bgCharacterAssets = dir[1]
freeplayDir = Constants.FILE_LOCS.get('FREEPLAYICON')[1]

folderMake(f'{result_folder}/{modFoldername}{bgCharacterAssets}')
folderMake(f'{result_folder}/{modFoldername}{freeplayDir}')

for character in files.findAll(f'{psychCharacterAssets}*'):
if Path(character).is_file():
logging.info(f'Copying asset {character}')
try:
fileCopy(character, result_folder + f'/{modFoldername}' + bgCharacterAssets + Path(character).name)
filename = Path(character).name
# Some goofy ah mods don't name icons with icon-, causing them to be invalid in base game.
if not filename.startswith('icon-') and filename != 'readme.txt':
logging.warn(f"Invalid icon name being renamed from '{filename}' to 'icon-{filename}'!")
filename = 'icon-' + filename

destination = f'{result_folder}/{modFoldername}{bgCharacterAssets}{filename}'
fileCopy(character, destination)
# Woah, freeplay icons
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)
except Exception as e:
logging.error(f'Could not copy asset {character}: {e}')
else:
Expand Down
1 change: 1 addition & 0 deletions psychtobase/src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import src.log as log
import src.Constants as Constants
import main

import webbrowser

Expand Down

0 comments on commit 91ac88a

Please sign in to comment.