trophies: add icons

This commit is contained in:
Lephe 2020-07-22 10:44:56 +02:00
parent 5566cb6262
commit 6b280c6901
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
39 changed files with 43 additions and 2 deletions

View File

@ -5,6 +5,7 @@ from flask_login import LoginManager
from flask_mail import Mail
from config import Config
import time
import slugify
app = Flask(__name__)
app.config.from_object(Config)
@ -49,3 +50,8 @@ from app.routes.forum import index, topic
from app.utils import pluralize # To use pluralize into the templates
from app.utils import date
from app.utils import is_title
# Add slugify into the available functions in every template
app.jinja_env.globals.update(
slugify=slugify.slugify
)

View File

@ -61,7 +61,7 @@
border-radius: 2px;
}
.trophy img {
height: 50px; margin-right: 5px;
height: 48px; margin-right: 8px;
}
.trophy div > * {
display: block;

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

View File

@ -46,7 +46,7 @@
<div class="trophies">
{% for t in trophies if t in member.trophies or t.hidden == False %}
<div class="trophy {{ '' if t in member.trophies else 'disabled' }}">
<img src="{{ url_for('static', filename='images/fa_124.png') }}">
<img src="{{ url_for('static', filename='images/trophies/'+slugify(t.name))+'.png' }}">
<div>
<em>{{ t.name }}</em>
<span>{{ t.description }}</span>

35
assets/trophies-generate.py Executable file
View File

@ -0,0 +1,35 @@
#! /usr/bin/python3
from PIL import Image
import os
import sys
import slugify
import yaml
if os.path.basename(os.getcwd()) != "assets":
print("This script should be started from the /assets folder of PCv5.")
sys.exit(1)
# Read the list of trophies from /app/data/trophies.yaml
with open("../app/data/trophies.yaml") as fp:
trophies = yaml.safe_load(fp.read())
names = [ slugify.slugify(t["name"]) for t in trophies ]
# Write trophy images to /app/static/images/trophies
try:
os.mkdir("../app/static/images/trophies")
except FileExistsError:
pass
# Skip blank squares in the source image
img = Image.open("trophies.png")
def trophy_iterator(img):
for y in range(img.height // 26):
for x in range(img.width // 26):
icon = img.crop((26*x+1, 26*y+1, 26*x+25, 26*y+25))
if len(icon.getcolors()) > 1:
yield icon.resize((48,48))
for (name, icon) in zip(names, trophy_iterator(img)):
icon.save(f"../app/static/images/trophies/{name}.png")

BIN
assets/trophies.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB