Merge pull request #220 from UniversityRadioYork/marks/party-mode

Add Party Mode
This commit is contained in:
Matthew Stratford 2021-03-13 14:29:06 +00:00 committed by GitHub
commit b57d04f894
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 7 deletions

View file

@ -324,6 +324,25 @@ export function AdvancedTab() {
requested to.)
</label>
</div>
<div className="form-check">
<input
className="form-check-input"
type="checkbox"
checked={settings.partyMode}
onChange={(e) =>
dispatch(
changeSetting({
key: "partyMode",
val: e.target.checked,
})
)
}
/>
<label>
Party Mode (no, seriously, don't enable this unless you know what
you're doing)
</label>
</div>
</>
);
}

View file

@ -13,6 +13,7 @@ interface Settings {
channelOutputIds: string[];
resetTrimOnLoad: boolean;
saveShowPlanChanges: boolean;
partyMode: boolean;
}
const settingsState = createSlice({
@ -29,6 +30,7 @@ const settingsState = createSlice({
channelOutputIds: Array(PLAYER_COUNT).fill(INTERNAL_OUTPUT_ID),
resetTrimOnLoad: true,
saveShowPlanChanges: true,
partyMode: false,
} as Settings,
reducers: {
changeSetting<K extends keyof Settings>(

View file

@ -41,6 +41,10 @@ export const Item = memo(function Item({
(state: RootState) => state.settings.showDebugInfo
);
const partyMode = useSelector((state: RootState) => state.settings.partyMode);
const showName =
!partyMode || column > 2 || !isTrack(x) || ("played" in x && x.played);
function triggerClick() {
if (column > -1) {
dispatch(MixerState.load(column, x));
@ -76,11 +80,16 @@ export const Item = memo(function Item({
}
function generateTooltipData() {
let data = ["Title: " + x.title.toString()];
let data = [];
if (partyMode) {
data.push("Title: 🎉🎉🎉PARTY MODE🎉🎉🎉");
} else {
data.push("Title: " + x.title.toString());
if ("artist" in x && x.artist !== "") data.push("Artist: " + x.artist);
if ("album" in x && x.album.title !== "")
data.push("Album: " + x.album.title);
if ("artist" in x && x.artist !== "") data.push("Artist: " + x.artist);
if ("album" in x && x.album.title !== "")
data.push("Album: " + x.album.title);
}
data.push("Length: " + x.length);
if ("intro" in x)
data.push(
@ -133,8 +142,12 @@ export const Item = memo(function Item({
>
<span className={"icon " + x.type} />
&nbsp;
{x.title.toString()}
{"artist" in x && x.artist !== "" && " - " + x.artist}
{showName && (
<>
{x.title.toString()}
{"artist" in x && x.artist !== "" && " - " + x.artist}
</>
)}
<small
className={
"border rounded border-danger text-danger p-1 m-1" +

View file

@ -220,11 +220,20 @@ function LoadedTrackInfo({ id }: { id: number }) {
(state: RootState) => state.mixer.players[id].loadError
);
const partyMode = useSelector((state: RootState) => state.settings.partyMode);
const showName =
!partyMode ||
loadedItem === null ||
!ShowPlanState.isTrack(loadedItem) ||
("played" in loadedItem && loadedItem.played);
return (
<span className="card-title">
<strong>
{loadedItem !== null && loading === -1
? loadedItem.title
? showName
? loadedItem.title
: ""
: loading !== -1
? `LOADING`
: loadError
@ -272,6 +281,8 @@ export function Player({
)
);
const partyMode = useSelector((state: RootState) => state.settings.partyMode);
useBeforeunload((event) => {
console.log("Checking player " + id + " for un-ended tracklists.");
const tracklistItemID = playerState.tracklistItemID;
@ -381,6 +392,7 @@ export function Player({
<span className="text-muted">
{playerState.loadedItem !== null && playerState.loading === -1
? "artist" in playerState.loadedItem &&
!partyMode &&
playerState.loadedItem.artist
: ""}
&nbsp;