| 
									
										
										
										
											2010-04-05 23:38:59 +02:00
										 |  |  | #include "Variables.h"
 | 
					
						
							| 
									
										
										
										
											2010-11-28 01:13:45 +01:00
										 |  |  | #include "SoundBaseGlobal.h"
 | 
					
						
							| 
									
										
										
										
											2010-04-05 23:38:59 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Engine { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Cmd_Set (const std::vector<std::string> args) { | 
					
						
							|  |  |  | 	if (args.size() != 2) { | 
					
						
							|  |  |  | 		CommandSetErrorString ("Usage: set <name> <value>\nSets variables <name> to value <value>."); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-28 01:13:45 +01:00
										 |  |  | 	// special variable sound_volume
 | 
					
						
							|  |  |  | 	if (args[0] == "effects_volume") { | 
					
						
							|  |  |  | 		SetEffectsVolume(atof(args[1].c_str())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	// special variable music_volume
 | 
					
						
							|  |  |  | 	if (args[0] == "music_volume") { | 
					
						
							|  |  |  | 		SetMusicVolume(atof(args[1].c_str())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-05 23:38:59 +02:00
										 |  |  | 	Variable *test = GetVariable (args[0]); | 
					
						
							|  |  |  | 	if (test) { | 
					
						
							|  |  |  | 		test->SetStringValue (args[1]); | 
					
						
							|  |  |  | 		test->SetFloatValue (atof (args[1].c_str())); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	CommandSetErrorString ("Variable '" + args[0] +"' not found!"); | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Variables::OnRegisterCommands () { | 
					
						
							|  |  |  | 	AddCommand ("set", Cmd_Set); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |