Skip to content

Commit

Permalink
Merge pull request #5718 from djballowe/feat/record-mode
Browse files Browse the repository at this point in the history
Feat/record mode
  • Loading branch information
matthewbcool authored Nov 23, 2022
2 parents 62178f4 + aa96fd3 commit cba6296
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 11 deletions.
16 changes: 15 additions & 1 deletion src/react-components/room/Tip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,18 @@
border-color: theme.$tip-button-color-pressed;
background-color: theme.$tip-button-color-pressed;
}
}
}

:local(.toast) {
animation: vanish 5s;
animation-fill-mode: forwards;
@keyframes vanish {
70% {
opacity: 1;
}
100% {
opacity: 0;
visibility: hidden;
}
}
}
36 changes: 28 additions & 8 deletions src/react-components/room/TipContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useCallback, useState } from "react";
import PropTypes from "prop-types";
import { FormattedMessage, useIntl, defineMessages } from "react-intl";
import { Tip } from "./Tip";
import { ToastTip } from "./ToastTip";
import { useEffect } from "react";
import { discordBridgesForPresences, hasEmbedPresences } from "../../utils/phoenix-utils";
import configs from "../../utils/configs";
Expand Down Expand Up @@ -75,7 +76,26 @@ export function FullscreenTip(props) {
);
}

export function TipContainer({ hide, inLobby, inRoom, isStreaming, isEmbedded, scene, store, hubId, presences }) {
export function RecordModeTip(props) {
return (
<ToastTip>
<FormattedMessage id="record-mode-enabled-tip" defaultMessage="Record mode on, press 'B' to toggle off" />
</ToastTip>
);
}

export function TipContainer({
hide,
inLobby,
inRoom,
isStreaming,
isEmbedded,
scene,
store,
hubId,
presences,
isRecordMode
}) {
const intl = useIntl();
const [lobbyTipDismissed, setLobbyTipDismissed] = useState(false);
const [broadcastTipDismissed, setBroadcastTipDismissed] = useState(() =>
Expand All @@ -94,15 +114,15 @@ export function TipContainer({ hide, inLobby, inRoom, isStreaming, isEmbedded, s

useEffect(
() => {
function onSceneTipChanged({ detail: tipId }) {
setOnboardingTipId(tipId);
}
function onSceneTipChanged({ detail: tipId }) {
setOnboardingTipId(tipId);
}

scene.addEventListener("tip-changed", onSceneTipChanged);
scene.addEventListener("tip-changed", onSceneTipChanged);

setOnboardingTipId(scene.systems.tips.activeTip);
},
[scene]
setOnboardingTipId(scene.systems.tips.activeTip);
},
[scene]
);

const discordBridges = presences ? discordBridgesForPresences(presences) : [];
Expand Down
17 changes: 17 additions & 0 deletions src/react-components/room/ToastTip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import styles from "./Tip.scss";

export function ToastTip({ className, children, ...rest }) {
return (
<div className={classNames(styles.tip, styles.toast, className)} {...rest}>
<div className={styles.content}>{children}</div>
</div>
);
}

ToastTip.propTypes = {
className: PropTypes.string,
children: PropTypes.node
};
25 changes: 24 additions & 1 deletion src/react-components/ui-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import { UserProfileSidebarContainer } from "./room/UserProfileSidebarContainer"
import { CloseRoomModal } from "./room/CloseRoomModal";
import { WebVRUnsupportedModal } from "./room/WebVRUnsupportedModal";
import { TweetModalContainer } from "./room/TweetModalContainer";
import { TipContainer, FullscreenTip } from "./room/TipContainer";
import { TipContainer, FullscreenTip, RecordModeTip } from "./room/TipContainer";
import { SpectatingLabel } from "./room/SpectatingLabel";
import { SignInMessages } from "./auth/SignInModal";
import { MediaDevicesEvents } from "../utils/media-devices-utils";
Expand Down Expand Up @@ -185,6 +185,7 @@ class UIRoot extends Component {
showPrefs: false,
watching: false,
isStreaming: false,
isRecordingMode: false,

waitingOnAudio: false,
audioTrackClone: null,
Expand Down Expand Up @@ -327,6 +328,21 @@ class UIRoot extends Component {
this.props.scene.addEventListener("action_toggle_ui", () =>
this.setState({ hide: !this.state.hide, hideUITip: false })
);
this.props.scene.addEventListener("action_toggle_record", () => {
const cursor = document.querySelector("#right-cursor");
if (this.state.isRecordingMode) {
// If isRecordingMode is true then toggle it off.
cursor.object3D.children[1].material.visible = true;
this.setState({ hide: false, hideUITip: false, isRecordingMode: false });
document.querySelector(".rs-fps-counter").style.visibility = "visible";
document.querySelector(".rs-base").style.visibility = "visible";
} else {
cursor.object3D.children[1].material.visible = false;
this.setState({ hide: true, hideUITip: true, isRecordingMode: true });
document.querySelector(".rs-fps-counter").style.visibility = "hidden";
document.querySelector(".rs-base").style.visibility = "hidden";
}
});
this.props.scene.addEventListener("devicechange", () => {
this.forceUpdate();
});
Expand Down Expand Up @@ -948,6 +964,13 @@ class UIRoot extends Component {
isGhost,
hide
};
if (this.state.isRecordingMode) {
return (
<div className={classNames(rootStyles)}>
<RoomLayoutContainer scene={this.props.scene} store={this.props.store} viewport={<RecordModeTip />} />
</div>
);
}
if (this.props.hide || this.state.hide) {
return (
<div className={classNames(rootStyles)}>
Expand Down
5 changes: 4 additions & 1 deletion src/systems/ui-hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AFRAME.registerSystem("ui-hotkeys", {
this.mediaSearchStore = window.APP.mediaSearchStore;
},

tick: function() {
tick: function () {
if (!this.userinput) {
this.userinput = this.el.systems.userinput;
}
Expand Down Expand Up @@ -62,5 +62,8 @@ AFRAME.registerSystem("ui-hotkeys", {
if (this.userinput.get(paths.actions.toggleUI)) {
this.el.emit("action_toggle_ui");
}
if (this.userinput.get(paths.actions.toggleRecord)) {
this.el.emit("action_toggle_record");
}
}
});
5 changes: 5 additions & 0 deletions src/systems/userinput/bindings/keyboard-mouse-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ export const keyboardMouseUserBindings = addSetsToBindings({
dest: { value: paths.actions.snapRotateRight },
xform: xforms.rising
},
{
src: { value: paths.device.keyboard.key("b") },
dest: { value: paths.actions.toggleRecord },
xform: xforms.rising
},
{
src: { value: paths.device.keyboard.key("Tab") },
dest: { value: paths.actions.toggleFreeze },
Expand Down
1 change: 1 addition & 0 deletions src/systems/userinput/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ paths.actions.thaw = "/actions/thaw";
paths.actions.muteMic = "/actions/muteMic";
paths.actions.toggleFly = "/actions/toggleFly";
paths.actions.toggleUI = "/actions/toggleUI";
paths.actions.toggleRecord = "/actions/toggleRecord";
paths.actions.waypointDeltaDistance = "/actions/waypointDeltaDistance";
paths.actions.focusChat = "/actions/focusChat";
paths.actions.focusChatCommand = "/actions/focusChatCommand";
Expand Down

0 comments on commit cba6296

Please sign in to comment.