Skip to content

Commit 4367f46

Browse files
committed
Cleanup to get ready for v0.2 release
1 parent 57c0ae0 commit 4367f46

12 files changed

+118
-32
lines changed

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"react-dom": "^16.13.1",
4545
"react-scripts": "3.4.1",
4646
"robotjs": "git+https://github.com/octalmage/robotjs.git#master",
47+
"smooth-scroll-into-view-if-needed": "^1.1.28",
4748
"webmidi": "^2.5.1"
4849
},
4950
"build": {

roadmap.txt renamed to roadmap.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
21
Current "roadmap" of upcoming changes
32

4-
v0.1 release
5-
- checkbox to turn off sending notes (for practicing without it playing)
6-
- checkbox to turn off auto octave swap
3+
v0.2
74

8-
v0.2 release
5+
- key switches for octaves (when in not auto octave mode)
96
- buttons for manually shifting the internal octave
10-
- keymap selector
7+
- keymap selector with a few options
8+
9+
v0.3
10+
1111
- Better ui for configuring note->key map
1212

1313
future ideas
14+
1415
- UI that shows a piano and keypresses
1516
- Automatically play through a song
1617
- Mac build
1718
- Send different note ranges to different game clients?
18-
-- Like if multiboxing multiple instruments
19-
-- May be against terms of service :(
19+
-- Like if multiboxing multiple instruments
20+
-- May be against terms of service :(

src/react/App.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
.app {
66
height: 100vh;
7+
overflow: hidden;
78
display: flex;
89
flex-direction: column;
910
align-items: center;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
3+
export default InstrumentSelector;
4+
5+
function InstrumentSelector(props) {
6+
return <div>Instrument: The Minstrel</div>;
7+
}

src/react/components/MIDIDisplay.js

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { useEffect, useRef } from 'react';
2+
import scrollIntoView from 'smooth-scroll-into-view-if-needed';
3+
4+
import { useKeySender } from '../hooks/useKeySender';
5+
6+
import styles from './MIDIMessageDisplay.module.css';
7+
8+
export default MIDIMessageDisplay;
9+
10+
function MIDIMessageDisplay(props) {
11+
const { sentMessages } = useKeySender();
12+
const messagesEndRef = useRef(null);
13+
14+
const scrollToBottom = () => {
15+
scrollIntoView(messagesEndRef.current);
16+
};
17+
18+
useEffect(scrollToBottom, [sentMessages]);
19+
20+
return (
21+
<div className={styles.MIDIMessageDisplay}>
22+
<h3 className={styles.header}>Messages</h3>
23+
<div className={styles.messages}>
24+
{sentMessages.map((message, i) => (
25+
<div key={i}>{message}</div>
26+
))}
27+
<div key="endDiv" ref={messagesEndRef} />
28+
</div>
29+
</div>
30+
);
31+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.MIDIMessageDisplay {
2+
display: flex;
3+
flex-direction: column;
4+
height: 100%;
5+
width: 100%;
6+
}
7+
8+
.header {
9+
flex: 0;
10+
}
11+
12+
.messages {
13+
flex: 1;
14+
overflow-y: auto;
15+
width: 100%;
16+
}

src/react/components/PianoDisplay.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { useKeySender } from '../hooks/useKeySender';
3+
4+
export default PianoDisplay;
5+
6+
function PianoDisplay(props) {
7+
const { octave } = useKeySender();
8+
return <div>Octave {octave}</div>;
9+
}

src/react/hooks/useKeySender.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const keyMap = {
5151
// TODO: Move to config since the sweet spot may be different per game/person?
5252
const MULTIPLE_OCTAVE_SHIFT_DELAY = 75;
5353

54+
const MESSAGE_LIMIT = 100;
55+
5456
function KeySenderProvider(props) {
5557
const { children } = props;
5658
const { isLoading: configIsLoading, config } = useConfig();
@@ -211,7 +213,10 @@ function KeySenderProvider(props) {
211213
function _addMessage(message) {
212214
setState((curr) => ({
213215
...curr,
214-
sentMessages: [message, ...curr.sentMessages].slice(0, 10),
216+
sentMessages: [...curr.sentMessages, message].slice(
217+
curr.sentMessages.length - MESSAGE_LIMIT,
218+
MESSAGE_LIMIT
219+
),
215220
}));
216221
}
217222

src/react/scenes/MainContent/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import React from 'react';
22

3-
import MIDIDisplay from '../../components/MIDIDisplay';
4-
import MIDIControls from '../../components/MIDIControls';
53
import { useConfig } from '../../hooks/useConfig';
64

5+
import MIDIControls from '../../components/MIDIControls';
6+
import InstrumentSelector from '../../components/InstrumentSelector';
7+
import PianoDisplay from '../../components/PianoDisplay';
8+
import MIDIMessageDisplay from '../../components/MIDIMessageDisplay';
9+
710
import styles from './styles.module.css';
811

912
export default MainContent;
@@ -18,10 +21,15 @@ function MainContent() {
1821
</header>
1922
<div className={styles.appContent}>
2023
<div className={styles.leftContent}>
21-
Input used for testing key press <input />
24+
<InstrumentSelector />
25+
<PianoDisplay />
26+
<div>
27+
Input used for testing key press <input />
28+
</div>
2229
</div>
30+
2331
<div className={styles.rightContent}>
24-
<MIDIDisplay />
32+
<MIDIMessageDisplay />
2533
</div>
2634
</div>
2735
<footer className={styles.appFooter}>

src/react/scenes/MainContent/styles.module.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
width: 100%;
1010
flex: 1;
1111
display: flex;
12+
overflow: hidden;
1213
}
1314

1415
.leftContent {
16+
flex: 1;
1517
padding: 1rem;
1618
height: 100%;
19+
display: flex;
20+
flex-direction: column;
1721
}
1822

1923
.rightContent {
24+
flex: 0 0 300px;
2025
padding: 1rem;
2126
margin-left: 1rem;
2227
height: 100%;

0 commit comments

Comments
 (0)