Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion media/editor/dmiEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
import * as ReactDOM from "react-dom/client";
import "./dmiEditor.css";
import * as select from "./state";
import { Dmi, DmiState } from "../../shared/dmi";
import { Dirs, Dmi, DmiState } from "../../shared/dmi";
import {
DocumentChangedEventMessage,
MessageType,
Expand All @@ -26,6 +26,23 @@ const Editor: React.FC = () => {
setZoom(value);
};

const [direction, setDirection] = useState(Dirs.SOUTH);
const ROTATION_DIRECTIONS = [
Dirs.SOUTH,
Dirs.WEST,
Dirs.NORTH,
Dirs.EAST
];
const cycleDirection = (counterclockwise: boolean) => {
let index = ROTATION_DIRECTIONS.indexOf(direction);
counterclockwise ? index-- : index++;
if (index < 0)
index = ROTATION_DIRECTIONS.length - 1;
else if (index > ROTATION_DIRECTIONS.length - 1)
index = 0;
setDirection(ROTATION_DIRECTIONS[index]);
};

const [openStateIndex, setOpenStateIndexRaw] = useState<number | null>(null);
const setOpenStateIndex = (value: number | null) => {
select.sessionPersistentData.setOpenStateId(value);
Expand Down Expand Up @@ -155,6 +172,16 @@ const Editor: React.FC = () => {
</VSCodeButton>
</div>
);
const dirDisplay = (
<div>
<VSCodeButton appearance="icon" onClick={() => cycleDirection(true)}>
<span className="codicon codicon-debug-step-back" />
</VSCodeButton>
<VSCodeButton appearance="icon" onClick={() => cycleDirection(false)}>
<span className="codicon codicon-debug-step-over" />
</VSCodeButton>
</div>
);
const backgroundDisplay = (
<VSCodeButton appearance="icon" onClick={toggleBackground}>
<span className="codicon codicon-color-mode" />
Expand All @@ -179,10 +206,13 @@ const Editor: React.FC = () => {
<StateList
filterString={searchText}
dmi={dmi}
direction={direction}
pushUpdate={pushDmiUpdate}
onOpen={state => setOpenStateIndex(dmi.states.findIndex(x => x === state))}
/>
);
// Direction buttons
infoBarElements.push(dirDisplay);
//Search bar
infoBarElements.push(
<VSCodeTextField
Expand Down
5 changes: 4 additions & 1 deletion media/editor/listView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ListStateDisplayProps = {
hidden: boolean;
duplicate: boolean;
editing?: boolean;
direction: Dirs;
delete: () => void;
select: () => void;
open: () => void;
Expand Down Expand Up @@ -61,7 +62,7 @@ const ListStateDisplay: React.FC<ListStateDisplayProps> = props => {
/>
{props.duplicate && <div className="duplicate">Duplicate</div>}
<div className="statePreview" onDoubleClick={props.open}>
<img className="frame" src={iconState.generate_preview(Dirs.SOUTH)} />
<img className="frame" src={iconState.generate_preview(props.direction)} />
</div>
</div>
);
Expand All @@ -70,6 +71,7 @@ const ListStateDisplay: React.FC<ListStateDisplayProps> = props => {
type StateListProps = {
dmi: Dmi;
filterString: string;
direction: Dirs;
pushUpdate: (newDmi: Dmi) => void;
onOpen: (state: DmiState) => void;
};
Expand Down Expand Up @@ -288,6 +290,7 @@ export const StateList: React.FC<StateListProps> = props => {
<ListStateDisplay
key={index}
state={state}
direction={props.direction}
modify={modify_state(index)}
delete={delete_state(index)}
select={() => setSelectedState(index)}
Expand Down
Loading