-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
158 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import ColumnListHeader from './ColumnListHeader'; | ||
import ColumnListItem from './ColumnListItem'; | ||
|
||
const TitleGfxList = ({ gfx, currentId }) => { | ||
return ( | ||
<> | ||
<ColumnListHeader>Title gfx</ColumnListHeader> | ||
{gfx.map(({ metadata }) => { | ||
const selected = metadata.id === currentId; | ||
const path = `/titlegfx/${metadata.id}`; | ||
const label = `Tileset ${metadata.id}`; | ||
|
||
return ( | ||
<ColumnListItem | ||
key={metadata.id} | ||
path={selected ? null : path}> | ||
{label} | ||
</ColumnListItem> | ||
); | ||
})} | ||
</> | ||
); | ||
}; | ||
|
||
export default TitleGfxList; |
30 changes: 19 additions & 11 deletions
30
src/containers/RoomGfxContainer.js → src/containers/GfxContainer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,56 @@ | ||
import { useParams } from 'react-router-dom'; | ||
import { useMatch, useParams } from 'react-router-dom'; | ||
import PrimaryColumn from '../components/PrimaryColumn'; | ||
import RoomGfxList from '../components/RoomGfxList'; | ||
import TitleGfxList from '../components/TitleGfxList'; | ||
import Main from '../components/Main'; | ||
import MainHeader from '../components/MainHeader'; | ||
import ResourceMetadata from '../components/ResourceMetadata'; | ||
import GfxCanvasContainer from './GfxCanvasContainer'; | ||
|
||
const RoomGfxContainer = ({ roomgfx }) => { | ||
const GfxContainer = ({ roomgfx, titlegfx }) => { | ||
const isRoomGfx = !!useMatch('/roomgfx/:gfcId'); | ||
const { gfcId } = useParams(); | ||
|
||
const currentGfcId = | ||
typeof gfcId === 'undefined' ? null : parseInt(gfcId, 10); | ||
const roomgfc = roomgfx[currentGfcId]; | ||
const gfc = isRoomGfx ? roomgfx[currentGfcId] : titlegfx[currentGfcId]; | ||
|
||
if (!roomgfc) { | ||
if (!gfc) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<PrimaryColumn> | ||
<RoomGfxList | ||
roomgfx={roomgfx} | ||
currentId={currentGfcId} | ||
gfx={roomgfx} | ||
currentId={isRoomGfx ? currentGfcId : null} | ||
/> | ||
<TitleGfxList | ||
gfx={titlegfx} | ||
currentId={isRoomGfx ? null : currentGfcId} | ||
/> | ||
</PrimaryColumn> | ||
<Main> | ||
<MainHeader | ||
title={ | ||
currentGfcId === null | ||
? 'Room graphics' | ||
: `Room graphics tileset ${currentGfcId}` | ||
? 'Graphics' | ||
: isRoomGfx | ||
? `Room graphics tileset ${currentGfcId}` | ||
: `Title graphics tileset ${currentGfcId}` | ||
}> | ||
{currentGfcId !== null && ( | ||
<ResourceMetadata metadata={roomgfc.metadata} /> | ||
<ResourceMetadata metadata={gfc.metadata} /> | ||
)} | ||
</MainHeader> | ||
<GfxCanvasContainer | ||
gfx={roomgfc.gfx} | ||
gfx={gfc.gfx} | ||
zoom={3} | ||
/> | ||
</Main> | ||
</> | ||
); | ||
}; | ||
|
||
export default RoomGfxContainer; | ||
export default GfxContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Parser from './parser.js'; | ||
import { hex } from '../utils.js'; | ||
|
||
const assert = console.assert; | ||
|
||
const parseTitles = (arrayBuffer, i = 0, offset = 0) => { | ||
const parser = new Parser(arrayBuffer); | ||
const metadata = { | ||
id: i, | ||
offset, | ||
size: arrayBuffer.byteLength, | ||
// decompressedSize: 0, // Comment out decompressed size until the buffer size is known. | ||
}; | ||
|
||
const unk1 = parser.getUint16(); // Probably resource length unused in titles. | ||
const unk2 = parser.getUint16(); | ||
|
||
assert(unk1 === 0, 'Unknown 1 is not 0.'); | ||
assert(unk2 === 0x0f10, 'Unknown 2 is not 0x0f10.'); | ||
|
||
const numberOfTiles = parser.getUint8() + 1; | ||
|
||
console.log('numberOfTiles', numberOfTiles); | ||
|
||
const gfx = []; | ||
let n = 0; | ||
while (n < numberOfTiles * 16) { | ||
const loop = parser.getUint8(); | ||
if (loop & 0x80) { | ||
for (let j = 0; j < (loop & 0x7f); j++) { | ||
gfx[n++] = parser.getUint8(); | ||
} | ||
} else { | ||
const data = parser.getUint8(); | ||
for (let j = 0; j < (loop & 0x7f); j++) { | ||
gfx[n++] = data; | ||
} | ||
} | ||
} | ||
|
||
assert( | ||
numberOfTiles === gfx.length / 8 / 2, | ||
'Number of tiles byte does not match number of tiles decoded.', | ||
); | ||
|
||
// metadata.decompressedSize = gfx.length; | ||
|
||
return { | ||
metadata, | ||
unk1, | ||
unk2, | ||
numberOfTiles, | ||
gfx, | ||
}; | ||
}; | ||
|
||
export default parseTitles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters