From 2f32943511669dd32244cc17baeaacb52e37c9ce Mon Sep 17 00:00:00 2001 From: Simon Kellner Date: Mon, 8 Jun 2020 10:40:53 +0200 Subject: [PATCH] Add --no-music flag, Implement NSUserDefaults for music settings --- GoldWars/GoldWars/Scenes/MenuScene.swift | 2 +- GoldWars/GoldWars/SoundManager.swift | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/GoldWars/GoldWars/Scenes/MenuScene.swift b/GoldWars/GoldWars/Scenes/MenuScene.swift index 82469a3..f7f145b 100644 --- a/GoldWars/GoldWars/Scenes/MenuScene.swift +++ b/GoldWars/GoldWars/Scenes/MenuScene.swift @@ -56,7 +56,7 @@ class MenuScene: SKScene { entityManager.add(Background(size: self.size)) entityManager.add(SpinningLogoEntity(position: CGPoint(x: midX, y: midY + 200))) - if SoundManager.sharedInstance.isMusicPlaying == false && SoundManager.sharedInstance.isMusicEnabled == true { + if SoundManager.sharedInstance.isMusicPlaying == false && SoundManager.sharedInstance.isMusicEnabled == true && !CommandLine.arguments.contains("--no-music") && !UserDefaults.standard.bool(forKey: "noMusic"){ SoundManager.sharedInstance.startMenuMusic() } } diff --git a/GoldWars/GoldWars/SoundManager.swift b/GoldWars/GoldWars/SoundManager.swift index b6cb5d4..9f7bb03 100644 --- a/GoldWars/GoldWars/SoundManager.swift +++ b/GoldWars/GoldWars/SoundManager.swift @@ -29,12 +29,14 @@ class SoundManager { audioPlayer.prepareToPlay() if self.isMusicEnabled == true { audioPlayer.play() + UserDefaults.standard.set(false, forKey: "noMusic") } } func stopMenuMusic() { audioPlayer.pause() self.isMusicPlaying = false + UserDefaults.standard.set(true, forKey: "noMusic") } func setVolume(_ volume: Float) {