diff --git a/branding/logo/logo.png b/branding/logo/logo.png index 71e127f..98e7cee 100644 Binary files a/branding/logo/logo.png and b/branding/logo/logo.png differ diff --git a/branding/logo/wordmark.png b/branding/logo/wordmark.png index a3991a8..78b0401 100644 Binary files a/branding/logo/wordmark.png and b/branding/logo/wordmark.png differ diff --git a/branding/menu/logo.png b/branding/menu/logo.png index 71e127f..9e5b40a 100644 Binary files a/branding/menu/logo.png and b/branding/menu/logo.png differ diff --git a/branding/menu/quit.png b/branding/menu/quit.png index c036e47..d17533d 100644 Binary files a/branding/menu/quit.png and b/branding/menu/quit.png differ diff --git a/branding/menu/settings.png b/branding/menu/settings.png index f283598..b145f45 100644 Binary files a/branding/menu/settings.png and b/branding/menu/settings.png differ diff --git a/branding/resources/emi/textures/gui/background.png b/branding/resources/emi/textures/gui/background.png index b361e09..7caf698 100644 Binary files a/branding/resources/emi/textures/gui/background.png and b/branding/resources/emi/textures/gui/background.png differ diff --git a/branding/resources/emi/textures/gui/buttons.png b/branding/resources/emi/textures/gui/buttons.png index c5c6e80..3375dbe 100644 Binary files a/branding/resources/emi/textures/gui/buttons.png and b/branding/resources/emi/textures/gui/buttons.png differ diff --git a/branding/resources/minecraft/textures/gui/sprites/icon/language.png b/branding/resources/minecraft/textures/gui/sprites/icon/language.png index ce3538f..fc0d886 100644 Binary files a/branding/resources/minecraft/textures/gui/sprites/icon/language.png and b/branding/resources/minecraft/textures/gui/sprites/icon/language.png differ diff --git a/tools/branding/build.py b/tools/branding/build.py index 42cdde3..ac96791 100644 --- a/tools/branding/build.py +++ b/tools/branding/build.py @@ -198,42 +198,22 @@ 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.. @@ -305,50 +285,160 @@ def button_icon(rows: str, outline: bool = False, canvas: int = 20, at: int = -1 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 +def shaded_disc(size: int, inside, colour, rim, lines=None) -> Image.Image: + """A small round pixel picture: `inside(x, y)` (centred coordinates, radius 1 = the edge) says what is solid, + lit from the top left, a darker rim, and optional `lines(x, y)` drawn lighter on top.""" + k, c = 8, (size - 1) / 2 + im = np.zeros((size, size, 4), np.float32) + for py in range(size): + for px in range(size): + hits = sum(inside((px - c + (i % k + 0.5) / k - 0.5) / (size / 2), (py - c + (i // k + 0.5) / k - 0.5) / (size / 2)) + for i in range(k * k)) + if hits * 2 >= k * k: + x, y = (px - c) / (size / 2), (py - c) / (size / 2) + light = 1.18 - 0.30 * (x + y) + rgb = np.array(colour, np.float32) * light + if lines and lines(x, y): + rgb = np.minimum(rgb * 1.55 + 40, 255) + im[py, px] = (*rgb, 255) + solid = im[..., 3] > 0 + edge = solid & ~(shift(solid, 1, 0) & shift(solid, -1, 0) & shift(solid, 0, 1) & shift(solid, 0, -1)) + im[edge, :3] = rim + return Image.fromarray(np.clip(im, 0, 255).astype(np.uint8), 'RGBA') - 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 + +def gear_icon(size: int = 14) -> Image.Image: + """Settings: a steel gear with eight teeth and a hole.""" + def inside(x, y): + r, a = math.hypot(x, y), math.atan2(y, x) + tooth = (math.degrees(a) % 45) < 21 + return 0.34 < r < (0.98 if tooth else 0.74) + return shaded_disc(size, inside, (196, 200, 206), (70, 72, 78)) + + +def globe_icon(size: int = 14) -> Image.Image: + """Language: a blue globe with a meridian, an oval meridian and three parallels.""" + def lines(x, y): + oval = 0.55 * math.sqrt(max(0.0, 1 - y * y)) + return abs(x) < 0.08 or abs(abs(x) - oval) < 0.08 or abs(y) < 0.08 or abs(abs(y) - 0.52) < 0.08 + return shaded_disc(size, lambda x, y: x * x + y * y < 0.97, (58, 108, 196), (24, 46, 100), lines) + + +def on_canvas(icon: Image.Image, canvas: int) -> Image.Image: + im = Image.new('RGBA', (canvas, canvas)) + im.alpha_composite(icon, ((canvas - icon.width) // 2, (canvas - icon.height) // 2)) + return im + + +def casingify(sheet: Image.Image, wood: np.ndarray, frame, face=None) -> Image.Image: + """EMI's little grey buttons and panels rebuilt in the look of our buttons. Buttons on EMI's sheet touch each other, + so a piece is told apart by its lines, not by gaps: the black lines (and a piece's outer edge) stay; the pixels + right next to them — the bevel — become the casing's metal frame; further in, the grey face becomes wood (or + `face`), and anything brighter or darker than the face around it is a symbol and is kept. A piece outlined in + white is EMI's highlighted state and gets brass. `frame` is (light, dark).""" + from collections import deque + px = np.asarray(sheet.convert('RGBA')).astype(np.float32) + out = px.copy() + solid = px[..., 3] > 0 + lum = px[..., :3].mean(axis=2) + h, w = solid.shape + inner = shift(solid, 1, 0) & shift(solid, -1, 0) & shift(solid, 0, 1) & shift(solid, 0, -1) + line = solid & ((lum < 45) | ~inner) + dist = np.full((h, w), 99, int) + near = np.zeros((h, w), np.float32) # brightness of the nearest line + q = deque() + for y, x in zip(*np.nonzero(line)): + dist[y, x], near[y, x] = 0, lum[y, x] + q.append((y, x)) + while q: + y, x = q.popleft() + for ny, nx in ((y + 1, x), (y - 1, x), (y, x + 1), (y, x - 1)): + if 0 <= ny < h and 0 <= nx < w and solid[ny, nx] and dist[ny, nx] > dist[y, x] + 1: + dist[ny, nx], near[ny, nx] = dist[y, x] + 1, near[y, x] + q.append((ny, nx)) + # pieces smaller than 8 x 8 (dots, little icons) are left alone + big = np.zeros((h, w), bool) + seen = np.zeros((h, w), bool) + for sy, sx in zip(*np.nonzero(solid)): + if seen[sy, sx]: + continue + piece, q = [], deque([(sy, sx)]) + seen[sy, sx] = True + while q: + y, x = q.popleft() + piece.append((y, x)) + for ny, nx in ((y + 1, x), (y - 1, x), (y, x + 1), (y, x - 1)): + if 0 <= ny < h and 0 <= nx < w and solid[ny, nx] and not seen[ny, nx]: + seen[ny, nx] = True + q.append((ny, nx)) + ys, xs = zip(*piece) + if max(ys) - min(ys) >= 7 and max(xs) - min(xs) >= 7: + big[tuple(zip(*piece))] = True + deep = big & (dist >= 2) + for y, x in zip(*np.nonzero(big)): + d, hot = dist[y, x], near[y, x] > 200 + if d == 0: + if hot: + out[y, x, :3] = BRASS[1] + continue + window = deep[max(0, y - 6):y + 7, max(0, x - 6):x + 7] + face_lum = float(np.median(lum[max(0, y - 6):y + 7, max(0, x - 6):x + 7][window])) if window.any() else lum[y, x] + light, dark = (BRASS[3], BRASS[0]) if hot else frame + if d == 1: + out[y, x, :3] = light if lum[y, x] >= face_lum else dark + elif abs(lum[y, x] - face_lum) > 32: # a symbol: kept, white turned to cream + r, g, b = px[y, x, :3] + if max(r, g, b) - min(r, g, b) < 24: + out[y, x, :3] = np.array(CREAM, np.float32) * (lum[y, x] / 255) ** 0.5 + else: + base = np.array(face, np.float32) if face is not None else wood[y % 16, x % 16] + out[y, x, :3] = base * (0.55 if face_lum < 70 else 1.12 if hot else 1.0) + return Image.fromarray(np.clip(out, 0, 255).astype(np.uint8), 'RGBA') + + +def casing_buttons(sheet: Image.Image, wood: np.ndarray, brass_wood: np.ndarray, frame, cell: int = 12) -> Image.Image: + """EMI's buttons: a grid of 12 x 12 cells, each a black ring, a one-pixel bevel and a flat face with a symbol. + The ring stays (a white ring — the highlighted state — turns brass), the bevel becomes the casing's metal frame, + a grey face becomes wood (brass casing's darker wood when highlighted, dimmed when disabled); a coloured face (EMI's + green "switched on") keeps its colour. Symbols are kept, grey ones in cream.""" + px = np.asarray(sheet.convert('RGBA')).astype(np.float32) + out = px.copy() + for cy in range(0, px.shape[0], cell): + for cx in range(0, px.shape[1], cell): + c = px[cy:cy + cell, cx:cx + cell] + if c.shape[:2] != (cell, cell) or (c[..., 3] > 0).sum() < cell * cell * 0.9: + continue + lum = c[..., :3].mean(axis=2) + ring = np.zeros((cell, cell), bool) + ring[0, :] = ring[-1, :] = ring[:, 0] = ring[:, -1] = True + bevel = np.zeros((cell, cell), bool) + bevel[1, 1:-1] = bevel[-2, 1:-1] = bevel[1:-1, 1] = bevel[1:-1, -2] = True + inside = ~ring & ~bevel + if lum[ring].mean() > 90 and lum[ring].mean() < 200: + continue # not a button cell + hot = lum[ring].mean() >= 200 + face = np.median(c[inside][:, :3], axis=0) # the face is textured; the symbol covers less of it + face_lum = face.mean() + coloured = face.max() - face.min() > 30 + dim = face_lum < 70 and not coloured + light, dark = (BRASS[3], BRASS[0]) if hot else frame + o = out[cy:cy + cell, cx:cx + cell] + if hot: + o[ring, :3] = BRASS[1] + for y in range(cell): + for x in range(cell): + if bevel[y, x]: + o[y, x, :3] = light if (y == 1 or x == 1) else dark + elif inside[y, x]: + p = c[y, x, :3] + if abs(p.mean() - face_lum) <= 28: # the face + if not coloured: + grain = (brass_wood if hot else wood)[(cy + y) % 16, (cx + x) % 16] + o[y, x, :3] = grain * (0.5 if dim else 1.0) + elif p.mean() < face_lum: # the symbol's shadow + o[y, x, :3] = (brass_wood if hot else wood)[(cy + y) % 16, (cx + x) % 16] * 0.4 + elif p.max() - p.min() < 24: # a grey symbol + o[y, x, :3] = np.array(CREAM, np.float32) * (0.55 if dim else 1.0) return Image.fromarray(np.clip(out, 0, 255).astype(np.uint8), 'RGBA') @@ -414,6 +504,13 @@ def main() -> None: 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') + casing_tile = texture(cr, 'assets/create/textures/block/andesite_casing.png').astype(int) + sheet = np.asarray(Image.open(io.BytesIO(cr.read('assets/create/textures/block/andesite_casing_connected.png'))).convert('RGBA')).astype(int) + cells = [sheet[ty:ty + 16, tx:tx + 16] for ty in range(0, sheet.shape[0], 16) for tx in range(0, sheet.shape[1], 16)] + casing_wood = min((c for c in cells if c[..., 3].min() == 255), key=lambda c: c[..., :3].std())[..., :3] * 0.8 + sheet = np.asarray(Image.open(io.BytesIO(cr.read('assets/create/textures/block/brass_casing_connected.png'))).convert('RGBA')).astype(int) + cells = [sheet[ty:ty + 16, tx:tx + 16] for ty in range(0, sheet.shape[0], 16) for tx in range(0, sheet.shape[1], 16)] + brass_wood = min((c for c in cells if c[..., 3].min() == 255), key=lambda c: c[..., :3].std())[..., :3] * 1.1 # 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), @@ -425,7 +522,7 @@ def main() -> None: '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)} + 'sprites/icon/language.png': on_canvas(globe_icon(13), 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)) @@ -449,15 +546,8 @@ def main() -> None: def mono(s: int, colour) -> Image.Image: return lettering(mask_of(font, NAME, True), colour, s, depth=0, outline=False) - # 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') + wordmark(12).save(OUT / 'logo' / 'wordmark.png') + stack([wordmark(12), motto(4)], gap=20).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') @@ -497,16 +587,19 @@ 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…" - logo.save(OUT / 'menu' / 'logo.png') # shown at a third of its size: one screen pixel per texel at GUI scale 3 + stack([wordmark(8), motto(3)], gap=12).save(OUT / 'menu' / 'logo.png') # --- every button of the game: andesite casing, brass casing under the cursor --------------------------------- # 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])): + andesite = (tuple(int(v) for v in casing_tile[1, 8]), tuple(int(v) for v in casing_tile[14, 8])) + for name, make in (('buttons', lambda s: casing_buttons(s, casing_wood, brass_wood, andesite)), + ('background', lambda s: casingify(s, casing_wood, andesite, face=(222, 208, 178))), + ('widgets', lambda s: greys_to(s, CREAM))): 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) + make(sprite).save(target) # branding/resources//… goes into the game as kubejs/assets//… for path, sprite in gui.items(): @@ -516,8 +609,8 @@ def main() -> None: 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') + button_icon(QUIT_ICON, canvas=24).save(OUT / 'menu' / 'quit.png') # the corner buttons are 24 x 24 + on_canvas(gear_icon(14), 24).save(OUT / 'menu' / 'settings.png') for name, rows in (('online', ONLINE_ICON), ('offline', OFFLINE_ICON), ('maintenance', MAINTENANCE_ICON)): 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')))) diff --git a/tools/branding/fancymenu.py b/tools/branding/fancymenu.py index b448cc0..8295d2b 100644 --- a/tools/branding/fancymenu.py +++ b/tools/branding/fancymenu.py @@ -194,8 +194,9 @@ class Layout: # --- the screens ------------------------------------------------------------------------------------------------------ def logo_size() -> tuple: + """The logo is 221 GUI pixels wide everywhere.""" w, h = Image.open(MENU / 'logo.png').size - return w // 3, h // 3 + return 221, round(h * 221 / w) def title_screen(version: str, labels: dict) -> Layout: @@ -209,11 +210,12 @@ def title_screen(version: str, labels: dict) -> Layout: lay.vanilla('mc_titlescreen_singleplayer_button', anchor='mid-centered', x=-100, y=0, w=98) lay.vanilla('mc_titlescreen_multiplayer_button', anchor='mid-centered', x=2, y=0, w=98, label='Сервери') - # bottom right corner: language, options, quit. Anchors give the corner; offsets are the element's top left. - lay.vanilla('376388', anchor='bottom-right', x=-72, y=-24, w=20) # language - lay.button('bottom-right', -48, -24, 20, icon='settings.png', tooltip='Налаштування', + # bottom right corner: language, options, quit — 24 x 24, so a 14 px icon fits inside the casing frame. + # Anchors give the corner; offsets are the element's top left. + lay.vanilla('376388', anchor='bottom-right', x=-84, y=-28, w=24, h=24) # language + lay.button('bottom-right', -56, -28, 24, 24, icon='settings.png', tooltip='Налаштування', action=('opengui', SCREENS + 'options.OptionsScreen')) - lay.button('bottom-right', -24, -24, 20, icon='quit.png', tooltip='Вийти з гри', action=('quitgame', '')) + lay.button('bottom-right', -28, -28, 24, 24, icon='quit.png', tooltip='Вийти з гри', action=('quitgame', '')) lay.vanilla('title_screen_copyright_button', anchor='bottom-centered', x=-98, y=-12, w=196, h=10) # bottom left corner: the pack version and whether a newer release is out @@ -261,7 +263,10 @@ def game_menu() -> Layout: lay.button('mid-centered', 2, -4, 100, label='Знайшов баг?', action=('openlink', GIT + '/issues/new'), 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) + lay.button('mid-centered', 2, 20, 100, label='Скарги на гравців', action=('paste_to_chat', 'false:/report '), + tooltip='Напиши нік гравця й що сталося, потім Enter — скаргу отримають модератори', + visible=[(SERVER_IP, 'if', HOST)]) + lay.button('mid-centered', 2, 20, 100, label='Скарги на гравців', active=NEVER, visible=[(SERVER_IP, 'if_not', HOST)]) # leaving: from our server straight to the title screen, from another one to the server list as usual ours, online = (SERVER_IP, 'if', HOST), (MULTIPLAYER, 'if', '') elsewhere = (SERVER_IP, 'if_not', HOST) @@ -336,7 +341,7 @@ 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 + options = option(options, 'global_menu_background_texture', '') # it also covered the world behind the game menu (fm / 'options.txt').write_text(options, encoding='utf-8') for source in RESOURCES.rglob('*'): # branding/resources//… → kubejs/assets//…