Skip to content

Commit

Permalink
No guitar option [SG-122]
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgfeller committed Jan 9, 2024
1 parent 9f48b9f commit 2c7d7bb
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/assets/images/no-guitar-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,29 @@ export class CoreGameCoordinationInitializer {
}
// All game coordinators MUST implement a play() and stop() method

this.noGuitarOption();

// Init game mode options after they have been added via instantiation of the correct gameModeCoordinator above
GameConfigurationManager.initGameModeOptions();
}

noGuitarOption(){
// Overwrite noteDetectorEnabled and metronomeEnabled if the user has selected "no guitar"
const noGuitarCheckbox = document.querySelector('#no-guitar-option input');
noGuitarCheckbox?.addEventListener('change', function () {
disableNoteDetector();
});
const self = this;
const disableNoteDetector = function() {
if (noGuitarCheckbox?.checked) {
self.coreGameCoordinator.metronomeEnabled = false;
self.coreGameCoordinator.noteDetectorEnabled = false;
}
}
disableNoteDetector();
}


/**
* Start and stop game or metronome
* Executed on click of start or stop button
Expand Down
2 changes: 1 addition & 1 deletion src/features/game-core/game-start/core-game-coordinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export class CoreGameCoordinator {
}
// Default value
this.stopAndResumeAfterVisibilityChange = false;
if (this.noteDetectorEnabled) {
GameElementsVisualizer.showGameElementsAndHideInstructions();
if (this.noteDetectorEnabled) {

// Prevent screen from getting dark on mobile
void this.screenWakeLocker.requestWakeLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {GameConfigurationManager} from "../../game-core/game-initialization/game
import {GameProgressVisualizer} from "../../game-core/game-progress/game-progress-visualizer.js?v=1.2.3";
import {NoteInKeyGenerator} from "./note-in-key-generator.js?v=1.2.3";
import {PracticeNoteDisplayer} from "../../practice-note-combination/practice-note-displayer.js?v=1.2.3";
import {NoteInKeyGameNoGuitarOption} from "./note-in-key-game-no-guitar-option.js";

export class NoteInKeyGameInitializer {

Expand Down Expand Up @@ -65,6 +66,9 @@ export class NoteInKeyGameInitializer {

// Level up event listener
document.addEventListener('leveled-up', this.levelUpEventHandler);

// Init no guitar game option
new NoteInKeyGameNoGuitarOption().initNoGuitarGameOption();
}

initStringOptionsEventListeners() {
Expand Down Expand Up @@ -190,6 +194,13 @@ export class NoteInKeyGameInitializer {
<!--<span class="normal-font-size"></span>-->
<img src="src/assets/images/entire-fretboard-icon.svg" class="button-icon">
</label>
<!-- For simplicity, the no-guitar option has the same id for all game modes and
the core-game-coordination-initializer sets the metronomeEnabled and noteDetectorEnabled values -->
<label class='checkbox-button option-for-game-mode' id="no-guitar-option">
<input type='checkbox'>
<!--<span class="normal-font-size"></span>-->
<img src="src/assets/images/no-guitar-icon.svg" class="button-icon">
</label>
`;
document.querySelector('#game-mode-options').insertAdjacentHTML('afterend', `
<span class="normal-font-size label-text options-title-span" id="string-option-title">Strings</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class NoteInKeyGameNoGuitarOption {
initNoGuitarGameOption() {

}
}

0 comments on commit 2c7d7bb

Please sign in to comment.