project_files/HedgewarsMobile/Classes/GameSetup.m
changeset 3948 24daa33a3114
parent 3941 017b2b31e1c6
child 3976 abaf741a4e21
equal deleted inserted replaced
3947:709fdb89f76c 3948:24daa33a3114
    33 
    33 
    34 -(id) initWithDictionary:(NSDictionary *)gameDictionary {
    34 -(id) initWithDictionary:(NSDictionary *)gameDictionary {
    35     if (self = [super init]) {
    35     if (self = [super init]) {
    36         ipcPort = randomPort();
    36         ipcPort = randomPort();
    37 
    37 
    38         // should check they exist and throw and exection if not
    38         // the general settings file + menu style (read by the overlay)
    39         NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
    39         NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
       
    40         self.menuStyle = [[dictSett objectForKey:@"menu"] boolValue];
    40         self.systemSettings = dictSett;
    41         self.systemSettings = dictSett;
    41         self.menuStyle = [[dictSett objectForKey:@"menu"] boolValue];
       
    42         [dictSett release];
    42         [dictSett release];
    43 
    43 
       
    44         // this game run settings
    44         self.gameConfig = [gameDictionary objectForKey:@"game_dictionary"];
    45         self.gameConfig = [gameDictionary objectForKey:@"game_dictionary"];
       
    46 
       
    47         // is it a netgame?
    45         isNetGame = [[gameDictionary objectForKey:@"netgame"] boolValue];
    48         isNetGame = [[gameDictionary objectForKey:@"netgame"] boolValue];
       
    49 
       
    50         // is it a Save?
    46         NSString *path = [gameDictionary objectForKey:@"savefile"];
    51         NSString *path = [gameDictionary objectForKey:@"savefile"];
    47         // if path is empty it means i have to create a new file, otherwise i read from that file
    52         // if path is empty it means that you have to create a new file, otherwise read from that file
    48         if ([path isEqualToString:@""] == YES) {
    53         if ([path isEqualToString:@""] == YES) {
    49             NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
    54             NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
    50             [outputFormatter setDateFormat:@"yyyy-MM-dd 'at' HH,mm"];
    55             [outputFormatter setDateFormat:@"yyyy.MM.dd '@' HH-mm"];
    51             NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]];
    56             NSString *newDateString = [outputFormatter stringFromDate:[NSDate date]];
    52             self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", newDateString];
    57             self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", newDateString];
    53             [outputFormatter release];
    58             [outputFormatter release];
    54         } else
    59         } else
    55             self.savePath = path;
    60             self.savePath = path;
   449         rotation = @"0";
   454         rotation = @"0";
   450     } else {
   455     } else {
   451         CGRect screenBounds = [[UIScreen mainScreen] bounds];
   456         CGRect screenBounds = [[UIScreen mainScreen] bounds];
   452         width = (int) screenBounds.size.height;
   457         width = (int) screenBounds.size.height;
   453         height = (int) screenBounds.size.width;
   458         height = (int) screenBounds.size.width;
   454         rotation = @"-90";
   459         UIDeviceOrientation orientation = (UIDeviceOrientation) [[self.gameConfig objectForKey:@"orientation"] intValue];
       
   460         if (orientation == UIDeviceOrientationLandscapeLeft)
       
   461             rotation = @"-90";
       
   462         else
       
   463             rotation = @"90";
       
   464 
   455     }
   465     }
   456         
   466         
   457     NSString *horizontalSize = [[NSString alloc] initWithFormat:@"%d", width];
   467     NSString *horizontalSize = [[NSString alloc] initWithFormat:@"%d", width];
   458     NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", height];
   468     NSString *verticalSize = [[NSString alloc] initWithFormat:@"%d", height];
   459     const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);
   469     const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);