branding/ holds the first pass of the project's look: the Create RP wordmark in Minecraft's pixel font filled with Create's brass texture, the gear mark, the state emblem, icons, four banners and the title screen for FancyMenu (background, logo, layout). tools/branding/build.py redraws everything from the key art; tools/branding/fancymenu.py installs the title screen into a config folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.4 KiB
Python
51 lines
2.4 KiB
Python
"""Writes the FancyMenu configuration of the Create RP title screen into a game's config folder.
|
|
|
|
python tools/branding/fancymenu.py <config dir> e.g. the client pack's config/ or a profile's config/
|
|
|
|
Layout: the key art as the background, our logo instead of Minecraft's, one wide button that joins the server,
|
|
then the usual buttons. The layout file itself is branding/menu/title_screen_layout.txt; this script only copies it
|
|
with the pictures and switches the window title, the window icon and the title-screen customisation on.
|
|
"""
|
|
import re
|
|
import shutil
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent.parent
|
|
MENU, ICONS = ROOT / 'branding' / 'menu', ROOT / 'branding' / 'icons'
|
|
WINDOW_TITLE = 'Create RP'
|
|
|
|
|
|
def option(text: str, key: str, value: str) -> str:
|
|
pattern = re.compile(r"^(\w:" + re.escape(key) + r" = ')[^']*(';)", re.M)
|
|
if not pattern.search(text):
|
|
raise SystemExit('FancyMenu option not found: ' + key)
|
|
return pattern.sub(lambda m: m.group(1) + value + m.group(2), text)
|
|
|
|
|
|
def main() -> None:
|
|
fm = Path(sys.argv[1]) / 'fancymenu'
|
|
(fm / 'assets').mkdir(parents=True, exist_ok=True)
|
|
(fm / 'customization').mkdir(parents=True, exist_ok=True)
|
|
shutil.copyfile(MENU / 'logo.png', fm / 'assets' / 'logo.png')
|
|
shutil.copyfile(MENU / 'background.png', fm / 'assets' / 'background.png')
|
|
for icon in ('favicon-16x16.png', 'favicon-32x32.png'):
|
|
shutil.copyfile(ICONS / icon, fm / 'assets' / icon)
|
|
shutil.copyfile(MENU / 'title_screen_layout.txt', fm / 'customization' / 'title_screen_layout.txt')
|
|
(fm / 'customizablemenus.txt').write_text(
|
|
'type = customizablemenus\n\nnet.minecraft.client.gui.screens.TitleScreen {\n}\n\n', encoding='utf-8')
|
|
|
|
options = (fm / 'options.txt').read_text(encoding='utf-8')
|
|
options = option(options, 'custom_window_title', WINDOW_TITLE)
|
|
options = option(options, 'show_custom_window_icon', 'true')
|
|
options = option(options, 'custom_window_icon_16', '/config/fancymenu/assets/favicon-16x16.png')
|
|
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', '')
|
|
(fm / 'options.txt').write_text(options, encoding='utf-8')
|
|
print('title screen installed into', fm)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|