Package the website logo for the DuneMenus title

This commit is contained in:
unimatrixgit 2026-11-28 15:48:26 +01:00
commit 911e581b1d
6 changed files with 35 additions and 4 deletions

View file

@ -102,7 +102,7 @@ jobs:
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(data)
PYTHON
node tools/build-central-resource-pack.mjs central-pack-base central-pack-output 3
node tools/build-central-resource-pack.mjs central-pack-base central-pack-output 4 network/resource-pack/shared
printf '%s\n' "$GITHUB_SHA" > central-pack-output/SOURCE_COMMIT
(cd central-pack-output && sha256sum -- *.zip central-pack-manifest.json SOURCE_COMMIT > SHA256SUMS)
- uses: actions/upload-artifact@v3

View file

@ -0,0 +1,13 @@
{
"providers": [
{
"type": "bitmap",
"file": "dunerealms:gui/menu-logo.png",
"height": 9,
"ascent": 8,
"chars": [
"\ue000"
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -129,12 +129,15 @@ export function buildCentralPack(baseDir,output,version,assetDirectories=[]){
const metadata=JSON.parse(entries.get('pack.mcmeta'));
metadata.pack.description='DuneRealms Central Resource Pack v'+version;
entries.set('pack.mcmeta',json(metadata));
const bytes=zip(entries),filename='DuneRealms-Central-v'+version+'.zip';
const sizes=[];
const bytes=zip(entries,(name,compressedBytes)=>sizes.push({name,compressedBytes}));
const filename='DuneRealms-Central-v'+version+'.zip';
const largestEntries=sizes.sort((a,b)=>b.compressedBytes-a.compressedBytes).slice(0,10);
if(bytes.length>=250*1024*1024)throw Error('The central pack exceeds the Java client download limit');
const manifest={
filename,url:'https://www.dunerealms.com/downloads/'+filename,
sha1:hash('sha1',bytes),sha256:hash('sha256',bytes),
bytes:bytes.length,profiles:Object.fromEntries(Object.entries(profiles).map(([id,profile])=>[id,profile.aliases]))
bytes:bytes.length,largestEntries,profiles:Object.fromEntries(Object.entries(profiles).map(([id,profile])=>[id,profile.aliases]))
};
fs.mkdirSync(output,{recursive:true});
fs.writeFileSync(path.join(output,filename),bytes);

View file

@ -17,11 +17,12 @@ const table=Array.from({length:256},(_,n)=>{for(let i=0;i<8;i++)n=(n&1)?0xedb883
const crc32=bytes=>{let n=0xffffffff;for(const b of bytes)n=table[(n^b)&255]^(n>>>8);return (n^0xffffffff)>>>0;};
const digest=(algorithm,bytes)=>createHash(algorithm).update(bytes).digest('hex');
export function zip(entries){
export function zip(entries,onEntry){
const locals=[],directory=[];let offset=0;
for(const [name,data] of [...entries].sort(([a],[b])=>a<b?-1:a>b?1:0)){
if(!/^[a-zA-Z0-9_./-]+$/.test(name)||name.startsWith('/')||name.split('/').includes('..'))throw Error('Unsafe ZIP path');
const key=Buffer.from(name),body=deflateRawSync(data,{level:9}),crc=crc32(data);
onEntry?.(name,body.length);
const local=Buffer.alloc(30);local.writeUInt32LE(0x04034b50);local.writeUInt16LE(20,4);local.writeUInt16LE(8,8);local.writeUInt16LE(0x5d77,12);local.writeUInt32LE(crc,14);local.writeUInt32LE(body.length,18);local.writeUInt32LE(data.length,22);local.writeUInt16LE(key.length,26);
locals.push(local,key,body);
const central=Buffer.alloc(46);central.writeUInt32LE(0x02014b50);central.writeUInt16LE(20,4);central.writeUInt16LE(20,6);central.writeUInt16LE(8,10);central.writeUInt16LE(0x5d77,14);central.writeUInt32LE(crc,16);central.writeUInt32LE(body.length,20);central.writeUInt32LE(data.length,24);central.writeUInt16LE(key.length,28);central.writeUInt32LE(offset,42);directory.push(central,key);

View file

@ -158,3 +158,17 @@ test('source assets combine only recognized additive JSON and report every colli
error=>error.message.includes(lang+'#dune')&&error.message.includes(texture));
assert.throws(()=>mergePackAssets(first,[inputs({'assets/dr_arrakis/../logo.png':'bad'})]),/Invalid resource asset path/);
});
test('the supplied DuneMenus logo glyph points to compact shared artwork',()=>{
const originalSource=new URL('../network/resource-pack/shared/',import.meta.url);
const fontFile='assets/dunerealms/font/menu.json';
const font=JSON.parse(fs.readFileSync(new URL(fontFile,originalSource)));
const provider=font.providers.find(entry=>entry.chars.includes('\ue000'));
assert.equal(provider.file,'dunerealms:gui/menu-logo.png');
assert(provider.ascent<=provider.height);
const image=fs.readFileSync(new URL('assets/dunerealms/textures/gui/menu-logo.png',originalSource));
assert.equal(image.subarray(0,8).toString('hex'),'89504e470d0a1a0a');
assert(image.readUInt32BE(16)<=96);
assert(image.readUInt32BE(20)<=36);
assert(image.length<16*1024);
});