-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# About the pull request <!-- Remove this text and explain what the purpose of your PR is. Mention if you have tested your changes. If you changed a map, make sure you used the mapmerge tool. If this is an Issue Correction, you can type "Fixes Issue #169420" to link the PR to the corresponding Issue number #169420. Remember: something that is self-evident to you might not be to others. Explain your rationale fully, even if you feel it goes without saying. --> Switches TGUI from Inferno to React. Part 2 of the PR #5435 Based heavily on the work from: https://github.com/tgstation/tgstation/pull/80044/files # Explain why it's good for the game React is a more suitable framework # Testing Photographs and Procedure <details> <summary>Screenshots & Videos</summary> Put screenshots and videos here with an empty line between the screenshots and the `<details>` tags. </details> # Changelog :cl: refactor: switched from infernojs to react /:cl:
- Loading branch information
1 parent
37d8e71
commit d5dfe13
Showing
221 changed files
with
2,775 additions
and
2,653 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
/**/*.bundle.* | ||
/**/*.chunk.* | ||
/**/*.hot-update.* | ||
/packages/inferno/** |
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,39 @@ | ||
/** | ||
* ### Key codes. | ||
* event.keyCode is deprecated, use this reference instead. | ||
* | ||
* Handles modifier keys (Shift, Alt, Control) and arrow keys. | ||
* | ||
* For alphabetical keys, use the actual character (e.g. 'a') instead of the key code. | ||
* | ||
* Something isn't here that you want? Just add it: | ||
* @url https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values | ||
* @usage | ||
* ```ts | ||
* import { KEY } from 'tgui/common/keys'; | ||
* | ||
* if (event.key === KEY.Enter) { | ||
* // do something | ||
* } | ||
* ``` | ||
*/ | ||
export enum KEY { | ||
Alt = 'Alt', | ||
Backspace = 'Backspace', | ||
Control = 'Control', | ||
Delete = 'Delete', | ||
Down = 'ArrowDown', | ||
End = 'End', | ||
Enter = 'Enter', | ||
Escape = 'Escape', | ||
Home = 'Home', | ||
Insert = 'Insert', | ||
Left = 'ArrowLeft', | ||
PageDown = 'PageDown', | ||
PageUp = 'PageUp', | ||
Right = 'ArrowRight', | ||
Shift = 'Shift', | ||
Space = ' ', | ||
Tab = 'Tab', | ||
Up = 'ArrowUp', | ||
} |
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
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 was deleted.
Oops, something went wrong.
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,109 @@ | ||
/** | ||
* @file | ||
* @copyright 2020 Aleksej Komarov | ||
* @license MIT | ||
*/ | ||
|
||
import { toFixed } from 'common/math'; | ||
import { useDispatch, useSelector } from 'tgui/backend'; | ||
import { Button, Collapsible, Flex, Knob, Section } from 'tgui/components'; | ||
import { useSettings } from '../settings'; | ||
import { selectAudio } from './selectors'; | ||
|
||
export const NowPlayingWidget = (props) => { | ||
const audio = useSelector(selectAudio), | ||
dispatch = useDispatch(), | ||
settings = useSettings(), | ||
title = audio.meta?.title, | ||
URL = audio.meta?.link, | ||
Artist = audio.meta?.artist || 'Unknown Artist', | ||
upload_date = audio.meta?.upload_date || 'Unknown Date', | ||
album = audio.meta?.album || 'Unknown Album', | ||
duration = audio.meta?.duration, | ||
date = !isNaN(upload_date) | ||
? upload_date?.substring(0, 4) + | ||
'-' + | ||
upload_date?.substring(4, 6) + | ||
'-' + | ||
upload_date?.substring(6, 8) | ||
: upload_date; | ||
|
||
return ( | ||
<Flex align="center"> | ||
{(audio.playing && ( | ||
<Flex.Item | ||
mx={0.5} | ||
grow={1} | ||
style={{ | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
}}> | ||
{ | ||
<Collapsible title={title || 'Unknown Track'} color={'blue'}> | ||
<Section> | ||
{URL !== 'Song Link Hidden' && ( | ||
<Flex.Item grow={1} color="label"> | ||
URL: {URL} | ||
</Flex.Item> | ||
)} | ||
<Flex.Item grow={1} color="label"> | ||
Duration: {duration} | ||
</Flex.Item> | ||
{Artist !== 'Song Artist Hidden' && | ||
Artist !== 'Unknown Artist' && ( | ||
<Flex.Item grow={1} color="label"> | ||
Artist: {Artist} | ||
</Flex.Item> | ||
)} | ||
{album !== 'Song Album Hidden' && album !== 'Unknown Album' && ( | ||
<Flex.Item grow={1} color="label"> | ||
Album: {album} | ||
</Flex.Item> | ||
)} | ||
{upload_date !== 'Song Upload Date Hidden' && | ||
upload_date !== 'Unknown Date' && ( | ||
<Flex.Item grow={1} color="label"> | ||
Uploaded: {date} | ||
</Flex.Item> | ||
)} | ||
</Section> | ||
</Collapsible> | ||
} | ||
</Flex.Item> | ||
)) || ( | ||
<Flex.Item grow={1} color="label"> | ||
Nothing to play. | ||
</Flex.Item> | ||
)} | ||
{audio.playing && ( | ||
<Flex.Item mx={0.5} fontSize="0.9em"> | ||
<Button | ||
tooltip="Stop" | ||
icon="stop" | ||
onClick={() => | ||
dispatch({ | ||
type: 'audio/stopMusic', | ||
}) | ||
} | ||
/> | ||
</Flex.Item> | ||
)} | ||
<Flex.Item mx={0.5} fontSize="0.9em"> | ||
<Knob | ||
minValue={0} | ||
maxValue={1} | ||
value={settings.adminMusicVolume} | ||
step={0.0025} | ||
stepPixelSize={1} | ||
format={(value) => toFixed(value * 100) + '%'} | ||
onDrag={(e, value) => | ||
settings.update({ | ||
adminMusicVolume: value, | ||
}) | ||
} | ||
/> | ||
</Flex.Item> | ||
</Flex> | ||
); | ||
}; |
Oops, something went wrong.