project_files/HedgewarsMobile/Classes/CommodityFunctions.m
changeset 3783 8e9daf967406
parent 3781 2bfda544ae48
child 3823 cca9bfb88a24
equal deleted inserted replaced
3782:dc3531e49e4c 3783:8e9daf967406
     9 #import "CommodityFunctions.h"
     9 #import "CommodityFunctions.h"
    10 #import <sys/types.h>
    10 #import <sys/types.h>
    11 #import <sys/sysctl.h>
    11 #import <sys/sysctl.h>
    12 #import <mach/mach.h>
    12 #import <mach/mach.h>
    13 #import <mach/mach_host.h>
    13 #import <mach/mach_host.h>
       
    14 #import "AudioToolbox/AudioToolbox.h"
    14 
    15 
    15 void createTeamNamed (NSString *nameWithoutExt) {
    16 void createTeamNamed (NSString *nameWithoutExt) {
    16     NSString *teamsDirectory = TEAMS_DIRECTORY();
    17     NSString *teamsDirectory = TEAMS_DIRECTORY();
    17 
    18 
    18     if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
    19     if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
   230     NSString *modelId = [NSString stringWithUTF8String:name];
   231     NSString *modelId = [NSString stringWithUTF8String:name];
   231     free(name);
   232     free(name);
   232 
   233 
   233     return modelId;
   234     return modelId;
   234 }
   235 }
       
   236 
       
   237 void playSound (NSString *snd) {
       
   238     //Get the filename of the sound file:
       
   239     NSString *path = [NSString stringWithFormat:@"%@/%@.wav",[[NSBundle mainBundle] resourcePath],snd];
       
   240     
       
   241     //declare a system sound id
       
   242     SystemSoundID soundID;
       
   243 
       
   244     //Get a URL for the sound file
       
   245     NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
       
   246 
       
   247     //Use audio sevices to create the sound
       
   248     AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
       
   249 
       
   250     //Use audio services to play the sound
       
   251     AudioServicesPlaySystemSound(soundID);
       
   252 }