From 258f0f08412d7cdfaee121f8a80a8c3634373125 Mon Sep 17 00:00:00 2001 From: Mario Pesch Date: Mon, 13 Dec 2021 15:35:25 +0100 Subject: [PATCH 1/2] add sound selector --- src/actions/generalActions.js | 16 +++++- src/actions/types.js | 1 + src/components/Blockly/BlocklyWindow.js | 3 ++ src/components/Blockly/msg/de/ui.js | 3 ++ src/components/Blockly/msg/en/ui.js | 5 +- src/components/Blockly/toolbox/Toolbox.js | 2 +- src/components/Settings/Settings.js | 4 ++ src/components/Settings/SoundsSelector.js | 63 +++++++++++++++++++++++ src/reducers/generalReducer.js | 16 ++++++ 9 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 src/components/Settings/SoundsSelector.js diff --git a/src/actions/generalActions.js b/src/actions/generalActions.js index f4dd22f..346d9f7 100644 --- a/src/actions/generalActions.js +++ b/src/actions/generalActions.js @@ -1,4 +1,11 @@ -import { VISIT, LANGUAGE, RENDERER, STATISTICS, PLATFORM } from "./types"; +import { + VISIT, + LANGUAGE, + RENDERER, + SOUNDS, + STATISTICS, + PLATFORM, +} from "./types"; export const visitPage = () => (dispatch) => { dispatch({ @@ -30,6 +37,13 @@ export const setRenderer = (renderer) => (dispatch) => { }); }; +export const setSounds = (sounds) => (dispatch) => { + dispatch({ + type: SOUNDS, + payload: sounds, + }); +}; + export const setStatistics = (showStatistics) => (dispatch) => { dispatch({ type: STATISTICS, diff --git a/src/actions/types.js b/src/actions/types.js index 223154d..6a10987 100644 --- a/src/actions/types.js +++ b/src/actions/types.js @@ -45,6 +45,7 @@ export const VISIT = "VISIT"; export const LANGUAGE = "LANGUAGE"; export const PLATFORM = "PLATFORM"; export const RENDERER = "RENDERER"; +export const SOUNDS = "SOUNDS"; export const STATISTICS = "STATISTICS"; // messages diff --git a/src/components/Blockly/BlocklyWindow.js b/src/components/Blockly/BlocklyWindow.js index 5580abe..c69fc9d 100644 --- a/src/components/Blockly/BlocklyWindow.js +++ b/src/components/Blockly/BlocklyWindow.js @@ -72,6 +72,7 @@ class BlocklyWindow extends Component { this.props.trashcan !== undefined ? this.props.trashcan : true } renderer={this.props.renderer} + sounds={this.props.sounds} maxInstances={getMaxInstances()} zoom={{ // https://developers.google.com/blockly/guides/configure/web/zoom @@ -123,11 +124,13 @@ BlocklyWindow.propTypes = { onChangeWorkspace: PropTypes.func.isRequired, clearStats: PropTypes.func.isRequired, renderer: PropTypes.string.isRequired, + sounds: PropTypes.string.isRequired, language: PropTypes.string.isRequired, }; const mapStateToProps = (state) => ({ renderer: state.general.renderer, + sounds: state.general.sounds, language: state.general.language, }); diff --git a/src/components/Blockly/msg/de/ui.js b/src/components/Blockly/msg/de/ui.js index 545208f..db7da8f 100644 --- a/src/components/Blockly/msg/de/ui.js +++ b/src/components/Blockly/msg/de/ui.js @@ -177,6 +177,9 @@ export const UI = { "Der Tablet Modus deaktiviert die Code anzeige und aktiviert die Möglichkeit den Programmcode über die senseBox Connect App zu übertragen. Weitere Informationen dazu findest du unter: ", settings_ota_on: "Aktiviert", settings_ota_off: "Deaktiviert", + settings_sounds: "Töne", + settings_sounds_text: + "Aktiviere oder Deaktiviere Töne beim hinzufügen und löschen von Blöcken. Standardmäßig deaktiviert", /** * 404 diff --git a/src/components/Blockly/msg/en/ui.js b/src/components/Blockly/msg/en/ui.js index b573b00..79708da 100644 --- a/src/components/Blockly/msg/en/ui.js +++ b/src/components/Blockly/msg/en/ui.js @@ -167,11 +167,14 @@ export const UI = { "The display of statistics on the usage of the blocks above the workspace can be shown or hidden.", settings_statistics_on: "On", settings_statistics_off: "Off", - settings_ota_head: "tablet mode", + settings_ota_head: "Tablet mode", settings_ota_text: "Tablet mode disables the code display and enables the possibility to transfer the program code via the senseBox Connect app. You can find more information on: ", settings_ota_on: "Activated", settings_ota_off: "Deactivated", + settings_sounds: "Sound", + settings_sounds_text: + "Enable or disable sounds when adding and deleting blocks. Disabled by default", /** * 404 diff --git a/src/components/Blockly/toolbox/Toolbox.js b/src/components/Blockly/toolbox/Toolbox.js index 0c1f6e3..9186bc8 100644 --- a/src/components/Blockly/toolbox/Toolbox.js +++ b/src/components/Blockly/toolbox/Toolbox.js @@ -94,7 +94,7 @@ class Toolbox extends React.Component { - + diff --git a/src/components/Settings/Settings.js b/src/components/Settings/Settings.js index ac1a538..ad1dde6 100644 --- a/src/components/Settings/Settings.js +++ b/src/components/Settings/Settings.js @@ -11,6 +11,7 @@ import LanguageSelector from "./LanguageSelector"; import RenderSelector from "./RenderSelector"; import StatsSelector from "./StatsSelector"; import OtaSelector from "./OtaSelector"; +import SoundsSelector from "./SoundsSelector"; import Button from "@material-ui/core/Button"; import Paper from "@material-ui/core/Paper"; @@ -48,6 +49,9 @@ class Settings extends Component { + + +