diff --git a/FMC Planner 2.xcodeproj/project.pbxproj b/FMC Planner 2.xcodeproj/project.pbxproj index c021235..8c6f4dd 100644 --- a/FMC Planner 2.xcodeproj/project.pbxproj +++ b/FMC Planner 2.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ E22EE9EA1C9DB7B4001F5BC0 /* FMC_Planner_2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9E91C9DB7B4001F5BC0 /* FMC_Planner_2Tests.m */; }; E22EE9F51C9DB7B4001F5BC0 /* FMC_Planner_2UITests.m in Sources */ = {isa = PBXBuildFile; fileRef = E22EE9F41C9DB7B4001F5BC0 /* FMC_Planner_2UITests.m */; }; E2763C721CA6C8AE001E4EDA /* LSKs.plist in Resources */ = {isa = PBXBuildFile; fileRef = E2763C711CA6C8AE001E4EDA /* LSKs.plist */; }; + E2763C751CA6E777001E4EDA /* ViewControllerServiceMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = E2763C741CA6E777001E4EDA /* ViewControllerServiceMenu.m */; }; E28E106D1C9FF93D006E2C6B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */; }; E28E10711CA01EC9006E2C6B /* MENU.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10701CA01EC9006E2C6B /* MENU.plist */; }; E28E10731CA0375F006E2C6B /* ROUTE.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10721CA0375F006E2C6B /* ROUTE.plist */; }; @@ -63,6 +64,8 @@ E22EE9F41C9DB7B4001F5BC0 /* FMC_Planner_2UITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FMC_Planner_2UITests.m; sourceTree = ""; }; E22EE9F61C9DB7B4001F5BC0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; E2763C711CA6C8AE001E4EDA /* LSKs.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = LSKs.plist; sourceTree = ""; }; + E2763C731CA6E777001E4EDA /* ViewControllerServiceMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControllerServiceMenu.h; sourceTree = ""; }; + E2763C741CA6E777001E4EDA /* ViewControllerServiceMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerServiceMenu.m; sourceTree = ""; }; E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; E28E10701CA01EC9006E2C6B /* MENU.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = MENU.plist; sourceTree = ""; }; E28E10721CA0375F006E2C6B /* ROUTE.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ROUTE.plist; sourceTree = ""; }; @@ -185,6 +188,7 @@ E22EE9D51C9DB7B3001F5BC0 /* ViewController.h */, E227C7811C9F42AB00DE0CA4 /* ViewControllerKeyboard.h */, E227C7841C9F474100DE0CA4 /* ViewControllerScreen.h */, + E2763C731CA6E777001E4EDA /* ViewControllerServiceMenu.h */, ); name = Header; sourceTree = ""; @@ -195,6 +199,7 @@ E22EE9D61C9DB7B3001F5BC0 /* ViewController.m */, E227C7821C9F42AB00DE0CA4 /* ViewControllerKeyboard.m */, E227C7851C9F474100DE0CA4 /* ViewControllerScreen.m */, + E2763C741CA6E777001E4EDA /* ViewControllerServiceMenu.m */, ); name = Implementation; sourceTree = ""; @@ -369,6 +374,7 @@ E22EE9D11C9DB7B3001F5BC0 /* main.m in Sources */, E2A927161CA30CEE00606E07 /* SharedDeclerations.m in Sources */, E227C7831C9F42AB00DE0CA4 /* ViewControllerKeyboard.m in Sources */, + E2763C751CA6E777001E4EDA /* ViewControllerServiceMenu.m in Sources */, E227C7861C9F474100DE0CA4 /* ViewControllerScreen.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index fe2b454..4538c32 100644 --- a/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/FMC Planner 2.xcodeproj/xcuserdata/Kili2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -2,4 +2,22 @@ + + + + + + diff --git a/FMC Planner 2/Base.lproj/Main.storyboard b/FMC Planner 2/Base.lproj/Main.storyboard index 00959a2..26433fb 100644 --- a/FMC Planner 2/Base.lproj/Main.storyboard +++ b/FMC Planner 2/Base.lproj/Main.storyboard @@ -54,6 +54,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FMC Planner 2/LSKs.plist b/FMC Planner 2/LSKs.plist index d21492d..c3910cf 100644 --- a/FMC Planner 2/LSKs.plist +++ b/FMC Planner 2/LSKs.plist @@ -13,7 +13,7 @@ - + CLEAR ENTRY EXPORT SERVICE diff --git a/FMC Planner 2/ViewController.h b/FMC Planner 2/ViewController.h index 9138e9e..e01ef19 100644 --- a/FMC Planner 2/ViewController.h +++ b/FMC Planner 2/ViewController.h @@ -9,6 +9,7 @@ #import "SharedDeclerations.h" #import "ViewControllerKeyboard.h" #import "ViewControllerScreen.h" +#import "ViewControllerServiceMenu.h" #import @interface ViewController : UIViewController diff --git a/FMC Planner 2/ViewController.m b/FMC Planner 2/ViewController.m index 3660c50..8f689a3 100644 --- a/FMC Planner 2/ViewController.m +++ b/FMC Planner 2/ViewController.m @@ -21,6 +21,7 @@ // Setup save system _save = [[NSMutableDictionary alloc] init]; _firstLoad = true; + self.title = @"FMC"; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { @@ -36,69 +37,19 @@ } - (void)saveToFile:(NSDictionary *)save { + NSString *file = + [SharedDeclerations savePathForFile:[_save valueForKey:@"MENU@LSKR1"]]; if (_firstLoad) { - if ([[NSFileManager defaultManager] - fileExistsAtPath: - [SharedDeclerations - savePathForFile:[_save valueForKey:@"MENU@LSKR1"]]]) { - if ([UIAlertController class]) { - UIAlertController *alert = [UIAlertController - alertControllerWithTitle:@"Load or replace?" - message: - @"The entered CO ROUTE alreay exists. " - @"Do you want to load or replace it?" - preferredStyle:UIAlertControllerStyleActionSheet]; - UIAlertAction *defaultAction = - [UIAlertAction actionWithTitle:@"Cancel" - style:UIAlertActionStyleCancel - handler:nil]; - UIAlertAction *loadAction = [UIAlertAction - actionWithTitle:@"Load" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self - loadSave:[_save valueForKey:@"MENU@LSKR1"]]; - }]; - UIAlertAction *replaceAction = [UIAlertAction - actionWithTitle:@"Replace" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [_save - writeToFile: - [SharedDeclerations - savePathForFile: - [_save - valueForKey:@"MENU@LSKR1"]] - atomically:YES]; - }]; - [alert addAction:defaultAction]; - [alert addAction:loadAction]; - [alert addAction:replaceAction]; - [self presentViewController:alert animated:YES completion:nil]; - } else { - UIAlertView *alert = [[UIAlertView alloc] - initWithTitle:@"Load or replace?" - message:@"The entered CO ROUTE alreay exists. Do " - @"you want to load " - @"or replace it?" - delegate:self - cancelButtonTitle:@"Cancel" - otherButtonTitles:@"Load", @"Replace", nil]; - [alert show]; - } - } else if (!([[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) { - [_save - writeToFile:[SharedDeclerations - savePathForFile:[_save - valueForKey:@"MENU@LSKR1"]] - atomically:YES]; + if ([[NSFileManager defaultManager] fileExistsAtPath:file]) { + [self alertViewiOS7:file]; + } else if (!([[_save valueForKey:@"MENU@LSKR1"] + isEqualToString:@""]) && + [_save valueForKey:@"MENU@LSKR1"] != nil) { + [_save writeToFile:file atomically:YES]; } } else if (!([_save valueForKey:@"MENU@LSKR1"] == nil || [[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) { - [_save - writeToFile:[SharedDeclerations - savePathForFile:[_save valueForKey:@"MENU@LSKR1"]] - atomically:YES]; + [_save writeToFile:file atomically:YES]; } _firstLoad = false; } @@ -113,7 +64,7 @@ } } -#pragma mark - Delegate vo UIAlertView +#pragma mark - Delegate for UIAlertView and UIAlertController outsource - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { @@ -129,4 +80,44 @@ } } +- (void)alertViewiOS7:(NSString *)file { + if ([UIAlertController class]) { + UIAlertController *alert = [UIAlertController + alertControllerWithTitle:@"Load or replace?" + message:@"The entered CO ROUTE alreay exists. " + @"Do you want to load or replace it?" + preferredStyle:UIAlertControllerStyleActionSheet]; + UIAlertAction *defaultAction = + [UIAlertAction actionWithTitle:@"Cancel" + style:UIAlertActionStyleCancel + handler:nil]; + UIAlertAction *loadAction = [UIAlertAction + actionWithTitle:@"Load" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [self loadSave:[_save valueForKey:@"MENU@LSKR1"]]; + }]; + UIAlertAction *replaceAction = + [UIAlertAction actionWithTitle:@"Replace" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [_save writeToFile:file atomically:YES]; + }]; + [alert addAction:defaultAction]; + [alert addAction:loadAction]; + [alert addAction:replaceAction]; + [self presentViewController:alert animated:YES completion:nil]; + } else { + UIAlertView *alert = [[UIAlertView alloc] + initWithTitle:@"Load or replace?" + message:@"The entered CO ROUTE alreay exists. Do " + @"you want to load " + @"or replace it?" + delegate:self + cancelButtonTitle:@"Cancel" + otherButtonTitles:@"Load", @"Replace", nil]; + [alert show]; + } +} + @end diff --git a/FMC Planner 2/ViewControllerScreen.m b/FMC Planner 2/ViewControllerScreen.m index 4895f88..012493e 100644 --- a/FMC Planner 2/ViewControllerScreen.m +++ b/FMC Planner 2/ViewControllerScreen.m @@ -82,12 +82,38 @@ } _main.backupCoRte = ((UILabel *)tapReg.view).text; ((UILabel *)tapReg.view).text = _Scratchpad.text; + } else if ([((UILabel *)tapReg.view) + .restorationIdentifier isEqualToString:@"LSKR4"]) { + [_main saveToFile:_main.save]; + _main.save = [[NSMutableDictionary alloc] init]; + [self clearScreen]; + NSArray *optional = [[[NSDictionary alloc] + initWithContentsOfFile:[[NSBundle mainBundle] + pathForResource:@"LSKs" + ofType:@"plist"]] + valueForKey:_Header.text]; + for (UILabel *label in _LSK) { + for (int i = 0; i < optional.count; i++) { + if (label.tag == i && [label.text isEqualToString:@""]) { + label.text = optional[i]; + if (!([optional[i] isEqualToString:@""])) { + label.userInteractionEnabled = YES; + } + } + } + } } else if ([((UILabel *)tapReg.view) .restorationIdentifier isEqualToString:@"LSKR5"]) { #warning EXPORT TO PMDG GOES HERE } else if ([((UILabel *)tapReg.view) .restorationIdentifier isEqualToString:@"LSKR6"]) { #warning SERVICE MENU GOES HERE + [self + presentViewController: + [self.storyboard + instantiateViewControllerWithIdentifier:@"ServiceMenu"] + animated:YES + completion:nil]; } else { ((UILabel *)tapReg.view).text = _Scratchpad.text; } diff --git a/FMC Planner 2/ViewControllerServiceMenu.h b/FMC Planner 2/ViewControllerServiceMenu.h new file mode 100644 index 0000000..d47c9ea --- /dev/null +++ b/FMC Planner 2/ViewControllerServiceMenu.h @@ -0,0 +1,17 @@ +// +// ViewControllerServiceMenu.h +// FMC Planner 2 +// +// Created by Kilian Hofmann on 26.03.16. +// Copyright © 2016 Kilian Hofmann. All rights reserved. +// + +#import "SharedDeclerations.h" +#import "ViewController.h" +#import + +@interface ViewControllerServiceMenu : UIViewController + +@property(strong, nonatomic) ViewController *main; + +@end diff --git a/FMC Planner 2/ViewControllerServiceMenu.m b/FMC Planner 2/ViewControllerServiceMenu.m new file mode 100644 index 0000000..dda52bf --- /dev/null +++ b/FMC Planner 2/ViewControllerServiceMenu.m @@ -0,0 +1,27 @@ +// +// ViewControllerServiceMenu.m +// FMC Planner 2 +// +// Created by Kilian Hofmann on 26.03.16. +// Copyright © 2016 Kilian Hofmann. All rights reserved. +// + +#import "ViewControllerServiceMenu.h" + +@implementation ViewControllerServiceMenu + +- (void)viewDidLoad { + [super viewDidLoad]; + self.title = @"Service Menu"; + self.navigationItem.leftBarButtonItem = + [[UIBarButtonItem alloc] initWithTitle:@"FMC" + style:UIBarButtonItemStyleDone + target:self + action:@selector(back)]; +} + +- (void)back { + [self dismissViewControllerAnimated:YES completion:nil]; +} + +@end