mirror of
				https://github.com/RetroDECK/ES-DE.git
				synced 2025-04-10 19:15:13 +00:00 
			
		
		
		
	Add a "disable sounds" option to the settings menu.
This commit is contained in:
		
							parent
							
								
									742cd4eac4
								
							
						
					
					
						commit
						4f416d13a0
					
				|  | @ -31,6 +31,7 @@ void Settings::setDefaults() | |||
| 	mBoolMap["DONTSHOWEXIT"] = false; | ||||
| 	mBoolMap["DEBUG"] = false; | ||||
| 	mBoolMap["WINDOWED"] = false; | ||||
| 	mBoolMap["DISABLESOUNDS"] = false; | ||||
| 
 | ||||
| 	mIntMap["DIMTIME"] = 30*1000; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| #include "Sound.h" | ||||
| #include "AudioManager.h" | ||||
| #include "Log.h" | ||||
| 
 | ||||
| #include "Settings.h" | ||||
| 
 | ||||
| Sound::Sound(const std::string & path) : mSampleData(NULL), mSamplePos(0), mSampleLength(0), playing(false) | ||||
| { | ||||
|  | @ -82,6 +82,9 @@ void Sound::play() | |||
| 	if(mSampleData == NULL) | ||||
| 		return; | ||||
| 
 | ||||
| 	if(Settings::getInstance()->getBool("DISABLESOUNDS")) | ||||
| 		return; | ||||
| 
 | ||||
| 	SDL_LockAudio(); | ||||
| 	if (playing) | ||||
| 	{ | ||||
|  |  | |||
|  | @ -229,6 +229,7 @@ void ComponentListComponent::moveCursor(Eigen::Vector2i dir) | |||
| 				return; | ||||
| 
 | ||||
| 			mCursor += searchAxis; | ||||
| 			LOG(LogInfo) << "checking " << mCursor.x() << ", " << mCursor.y(); | ||||
| 		} | ||||
| 
 | ||||
| 		//now again on search axis-
 | ||||
|  | @ -239,7 +240,10 @@ void ComponentListComponent::moveCursor(Eigen::Vector2i dir) | |||
| 				return; | ||||
| 
 | ||||
| 			mCursor -= searchAxis; | ||||
| 			LOG(LogInfo) << "checking " << mCursor.x() << ", " << mCursor.y(); | ||||
| 		} | ||||
| 
 | ||||
| 		mCursor = curDirPos; | ||||
| 	} | ||||
| 
 | ||||
| 	//failed to find another focusable element in this direction
 | ||||
|  |  | |||
|  | @ -4,9 +4,10 @@ | |||
| #include "../VolumeControl.h" | ||||
| 
 | ||||
| GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window),  | ||||
| 	mList(window, Eigen::Vector2i(2, 3)),  | ||||
| 	mList(window, Eigen::Vector2i(2, 4)),  | ||||
| 	mDrawFramerateSwitch(window), | ||||
| 	mVolumeSlider(window, 0, 100, 1), | ||||
| 	mDisableSoundsSwitch(window, false), | ||||
| 	mSaveLabel(window) | ||||
| { | ||||
| 	loadStates(); | ||||
|  | @ -26,19 +27,32 @@ GuiSettingsMenu::GuiSettingsMenu(Window* window) : GuiComponent(window), | |||
| 	//drawFramerate switch
 | ||||
| 	mList.setEntry(Vector2i(1, 0), Vector2i(1, 1), &mDrawFramerateSwitch, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(true, true)); | ||||
| 
 | ||||
| 	//volume label
 | ||||
| 	label = new TextComponent(mWindow); | ||||
| 	label->setText("System volume: "); | ||||
| 	label->setColor(0x0000FFFF); | ||||
| 	mLabels.push_back(label); | ||||
| 	mList.setEntry(Vector2i(0, 1), Vector2i(1, 1), label, false, ComponentListComponent::AlignRight, Matrix<bool, 1, 2>(true, true)); | ||||
| 
 | ||||
| 	//volume slider
 | ||||
| 	mList.setEntry(Vector2i(1, 1), Vector2i(1, 1), &mVolumeSlider, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(true, true)); | ||||
| 
 | ||||
| 	//disable sounds
 | ||||
| 	label = new TextComponent(mWindow); | ||||
| 	label->setText("Disable sounds: "); | ||||
| 	label->setColor(0x0000FFFF); | ||||
| 	mLabels.push_back(label); | ||||
| 	mList.setEntry(Vector2i(0, 2), Vector2i(1, 1), label, false, ComponentListComponent::AlignRight, Matrix<bool, 1, 2>(true, true)); | ||||
| 
 | ||||
| 	mList.setEntry(Vector2i(1, 2), Vector2i(1, 1), &mDisableSoundsSwitch, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(true, true)); | ||||
| 
 | ||||
| 
 | ||||
| 	//save label
 | ||||
| 	mSaveLabel.setText("SAVE"); | ||||
| 	mSaveLabel.setColor(0x000000FF); | ||||
| 	mList.setEntry(Vector2i(0, 2), Vector2i(2, 1), &mSaveLabel, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(false, true)); | ||||
| 	mList.setEntry(Vector2i(0, 3), Vector2i(2, 1), &mSaveLabel, true, ComponentListComponent::AlignCenter, Matrix<bool, 1, 2>(false, true)); | ||||
| 
 | ||||
| 	//center list
 | ||||
| 	mList.setPosition(Renderer::getScreenWidth() / 2 - mList.getSize().x() / 2, 0); | ||||
| } | ||||
| 
 | ||||
|  | @ -78,6 +92,8 @@ void GuiSettingsMenu::loadStates() | |||
| 	mDrawFramerateSwitch.setState(s->getBool("DRAWFRAMERATE")); | ||||
| 
 | ||||
| 	mVolumeSlider.setValue((float)VolumeControl::getInstance()->getVolume()); | ||||
| 
 | ||||
| 	mDisableSoundsSwitch.setState(s->getBool("DISABLESOUNDS")); | ||||
| } | ||||
| 
 | ||||
| void GuiSettingsMenu::applyStates() | ||||
|  | @ -87,5 +103,7 @@ void GuiSettingsMenu::applyStates() | |||
| 
 | ||||
| 	VolumeControl::getInstance()->setVolume((int)mVolumeSlider.getValue()); | ||||
| 
 | ||||
| 	s->setBool("DISABLESOUNDS", mDisableSoundsSwitch.getState()); | ||||
| 
 | ||||
| 	s->saveFile(); | ||||
| } | ||||
|  |  | |||
|  | @ -24,6 +24,7 @@ private: | |||
| 
 | ||||
| 	SwitchComponent mDrawFramerateSwitch; | ||||
| 	SliderComponent mVolumeSlider; | ||||
| 	SwitchComponent mDisableSoundsSwitch; | ||||
| 	TextComponent mSaveLabel; | ||||
| 
 | ||||
| 	std::vector<GuiComponent*> mLabels; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Aloshi
						Aloshi