9 changed files with 200 additions and 3 deletions
@ -0,0 +1,139 @@ |
|||||
|
class gbxReplay { |
||||
|
|
||||
|
CHUNKS_OFFSET = 17; |
||||
|
HEADER_OFFSET = 21; |
||||
|
UNASSIGNED = 0xFFFFFFFF; |
||||
|
|
||||
|
calcChunkOffset(num) { |
||||
|
return (((num) * 8) + this.HEADER_OFFSET) |
||||
|
} |
||||
|
|
||||
|
isNumber(id) { return (((id) & 0xC0000000) == 0)} |
||||
|
isString(id) { return (((id) & 0xC0000000) != 0)} |
||||
|
isUnassigned(id) {return ((id) == this.UNASSIGNED)} |
||||
|
getIndex(id) {return ((id) & 0x3FFFFFFF)} |
||||
|
|
||||
|
readIdentifier(buff, idList, outString, stringLen) |
||||
|
{ |
||||
|
if ( idList.version < 3 ) { |
||||
|
idList.version = buff.readUInt32(); |
||||
|
} |
||||
|
|
||||
|
let id = buff.readUInt32(); |
||||
|
if(this.isUnassigned(id)) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if(this.isNumber(id)){ |
||||
|
console.log("number") |
||||
|
} |
||||
|
|
||||
|
if(idList.version == 2) { |
||||
|
outString = buff.readString(stringLen) |
||||
|
console.log(outString) |
||||
|
} |
||||
|
|
||||
|
if(this.isString(id) && this.getIndex(id) == 0) { |
||||
|
outString = buff.readString(stringLen) |
||||
|
|
||||
|
console.log(outString) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
parseReplayChunk(buff, chunkInfo) { |
||||
|
buff.seek(0+chunkInfo.dwOffset); |
||||
|
let version = buff.readUInt32(); |
||||
|
let isVSK = version >= 9999 ? true : false; |
||||
|
|
||||
|
let idList = { version: 0, index: 0, list:[[]]} |
||||
|
|
||||
|
if( chunkInfo.dwSize <= 4) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if((!isVSK && version >= 3) || (isVSK && version >= 10000)) { |
||||
|
let outString = ""; |
||||
|
this.readIdentifier(buff, idList, outString, 512); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
parseAuthorChunk(buff, chunkInfo) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
parseCommunityChunk(buff, chunkInfo) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
parse(buff) |
||||
|
{ |
||||
|
buff.seek(0+this.CHUNKS_OFFSET); |
||||
|
let numChunks = buff.readUInt32(); |
||||
|
|
||||
|
if(numChunks == 0) { |
||||
|
return true; |
||||
|
} |
||||
|
else if (numChunks > 0xff) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
let chunkId, chunkSize = 0; |
||||
|
let chunkOffset = this.calcChunkOffset(numChunks) |
||||
|
let chunkVersion = {} |
||||
|
let chunkCommunity = {} |
||||
|
let chunkAuthor = {} |
||||
|
|
||||
|
for (let counter = 1; counter <= numChunks; counter++) { |
||||
|
chunkId = buff.readUInt32(); |
||||
|
chunkSize = buff.readUInt32(); |
||||
|
|
||||
|
chunkSize &= 0x7FFFFFFF; |
||||
|
|
||||
|
switch (chunkId){ |
||||
|
case 0x03093000: // (TM)
|
||||
|
case 0x2403F000: // (VSK, TM)
|
||||
|
chunkVersion.dwId = chunkId; |
||||
|
chunkVersion.dwSize = chunkSize; |
||||
|
chunkVersion.dwOffset = chunkOffset; |
||||
|
chunkOffset += chunkSize; |
||||
|
break; |
||||
|
case 0x03093001: // (TM)
|
||||
|
case 0x2403F001: // (VSK, TM)
|
||||
|
chunkCommunity.dwId = chunkId; |
||||
|
chunkCommunity.dwSize = chunkSize; |
||||
|
chunkCommunity.dwOffset = chunkOffset; |
||||
|
chunkOffset += chunkSize; |
||||
|
//OutputTextFmt(hwndCtl, szOutput, _countof(szOutput), g_szChunk, dwCouter, dwChunkId, dwChunkSize);
|
||||
|
break; |
||||
|
|
||||
|
case 0x03093002: // (MP)
|
||||
|
chunkAuthor.dwId = chunkId; |
||||
|
chunkAuthor.dwSize = chunkSize; |
||||
|
chunkAuthor.dwOffset = chunkOffset; |
||||
|
chunkOffset += chunkSize; |
||||
|
//OutputTextFmt(hwndCtl, szOutput, _countof(szOutput), g_szChunk, dwCouter, dwChunkId, dwChunkSize);
|
||||
|
break; |
||||
|
|
||||
|
default: |
||||
|
chunkOffset += chunkSize; |
||||
|
//OutputTextFmt(hwndCtl, szOutput, _countof(szOutput), g_szChunk, dwCouter, dwChunkId, dwChunkSize);
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (chunkVersion.dwSize > 0) { |
||||
|
this.parseReplayChunk(buff, chunkVersion); |
||||
|
} |
||||
|
|
||||
|
if (chunkCommunity.dwSize > 0) { |
||||
|
this.parseCommunityChunk(buff, chunkCommunity); |
||||
|
} |
||||
|
|
||||
|
if (chunkAuthor.dwSize > 0) { |
||||
|
this.parseAuthorChunk(buff, chunkAuthor); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
module.exports = gbxReplay; |
||||
@ -0,0 +1,3 @@ |
|||||
|
.full-width-button { |
||||
|
width: 100%; |
||||
|
} |
||||
@ -1 +1,12 @@ |
|||||
<p>upload-replay-dialog works!</p> |
<input type="file" class="file-input" |
||||
|
(change)="onFileSelected($event)" #fileUpload> |
||||
|
|
||||
|
<div class="file-upload"> |
||||
|
|
||||
|
{{fileName || "No file uploaded yet."}} |
||||
|
|
||||
|
<button mat-fab color="primary" class="upload-btn" |
||||
|
(click)="fileUpload.click()"> |
||||
|
<mat-icon>attach_file</mat-icon> |
||||
|
</button> |
||||
|
</div> |
||||
|
|||||
@ -0,0 +1,3 @@ |
|||||
|
.file-input { |
||||
|
display: none; |
||||
|
} |
||||
Loading…
Reference in new issue