diff --git a/src/components/RoomsList.js b/src/components/RoomsList.js
index 074d289..40446a6 100644
--- a/src/components/RoomsList.js
+++ b/src/components/RoomsList.js
@@ -1,11 +1,11 @@
import ColumnListHeader from './ColumnListHeader';
import ColumnListItem from './ColumnListItem';
-const RoomsList = ({ rooms, currentId }) => {
+const RoomsList = ({ items, currentId }) => {
return (
<>
Rooms
- {rooms.map(({ metadata, header }) => {
+ {items.map(({ metadata, header }) => {
if (!header) {
// Some rooms are empty.
return null;
diff --git a/src/components/TitlesList.js b/src/components/TitlesList.js
new file mode 100644
index 0000000..14b56db
--- /dev/null
+++ b/src/components/TitlesList.js
@@ -0,0 +1,25 @@
+import ColumnListHeader from './ColumnListHeader';
+import ColumnListItem from './ColumnListItem';
+
+const TitlesList = ({ items, currentId }) => {
+ return (
+ <>
+
Titles
+ {items.map(({ metadata }) => {
+ const selected = metadata.id === currentId;
+ const path = `/titles/${metadata.id}`;
+ const label = `Title ${metadata.id}`;
+
+ return (
+
+ {label}
+
+ );
+ })}
+ >
+ );
+};
+
+export default TitlesList;
diff --git a/src/containers/ResourceExplorer.js b/src/containers/ResourceExplorer.js
index da24dc4..cfcdc4e 100644
--- a/src/containers/ResourceExplorer.js
+++ b/src/containers/ResourceExplorer.js
@@ -3,6 +3,7 @@ import RoomsContainer from './RoomsContainer';
import GfxContainer from './GfxContainer';
import PrepositionsContainer from './PrepositionsContainer';
import RomMapContainer from './RomMapContainer';
+import TitlesContainer from './TitlesContainer';
import SettingsContainer from './SettingsContainer';
import ScriptContainer from './ScriptContainer';
@@ -18,21 +19,41 @@ const ResourceExplorer = ({ rom, res, resources }) => {
element={
}>
}
/>
+
+ }>
+
+ }
+ />
+
{
- const { roomId } = useParams();
+const RoomsContainer = ({ rooms, titles, roomgfx, globdata }) => {
+ const isRoom = !!useMatch('/rooms/:id');
+ const { id } = useParams();
const [hoveredObject, setHoveredObject] = useState(null);
const [selectedObjects, setSelectedObjects] = useState([]);
const [hoveredBox, setHoveredBox] = useState(null);
const [currentTab, setCurrentTab] = useState('Palettes');
const [room, setRoom] = useState(null);
- const currentRoomId =
- typeof roomId === 'undefined' ? null : parseInt(roomId, 10);
+ const currentId = typeof id === 'undefined' ? null : parseInt(id, 10);
const baseTiles = roomgfx?.find(({ metadata }) => metadata.id === 0);
let roomgfc = roomgfx?.find(
({ metadata }) => metadata.id === room?.nametable?.tileset,
@@ -29,7 +30,7 @@ const RoomsContainer = ({ rooms, roomgfx, globdata }) => {
useEffect(() => {
const room =
- rooms.find(({ metadata }) => metadata.id === currentRoomId) || null;
+ rooms.find(({ metadata }) => metadata.id === currentId) || null;
setRoom(room);
// Clear the selected objects when the room changes.
@@ -40,7 +41,7 @@ const RoomsContainer = ({ rooms, roomgfx, globdata }) => {
selectedObjects[i] = !!(initialState & 0b10000000);
}
setSelectedObjects(selectedObjects);
- }, [roomId]);
+ }, [id]);
const setSelectedObjectState = (id, state) => {
const newSelectedObjects = [...selectedObjects];
@@ -75,8 +76,12 @@ const RoomsContainer = ({ rooms, roomgfx, globdata }) => {
<>
+
{(room?.objectImages?.length || room?.boxes?.length) && (
diff --git a/src/containers/RoomCanvasContainer.js b/src/containers/ScreenCanvasContainer.js
similarity index 69%
rename from src/containers/RoomCanvasContainer.js
rename to src/containers/ScreenCanvasContainer.js
index 9803cdc..4402f7a 100644
--- a/src/containers/RoomCanvasContainer.js
+++ b/src/containers/ScreenCanvasContainer.js
@@ -2,28 +2,31 @@ import { useRef, useState, useEffect } from 'react';
import { clsx } from 'clsx';
import { getPalette } from '../lib/paletteUtils';
-const RoomCanvasContainer = ({
- room,
+// Display a screen on a canvas. Used by rooms and title screens.
+
+const ScreenCanvasContainer = ({
+ screen,
baseTiles,
- roomgfc,
+ gfc,
selectedObjects,
hoveredBox,
+ crop = true,
zoom = 1,
}) => {
const canvasRef = useRef(null);
const [isComputing, setIsComputing] = useState(true);
- const { width, height } = room.header;
+ const { width, height } = screen.header;
useEffect(() => {
const canvas = canvasRef.current;
const ctx = canvas.getContext('2d');
setTimeout(() => {
- draw(ctx, room, baseTiles, roomgfc, selectedObjects);
- drawBoxes(ctx, room.boxes, hoveredBox);
+ draw(ctx, screen, baseTiles, gfc, selectedObjects, crop);
+ drawBoxes(ctx, screen.boxes, hoveredBox);
setIsComputing(false);
});
- }, [room, selectedObjects, hoveredBox]);
+ }, [screen, selectedObjects, hoveredBox, crop]);
return (