-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIFEmptyNaturalProject.m
70 lines (54 loc) · 2.15 KB
/
IFEmptyNaturalProject.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// IFEmptyNaturalProject.m
// Inform
//
// Created by Andrew Hunter on Sat Sep 13 2003.
// Copyright (c) 2003 Andrew Hunter. All rights reserved.
//
#import "IFEmptyNaturalProject.h"
#import "IFPreferences.h"
@implementation IFEmptyNaturalProject
- (NSString*) projectName {
return [[NSBundle mainBundle] localizedStringForKey: @"Empty project"
value: @"Empty project"
table: nil];
}
- (NSString*) projectHeading {
return [[NSBundle mainBundle] localizedStringForKey: @"Natural Inform"
value: @"Natural Inform"
table: nil];
}
- (NSAttributedString*) projectDescription {
return [[[NSAttributedString alloc] initWithString:
[[NSBundle mainBundle] localizedStringForKey: @"Creates an empty Natural Inform project"
value: @"Creates an empty Natural Inform project"
table: nil]] autorelease];
}
- (NSObject<IFProjectSetupView>*) configView {
return nil;
}
- (void) setupFile: (IFProjectFile*) file
fromView: (NSObject<IFProjectSetupView>*) view {
IFCompilerSettings* settings = [[IFCompilerSettings alloc] init];
[settings setElasticTabs: [[IFPreferences sharedPreferences] elasticTabs]];
[settings setUsingNaturalInform: YES];
[settings setLibraryToUse: @"Natural"];
[file setSettings: [settings autorelease]];
// Default file content
NSString* name = [[[file filename] lastPathComponent] stringByDeletingPathExtension];
if ([name length] == 0 || name == nil) name = @"Untitled";
NSString* longuserName = [[IFPreferences sharedPreferences] newGameAuthorName];
// If longusername contains a '.', then we have to enclose it in quotes
BOOL needQuotes = NO;
int x;
for (x=0; x<[longuserName length]; x++) {
if ([longuserName characterAtIndex: x] == '.') needQuotes = YES;
}
if (needQuotes) longuserName = [NSString stringWithFormat: @"\"%@\"", longuserName];
// The contents of the file
NSString* defaultContents = [NSString stringWithFormat: @"\"%@\" by %@\n\n", name, longuserName];
// Create the default file
[file addSourceFile: @"story.ni"
withContents: [defaultContents dataUsingEncoding: NSASCIIStringEncoding]];
}
@end