Detailed logo, smaller icons inside the casing frame, sliders and other widgets, EMI panels, list screens, in-game bug reports

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Fulldroper
2026-10-14 06:54:26 +03:00
co-authored by Claude Opus 5.5
parent 4051a18f24
commit ba4dbd1052
34 changed files with 268 additions and 65 deletions
+162 -43
View File
@@ -198,37 +198,42 @@ ICON_COLOURS = {
}
QUIT_ICON = '''
#######......
#++++++......
#+...........
#+.......#...
#+.......##..
#+..########.
#+..#########
#+..+++++##+.
#+.......#+..
#+.......+...
#+...........
#######......
+++++++......
#####.....
#.........
#.....#...
#.....##..
#..#######
#..#######
#.....##..
#.....#...
#.........
+++++.....
''' # sign-out: a door frame with an arrow going out
SETTINGS_ICON = '''
.....###.....
..#..###..#..
.###########.
..#########..
..###+++###..
#####...#####
#####...#####
#####...#####
++###...###++
..#########..
.###########.
.+#++###++#+.
.....+++.....
....#....
.#.###.#.
..#####..
.###.###.
###...###
.###.###.
..#####..
.+.###.+.
....+....
''' # settings: a gear
LANGUAGE_ICON = '''
..#####..
.#..#..#.
#...#...#
#...#...#
#########
#...#...#
#...#...#
.+..#..+.
..+++++..
''' # globe; replaces Minecraft's own language icon, which is too big for the frame
ONLINE_ICON = '''
....GGGGG....
..GGGGGGGGG..
@@ -278,14 +283,16 @@ AAAa.........
''' # wrench
def button_icon(rows: str, outline: bool = False) -> Image.Image:
"""A 20x20 picture for a 20x20 button; the drawing starts at (4, 4), where Minecraft puts its own icons.
An icon shown without a button behind it gets a dark outline, so it reads on any background."""
im = Image.new('RGBA', (20, 20), (0, 0, 0, 0))
for y, row in enumerate(rows.split()):
def button_icon(rows: str, outline: bool = False, canvas: int = 20, at: int = -1) -> Image.Image:
"""A picture for a square button: the drawing is centred (or starts at `at`). An icon shown without a button
behind it gets a dark outline, so it reads on any background."""
grid = rows.split()
at = (canvas - len(grid[0])) // 2 if at < 0 else at
im = Image.new('RGBA', (canvas, canvas), (0, 0, 0, 0))
for y, row in enumerate(grid):
for x, c in enumerate(row):
if c != '.':
im.putpixel((4 + x, 4 + y), ICON_COLOURS[c] + (255,))
im.putpixel((at + x, at + y), ICON_COLOURS[c] + (255,))
if outline:
solid = np.asarray(im)[..., 3] > 0
near = np.zeros_like(solid)
@@ -298,6 +305,80 @@ def button_icon(rows: str, outline: bool = False) -> Image.Image:
return im
def detailed_lettering(mask: np.ndarray, fill, grain: np.ndarray, k: int = 10, depth: int = 1) -> Image.Image:
"""The logo's lettering: the same blocky letters, colours, dark side and ink outline as `lettering`, but drawn
`k` times finer. Every font pixel keeps the colour `lettering` gives it; inside it the metal's grain shows, and
the bevel is two fine pixels wide instead of a whole font pixel."""
pad = 1 + depth
m = np.pad(mask, pad)
h, w = m.shape
yy, xx = np.mgrid[0:h, 0:w]
if isinstance(fill, np.ndarray):
base = fill[yy % fill.shape[0], xx % fill.shape[1]].astype(np.float32)
dark = fill.reshape(-1, 3).mean(axis=0) * 0.45
else:
base = np.broadcast_to(np.array(fill, np.float32), (h, w, 3)).copy()
dark = np.array(fill, np.float32) * 0.45
side = np.zeros_like(m)
for d in range(1, depth + 1):
side |= shift(m, d, d)
side &= ~m
body = m | side
edge = np.zeros_like(m)
for dy in (-1, 0, 1):
for dx in (-1, 0, 1):
edge |= shift(body, dy, dx)
edge &= ~body
up = lambda a: np.repeat(np.repeat(a, k, 0), k, 1)
M, S, E = up(m), up(side), up(edge)
H, W = M.shape
# the grain: the inside of the block's texture, mirrored so it tiles without a seam, as a gentle brightness map
g = grain[2:14, 2:14].astype(np.float32).mean(axis=2)
g = np.concatenate([np.concatenate([g, g[:, ::-1]], 1), np.concatenate([g[::-1], g[::-1, ::-1]], 1)], 0)
g = (g / g.mean()) ** 0.8
YY, XX = np.mgrid[0:H, 0:W]
colour = up(base) * g[YY % g.shape[0], XX % g.shape[1]][..., None]
for width, lit, shade in ((1, 1.30, 0.62), (2, 1.15, 0.78), (3, 1.06, 0.90)): # the bevel, strongest at the rim
colour[M & ~shift(M, 0, -width)] *= (shade + 1) / 2 # right
colour[M & ~shift(M, 0, width)] *= (lit + 1) / 2 # left
colour[M & ~shift(M, -width, 0)] *= shade # bottom in shade
colour[M & ~shift(M, width, 0)] *= lit # top catches the light
out = np.zeros((H, W, 4), np.float32)
out[..., :3] = INK
out[S, :3] = dark * (0.85 + 0.15 * g[YY % g.shape[0], XX % g.shape[1]])[S][..., None]
out[M, :3] = colour[M]
out[M | S | E, 3] = 255
return Image.fromarray(np.clip(out, 0, 255).astype(np.uint8), 'RGBA')
def tint(sprite: Image.Image, colour) -> Image.Image:
"""A grey Minecraft sprite in another colour: brightness and transparency kept."""
px = np.asarray(sprite.convert('RGBA')).astype(np.float32)
px[..., :3] = px[..., :3].mean(axis=2, keepdims=True) / 255 * np.array(colour, np.float32)
return Image.fromarray(np.clip(px, 0, 255).astype(np.uint8), 'RGBA')
def greys_to(sprite: Image.Image, colour) -> Image.Image:
"""Only the grey pixels of a sprite take the colour (their brightness kept); coloured details stay as they are."""
px = np.asarray(sprite.convert('RGBA')).astype(np.float32)
grey = (px[..., :3].max(axis=2) - px[..., :3].min(axis=2)) < 24
px[grey, :3] = px[grey, :3].mean(axis=1, keepdims=True) / 255 * np.array(colour, np.float32)
return Image.fromarray(np.clip(px, 0, 255).astype(np.uint8), 'RGBA')
def plate(tile: np.ndarray, w: int, h: int, tone: float = 1.0) -> Image.Image:
"""A small metal plate with a black outline: the slider's handle."""
px = np.zeros((h, w, 3), np.float32)
inner = np.tile(tile, (2, 2, 1))[:h - 2, :w - 2].astype(np.float32) * tone
inner[0] *= 1.2
inner[:, 0] *= 1.1
inner[-1] *= 0.7
inner[:, -1] *= 0.8
px[1:-1, 1:-1] = inner
return Image.fromarray(np.clip(px, 0, 255).astype(np.uint8), 'RGB').convert('RGBA')
def casing_button(jar: zipfile.ZipFile, casing: str, tone: float = 1.0, grey: float = 0.0) -> Image.Image:
"""A 200x20 button sprite built from a Create casing: black outline, the casing's 3 px metal frame, its wood
inside. The wood is tiled with the block's own 16 px period and the sprite is nine-sliced with a 4 px border,
@@ -329,14 +410,32 @@ BUTTON_META = '{"gui": {"scaling": {"type": "nine_slice", "width": 200, "height"
def main() -> None:
mc_jar, create_jar, key_art = sys.argv[1], sys.argv[2], Path(sys.argv[3])
emblem_raw = Path(sys.argv[4]) if len(sys.argv) > 4 else None
emi_jar = sys.argv[5] if len(sys.argv) > 5 else None # EMI's panels are recoloured when its jar is given
with zipfile.ZipFile(mc_jar) as mc, zipfile.ZipFile(create_jar) as cr:
font = Font(mc)
brass = texture(cr, 'assets/create/textures/block/brass_block.png')
buttons = {'button': casing_button(cr, 'andesite_casing', tone=0.82),
'button_highlighted': casing_button(cr, 'brass_casing', tone=1.12),
'button_disabled': casing_button(cr, 'andesite_casing', tone=0.42, grey=0.6)}
# sprites of Minecraft's widgets, by their path under assets/minecraft/textures/gui/
vanilla = lambda path: Image.open(io.BytesIO(mc.read('assets/minecraft/textures/gui/' + path))).convert('RGBA')
gui = {'sprites/widget/button.png': casing_button(cr, 'andesite_casing', tone=0.82),
'sprites/widget/button_highlighted.png': casing_button(cr, 'brass_casing', tone=1.12),
'sprites/widget/button_disabled.png': casing_button(cr, 'andesite_casing', tone=0.42, grey=0.6),
'sprites/widget/slider.png': casing_button(cr, 'andesite_casing', tone=0.45, grey=0.3),
'sprites/widget/slider_highlighted.png': casing_button(cr, 'brass_casing', tone=0.6),
'sprites/widget/slider_handle.png': plate(brass, 8, 20, 0.92),
'sprites/widget/slider_handle_highlighted.png': plate(brass, 8, 20, 1.15),
'sprites/widget/text_field_highlighted.png': tint(vanilla('sprites/widget/text_field_highlighted.png'), BRASS[3]),
'sprites/widget/scroller.png': tint(vanilla('sprites/widget/scroller.png'), BRASS[3]),
'sprites/icon/language.png': button_icon(LANGUAGE_ICON, canvas=15)}
for name, (top, bottom) in (('header', (BRASS[0], BRASS[2])), ('footer', (BRASS[2], BRASS[0]))):
line = Image.new('RGBA', (32, 2), top + (255,))
line.paste(bottom + (255,), (0, 1, 32, 2))
gui[f'{name}_separator.png'] = gui[f'inworld_{name}_separator.png'] = line
casing = [p for p in gui if 'casing' in p or p.endswith(('button.png', 'button_highlighted.png', 'button_disabled.png',
'slider.png', 'slider_highlighted.png'))]
meta = {p: (BUTTON_META if p in casing else mc.read('assets/minecraft/textures/gui/' + p + '.mcmeta').decode())
for p in gui if p in casing or 'assets/minecraft/textures/gui/' + p + '.mcmeta' in mc.namelist()}
for d in ('logo', 'icons', 'banners', 'menu', 'ui'):
for d in ('logo', 'icons', 'banners', 'menu'):
(OUT / d).mkdir(parents=True, exist_ok=True)
# --- wordmark: CREATE in brass, RP in brick red, the motto underneath -------------------------
@@ -350,8 +449,15 @@ def main() -> None:
def mono(s: int, colour) -> Image.Image:
return lettering(mask_of(font, NAME, True), colour, s, depth=0, outline=False)
wordmark(12).save(OUT / 'logo' / 'wordmark.png')
stack([wordmark(12), motto(4)], gap=20).save(OUT / 'logo' / 'logo.png')
# the logo itself: the same letters as `wordmark`, drawn ten times finer (see detailed_lettering)
fine = beside([detailed_lettering(mask_of(font, 'CREATE', True), brass, brass),
detailed_lettering(mask_of(font, 'RP', True), BRICK, brass)], gap=20)
logo = stack([fine, motto(4)], gap=15)
canvas = Image.new('RGBA', (-(-logo.width // 3) * 3, -(-logo.height // 3) * 3)) # sides multiples of 3: the menus
canvas.alpha_composite(logo, ((canvas.width - logo.width) // 2, 0)) # show it at a third, pixel for pixel
logo = canvas
fine.save(OUT / 'logo' / 'wordmark.png')
logo.save(OUT / 'logo' / 'logo.png')
mono(12, (255, 255, 255)).save(OUT / 'logo' / 'wordmark-white.png')
mono(12, INK).save(OUT / 'logo' / 'wordmark-dark.png')
@@ -391,16 +497,29 @@ def main() -> None:
# --- FancyMenu: title screen background, the logo it shows, window icons -------------------------
shade(cover(art, 1920, 1080), *((0.95, 1.0) if night else (0.80, 0.92))).convert('RGB').save(OUT / 'menu' / 'background.png')
shade(cover(art, 1920, 1080), 0.42, 0.42).convert('RGB').save(OUT / 'menu' / 'background_dim.png') # behind "Connecting…"
stack([wordmark(8), motto(3)], gap=12).save(OUT / 'menu' / 'logo.png')
logo.save(OUT / 'menu' / 'logo.png') # shown at a third of its size: one screen pixel per texel at GUI scale 3
# --- every button of the game: andesite casing, brass casing under the cursor ---------------------------------
for name, sprite in buttons.items():
sprite.save(OUT / 'ui' / f'{name}.png')
(OUT / 'ui' / f'{name}.png.mcmeta').write_text(BUTTON_META, encoding='utf-8', newline='\n')
# EMI: its grey recipe panels and slots in cream, its small buttons in brass
if emi_jar:
with zipfile.ZipFile(emi_jar) as emi:
for name, colour in (('background', CREAM), ('widgets', CREAM), ('buttons', BRASS[3])):
sprite = Image.open(io.BytesIO(emi.read(f'assets/emi/textures/gui/{name}.png')))
target = OUT / 'resources' / 'emi' / 'textures' / 'gui' / f'{name}.png'
target.parent.mkdir(parents=True, exist_ok=True)
greys_to(sprite, colour).save(target)
# branding/resources/<namespace>/… goes into the game as kubejs/assets/<namespace>/…
for path, sprite in gui.items():
target = OUT / 'resources' / 'minecraft' / 'textures' / 'gui' / path
target.parent.mkdir(parents=True, exist_ok=True)
sprite.save(target)
if path in meta:
target.with_name(target.name + '.mcmeta').write_text(meta[path], encoding='utf-8', newline='\n')
button_icon(QUIT_ICON).save(OUT / 'menu' / 'quit.png')
button_icon(SETTINGS_ICON).save(OUT / 'menu' / 'settings.png')
for name, rows in (('online', ONLINE_ICON), ('offline', OFFLINE_ICON), ('maintenance', MAINTENANCE_ICON)):
button_icon(rows, outline=True).save(OUT / 'menu' / f'status-{name}.png')
button_icon(rows, outline=True, at=4).save(OUT / 'menu' / f'status-{name}.png')
print('done:', ', '.join(sorted(str(p.relative_to(OUT)).replace('\\', '/') for p in OUT.rglob('*.png'))))
+42 -15
View File
@@ -10,11 +10,13 @@ What it writes:
config/fancymenu/customization/ layouts, built here from fancymenu_template.txt:
createrp_title.txt the title screen
createrp_screens.txt connecting / loading / disconnected screens: our background and logo
createrp_lists.txt server list, world list and their dialogs: our background
createrp_pause.txt the game menu
config/fancymenu/custom_gui_screens.txt the game menu is our own screen that replaces Minecraft's one, so that
buttons other mods add to the pause screen (Mods, Create) never get into it
config/fancymenu/customizablemenus.txt, options.txt which screens are customised; window title and icon
kubejs/assets/minecraft/…/widget/ button sprites for the whole game: andesite casing, brass under the cursor
kubejs/assets/… branding/resources/…: sprites for the whole game (buttons, sliders, separators,
the language icon, EMI's panels) — andesite casing, brass under the cursor
config/create-client.toml Create's own button is taken out of the title screen and the game menu
"""
import re
@@ -31,7 +33,7 @@ ROOT = Path(__file__).resolve().parent.parent.parent
sys.path.insert(0, str(ROOT / 'tools' / 'signs'))
from render import BASELINE, LINE_H, Font # noqa: E402 (the pixel font reader made for the building signs)
MENU, ICONS, UI = ROOT / 'branding' / 'menu', ROOT / 'branding' / 'icons', ROOT / 'branding' / 'ui'
MENU, ICONS, RESOURCES = ROOT / 'branding' / 'menu', ROOT / 'branding' / 'icons', ROOT / 'branding' / 'resources'
WINDOW_TITLE = 'Create RP'
HOST = 'create.fulldroper.ks.ua'
GIT = 'https://git.fulldroper.ks.ua/Pinecraft-CreateRP/client'
@@ -39,9 +41,15 @@ LATEST_RELEASE = 'https://git.fulldroper.ks.ua/api/v1/repos/Pinecraft-CreateRP/c
ASSET = '[source:local]/config/fancymenu/assets/'
SCREENS = 'net.minecraft.client.gui.screens.'
# screens that get our background and logo: (FancyMenu's name, class)
PLAIN_SCREENS = [('connect_screen', 'ConnectScreen'), ('disconnected_screen', 'DisconnectedScreen'),
('generic_dirt_message_screen', 'GenericMessageScreen'), ('receiving_level_screen', 'ReceivingLevelScreen'),
('progress_screen', 'ProgressScreen'), ('level_loading_screen', 'LevelLoadingScreen')]
PLAIN_SCREENS = [('connect_screen', SCREENS + 'ConnectScreen'), ('disconnected_screen', SCREENS + 'DisconnectedScreen'),
('generic_dirt_message_screen', SCREENS + 'GenericMessageScreen'),
('receiving_level_screen', SCREENS + 'ReceivingLevelScreen'),
('progress_screen', SCREENS + 'ProgressScreen'), ('level_loading_screen', SCREENS + 'LevelLoadingScreen')]
# screens with lists, a title and a search box: only our background, the logo would cover them
LIST_SCREENS = [('join_multiplayer_screen', SCREENS + 'multiplayer.JoinMultiplayerScreen'),
('select_world_screen', SCREENS + 'worldselection.SelectWorldScreen'),
('direct_join_server_screen', SCREENS + 'DirectJoinServerScreen'),
('edit_server_screen', SCREENS + 'EditServerScreen')]
PAUSE_GUI = 'createrp_pause'
@@ -185,9 +193,15 @@ class Layout:
# --- the screens ------------------------------------------------------------------------------------------------------
def logo_size() -> tuple:
w, h = Image.open(MENU / 'logo.png').size
return w // 3, h // 3
def title_screen(version: str, labels: dict) -> Layout:
lay = Layout('title', 'title_screen', background='background.png', fireflies=True)
lay.image('logo.png', 'mid-centered', -110, -104, 221, 60)
lw, lh = logo_size()
lay.image('logo.png', 'mid-centered', -(lw // 2), -44 - lh, lw, lh)
# a button-high gap under the logo, then rows 24 apart
lay.button('mid-centered', -100, -24, 200, label='Грати', action=('joinserver', HOST), active=server('online'))
for state, tip in (('online', 'Сервер онлайн'), ('maintenance', 'Технічні роботи'), ('offline', 'Сервер офлайн')):
@@ -225,17 +239,27 @@ def plain_screens() -> Layout:
"""Connecting, loading terrain, disconnected and the like: the dimmed key art and the logo at the top."""
lay = Layout('screens', '%fancymenu:universal_layout%', background='background_dim.png',
whitelist=[name for name, _ in PLAIN_SCREENS])
lay.image('logo.png', 'top-centered', -110, 16, 221, 60)
lw, lh = logo_size()
lay.image('logo.png', 'top-centered', -(lw // 2), 16, lw, lh)
return lay
def list_screens() -> Layout:
return Layout('lists', '%fancymenu:universal_layout%', background='background_dim.png',
whitelist=[name for name, _ in LIST_SCREENS])
def game_menu() -> Layout:
lay = Layout('pause', PAUSE_GUI)
lay.image('logo.png', 'mid-centered', -110, -112, 221, 60)
lw, lh = logo_size()
lay.image('logo.png', 'mid-centered', -(lw // 2), -52 - lh, lw, lh)
lay.button('mid-centered', -102, -28, 204, label='Назад до гри', action=('closegui', ''))
lay.button('mid-centered', -102, -4, 100, label='Залишити відгук', active=NEVER)
lay.button('mid-centered', 2, -4, 100, label='Знайшов баг?', action=('paste_to_chat', 'false:/bug '),
tooltip='Опиши, що сталося, і натисни Enter — розробники отримають задачу з твоїм ніком і місцем у світі',
visible=[(SERVER_IP, 'if', HOST)])
lay.button('mid-centered', 2, -4, 100, label='Знайшов баг?', action=('openlink', GIT + '/issues/new'),
tooltip='Відкриє в браузері сторінку створення задачі в нашому Git')
tooltip='Відкриє в браузері сторінку створення задачі в нашому Git', visible=[(SERVER_IP, 'if_not', HOST)])
lay.button('mid-centered', -102, 20, 100, label='Налаштування...', action=('opengui', SCREENS + 'options.OptionsScreen'))
lay.button('mid-centered', 2, 20, 100, label='Скарги на гравців', active=NEVER)
# leaving: from our server straight to the title screen, from another one to the server list as usual
@@ -297,11 +321,12 @@ def main() -> None:
shutil.copyfile(ICONS / icon, fm / 'assets' / icon)
(fm / 'customization' / 'title_screen_layout.txt').unlink(missing_ok=True) # the name used before the generator
for name, layout in (('title', title_screen(version, labels)), ('screens', plain_screens()), ('pause', game_menu())):
for name, layout in (('title', title_screen(version, labels)), ('screens', plain_screens()), ('lists', list_screens()),
('pause', game_menu())):
(fm / 'customization' / f'createrp_{name}.txt').write_text(layout.text(), encoding='utf-8', newline='\n')
(fm / 'custom_gui_screens.txt').write_text(CUSTOM_GUIS, encoding='utf-8', newline='\n')
(fm / 'customizablemenus.txt').write_text(
'type = customizablemenus\n\n' + ''.join(f'{SCREENS}{c} {{\n}}\n\n' for c in ['TitleScreen'] + [c for _, c in PLAIN_SCREENS]),
'type = customizablemenus\n\n' + ''.join(f'{c} {{\n}}\n\n' for c in [SCREENS + 'TitleScreen'] + [c for _, c in PLAIN_SCREENS + LIST_SCREENS]),
encoding='utf-8', newline='\n')
options = (fm / 'options.txt').read_text(encoding='utf-8')
@@ -311,12 +336,14 @@ def main() -> None:
options = option(options, 'custom_window_icon_32', '/config/fancymenu/assets/favicon-32x32.png')
options = option(options, 'custom_window_icon_macos', '')
options = option(options, 'global_background_panorama', '')
options = option(options, 'global_menu_background_texture', ASSET + 'background_dim.png') # every other menu screen
(fm / 'options.txt').write_text(options, encoding='utf-8')
sprites = config.parent / 'kubejs' / 'assets' / 'minecraft' / 'textures' / 'gui' / 'sprites' / 'widget'
sprites.mkdir(parents=True, exist_ok=True)
for sprite in UI.iterdir(): # button.png, button_highlighted.png, button_disabled.png and their .mcmeta
shutil.copyfile(sprite, sprites / sprite.name)
for source in RESOURCES.rglob('*'): # branding/resources/<namespace>/… → kubejs/assets/<namespace>/…
if source.is_file():
target = config.parent / 'kubejs' / 'assets' / source.relative_to(RESOURCES)
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source, target)
create = config / 'create-client.toml' # Create draws its button itself; row 0 switches it off
if create.is_file():