- Refactoring. Separation of game log viewing code to GameLogViewController ios-revival
authorantonc27 <antonc27@mail.ru>
Tue, 15 Sep 2015 04:28:25 +0200
branchios-revival
changeset 11180 906c1878bc2c
parent 11179 e1a098f950a9
child 11181 015596575698
- Refactoring. Separation of game log viewing code to GameLogViewController
project_files/HedgewarsMobile/Classes/GameLogViewController.h
project_files/HedgewarsMobile/Classes/GameLogViewController.m
project_files/HedgewarsMobile/Classes/MainMenuViewController.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/Classes/GameLogViewController.h	Tue Sep 15 04:28:25 2015 +0200
@@ -0,0 +1,23 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2015 Anton Malmygin <antonc27@mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ */
+
+#import <UIKit/UIKit.h>
+
+@interface GameLogViewController : UIViewController
+
+@end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/Classes/GameLogViewController.m	Tue Sep 15 04:28:25 2015 +0200
@@ -0,0 +1,68 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2015 Anton Malmygin <antonc27@mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ */
+
+#import "GameLogViewController.h"
+
+@interface GameLogViewController ()
+
+@end
+
+@implementation GameLogViewController
+
+#pragma mark - View life cycle
+
+- (void)viewDidLoad
+{
+    [super viewDidLoad];
+    
+    UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(dismissAction)];
+    self.navigationItem.rightBarButtonItem = closeButton;
+    [closeButton release];
+    
+    NSString *debugStr = nil;
+    if ([[NSFileManager defaultManager] fileExistsAtPath:DEBUG_FILE()])
+        debugStr = [[NSString alloc] initWithContentsOfFile:DEBUG_FILE() encoding:NSUTF8StringEncoding error:nil];
+    else
+        debugStr = [[NSString alloc] initWithString:@"Here be log"];
+    
+    UITextView *logView = [[UITextView alloc] initWithFrame:self.view.frame];
+    [logView setAutoresizingMask:(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth)];
+    logView.text = debugStr;
+    [debugStr release];
+    logView.editable = NO;
+    
+    [self.view addSubview:logView];
+    [logView release];
+}
+
+#pragma mark - Actions
+
+- (void)dismissAction
+{
+    [self dismissViewControllerAnimated:YES completion:nil];
+}
+
+#pragma mark - Memory warning
+
+- (void)didReceiveMemoryWarning
+{
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+@end
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Mon Sep 14 07:02:06 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Tue Sep 15 04:28:25 2015 +0200
@@ -29,6 +29,10 @@
 #import "ServerProtocolNetwork.h"
 #import "GameInterfaceBridge.h"
 
+#ifdef DEBUG
+#import "GameLogViewController.h"
+#endif
+
 @interface MainMenuViewController ()
 @property (retain, nonatomic) IBOutlet UIButton *simpleGameButton;
 @property (retain, nonatomic) IBOutlet UIButton *missionsButton;
@@ -104,7 +108,6 @@
     UIButton *button = (UIButton *)sender;
     UIAlertView *alert;
     NSString *xib = nil;
-    NSString *debugStr = nil;
 
     [[AudioManagerController mainManager] playClickSound];
     switch (button.tag) {
@@ -130,40 +133,15 @@
             break;
         case 3:
 #ifdef DEBUG
-            if ([[NSFileManager defaultManager] fileExistsAtPath:DEBUG_FILE()])
-                debugStr = [[NSString alloc] initWithContentsOfFile:DEBUG_FILE()];
-            else
-                debugStr = [[NSString alloc] initWithString:@"Here be log"];
-            UITextView *scroll = [[UITextView alloc] initWithFrame:self.view.frame];
-            scroll.text = debugStr;
-            [debugStr release];
-            scroll.editable = NO;
-            scroll.alpha = 0;
-
-            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
-            [btn addTarget:scroll action:@selector(removeFromSuperview) forControlEvents:UIControlEventTouchUpInside];
-            [btn addTarget:btn action:@selector(removeFromSuperview) forControlEvents:UIControlEventTouchUpInside];
-            btn.frame = CGRectMake(self.view.frame.size.width-58, -6, 64, 64);
-            btn.backgroundColor = [UIColor blackColor];
-            btn.titleLabel.textColor = [UIColor whiteColor];
-            btn.titleLabel.textAlignment = UITextAlignmentCenter;
-            btn.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
-            [btn setTitle:@"Close" forState:UIControlStateNormal];
-            btn.alpha = 0;
-            [btn.layer setCornerRadius:10.0f];
-            [btn.layer setMasksToBounds:YES];
-
-            [self.view addSubview:scroll];
-            [self.view addSubview:btn];
-
-            [UIView beginAnimations:@"fadein" context:NULL];
-            [UIView setAnimationDuration:0.25f];
-            btn.alpha = 1;
-            scroll.alpha = 1;
-            [UIView commitAnimations];
-            [scroll release];
+            {
+                GameLogViewController *gameLogVC = [[GameLogViewController alloc] init];
+                UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:gameLogVC];
+                [gameLogVC release];
+                
+                [self presentViewController:navController animated:YES completion:nil];
+                [navController release];
+            }
 #else
-            debugStr = debugStr; // prevent compiler warning
             if (nil == self.aboutViewController) {
                 AboutViewController *about = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
                 about.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Mon Sep 14 07:02:06 2015 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Tue Sep 15 04:28:25 2015 +0200
@@ -252,6 +252,7 @@
 		F65E1DBF1B9B95A400A78ADF /* Icon-60@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F65E1DBC1B9B95A400A78ADF /* Icon-60@2x.png */; };
 		F65E1DC01B9B95A400A78ADF /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = F65E1DBD1B9B95A400A78ADF /* Icon-76.png */; };
 		F65E1DC11B9B95A400A78ADF /* Icon-76@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F65E1DBE1B9B95A400A78ADF /* Icon-76@2x.png */; };
+		F6BA38461BA7A834005D16EA /* GameLogViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F6BA38451BA7A834005D16EA /* GameLogViewController.m */; };
 		F6D7E09F1B76884E004F3BCF /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F6D7E09E1B76884E004F3BCF /* Default-568h@2x.png */; };
 		F6D7E0C21B768F19004F3BCF /* uLandGenPerlin.pas in Sources */ = {isa = PBXBuildFile; fileRef = F6D7E0BF1B768F19004F3BCF /* uLandGenPerlin.pas */; };
 		F6D7E0C31B768F19004F3BCF /* uLandGenTemplateBased.pas in Sources */ = {isa = PBXBuildFile; fileRef = F6D7E0C01B768F19004F3BCF /* uLandGenTemplateBased.pas */; };
@@ -720,6 +721,8 @@
 		F65E1DBC1B9B95A400A78ADF /* Icon-60@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-60@2x.png"; path = "Resources/Icons/Icon-60@2x.png"; sourceTree = "<group>"; };
 		F65E1DBD1B9B95A400A78ADF /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-76.png"; path = "Resources/Icons/Icon-76.png"; sourceTree = "<group>"; };
 		F65E1DBE1B9B95A400A78ADF /* Icon-76@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-76@2x.png"; path = "Resources/Icons/Icon-76@2x.png"; sourceTree = "<group>"; };
+		F6BA38441BA7A834005D16EA /* GameLogViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameLogViewController.h; sourceTree = "<group>"; };
+		F6BA38451BA7A834005D16EA /* GameLogViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameLogViewController.m; sourceTree = "<group>"; };
 		F6D7E09E1B76884E004F3BCF /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
 		F6D7E0BF1B768F19004F3BCF /* uLandGenPerlin.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uLandGenPerlin.pas; path = ../../hedgewars/uLandGenPerlin.pas; sourceTree = "<group>"; };
 		F6D7E0C01B768F19004F3BCF /* uLandGenTemplateBased.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uLandGenTemplateBased.pas; path = ../../hedgewars/uLandGenTemplateBased.pas; sourceTree = "<group>"; };
@@ -893,6 +896,8 @@
 				61F2E7CB1205EDE0005734F7 /* AboutViewController.h */,
 				61F2E7CC1205EDE0005734F7 /* AboutViewController.m */,
 				61F2E7CD1205EDE0005734F7 /* AboutViewController.xib */,
+				F6BA38441BA7A834005D16EA /* GameLogViewController.h */,
+				F6BA38451BA7A834005D16EA /* GameLogViewController.m */,
 				6167A6731391514600AA6D07 /* RestoreViewController.h */,
 				6167A6741391514600AA6D07 /* RestoreViewController.m */,
 				6167A6751391514600AA6D07 /* RestoreViewController-iPhone.xib */,
@@ -1692,6 +1697,7 @@
 				61798820114AA34C00BA94A9 /* uAIActions.pas in Sources */,
 				61798821114AA34C00BA94A9 /* uAIAmmoTests.pas in Sources */,
 				61798822114AA34C00BA94A9 /* uAIMisc.pas in Sources */,
+				F6BA38461BA7A834005D16EA /* GameLogViewController.m in Sources */,
 				61798823114AA34C00BA94A9 /* uAmmos.pas in Sources */,
 				61798824114AA34C00BA94A9 /* uChat.pas in Sources */,
 				61798825114AA34C00BA94A9 /* uCollisions.pas in Sources */,