"""Génère les sprites de la proposition C (boutons et curseurs plats, logo vide) sans dépendance. Usage : python outils/sprites-c.py (écrit dans src/main/resources/assets/minecraft/textures/gui)""" import json, os, struct, zlib RACINE = os.path.join(os.path.dirname(__file__), "..", "src", "main", "resources", "assets", "minecraft", "textures", "gui") def png(chemin, l, h, pixel): brut = b"".join(b"\x00" + b"".join(bytes(pixel(x, y)) for x in range(l)) for y in range(h)) def bloc(t, d): return struct.pack(">I", len(d)) + t + d + struct.pack(">I", zlib.crc32(t + d) & 0xFFFFFFFF) os.makedirs(os.path.dirname(chemin), exist_ok=True) with open(chemin, "wb") as f: f.write(b"\x89PNG\r\n\x1a\n" + bloc(b"IHDR", struct.pack(">IIBBBBB", l, h, 8, 6, 0, 0, 0)) + bloc(b"IDAT", zlib.compress(brut, 9)) + bloc(b"IEND", b"")) def aplat(fond, filet): def p(l, h): return lambda x, y: filet if x in (0, l - 1) or y in (0, h - 1) else fond return p def sprite(nom, l, h, fabrique): chemin = os.path.join(RACINE, "sprites", "widget", nom + ".png") png(chemin, l, h, fabrique(l, h)) with open(chemin + ".mcmeta", "w") as f: json.dump({"gui": {"scaling": {"type": "nine_slice", "width": l, "height": h, "border": 1}}}, f) NOIR = lambda a: (0, 0, 0, a) BLANC = lambda a: (255, 255, 255, a) # Boutons : aplat noir translucide + filet clair de 1 px de texture (3 à 4 px à l'écran), aucun arrondi. sprite("button", 200, 20, aplat(NOIR(140), BLANC(60))) sprite("button_highlighted", 200, 20, aplat(NOIR(170), BLANC(255))) sprite("button_disabled", 200, 20, aplat(NOIR(90), BLANC(25))) # Curseurs : même piste que les boutons, poignée claire pleine. sprite("slider", 200, 20, aplat(NOIR(140), BLANC(60))) sprite("slider_highlighted", 200, 20, aplat(NOIR(170), BLANC(160))) sprite("slider_handle", 8, 20, aplat(BLANC(200), BLANC(255))) sprite("slider_handle_highlighted", 8, 20, aplat(BLANC(255), BLANC(255))) # Logo Minecraft et « Java Edition » vides : le mot GASTINEL est écrit par le mod en police Minecraft. for nom, l, h in (("minecraft", 256, 64), ("minceraft", 256, 64), ("edition", 128, 16)): png(os.path.join(RACINE, "title", nom + ".png"), l, h, lambda x, y: (0, 0, 0, 0))