project_files/HedgewarsMobile/Classes/GameLogViewController.m
author antonc27 <antonc27@mail.ru>
Tue, 15 Sep 2015 04:28:25 +0200
branchios-revival
changeset 11180 906c1878bc2c
child 11181 015596575698
permissions -rw-r--r--
- Refactoring. Separation of game log viewing code to GameLogViewController
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11180
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     1
/*
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     3
 * Copyright (c) 2015 Anton Malmygin <antonc27@mail.ru>
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     4
 *
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     8
 *
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    13
 *
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    17
 */
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    18
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    19
#import "GameLogViewController.h"
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    20
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    21
@interface GameLogViewController ()
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    22
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    23
@end
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    24
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    25
@implementation GameLogViewController
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    26
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    27
#pragma mark - View life cycle
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    28
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    29
- (void)viewDidLoad
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    30
{
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    31
    [super viewDidLoad];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    32
    
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    33
    UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(dismissAction)];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    34
    self.navigationItem.rightBarButtonItem = closeButton;
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    35
    [closeButton release];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    36
    
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    37
    NSString *debugStr = nil;
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    38
    if ([[NSFileManager defaultManager] fileExistsAtPath:DEBUG_FILE()])
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    39
        debugStr = [[NSString alloc] initWithContentsOfFile:DEBUG_FILE() encoding:NSUTF8StringEncoding error:nil];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    40
    else
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    41
        debugStr = [[NSString alloc] initWithString:@"Here be log"];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    42
    
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    43
    UITextView *logView = [[UITextView alloc] initWithFrame:self.view.frame];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    44
    [logView setAutoresizingMask:(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth)];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    45
    logView.text = debugStr;
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    46
    [debugStr release];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    47
    logView.editable = NO;
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    48
    
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    49
    [self.view addSubview:logView];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    50
    [logView release];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    51
}
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    52
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    53
#pragma mark - Actions
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    54
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    55
- (void)dismissAction
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    56
{
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    57
    [self dismissViewControllerAnimated:YES completion:nil];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    58
}
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    59
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    60
#pragma mark - Memory warning
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    61
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    62
- (void)didReceiveMemoryWarning
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    63
{
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    64
    [super didReceiveMemoryWarning];
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    65
    // Dispose of any resources that can be recreated.
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    66
}
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    67
906c1878bc2c - Refactoring. Separation of game log viewing code to GameLogViewController
antonc27 <antonc27@mail.ru>
parents:
diff changeset
    68
@end