Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CATTY-142 Create example project #1836

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Catty/DataModel/Project/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
- (void)saveToDiskWithNotification:(BOOL)notify andCompletion:(void (^ _Nullable)(void))completion;
- (BOOL)isLastUsedProject;
- (void)setAsLastUsedProject;
- (void)translateDefaultProject;
- (void)translateDefaultProject:(NSString* _Nonnull)projectName;
- (void)renameToProjectName:(NSString* _Nonnull)projectName andShowSaveNotification:(BOOL)showSaveNotification;
- (void)renameToProjectName:(NSString* _Nonnull)projectName andProjectId:(NSString* _Nonnull)projectId andShowSaveNotification:(BOOL)showSaveNotification;
- (void)setDescription:(NSString* _Nonnull)description;
Expand Down
4 changes: 2 additions & 2 deletions src/Catty/DataModel/Project/Project.m
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ + (void)removeProjectFromDiskWithProjectName:(NSString*)projectName projectID:(N
[fileManager addDefaultProjectToProjectsRootDirectoryIfNoProjectsExist];
}

- (void)translateDefaultProject
- (void)translateDefaultProject:(NSString*) projectName
{
NSUInteger index = 0;
for (SpriteObject *spriteObject in self.scene.objects) {
Expand All @@ -411,7 +411,7 @@ - (void)translateDefaultProject
}
++index;
}
[self renameToProjectName:kLocalizedMyFirstProject andShowSaveNotification:NO]; // saves to disk!
[self renameToProjectName:projectName andShowSaveNotification:NO];
}

+ (NSString*)basePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,29 @@ import Foundation
return UIImage(named: "person.crop.circle#navbar")
}
}

func createProject(inputName: String, isdefault: Bool) {
print("createProject bool: \(isdefault)")
if isdefault {
if let project = CBFileManager.shared().addDefaultProject(toProjectsRootDirectory: inputName) {
self.openProject(project)
}
} else {
let project = self.projectManager.createProject(name: inputName, projectId: nil)
self.openProject(project)
}
}

func createProjectCreationDialogue() {
Util.askUser(forProject: #selector(createProject(inputName: isdefault: )),
target: self,
promptTitle: kLocalizedNewProject,
promptMessage: kLocalizedProjectName,
promptValue: nil,
promptPlaceholder: kLocalizedEnterYourProjectNameHere,
minInputLength: UInt(kMinNumOfProjectNameCharacters),
maxInputLength: UInt(kMaxNumOfProjectNameCharacters),
invalidInputAlertMessage: kLocalizedProjectNameAlreadyExistsDescription,
existingNames: Project.allProjectNames())
}
}
11 changes: 11 additions & 0 deletions src/Catty/Helpers/Util/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ if (__functor) __functor(__VA_ARGS__); \
invalidInputAlertMessage:(NSString* _Nullable)invalidInputAlertMessage
existingNames:(NSArray* _Nullable)existingNames;

+ (void)askUserForProject:(SEL _Nullable)action
target:(id _Nullable)target
promptTitle:(NSString* _Nullable)title
promptMessage:(NSString* _Nullable)message
promptValue:(NSString* _Nullable)value
promptPlaceholder:(NSString* _Nullable)placeholder
minInputLength:(NSUInteger)minInputLength
maxInputLength:(NSUInteger)maxInputLength
invalidInputAlertMessage:(NSString* _Nullable)invalidInputAlertMessage
existingNames:(NSArray* _Nullable)existingNames;

+ (void)askUserForTextAndPerformAction:(SEL _Nullable)action
target:(id _Nullable)target
cancelAction:(SEL _Nullable)cancelAction
Expand Down
Loading
Loading