You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					26 lines
				
				580 B
			
		
		
			
		
	
	
					26 lines
				
				580 B
			| 
								 
											5 years ago
										 
									 | 
							
								#include <QUrl>
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								#include "sound.hpp"
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								Sound::Sound() {
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								  for (auto &kv : sound_map) {
							 | 
						||
| 
								 | 
							
								    auto path = QUrl::fromLocalFile(kv.second.first);
							 | 
						||
| 
								 | 
							
								    sounds[kv.first].setSource(path);
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								void Sound::play(AudibleAlert alert) {
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								  int loops = sound_map[alert].second> - 1 ? sound_map[alert].second : QSoundEffect::Infinite;
							 | 
						||
| 
								 | 
							
								  sounds[alert].setLoopCount(loops);
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								  sounds[alert].setVolume(volume);
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								  sounds[alert].play();
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								void Sound::stop() {
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								  for (auto &kv : sounds) {
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								    // Only stop repeating sounds
							 | 
						||
| 
								 | 
							
								    if (sound_map[kv.first].second != 0) {
							 | 
						||
| 
								 | 
							
								      kv.second.stop();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								  }
							 | 
						||
| 
								 | 
							
								}
							 |