project_files/HedgewarsMobile/Classes/CommodityFunctions.m
changeset 5201 7b9aa7aac336
parent 4947 cfac6aab84a0
child 5206 db775bddf771
equal deleted inserted replaced
5200:7440fe992e73 5201:7b9aa7aac336
    26 #import <mach/mach_host.h>
    26 #import <mach/mach_host.h>
    27 #import <QuartzCore/QuartzCore.h>
    27 #import <QuartzCore/QuartzCore.h>
    28 #import <AudioToolbox/AudioToolbox.h>
    28 #import <AudioToolbox/AudioToolbox.h>
    29 #import <CommonCrypto/CommonDigest.h>
    29 #import <CommonCrypto/CommonDigest.h>
    30 #import "PascalImports.h"
    30 #import "PascalImports.h"
       
    31 #import "hwconsts.h"
    31 
    32 
    32 BOOL inline rotationManager (UIInterfaceOrientation interfaceOrientation) {
    33 BOOL inline rotationManager (UIInterfaceOrientation interfaceOrientation) {
    33     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) ||
    34     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) ||
    34            (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    35            (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    35 }
    36 }
    36 
    37 
    37 NSInteger inline randomPort () {
    38 NSInteger inline randomPort () {
    38     srandom(time(NULL));
    39     srandom(time(NULL));
    39     NSInteger res = (random() % 64511) + 1024;
    40     NSInteger res = (random() % 64511) + 1024;
    40     return (res == DEFAULT_NETGAME_PORT) ? randomPort() : res;
    41     return (res == NETGAME_DEFAULT_PORT) ? randomPort() : res;
    41 }
    42 }
    42 
    43 
    43 void popError (const char *title, const char *message) {
    44 void popError (const char *title, const char *message) {
    44     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:title]
    45     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:title]
    45                                                     message:[NSString stringWithUTF8String:message]
    46                                                     message:[NSString stringWithUTF8String:message]
   105         AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
   106         AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
   106         AudioServicesPlaySystemSound(soundID);
   107         AudioServicesPlaySystemSound(soundID);
   107     }
   108     }
   108 }
   109 }
   109 
   110 
   110 NSArray inline *getAvailableColors (void) {
   111 NSArray *getAvailableColors (void) {
   111     return [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:0x3376E9],     // bluette
   112     unsigned int colors[] = HW_TEAMCOLOR_ARRAY;
   112                                      [NSNumber numberWithUnsignedInt:0x3e9321],     // greeeen
   113     NSMutableArray *array = [[NSMutableArray alloc] init];
   113                                      [NSNumber numberWithUnsignedInt:0xa23dbb],     // violett
   114 
   114                                      [NSNumber numberWithUnsignedInt:0xff9329],     // oranngy
   115     int i = 0;
   115                                      [NSNumber numberWithUnsignedInt:0xdd0000],     // reddish
   116     while(colors[i] != 0)
   116                                      [NSNumber numberWithUnsignedInt:0x737373],     // graaaay
   117         [array addObject:[NSNumber numberWithUnsignedInt:(colors[i++] & 0x00FFFFFF)]];
   117                                      [NSNumber numberWithUnsignedInt:0x00FFFF],     // cyannnn  
   118 
   118                                      [NSNumber numberWithUnsignedInt:0xFF8888],     // peachyj
   119     NSArray *final = [NSArray arrayWithArray:array];
   119                                      nil];
   120     [array release];
       
   121     return final;
   120 }
   122 }
   121 
   123 
   122 UILabel *createBlueLabel (NSString *title, CGRect frame) {
   124 UILabel *createBlueLabel (NSString *title, CGRect frame) {
   123     return createLabelWithParams(title, frame, 1.5f, UICOLOR_HW_YELLOW_BODER, UICOLOR_HW_DARKBLUE);
   125     return createLabelWithParams(title, frame, 1.5f, UICOLOR_HW_YELLOW_BODER, UICOLOR_HW_DARKBLUE);
   124 }
   126 }