Skip to content

Commit 7307511

Browse files
authored
Button Sound Fix [AARD-2054] (#1263)
2 parents d978ee0 + 0ca1641 commit 7307511

38 files changed

+124
-70
lines changed

fission/src/ui/UIProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import CloseIcon from "@mui/icons-material/Close"
2-
import { IconButton } from "@mui/material"
2+
import { IconButton } from "./components/StyledComponents"
33
import type { SnackbarKey, SnackbarMessage, VariantType } from "notistack"
44
import { useSnackbar } from "notistack"
55
import type React from "react"

fission/src/ui/components/AnalyticsConsent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Box, Button } from "@mui/material"
1+
import { Box } from "@mui/material"
2+
import { Button } from "./StyledComponents"
23
import { AiOutlineClose } from "react-icons/ai"
34
import Label from "./Label"
45

fission/src/ui/components/ContextMenu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Button, Divider, Stack } from "@mui/material"
1+
import { Divider, Stack } from "@mui/material"
2+
import { Button } from "./StyledComponents"
23
import type React from "react"
34
import { useEffect, useState } from "react"
45
import { type ContextData, ContextSupplierEvent } from "./ContextMenuData"

fission/src/ui/components/MainHUD.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Box, Button, IconButton, Stack } from "@mui/material"
1+
import { Box, Stack } from "@mui/material"
2+
import { Button, IconButton } from "./StyledComponents"
23
import { motion } from "framer-motion"
34
import type React from "react"
45
import { useEffect, useState } from "react"
@@ -7,7 +8,6 @@ import APS, { APS_USER_INFO_UPDATE_EVENT } from "@/aps/APS"
78
import logo from "@/assets/autodesk_logo.png"
89
import { globalAddToast } from "@/components/GlobalUIControls.ts"
910
import MatchMode, { MatchStateChangeEvent } from "@/systems/match_mode/MatchMode"
10-
import { SoundPlayer } from "@/systems/sound/SoundPlayer"
1111
import { deobf } from "@/util/Utility"
1212
import { useThemeContext } from "../helpers/ThemeProviderHelpers"
1313
import { useUIContext } from "../helpers/UIProviderHelpers"
@@ -36,7 +36,6 @@ const MainHUDButton: React.FC<ButtonProps> = ({ value, icon, onClick, larger })
3636
return (
3737
<Button
3838
onClick={onClick}
39-
{...SoundPlayer.buttonSoundEffects()}
4039
className={`relative flex flex-row
4140
cursor-pointer
4241
w-full m-auto px-2 py-1 border-none rounded-md ${larger ? "justify-center" : ""}

fission/src/ui/components/Modal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Button, Card, CardActions, CardContent, CardHeader, Modal as MUIModal } from "@mui/material"
1+
import { Card, CardActions, CardContent, CardHeader, Modal as MUIModal } from "@mui/material"
2+
import { Button } from "./StyledComponents"
23
import React, { type ReactElement } from "react"
34
import type { Modal as ModalType, Panel as PanelType } from "../helpers/UIProviderHelpers"
45
import { CloseType, useUIContext } from "../helpers/UIProviderHelpers"

fission/src/ui/components/Panel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Button, Card, CardActions, CardContent, CardHeader } from "@mui/material"
1+
import { Card, CardActions, CardContent, CardHeader } from "@mui/material"
2+
import { Button } from "./StyledComponents"
23
import React, { type ReactElement } from "react"
34
import Draggable from "react-draggable"
45
import {

fission/src/ui/components/SelectButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type Jolt from "@azaleacolburn/jolt-physics"
2-
import { Button, Stack } from "@mui/material"
2+
import { Stack } from "@mui/material"
3+
import { Button } from "./StyledComponents"
34
import type React from "react"
45
import { useCallback, useEffect, useRef, useState } from "react"
56
import World from "@/systems/World"

fission/src/ui/components/SelectMenu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Button, Divider, IconButton, Stack } from "@mui/material"
1+
import { Divider, Stack } from "@mui/material"
2+
import { Button, IconButton } from "./StyledComponents"
23
import type React from "react"
34
import { useEffect, useState } from "react"
45
import Label from "./Label"

fission/src/ui/components/StyledComponents.tsx

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
import InfoIcon from "@mui/icons-material/Info"
2-
import { Box, Button, type ButtonProps, IconButton, type IconButtonProps, Stack, Tooltip } from "@mui/material"
2+
import {
3+
Box,
4+
Button as MuiButton,
5+
type ButtonProps,
6+
IconButton as MuiIconButton,
7+
type IconButtonProps,
8+
Stack,
9+
Tooltip,
10+
ToggleButton as MuiToggleButton,
11+
type ToggleButtonProps,
12+
ToggleButtonGroup as MuiToggleButtonGroup,
13+
type ToggleButtonGroupProps,
14+
} from "@mui/material"
15+
import { SoundPlayer } from "@/systems/sound/SoundPlayer"
316
import { AiFillWarning, AiOutlineDoubleRight, AiOutlineInfoCircle } from "react-icons/ai"
417
import { BiRefresh } from "react-icons/bi"
518
import { BsCodeSquare } from "react-icons/bs"
@@ -83,6 +96,38 @@ export const Spacer = (heightPx?: number, widthPx?: number) => {
8396
return <Box minHeight={`${heightPx}px`} minWidth={`${widthPx}px`} />
8497
}
8598

99+
export const Button: React.FC<ButtonProps> = ({ children, onClick, onMouseDown, onMouseUp, ...props }) => {
100+
return (
101+
<MuiButton onClick={onClick} {...SoundPlayer.buttonSoundEffects()} {...props}>
102+
{children}
103+
</MuiButton>
104+
)
105+
}
106+
107+
export const IconButton: React.FC<IconButtonProps> = ({ children, onClick, onMouseDown, onMouseUp, ...props }) => {
108+
return (
109+
<MuiIconButton onClick={onClick} {...SoundPlayer.buttonSoundEffects()} {...props}>
110+
{children}
111+
</MuiIconButton>
112+
)
113+
}
114+
115+
export const ToggleButton: React.FC<ToggleButtonProps> = ({ children, onClick, onMouseDown, onMouseUp, ...props }) => {
116+
return (
117+
<MuiToggleButton onClick={onClick} {...SoundPlayer.buttonSoundEffects()} {...props}>
118+
{children}
119+
</MuiToggleButton>
120+
)
121+
}
122+
123+
export const ToggleButtonGroup: React.FC<ToggleButtonGroupProps> = ({ children, onMouseDown, onMouseUp, ...props }) => {
124+
return (
125+
<MuiToggleButtonGroup {...SoundPlayer.buttonSoundEffects()} {...props}>
126+
{children}
127+
</MuiToggleButtonGroup>
128+
)
129+
}
130+
86131
export const PositiveButton: React.FC<ButtonProps> = ({ children, onClick, ...props }) => {
87132
return (
88133
<Button onClick={onClick} {...props} color="success">
@@ -166,7 +211,7 @@ export const RefreshButton = (onClick: () => void, props: IconButtonProps = {})
166211
export const CustomTooltip = (text: string) => {
167212
return (
168213
<Tooltip title={text}>
169-
<IconButton
214+
<MuiIconButton
170215
size="small"
171216
disableRipple
172217
sx={{
@@ -195,7 +240,7 @@ export const CustomTooltip = (text: string) => {
195240
}}
196241
>
197242
<InfoIcon fontSize="small" />
198-
</IconButton>
243+
</MuiIconButton>
199244
</Tooltip>
200245
)
201246
}
@@ -208,3 +253,6 @@ export const LabelWithTooltip = (labelText: string, tooltipText: string) => {
208253
</Stack>
209254
)
210255
}
256+
257+
// Export the raw MUI components for cases where sound effects are not wanted
258+
export { MuiButton, MuiIconButton, MuiToggleButton, MuiToggleButtonGroup }

fission/src/ui/components/TransformGizmoControl.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Button, ToggleButton, ToggleButtonGroup } from "@mui/material"
1+
import { Button, ToggleButton, ToggleButtonGroup } from "./StyledComponents"
22
import type React from "react"
33
import { useEffect, useState } from "react"
44
import * as THREE from "three"
55
import InputSystem from "@/systems/input/InputSystem"
66
import GizmoSceneObject, { type GizmoMode } from "@/systems/scene/GizmoSceneObject"
7-
import { SoundPlayer } from "@/systems/sound/SoundPlayer"
7+
88
import World from "@/systems/World"
99
import type TransformGizmoControlProps from "./TransformGizmoControlProps"
1010

@@ -108,7 +108,6 @@ const TransformGizmoControl: React.FC<TransformGizmoControlProps> = ({
108108
setMode(v)
109109
gizmo?.setMode(v)
110110
}}
111-
{...SoundPlayer.buttonSoundEffects()}
112111
sx={{
113112
...(sx ?? {}),
114113
alignSelf: "center",

0 commit comments

Comments
 (0)