diff --git a/src/Catty.xcodeproj/project.pbxproj b/src/Catty.xcodeproj/project.pbxproj index a55b5f5c55..86e2271586 100644 --- a/src/Catty.xcodeproj/project.pbxproj +++ b/src/Catty.xcodeproj/project.pbxproj @@ -1356,7 +1356,6 @@ 92FF314E1A24DEB300093DA7 /* LookImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF311B1A24DEB300093DA7 /* LookImageViewController.m */; }; 92FF314F1A24DEB300093DA7 /* LooksTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF311D1A24DEB300093DA7 /* LooksTableViewController.m */; }; 92FF31551A24DEB300093DA7 /* SoundsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF312B1A24DEB300093DA7 /* SoundsTableViewController.m */; }; - 92FF31571A24DEB300093DA7 /* ObjectTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF312F1A24DEB300093DA7 /* ObjectTableViewController.m */; }; 92FF31581A24DEB300093DA7 /* SceneTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF31311A24DEB300093DA7 /* SceneTableViewController.m */; }; 92FF31591A24DEB300093DA7 /* DownloadTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF31341A24DEB300093DA7 /* DownloadTabBarController.m */; }; 92FF315B1A24DEB300093DA7 /* ProjectDetailStoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF31381A24DEB300093DA7 /* ProjectDetailStoreViewController.m */; }; @@ -1751,6 +1750,7 @@ AAF6D9DE1BC0C1F300686849 /* PlaceAtBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DD1BC0C1F300686849 /* PlaceAtBrick+Instruction.swift */; }; AAF6D9E01BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */; }; AAF6D9E21BC0C48300686849 /* PointToBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */; }; + B06830562A6007DC00BF06BD /* ObjectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B06830552A6007DC00BF06BD /* ObjectViewController.swift */; }; BA1FA9981F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA9971F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m */; }; BA1FA99D1F02AEDC0084184D /* InsertItemIntoUserListBrick.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99C1F02AEDC0084184D /* InsertItemIntoUserListBrick.m */; }; BA1FA9A01F02B0020084184D /* InsertItemIntoUserListBrickCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99F1F02B0020084184D /* InsertItemIntoUserListBrickCell.m */; }; @@ -3758,8 +3758,6 @@ 92FF311D1A24DEB300093DA7 /* LooksTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LooksTableViewController.m; sourceTree = ""; }; 92FF312A1A24DEB300093DA7 /* SoundsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoundsTableViewController.h; sourceTree = ""; }; 92FF312B1A24DEB300093DA7 /* SoundsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SoundsTableViewController.m; sourceTree = ""; }; - 92FF312E1A24DEB300093DA7 /* ObjectTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectTableViewController.h; sourceTree = ""; }; - 92FF312F1A24DEB300093DA7 /* ObjectTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectTableViewController.m; sourceTree = ""; }; 92FF31301A24DEB300093DA7 /* SceneTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneTableViewController.h; sourceTree = ""; }; 92FF31311A24DEB300093DA7 /* SceneTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SceneTableViewController.m; sourceTree = ""; }; 92FF31331A24DEB300093DA7 /* DownloadTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadTabBarController.h; sourceTree = ""; }; @@ -4395,6 +4393,7 @@ AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointInDirectionBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointInDirectionBrick+Instruction.swift"; sourceTree = ""; }; AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointToBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointToBrick+Instruction.swift"; sourceTree = ""; }; ABD74577198FBC2984BDDE56 /* hu */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = ""; }; + B06830552A6007DC00BF06BD /* ObjectViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectViewController.swift; sourceTree = ""; }; B11EA657D0D5E2E348790671 /* ta */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ta; path = ta.lproj/Localizable.strings; sourceTree = ""; }; B46B270517703F9400172837 /* CattyTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CattyTests-Info.plist"; sourceTree = ""; }; B46B270717703F9400172837 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -9226,11 +9225,10 @@ 92FF31181A24DEB300093DA7 /* MaintainObject */ = { isa = PBXGroup; children = ( + B06830552A6007DC00BF06BD /* ObjectViewController.swift */, 92FF31191A24DEB300093DA7 /* MaintainLooks */, 92FF311E1A24DEB300093DA7 /* MaintainScript */, 92FF31271A24DEB300093DA7 /* MaintainSounds */, - 92FF312E1A24DEB300093DA7 /* ObjectTableViewController.h */, - 92FF312F1A24DEB300093DA7 /* ObjectTableViewController.m */, ); path = MaintainObject; sourceTree = ""; @@ -12886,6 +12884,7 @@ AA401FE91BBEF6F9001BC49F /* CBInstructionProtocol.swift in Sources */, AABCB3E21BB36529009F67D2 /* CBScheduler.swift in Sources */, BACDF3521F1F9B7E00346167 /* DeleteItemOfUserListBrick.m in Sources */, + B06830562A6007DC00BF06BD /* ObjectViewController.swift in Sources */, BB9EC0E527D62CBA009FF8CE /* FormTableViewCell.swift in Sources */, 4614B1DD25608E8B004174AD /* StitchBrickCell.swift in Sources */, AABCB3DF1BB3650B009F67D2 /* CBBackendProtocol.swift in Sources */, @@ -12994,7 +12993,6 @@ 4C2EE41E1B555B55006DE9B8 /* CBXMLOpenedNestingBricksStack.m in Sources */, 7B09EB6A29B1DF8200590F3D /* LoginViewController.swift in Sources */, 5EFBD5F92145533B003B3CDC /* ProjectDescriptionViewController.swift in Sources */, - 92FF31571A24DEB300093DA7 /* ObjectTableViewController.m in Sources */, 4CE3D68F2107B68600005629 /* VisualDetectionManagerProtocol.swift in Sources */, BB6FE23C2812BD4E007ABDA9 /* FormCrashReportsSwitchTableViewCell.swift in Sources */, 929CC0EF1BC39B8C0027DEC0 /* PhiroMotorStopBrickCell.m in Sources */, diff --git a/src/Catty/Storyboard+XIB/iPhone.storyboard b/src/Catty/Storyboard+XIB/iPhone.storyboard index 9a24cd1e38..8e51df0fe6 100644 --- a/src/Catty/Storyboard+XIB/iPhone.storyboard +++ b/src/Catty/Storyboard+XIB/iPhone.storyboard @@ -209,83 +209,93 @@ - + - + - - + + - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - + + - + - + @@ -316,19 +326,19 @@ - + - + - + - + - + @@ -392,7 +402,7 @@ @@ -1142,7 +1153,7 @@ - + @@ -1993,7 +2004,7 @@ - + @@ -2166,8 +2177,8 @@ - - + + diff --git a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h index c4d2a294a9..e1158cede8 100644 --- a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h +++ b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.h @@ -28,6 +28,7 @@ @property (nonatomic, strong) PlaceHolderView *placeHolderView; @property (nonatomic, assign) BOOL allBricksSelected; +@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; - (void)showPlaceHolder:(BOOL)show; - (void)setupToolBar; diff --git a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m index 45ebd630fb..af2c197330 100644 --- a/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m +++ b/src/Catty/ViewController/BaseViewController/BaseCollectionViewController.m @@ -33,7 +33,6 @@ @interface BaseCollectionViewController () @property (nonatomic, strong) LoadingView* loadingView; -@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; @end @implementation BaseCollectionViewController @@ -191,7 +190,7 @@ - (void)showLoadingView self.navigationController.navigationBar.userInteractionEnabled = NO; self.navigationController.toolbar.userInteractionEnabled = NO; self.navigationController.interactivePopGestureRecognizer.enabled = NO; - [self showPlaceHolder:NO]; + //[self showPlaceHolder:NO]; [self.loadingView show]; } diff --git a/src/Catty/ViewController/BaseViewController/BaseTableViewController.h b/src/Catty/ViewController/BaseViewController/BaseTableViewController.h index e63e291c38..31acea4905 100644 --- a/src/Catty/ViewController/BaseViewController/BaseTableViewController.h +++ b/src/Catty/ViewController/BaseViewController/BaseTableViewController.h @@ -29,6 +29,7 @@ @property (nonatomic, strong) NSArray *editableSections; @property (nonatomic, strong, readonly) UIBarButtonItem *selectAllRowsButtonItem; @property (nonatomic, strong) PlaceHolderView *placeHolderView; +@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; - (void)setStagePresenterViewController:(StagePresenterViewController*) mockViewController; - (void)showPlaceHolder:(BOOL)show; diff --git a/src/Catty/ViewController/BaseViewController/BaseTableViewController.m b/src/Catty/ViewController/BaseViewController/BaseTableViewController.m index a3266cad9e..b863478394 100644 --- a/src/Catty/ViewController/BaseViewController/BaseTableViewController.m +++ b/src/Catty/ViewController/BaseViewController/BaseTableViewController.m @@ -40,7 +40,6 @@ @interface BaseTableViewController () @property (nonatomic, strong) LoadingView* loadingView; @property (nonatomic, strong) UIBarButtonItem *selectAllRowsButtonItem; @property (nonatomic, strong) UIBarButtonItem *normalModeRightBarButtonItem; -@property (nonatomic, strong) StagePresenterViewController *stagePresenterViewController; @end @implementation BaseTableViewController @@ -438,7 +437,7 @@ - (void)showLoadingView self.navigationController.navigationBar.userInteractionEnabled = NO; self.navigationController.toolbar.userInteractionEnabled = NO; self.navigationController.interactivePopGestureRecognizer.enabled = NO; - [self showPlaceHolder:NO]; + //[self showPlaceHolder:NO]; [self.loadingView show]; } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.h index 3bfd0b3846..9d6a7e19a5 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.h @@ -26,17 +26,27 @@ @class SpriteObject; @class Brick; @class Look; + +@protocol EnableAndDisableSegmentedControllDelegate +- (void)enableSegmentedControll; +- (void)disableSegmentedControll; +@end + @protocol BrickLookProtocol; @protocol PaintDelegate - (void)addPaintedImage:(UIImage *)image andPath:(NSString *)path; - (void)addMediaLibraryLoadedImage:(UIImage*)image withName:(NSString *)name; +- (void)addLookAction:(id)sender; +- (void)initNavigationBar; @end @interface LooksTableViewController : BaseTableViewController @property (strong, nonatomic) SpriteObject *object; +@property (weak, nonatomic) id segmentedControllDelegate; +@property (weak, nonatomic) UIViewController *parentNavigationController; @property (nonatomic) BOOL showAddLookActionSheetAtStartForScriptEditor; @property (nonatomic) BOOL showAddLookActionSheetAtStartForObject; @property (copy) void (^afterSafeBlock)(Look* look); diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m index 7d6e67b3fd..d26b55a756 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainLooks/LooksTableViewController.m @@ -55,7 +55,7 @@ @implementation LooksTableViewController - (void)initNavigationBar { UIBarButtonItem *editButtonItem = [TableUtil editButtonItemWithTarget:self action:@selector(editAction:)]; - self.navigationItem.rightBarButtonItem = editButtonItem; + self.parentNavigationController.navigationItem.rightBarButtonItem = editButtonItem; [self changeEditingBarButtonState]; } @@ -88,12 +88,12 @@ - (void)viewDidLoad - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self reloadData]; } #pragma mark - actions - (void)editAction:(id)sender { + [self.tableView setEditing:false animated:YES]; NSString *actionSheetTitle = self.object.isBackground ? kLocalizedEditBackgrounds : kLocalizedEditLooks; @@ -104,24 +104,27 @@ - (void)editAction:(id)sender NSString *destructiveActionTitle = self.object.isBackground ? kLocalizedDeleteBackgrounds : kLocalizedDeleteLooks; [[actionSheet addDestructiveActionWithTitle:destructiveActionTitle handler:^{ + [self.segmentedControllDelegate disableSegmentedControll]; self.deletionMode = YES; self.copyMode = NO; [self setupEditingToolBar]; - [super changeToEditingMode:sender]; + [self changeToEditingMode:sender]; }] addDefaultActionWithTitle:kLocalizedCopyLooks handler:^{ + [self.segmentedControllDelegate disableSegmentedControll]; self.deletionMode = NO; self.copyMode = YES; [self setupEditingToolBar]; - [super changeToEditingMode:sender]; + [self changeToEditingMode:sender]; }]; } if (self.object.lookList.count >= 2) { [actionSheet addDefaultActionWithTitle:kLocalizedMoveLooks handler:^{ + [self.segmentedControllDelegate disableSegmentedControll]; self.deletionMode = NO; self.copyMode = NO; - [super changeToMoveMode:sender]; + [self changeToMoveMode:sender]; }]; } @@ -133,6 +136,46 @@ - (void)editAction:(id)sender showWithController:self]; } +- (void)changeToMoveMode:(id)sender +{ + UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedDone + style:UIBarButtonItemStylePlain + target:self + action:@selector(exitEditingMode)]; + self.parentNavigationController.navigationItem.hidesBackButton = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; + [self.tableView reloadData]; + [self.tableView setEditing:YES animated:YES]; + self.tableView.allowsMultipleSelectionDuringEditing = NO; + self.parentNavigationController.navigationController.toolbar.hidden = true; + self.editing = YES; +} + +- (void)changeToEditingMode:(id)sender +{ + UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel + style:UIBarButtonItemStylePlain + target:self + action:@selector(exitEditingMode)]; + self.parentNavigationController.navigationItem.hidesBackButton = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; + [self.tableView reloadData]; + [self.tableView setEditing:YES animated:YES]; + self.tableView.allowsMultipleSelectionDuringEditing = YES; + self.editing = YES; +} + +- (void)exitEditingMode +{ + self.parentNavigationController.navigationItem.hidesBackButton = NO; + [self initNavigationBar]; + [self.tableView setEditing:NO animated:YES]; + [self setupToolBar]; + self.editing = NO; + [self.segmentedControllDelegate enableSegmentedControll]; + self.parentNavigationController.navigationController.toolbar.hidden = false; +} + - (void)toggleDetailCellsMode { self.useDetailCells = !self.useDetailCells; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; @@ -189,7 +232,7 @@ - (void)copySelectedLooksAction:(id)sender NSArray *selectedRowsIndexPaths = [self.tableView indexPathsForSelectedRows]; if (! [selectedRowsIndexPaths count]) { // nothing selected, nothing to delete... - [super exitEditingMode]; + [self exitEditingMode]; return; } @@ -199,7 +242,7 @@ - (void)copySelectedLooksAction:(id)sender [looksToCopy addObject:look]; } [self copyLooksActionWithSourceLooks:looksToCopy]; - [super exitEditingMode]; + [self exitEditingMode]; } - (void)copyLooksActionWithSourceLooks:(NSArray *)sourceLooks @@ -242,7 +285,7 @@ - (void)confirmDeleteSelectedLooksAction:(id)sender NSArray *selectedRowsIndexPaths = [self.tableView indexPathsForSelectedRows]; if (! [selectedRowsIndexPaths count]) { // nothing selected, nothing to delete... - [super exitEditingMode]; + [self exitEditingMode]; return; } [self deleteSelectedLooksAction]; @@ -259,7 +302,7 @@ - (void)deleteSelectedLooksAction [self.dataCache removeObjectForKey:look.fileName]; } [self.object removeLooks:looksToRemove AndSaveToDisk:YES]; - [super exitEditingMode]; + [self exitEditingMode]; [self.tableView deleteRowsAtIndexPaths:selectedRowsIndexPaths withRowAnimation:UITableViewRowAnimationNone]; [self showPlaceHolder:(! (BOOL)[self.object.lookList count])]; [self hideLoadingView]; @@ -304,6 +347,7 @@ - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS return cell; } + CatrobatBaseCell* imageCell = (CatrobatBaseCell*)cell; Look *look = [self.object.lookList objectAtIndex:indexPath.row]; imageCell.iconImageView.image = nil; @@ -694,7 +738,7 @@ - (void)setupToolBar UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; - self.toolbarItems = [NSArray arrayWithObjects: flex, add, flex, flex, play, flex, nil]; + self.parentNavigationController.toolbarItems = [NSArray arrayWithObjects: flex, add, flex, flex, play, flex, nil]; } - (void)setupEditingToolBar @@ -716,7 +760,7 @@ - (void)setupEditingToolBar UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; - self.toolbarItems = [NSArray arrayWithObjects:self.selectAllRowsButtonItem, flex, editActionButton, nil]; + self.parentNavigationController.toolbarItems = [NSArray arrayWithObjects:self.selectAllRowsButtonItem, flex, editActionButton, nil]; } #pragma mark paintDelegate @@ -872,9 +916,9 @@ - (BOOL)checkUserAuthorisation:(UIImagePickerControllerSourceType)pickerType - (void)changeEditingBarButtonState { if (self.object.lookList.count >= 1) { - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentViewController.navigationItem.rightBarButtonItem.enabled = YES; } else { - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentViewController.navigationItem.rightBarButtonItem.enabled = NO; } } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h index 95ed4b6fe1..50f43236d3 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.h @@ -24,11 +24,19 @@ #import "BaseCollectionViewController.h" @class SpriteObject; +@protocol EnableAndDisableSegmentedControllDelegate; @interface ScriptCollectionViewController : BaseCollectionViewController @property (nonatomic, strong) SpriteObject *object; +@property (nonatomic, strong) UIViewController *parentNavigationController; +@property (weak, nonatomic) id segmentedControllDelegate; + - (void)removeBrickOrScript:(id)scriptOrBrick atIndexPath:(NSIndexPath*)indexPath; +-(void)turnOnInsertingBrickMode; +-(void)reloadData; +- (void)showBrickPickerAction:(id)sender; +- (void)changeDeleteBarButtonState; @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m index f45a73fc22..c23d5c6c90 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainScript/ScriptCollectionViewController.m @@ -114,6 +114,7 @@ - (void)viewDidLoad - (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; // do not call super to prevent automatic scrolling when opening a UIPickerView @@ -369,6 +370,7 @@ - (void)deleteAlertView addDefaultActionWithTitle:kLocalizedYes handler:^{ [self deleteSelectedBricks]; self.allBricksSelected = NO; + [self.segmentedControllDelegate enableSegmentedControll]; }] build] showWithController:self]; } @@ -789,6 +791,7 @@ -(void)deleteSelectedBricks -(void)turnOnInsertingBrickMode { + NSLog(@"@%ss","turn on"); [[BrickInsertManager sharedInstance] setBrickInsertionMode:YES]; for (UIButton *button in self.navigationController.toolbar.items) { button.enabled = NO; @@ -797,7 +800,7 @@ -(void)turnOnInsertingBrickMode layout.longPressGestureRecognizer.minimumPressDuration = 0.1; [self.navigationItem setHidesBackButton:YES animated:NO]; dispatch_async(dispatch_get_main_queue(), ^{ - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = NO; }); } @@ -812,7 +815,7 @@ -(void)turnOffInsertingBrickMode layout.longPressGestureRecognizer.minimumPressDuration = 0.5; [self.navigationItem setHidesBackButton:NO animated:NO]; dispatch_async(dispatch_get_main_queue(), ^{ - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = YES; }); } @@ -824,11 +827,11 @@ - (void)changeDeleteBarButtonState } else { navBarButton= [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel style:UIBarButtonItemStylePlain target:self action:@selector(exitDeleteMode)]; } - self.navigationItem.rightBarButtonItem = navBarButton; + self.parentNavigationController.navigationItem.rightBarButtonItem = navBarButton; if (self.object.scriptList.count) { - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = YES; } else { - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = NO; } } @@ -1178,6 +1181,7 @@ -(void)enableUserInteractionAndResetHighlight for (BrickCell *cell in self.collectionView.visibleCells) { cell.enabled = YES; cell.alpha = kBrickCellActiveOpacity; + [self.segmentedControllDelegate enableSegmentedControll]; } CGFloat maxContentOffset = self.collectionView.contentSize.height + self.collectionView.contentInset.bottom - self.collectionView.bounds.size.height; @@ -1197,17 +1201,18 @@ -(void)disableUserInteractionAndHighlight:(BrickCell*)brickCell withMarginBottom collectionViewLayout.longPressGestureRecognizer.enabled = NO; self.collectionView.scrollEnabled = NO; self.isEditingBrickMode = YES; - self.navigationController.toolbar.userInteractionEnabled = NO; - self.navigationController.navigationBar.userInteractionEnabled = NO; + self.parentNavigationController.navigationController.toolbar.userInteractionEnabled = NO; + self.parentNavigationController.navigationController.navigationBar.userInteractionEnabled = NO; // disable swipe back gesture - if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { - self.navigationController.interactivePopGestureRecognizer.enabled = NO; + if ([self.parentNavigationController.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { + self.parentNavigationController.navigationController.interactivePopGestureRecognizer.enabled = NO; } for (BrickCell *cell in self.collectionView.visibleCells) { if (cell != brickCell) { cell.enabled = NO; cell.alpha = kBrickCellInactiveWhileEditingOpacity; + [self.segmentedControllDelegate disableSegmentedControll]; } } @@ -1292,8 +1297,9 @@ - (void)selectAllRows:(id)sender -(void)enterDeleteMode { + [self.segmentedControllDelegate disableSegmentedControll]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel style:UIBarButtonItemStylePlain target:self action:@selector(exitDeleteMode)]; - self.navigationItem.rightBarButtonItem = cancelButton; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; [UIView animateWithDuration:0.5f delay:0.0f usingSpringWithDamping:0.6f initialSpringVelocity:1.5f options:UIViewAnimationOptionCurveEaseInOut animations:^{ for (BrickCell *brickCell in self.collectionView.visibleCells) { @@ -1311,7 +1317,7 @@ -(void)enterDeleteMode -(void)exitDeleteMode { UIBarButtonItem *deleteButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedDelete style:UIBarButtonItemStylePlain target:self action:@selector(enterDeleteMode)]; - self.navigationItem.rightBarButtonItem = deleteButton; + self.parentNavigationController.navigationItem.rightBarButtonItem = deleteButton; [UIView animateWithDuration:0.3f delay:0.0f usingSpringWithDamping:0.65f initialSpringVelocity:0.5f options:UIViewAnimationOptionCurveEaseInOut animations:^{ @@ -1334,6 +1340,7 @@ -(void)exitDeleteMode }]; self.editing = NO; self.allBricksSelected = NO; + [self.segmentedControllDelegate enableSegmentedControll]; } -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer @@ -1341,4 +1348,22 @@ -(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer return NO; } +- (void)setupToolBar +{ + [super setupToolBar]; + +// UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd +// target:self +// action:@selector(showBrickPickerAction:)]; +// UIBarButtonItem *play = [[PlayButton alloc] initWithTarget:self +// action:@selector(playSceneAction:)]; +// UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace +// target:self +// action:nil]; +// self.parentNavigationController.toolbarItems = [NSArray arrayWithObjects: flex, add, flex, flex, play, flex, nil]; + + + self.parentNavigationController.toolbarItems = self.toolbarItems; +} + @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h index 463d3465e0..3c5a8803f0 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.h @@ -25,9 +25,11 @@ @class SpriteObject; @class Sound; +@protocol EnableAndDisableSegmentedControllDelegate; @protocol SoundDelegate - (void)addSound:(Sound *)sound; +- (void)initNavigationBar; @end @@ -35,6 +37,11 @@ @property (strong, nonatomic) SpriteObject *object; @property (nonatomic) BOOL showAddSoundActionSheetAtStart; +@property (weak, nonatomic) id segmentedControllDelegate; +@property (nonatomic, strong) UIViewController *parentNavigationController; @property (copy) void (^afterSafeBlock)(Sound* look); +- (void)playSceneAction:(id)sender; +- (void)addSoundAction:(id)sender; + @end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m index 057937465a..c7e7d165ab 100644 --- a/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m +++ b/src/Catty/ViewController/Continue&New/MaintainObject/MaintainSounds/SoundsTableViewController.m @@ -51,7 +51,7 @@ @implementation SoundsTableViewController - (void)initNavigationBar { UIBarButtonItem *editButtonItem = [TableUtil editButtonItemWithTarget:self action:@selector(editAction:)]; - self.navigationItem.rightBarButtonItem = editButtonItem; + self.parentNavigationController.navigationItem.rightBarButtonItem = editButtonItem; } #pragma mark - events @@ -68,7 +68,8 @@ - (void)viewDidLoad self.currentPlayingSong = nil; self.currentPlayingSongCell = nil; self.placeHolderView.title = kLocalizedTapPlusToAddSound; - [self showPlaceHolder:(! (BOOL)[self.object.soundList count])]; + //[self showPlaceHolder:(! (BOOL)[self.object.soundList count])]; + self.placeHolderView.hidden = (self.object.soundList.count != 0); [self setupToolBar]; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; self.isAllowed = YES; @@ -76,6 +77,7 @@ - (void)viewDidLoad if(self.showAddSoundActionSheetAtStart) { [self addSoundAction:nil]; } + } - (void)viewWillAppear:(BOOL)animated @@ -83,6 +85,7 @@ - (void)viewWillAppear:(BOOL)animated [super viewWillAppear:animated]; [self.navigationController setToolbarHidden:NO]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; + } - (void)viewWillDisappear:(BOOL)animated @@ -109,14 +112,14 @@ - (void)editAction:(id)sender [actionSheet addDestructiveActionWithTitle:kLocalizedDeleteSounds handler:^{ self.deletionMode = YES; [self setupEditingToolBar]; - [super changeToEditingMode:sender]; + [self changeToEditingMode:sender]; }]; } if (self.object.soundList.count >= 2) { [actionSheet addDefaultActionWithTitle:kLocalizedMoveSounds handler:^{ self.deletionMode = NO; - [super changeToMoveMode:sender]; + [self changeToMoveMode:sender]; }]; } @@ -219,7 +222,7 @@ - (void)confirmDeleteSelectedSoundsAction:(id)sender NSArray *selectedRowsIndexPaths = [self.tableView indexPathsForSelectedRows]; if (! [selectedRowsIndexPaths count]) { // nothing selected, nothing to delete... - [super exitEditingMode]; + [self exitEditingMode]; return; } self.deletionMode = NO; @@ -237,7 +240,7 @@ - (void)deleteSelectedSoundsAction [soundsToRemove addObject:sound]; } [self.object removeSounds:soundsToRemove AndSaveToDisk:YES]; - [super exitEditingMode]; + [self exitEditingMode]; [self.tableView deleteRowsAtIndexPaths:selectedRowsIndexPaths withRowAnimation:UITableViewRowAnimationNone]; [super showPlaceHolder:(! (BOOL)[self.object.soundList count])]; [self hideLoadingView]; @@ -582,10 +585,48 @@ - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)fl } } +- (void)changeToMoveMode:(id)sender +{ + [self.segmentedControllDelegate disableSegmentedControll]; + UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedDone + style:UIBarButtonItemStylePlain + target:self + action:@selector(exitEditingMode)]; + self.parentNavigationController.navigationItem.hidesBackButton = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; + [self.tableView reloadData]; + [self.tableView setEditing:YES animated:YES]; + self.tableView.allowsMultipleSelectionDuringEditing = NO; + self.parentNavigationController.navigationController.toolbar.hidden = true; + self.editing = YES; +} + +- (void)changeToEditingMode:(id)sender +{ + [self.segmentedControllDelegate disableSegmentedControll]; + UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:kLocalizedCancel + style:UIBarButtonItemStylePlain + target:self + action:@selector(exitEditingMode)]; + self.parentNavigationController.navigationItem.hidesBackButton = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem = cancelButton; + [self.tableView reloadData]; + [self.tableView setEditing:YES animated:YES]; + self.tableView.allowsMultipleSelectionDuringEditing = YES; + self.editing = YES; +} + - (void)exitEditingMode { [super exitEditingMode]; self.deletionMode = NO; + self.parentNavigationController.navigationItem.hidesBackButton = NO; + [self initNavigationBar]; + self.parentNavigationController.navigationController.toolbar.hidden = false; + [self.tableView setEditing:NO animated:YES]; + [self setupToolBar]; + self.editing = NO; + [self.segmentedControllDelegate enableSegmentedControll]; } #pragma mark - Helper Methods @@ -675,6 +716,7 @@ - (void)setupToolBar target:self action:nil]; self.toolbarItems = [NSArray arrayWithObjects: flex, add, flex, flex, play, flex, nil]; + self.parentNavigationController.toolbarItems = self.toolbarItems; } - (void)setupEditingToolBar @@ -689,14 +731,15 @@ - (void)setupEditingToolBar target:self action:nil]; self.toolbarItems = [NSArray arrayWithObjects:self.selectAllRowsButtonItem, flex, deleteButton, nil]; + self.parentNavigationController.toolbarItems = self.toolbarItems; } - (void)changeEditingBarButtonState { if (self.object.soundList.count >= 1) { - self.navigationItem.rightBarButtonItem.enabled = YES; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = YES; } else { - self.navigationItem.rightBarButtonItem.enabled = NO; + self.parentNavigationController.navigationItem.rightBarButtonItem.enabled = NO; } } diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h deleted file mode 100644 index d93e096cab..0000000000 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2010-2023 The Catrobat Team - * (http://developer.catrobat.org/credits) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * An additional term exception under section 7 of the GNU Affero - * General Public License, version 3, is available at - * (http://developer.catrobat.org/license_additional_term) - * - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#import -#import "BaseTableViewController.h" - -@class SpriteObject; - -@interface ObjectTableViewController : BaseTableViewController -@property (strong, nonatomic) SpriteObject *object; -@end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m deleted file mode 100644 index becb719e72..0000000000 --- a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectTableViewController.m +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright (C) 2010-2023 The Catrobat Team - * (http://developer.catrobat.org/credits) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * An additional term exception under section 7 of the GNU Affero - * General Public License, version 3, is available at - * (http://developer.catrobat.org/license_additional_term) - * - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#import "ObjectTableViewController.h" -#import "ScriptCollectionViewController.h" -#import "LooksTableViewController.h" -#import "SoundsTableViewController.h" -#import "SegueDefines.h" -#import "TableUtil.h" -#import "CatrobatImageCell.h" -#import "Util.h" -#import "Pocket_Code-Swift.h" - -@interface ObjectTableViewController () - -@end - -@implementation ObjectTableViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - self.title = self.object.name; - self.navigationItem.title = self.object.name; - [self setupToolBar]; - self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; -} - -#pragma mark - Table view data source -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ - return 1; -} - -- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section -{ - return 3; -} - -- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath -{ - static NSString *CellIdentifier = @"MenuCell"; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; - - if ([cell conformsToProtocol:@protocol(CatrobatImageCell)]) { - UITableViewCell *imageCell = (UITableViewCell*)cell; - switch (indexPath.row) { - case 0: - imageCell.iconImageView.image = [UIImage imageNamed:@"catrobat.scripts"]; - imageCell.titleLabel.text = kLocalizedScripts; - break; - case 1: - imageCell.iconImageView.image = [UIImage imageNamed:@"eye.fill"]; - imageCell.titleLabel.text = (self.object.isBackground - ? kLocalizedBackgrounds - : kLocalizedLooks); - break; - case 2: - imageCell.iconImageView.image = [UIImage imageNamed:@"speaker.wave.2.fill"]; - imageCell.titleLabel.text = kLocalizedSounds; - break; - } - - imageCell.iconImageView.contentMode = UIViewContentModeScaleAspectFit; - imageCell.iconImageView.tintAdjustmentMode = UIViewTintAdjustmentModeNormal; - } - return cell; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath -{ - return [TableUtil heightForImageCell]; -} - -#pragma mark - table view delegates -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Pass the selected object to the new view controller - static NSString *toScriptsSegueID = kSegueToScripts; - static NSString *toLooksSegueID = kSegueToLooks; - static NSString *toSoundsSegueID = kSegueToSounds; - - UITableViewCell* sender = [tableView cellForRowAtIndexPath:indexPath]; - if (indexPath.row == 0) - [self performSegueWithIdentifier:toScriptsSegueID sender:sender]; - else if (indexPath.row == 1) - [self performSegueWithIdentifier:toLooksSegueID sender:sender]; - else if (indexPath.row == 2) - [self performSegueWithIdentifier:toSoundsSegueID sender:sender]; - - [tableView deselectRowAtIndexPath:indexPath animated:YES]; -} - -#pragma mark - segue handlers -- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender -{ - // Pass the selected object to the new view controller. - static NSString *toScriptsSegueID = kSegueToScripts; - static NSString *toLooksSegueID = kSegueToLooks; - static NSString *toSoundsSegueID = kSegueToSounds; - - UIViewController* destController = segue.destinationViewController; - if ([sender isKindOfClass:[UITableViewCell class]]) { - if (([segue.identifier isEqualToString:toScriptsSegueID] || - [segue.identifier isEqualToString:toLooksSegueID] || - [segue.identifier isEqualToString:toSoundsSegueID]) && - [destController respondsToSelector:@selector(setObject:)]) { - [destController performSelector:@selector(setObject:) withObject:self.object]; - } - } -} - -#pragma mark - helpers -- (void)setupToolBar -{ - [super setupToolBar]; - - UIBarButtonItem *play = [[PlayButton alloc] initWithTarget:self - action:@selector(playSceneAction:)]; - UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace - target:self - action:nil]; - self.toolbarItems = [NSArray arrayWithObjects: flex, play, flex, nil]; -} - -@end diff --git a/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift new file mode 100644 index 0000000000..67ce26ad3f --- /dev/null +++ b/src/Catty/ViewController/Continue&New/MaintainObject/ObjectViewController.swift @@ -0,0 +1,152 @@ +/** + * Copyright (C) 2010-2023 The Catrobat Team + * (http://developer.catrobat.org/credits) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * An additional term exception under section 7 of the GNU Affero + * General Public License, version 3, is available at + * (http://developer.catrobat.org/license_additional_term) + * + * 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +import UIKit + +class ObjectViewController: UIViewController, EnableAndDisableSegmentedControllDelegate { + + @IBOutlet private weak var objectSegmentedControl: UISegmentedControl! + @IBOutlet private weak var soundsContainerView: UIView! + @IBOutlet private weak var scriptsContainerView: UIView! + @IBOutlet private weak var looksContainerView: UIView! + public var object: SpriteObject? + + var soundsViewController: SoundsTableViewController? + var looksViewController: LooksTableViewController? + var scriptsViewController: ScriptCollectionViewController? + + override func viewDidLoad() { + super.viewDidLoad() + configureSegmentedControll() + scriptsContainerView.isHidden = true + + if let object = object { + self.title = object.name + self.navigationItem.title = object.name + } + let leftSwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeGesture(_:))) + leftSwipeGestureRecognizer.direction = .left + objectSegmentedControl.addGestureRecognizer(leftSwipeGestureRecognizer) + + let rightSwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeGesture(_:))) + rightSwipeGestureRecognizer.direction = .right + objectSegmentedControl.addGestureRecognizer(rightSwipeGestureRecognizer) + + navigationController?.setToolbarHidden(false, animated: true) + showScripts() + } + + // TODO There is a bug, sometimes if you swipe, the text color of the selected segment does not get adjusted + + @objc func handleSwipeGesture(_ gesture: UISwipeGestureRecognizer) { + if gesture.direction == .left { + if objectSegmentedControl.selectedSegmentIndex < 2 { + objectSegmentedControl.selectedSegmentIndex += 1 + } + } else if gesture.direction == .right { + if objectSegmentedControl.selectedSegmentIndex > 0 { + objectSegmentedControl.selectedSegmentIndex -= 1 + } + } + objectSegmentedControl.sendActions(for: .valueChanged) + } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "toLooks" { + let destVC = segue.destination as! LooksTableViewController + destVC.object = object + destVC.segmentedControllDelegate = self + destVC.parentNavigationController = self + looksViewController = destVC + } else if segue.identifier == "toSounds" { + let destVC = segue.destination as! SoundsTableViewController + destVC.object = object + destVC.segmentedControllDelegate = self + destVC.parentNavigationController = self + soundsViewController = destVC + } else if segue.identifier == "toScripts" { + let destVC = segue.destination as! ScriptCollectionViewController + destVC.object = object + destVC.segmentedControllDelegate = self + destVC.parentNavigationController = self + scriptsViewController = destVC + } + } + + func configureSegmentedControll() { + + self.objectSegmentedControl.setTitle(kLocalizedScripts, forSegmentAt: 0) + self.objectSegmentedControl.setTitle(kLocalizedBackgrounds, forSegmentAt: 1) + self.objectSegmentedControl.setTitle(kLocalizedSounds, forSegmentAt: 2) + } + + @IBAction private func segmentTapped(_ sender: UISegmentedControl) { + + switch sender.selectedSegmentIndex { + case 0: + showScripts() + case 1: + showBackgrounds() + case 2: + showSounds() + default: + break + } + } + + @objc func setObject(_ object: SpriteObject) { + self.object = object + } + + func showBackgrounds() { + scriptsContainerView.isHidden = true + looksContainerView.isHidden = false + soundsContainerView.isHidden = true + looksViewController?.initNavigationBar() + looksViewController?.setupToolBar() + } + + func showScripts() { + scriptsContainerView.isHidden = false + looksContainerView.isHidden = true + soundsContainerView.isHidden = true + scriptsViewController?.setupToolBar() + scriptsViewController?.changeDeleteBarButtonState() + } + + func showSounds() { + scriptsContainerView.isHidden = true + looksContainerView.isHidden = true + soundsContainerView.isHidden = false + soundsViewController?.initNavigationBar() + soundsViewController?.setupToolBar() + } + + func enableSegmentedControll() { + objectSegmentedControl.isEnabled = true + } + + func disableSegmentedControll() { + objectSegmentedControl.isEnabled = false + } + +} diff --git a/src/Catty/ViewController/Continue&New/SceneTableViewController.m b/src/Catty/ViewController/Continue&New/SceneTableViewController.m index 692d20c111..34bdc3653f 100644 --- a/src/Catty/ViewController/Continue&New/SceneTableViewController.m +++ b/src/Catty/ViewController/Continue&New/SceneTableViewController.m @@ -22,7 +22,6 @@ #import "SceneTableViewController.h" #import "TableUtil.h" -#import "ObjectTableViewController.h" #import "SegueDefines.h" #import "Brick.h" #import "CatrobatImageCell.h" @@ -632,10 +631,13 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender UITableViewCell *cell = (UITableViewCell*) sender; NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; if ([segue.identifier isEqualToString:toObjectSegueID]) { - if ([destController isKindOfClass:[ObjectTableViewController class]]) { - ObjectTableViewController *tvc = (ObjectTableViewController*) destController; + if ([destController isKindOfClass:[ObjectViewController class]]) { + ObjectViewController *tvc = (ObjectViewController*) destController; + if ([tvc respondsToSelector:@selector(setObject:)]) { SpriteObject* object = [self.scene.objects objectAtIndex:(kBackgroundObjectIndex + indexPath.section + indexPath.row)]; + //tvc.title = object.name; + //tvc.navigationItem.title = object.name; [destController performSelector:@selector(setObject:) withObject:object]; } } diff --git a/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift b/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift index 19f3d7d2a2..dd8d879c77 100644 --- a/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift +++ b/src/Catty/ViewController/Stage/StagePresenterViewControllerResourcesExtension.swift @@ -24,7 +24,7 @@ import BluetoothHelper import CoreBluetooth import UIKit -@objc extension StagePresenterViewController { +@objc public extension StagePresenterViewController { @objc(checkResourcesAndPushViewControllerTo:completion:) func checkResourcesAndPushViewController(to navigationController: UINavigationController, completion: @escaping () -> Void = {}) {