"""Build the native inventory backgrounds from existing approved seals and portrait atlas. No invented adviser artwork. The Java UI is a native 176px inventory, not HTML. """ from pathlib import Path import json from PIL import Image,ImageDraw,ImageFont,ImageOps ROOT=Path(__file__).resolve().parents[1] BASE=ROOT/'DuneResourcePack/assets/dunerealms' OUT=BASE/'textures/gui/house_selector';OUT.mkdir(parents=True,exist_ok=True) HOUSES=[('atreides','AERDRECHT','house-aerdrecht-v1.png','Thufir Hawat'),('harkonnen','HARKVEEN','house-harkveen-v1.png','Piter de Vries'),('corrino','KORENHOLT','house-korenholt-v1.png','Count Hasimir Fenring'),('ordos','OORDWIJK','house-oordwijk-v1.png','Roma Atani'),('fremen','VRIJDUIN','house-vrijduin-v1.png','Stilgar')] SCALE=4 GOLD='#bda15c';LIGHT='#f2d995';GREEN='#12372b';font=lambda n:ImageFont.load_default(size=n*SCALE) def rectangle(im,box,**kwargs): if 'width' in kwargs:kwargs['width']*=SCALE ImageDraw.Draw(im).rectangle(tuple(round(v*SCALE) for v in box),**kwargs) def text(im,x,y,t,n=7,fill=LIGHT): d=ImageDraw.Draw(im);f=font(n);w=d.textbbox((0,0),t,font=f)[2];d.text((round(x*SCALE-w/2),round(y*SCALE)),t,font=f,fill=fill) def base(): im=Image.new('RGBA',(176*SCALE,222*SCALE),'#0a2119') rectangle(im,(0,0,175,221),outline=GOLD,width=1);rectangle(im,(3,3,172,126),outline='#62572e',width=1) # Minecraft draws the player inventory caption itself; do not bake a second one. for y in [140,158,176,198]: for x in range(8,170,18):rectangle(im,(x-1,y-1,x+16,y+16),fill='#0a1c17',outline='#52604a',width=1) return im def button(im,box,label): rectangle(im,box,fill='#294b32',outline=GOLD,width=1);text(im,(box[0]+box[2])/2,box[1]+4,label,7) providers=[{'type':'space','advances':{'\ue32f':-8,'\ue32e':-1,'\ue32d':-176}}] def save_screen(im,name,index): im.save(OUT/name) tiles=OUT/'tiles';tiles.mkdir(exist_ok=True) padded=Image.new('RGBA',(704,896));padded.alpha_composite(im) for row in range(4): for column in range(4): file=f'screen-{index}-{row}-{column}.png' padded.crop((column*176,row*224,(column+1)*176,(row+1)*224)).save(tiles/file) providers.append({'type':'bitmap','file':f'dunerealms:gui/house_selector/tiles/{file}','ascent':13-row*56,'height':56,'chars':[chr(0xe400+index*16+row*4+column)]}) coords=[(8,26,59,61),(62,26,113,61),(116,26,167,61),(26,62,77,97),(98,62,149,97)] for selected in range(-1,5): im=base();text(im,88,5,'CHOOSE YOUR HOUSE',9);text(im,88,17,'DECLARE YOUR ALLEGIANCE',6) for i,(id,name,file,mentor) in enumerate(HOUSES): box=coords[i];rectangle(im,box,fill='#32583c' if i==selected else '#15352a',outline=LIGHT if i==selected else '#766339',width=1) seal=Image.open(ROOT/'website/web/assets/seals'/file).convert('RGBA');seal.thumbnail((24*SCALE,24*SCALE),Image.Resampling.LANCZOS);im.alpha_composite(seal,(round((box[0]+box[2])*SCALE/2-seal.width/2),(box[1]+2)*SCALE));text(im,(box[0]+box[2])/2,box[3]-8,name,7) text(im,88,99,('SELECTED: '+HOUSES[selected][1]) if selected>=0 else 'SELECT A HOUSE TO CONTINUE',6) button(im,(8,108,43,125),'CLOSE') button(im,(62,108,113,125),'SCOREBOARD') if selected>=0:button(im,(130,108,167,125),'CONFIRM') save_screen(im,f'select-{selected+1}.png',selected+1) atlas=Image.open(ROOT/'website/web/assets/mentat-portraits-atlas-v1.png').convert('RGBA');cw=atlas.width//4;ch=atlas.height//2 for i,(id,name,file,mentor) in enumerate(HOUSES): im=base();text(im,88,5,'YOUR MENTAT',10);text(im,88,17,name,6) portrait=atlas.crop(((i%4)*cw,(i//4)*ch,(i%4+1)*cw,(i//4+1)*ch));portrait=ImageOps.fit(portrait,(58*SCALE,45*SCALE),method=Image.Resampling.LANCZOS);im.alpha_composite(portrait,(59*SCALE,26*SCALE));rectangle(im,(58,25,117,71),outline=GOLD,width=1) text(im,88,73,mentor,8 if len(mentor)<20 else 7);text(im,88,82,'YOUR BRIEFING IS READY',5) button(im,(26,89,77,106),'REPORT');button(im,(98,89,149,106),'TRAVEL');button(im,(8,108,43,125),'HOUSE') button(im,(62,108,113,125),'SCOREBOARD') save_screen(im,f'mentat-{id}.png',i+6) # Standalone cell images are also reusable by Bedrock form buttons. cell=atlas.crop(((i%4)*cw,(i//4)*ch,(i%4+1)*cw,(i//4+1)*ch));cell.save(ROOT/f'website/web/assets/gui/mentat-{id}-v1.png') ROUTES=[('caladan','KALADAM','pelareth'),('giedi-prime','GIEDERMARK','varkesh'),('kaitain','KAITERHOF','orivane'),('sigma-draconis-iv','SIGMADRAKEN IV','nivareth'),('arrakis','ARRAKDUIN','serevan')] for selected in range(5): im=base();text(im,88,5,'SPACING GUILD',10);text(im,88,17,'IMPERIAL DEPARTURES',6) for i,(world,name,sigil) in enumerate(ROUTES): allowed=i==selected;box=coords[i] rectangle(im,box,fill='#32583c' if allowed else '#142521',outline=LIGHT if allowed else '#46504a',width=1) icon=Image.open(ROOT/f'website/web/assets/planet-glyphs/{sigil}-128.png').convert('RGBA') if not allowed: alpha=icon.getchannel('A');icon=ImageOps.grayscale(icon).convert('RGBA');icon.putalpha(alpha) icon.thumbnail((23*SCALE,23*SCALE),Image.Resampling.LANCZOS) im.alpha_composite(icon,(round((box[0]+box[2])*SCALE/2-icon.width/2),(box[1]+2)*SCALE)) text(im,(box[0]+box[2])/2,box[3]-8,name,5 if len(name)>12 else 6,fill=LIGHT if allowed else '#7e8b80') text(im,88,99,'YOUR HOUSE WORLD ONLY - EVERY 15 MIN',5) button(im,(8,108,43,125),'BACK');button(im,(62,108,113,125),'CANCEL');button(im,(130,108,167,125),'BOOK') save_screen(im,f'travel-{HOUSES[selected][0]}.png',11+selected) for world,name,sigil in ROUTES: icon=Image.open(ROOT/f'website/web/assets/planet-glyphs/{sigil}-128.png').convert('RGBA') icon.save(ROOT/f'website/web/assets/gui/guild-world-{world}-v1.png') alpha=icon.getchannel('A');icon=ImageOps.grayscale(icon).convert('RGBA');icon.putalpha(alpha) icon.save(ROOT/f'website/web/assets/gui/guild-world-{world}-locked-v1.png') (BASE/'font').mkdir(exist_ok=True);(BASE/'font/house_selector.json').write_text(json.dumps({'providers':providers},indent=2)) (BASE/'items/drgui_transparent.json').write_text(json.dumps({'model':{'type':'minecraft:model','model':'dunerealms:item/drgui_transparent'}})) (BASE/'models/item/drgui_transparent.json').write_text(json.dumps({'parent':'minecraft:item/generated','textures':{'layer0':'dunerealms:item/drgui_transparent'}})) Image.new('RGBA',(1,1),(0,0,0,0)).save(BASE/'textures/item/drgui_transparent.png') print('Rendered six House selectors, five Mentats, five Guild screens and native form icons.')