diff --git a/Carbon/Resources/ResKnife.rsrc b/Carbon/Resources/ResKnife.rsrc index e69de29..b1eba82 100644 Binary files a/Carbon/Resources/ResKnife.rsrc and b/Carbon/Resources/ResKnife.rsrc differ diff --git a/Cocoa/Classes/Resource.m b/Cocoa/Classes/Resource.m index 99fe482..3630223 100644 --- a/Cocoa/Classes/Resource.m +++ b/Cocoa/Classes/Resource.m @@ -1,4 +1,6 @@ #import "Resource.h" +#import "ResourceDocument.h" +#import "ResourceDataSource.h" // should these be above or below "@implementation Resource" ? NSString *ResourceWillChangeNotification = @"ResourceWillChangeNotification"; @@ -67,6 +69,52 @@ NSString *ResourceDidChangeNotification = @"ResourceDidChangeNotification"; return [resource autorelease]; } ++ (NSArray *)allResourcesOfType:(NSString *)typeValue inDocument:(NSDocument *)document +{ + NSMutableArray *array = [NSMutableArray array]; + NSDocument *doc; + NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator]; + while( doc = [enumerator nextObject] ) + { + // parse document for resources + if( document == nil || document == doc ) + [array addObjectsFromArray:[[(ResourceDocument *)doc dataSource] allResourcesOfType:typeValue]]; + } + return [NSArray arrayWithArray:array]; +} + ++ (Resource *)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)document +{ + NSDocument *doc; + NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator]; + while( doc = [enumerator nextObject] ) + { + if( document == nil || document == doc ) + { + // parse document for correct resource + Resource *resource = [[(ResourceDocument *)doc dataSource] resourceOfType:typeValue andID:resIDValue]; + if( resource ) return resource; + } + } + return nil; +} + ++ (Resource *)resourceOfType:(NSString *)typeValue withName:(NSString *)nameValue inDocument:(NSDocument *)document +{ + NSDocument *doc; + NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator]; + while( doc = [enumerator nextObject] ) + { + if( document == nil || document == doc ) + { + // parse document for correct resource + Resource *resource = [[(ResourceDocument *)doc dataSource] resourceOfType:typeValue withName:nameValue]; + if( resource ) return resource; + } + } + return nil; +} + - (void)dealloc { [name release]; diff --git a/Cocoa/Classes/ResourceDataSource.h b/Cocoa/Classes/ResourceDataSource.h index c9f4457..b04043e 100644 --- a/Cocoa/Classes/ResourceDataSource.h +++ b/Cocoa/Classes/ResourceDataSource.h @@ -18,6 +18,8 @@ - (void)removeResource:(Resource *)resource; // accessors -- (Resource *)resourceNamed:(NSString *)name ofType:(NSString *)type; +- (Resource *)resourceOfType:(NSString *)type andID:(NSNumber *)resID; +- (Resource *)resourceOfType:(NSString *)type withName:(NSString *)name; +- (NSArray *)allResourcesOfType:(NSString *)type; @end diff --git a/Cocoa/Classes/ResourceDataSource.m b/Cocoa/Classes/ResourceDataSource.m index 309db05..06aaa98 100644 --- a/Cocoa/Classes/ResourceDataSource.m +++ b/Cocoa/Classes/ResourceDataSource.m @@ -107,7 +107,19 @@ NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResourc /* ACCESSORS */ -- (Resource *)resourceNamed:(NSString *)name ofType:(NSString *)type +- (Resource *)resourceOfType:(NSString *)type andID:(NSNumber *)resID +{ + Resource *resource; + NSEnumerator *enumerator = [resources objectEnumerator]; + while( resource = [enumerator nextObject] ) + { + if( [[resource resID] isEqualToNumber:resID] && [[resource type] isEqualToString:type] ) + return resource; + } + return nil; +} + +- (Resource *)resourceOfType:(NSString *)type withName:(NSString *)name { Resource *resource; NSEnumerator *enumerator = [resources objectEnumerator]; @@ -119,4 +131,17 @@ NSString *DataSourceDidRemoveResourceNotification = @"DataSourceDidRemoveResourc return nil; } +- (NSArray *)allResourcesOfType:(NSString *)type +{ + Resource *resource; + NSMutableArray *array = [NSMutableArray array]; + NSEnumerator *enumerator = [resources objectEnumerator]; + while( resource = [enumerator nextObject] ) + { + if( [[resource type] isEqualToString:type] ) + [array addObject:resource]; + } + return [NSArray arrayWithArray:array]; +} + @end diff --git a/Cocoa/Classes/ResourceDocument.m b/Cocoa/Classes/ResourceDocument.m index 02fd2f4..736d63c 100644 --- a/Cocoa/Classes/ResourceDocument.m +++ b/Cocoa/Classes/ResourceDocument.m @@ -297,7 +297,8 @@ static NSString *RKShowInfoItemIdentifier = @"com.nickshanks.resknife.toolbar.sh NSBundle *templateEditor = [NSBundle bundleWithPath:[[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent:@"Template Editor.plugin"]]; // bug: this only checks the CURRENT DOCUMENT for template resources - Resource *tmpl = [dataSource resourceNamed:[resource type] ofType:@"TMPL"]; +// Resource *tmpl = [dataSource resourceOfType:@"TMPL" withName:[resource type]]; + Resource *tmpl = [Resource resourceOfType:@"TMPL" withName:[resource type] inDocument:nil]; // open the resources, passing in the template to use if( tmpl && [[templateEditor principalClass] respondsToSelector:@selector(initWithResources:)] ) diff --git a/Cocoa/Plug-Ins/ResKnifeResourceProtocol.h b/Cocoa/Plug-Ins/ResKnifeResourceProtocol.h index 8d68af8..32856b9 100644 --- a/Cocoa/Plug-Ins/ResKnifeResourceProtocol.h +++ b/Cocoa/Plug-Ins/ResKnifeResourceProtocol.h @@ -1,4 +1,4 @@ -#import +#import /* This protocol allows your plug to interrogate a resource to find out information about it. */ @@ -17,6 +17,17 @@ - (NSData *)data; - (void)setData:(NSData *)newData; +// These methods are used to retrieve resources other than the one you're editing. +// Passing a document of nil will indicate to search in all open documents. +// There is currently no way to search in files which haven't been opened. +// All returned objects are auoreleased. Retain if you want to keep them. + +// This method may return an empty array ++ (NSArray *)allResourcesOfType:(NSString *)typeValue inDocument:(NSDocument *)document; +// The next two return the first matching resource found, or nil. ++ (id)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)document; ++ (id)resourceOfType:(NSString *)typeValue withName:(NSString *)nameValue inDocument:(NSDocument *)document; + @end // Resource notifications diff --git a/NovaTools/DataSource.h b/NovaTools/DataSource.h new file mode 100755 index 0000000..1788c29 --- /dev/null +++ b/NovaTools/DataSource.h @@ -0,0 +1,23 @@ +#import + +@interface DataSource : NSObject +{ + NSString *type; + NSMutableDictionary *data; + NSMutableArray *parsed; // a subset of data, parsed to contain the typed string +} + +- (id)initForType:(NSString *)typeString; + +- (NSDictionary *)data; +- (void)setData:(NSMutableDictionary *)newData; +- (void)setString:(NSString *)newData forResID:(int)resID; +- (void)parseForString:(NSString *)string sorted:(BOOL)sort; +- (id)objectValueForResID:(NSNumber *)resID; +- (NSString *)stringValueForResID:(NSNumber *)resID; + +// NSComboBoxDataSource informal protocol +- (id)comboBox:(NSComboBox *)comboBox objectValueForItemAtIndex:(int)index; +- (int)numberOfItemsInComboBox:(NSComboBox *)comboBox; + +@end diff --git a/NovaTools/DataSource.m b/NovaTools/DataSource.m new file mode 100755 index 0000000..71fd06e --- /dev/null +++ b/NovaTools/DataSource.m @@ -0,0 +1,109 @@ +#import "DataSource.h" +#import "ResKnifeResourceProtocol.h" + +@implementation DataSource + +- (id)init +{ + [self autorelease]; + return nil; +} + +- (id)initForType:(NSString *)typeString +{ + self = [super init]; + type = [typeString copy]; + data = [[NSMutableDictionary alloc] init]; + { + id resource; + NSArray *resources = [NSClassFromString(@"Resource") allResourcesOfType:type inDocument:nil]; + NSEnumerator *enumerator = [resources objectEnumerator]; + while( resource = [enumerator nextObject] ) + [data setObject:[resource name] forKey:[resource resID]]; + } + parsed = [[NSMutableArray alloc] initWithArray:[data allValues]]; + return self; +} + +- (void)dealloc +{ + [data release]; + [parsed release]; + [super dealloc]; +} + +- (NSDictionary *)data +{ + return data; +} + +- (void)setData:(NSMutableDictionary *)newData +{ + id old = data; + data = [newData retain]; + [self parseForString:@"" sorted:YES]; + [old autorelease]; +} + +- (void)setString:(NSString *)string forResID:(int)resID +{ + [data setObject:string forKey:[NSNumber numberWithInt:resID]]; +} + +- (void)parseForString:(NSString *)string sorted:(BOOL)sort +{ + NSNumber *resID; + NSEnumerator *enumerator = [[data allKeys] objectEnumerator]; + [parsed removeAllObjects]; + while( resID = [enumerator nextObject] ) + { + NSString *value = [data objectForKey:resID]; + NSRange range = [value rangeOfString:string options:NSCaseInsensitiveSearch]; + if( range.location != NSNotFound || [string isEqualToString:@""] ) + [parsed addObject:[NSString stringWithFormat:@"%@ {%@}", value, resID]]; + } + if( sort ) [parsed sortUsingSelector:@selector(caseInsensitiveCompare:)]; +} + +- (id)objectValueForResID:(NSNumber *)resID +{ + return [data objectForKey:resID]; +} + +- (NSString *)stringValueForResID:(NSNumber *)resID +{ + return [NSString stringWithFormat:@"%@ {%@}", [data objectForKey:resID], resID]; +} + +/* NSComboBox Informal Prototype Implementation */ + +- (id)comboBox:(NSComboBox *)comboBox objectValueForItemAtIndex:(int)index +{ + return [parsed objectAtIndex:index]; +} + +- (int)numberOfItemsInComboBox:(NSComboBox *)comboBox +{ + return [parsed count]; +} + +/* Combo Box Delegate Methods */ + +- (void)controlTextDidBeginEditing:(NSNotification *)notification +{ + [self parseForString:[[notification object] stringValue] sorted:YES]; + [[notification object] reloadData]; +} + +- (void)controlTextDidChange:(NSNotification *)notification +{ + [self parseForString:[[notification object] stringValue] sorted:YES]; + [[notification object] reloadData]; +} + +- (BOOL)control:(NSControl *)control isValidObject:(id)object +{ + return [parsed containsObject:object]; +} + +@end diff --git a/NovaTools/English.lproj/Resource Types.strings b/NovaTools/English.lproj/Resource Types.strings index d9a9a4b..3b47099 100644 Binary files a/NovaTools/English.lproj/Resource Types.strings and b/NovaTools/English.lproj/Resource Types.strings differ diff --git a/NovaTools/NovaWindowController.h b/NovaTools/NovaWindowController.h index 5c6b6ad..4bee0c9 100644 --- a/NovaTools/NovaWindowController.h +++ b/NovaTools/NovaWindowController.h @@ -1,4 +1,5 @@ #import +#import "DataSource.h" #import "ResKnifePluginProtocol.h" #import "ResKnifeResourceProtocol.h" @@ -6,8 +7,15 @@ @interface NovaWindowController : NSWindowController { id resource; + NSUndoManager *undoManager; + + DataSource *governmentDataSource; + DataSource *planetDataSource; + DataSource *shipDataSource; } +- (void)setResource:(id )newResource; +- (void)setUndoManager:(NSUndoManager *)newUndoManager; - (IBAction)toggleResID:(id)sender; @end diff --git a/NovaTools/NovaWindowController.m b/NovaTools/NovaWindowController.m index 5494cd1..ca33d41 100644 --- a/NovaTools/NovaWindowController.m +++ b/NovaTools/NovaWindowController.m @@ -7,7 +7,7 @@ @implementation NovaWindowController -- (id)initWithResource:(id)newResource +- (id)initWithResource:(id )newResource { id oldSelf = self; NSData *classData = [[(id )newResource type] dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; @@ -18,29 +18,59 @@ if( !self ) return nil; // do global stuff here - resource = [newResource retain]; + resource = [(id)newResource retain]; + undoManager = [[NSUndoManager alloc] init]; return self; } -- (id)initWithResources:(id)newResource, ... +- (id)initWithResources:(id )newResource, ... { return nil; } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [(id)resource autorelease]; + [undoManager release]; + [shipDataSource release]; + [super dealloc]; +} + - (void)windowDidLoad { + NSBundle *plugBundle = [NSBundle bundleWithIdentifier:@"au.com.sutherland-studios.resknife.novatools"]; + [super windowDidLoad]; - - // insert the resources' data into the text fields -// [self refreshData:[resource data]]; + + // create the data sources (here because this is called just before they are applied to the combo boxes) + governmentDataSource = [[DataSource alloc] initForType:[plugBundle localizedStringForKey:@"govt" value:@"" table:@"Resource Types"]]; + planetDataSource = [[DataSource alloc] initForType:[plugBundle localizedStringForKey:@"spob" value:@"" table:@"Resource Types"]]; + shipDataSource = [[DataSource alloc] initForType:[plugBundle localizedStringForKey:@"ship" value:@"" table:@"Resource Types"]]; // we don't want this notification until we have a window! // bug: only registers for notifications on the resource we're editing, need dependant resources too (pass nil for object?) // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceDataDidChange:) name:ResourceDataDidChangeNotification object:resource]; - - // finally, show the window - [self showWindow:self]; +} + +- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)sender +{ + return undoManager; +} + +- (void)setResource:(id )newResource +{ + id old = resource; + resource = [(id)newResource retain]; + [old release]; +} + +- (void)setUndoManager:(NSUndoManager *)newUndoManager +{ + id old = undoManager; + undoManager = [newUndoManager retain]; + [old release]; } - (IBAction)toggleResID:(id)sender diff --git a/NovaTools/boom/BoomWindowController.m b/NovaTools/boom/BoomWindowController.m index 29ff51e..99f03c9 100644 --- a/NovaTools/boom/BoomWindowController.m +++ b/NovaTools/boom/BoomWindowController.m @@ -14,4 +14,10 @@ return self; } +- (void)windowDidLoad +{ + [super windowDidLoad]; + [self showWindow:self]; +} + @end diff --git a/NovaTools/char/CharWindowController.h b/NovaTools/char/CharWindowController.h index 361b63b..7e7b5d5 100644 --- a/NovaTools/char/CharWindowController.h +++ b/NovaTools/char/CharWindowController.h @@ -1,11 +1,20 @@ #import #import "NovaWindowController.h" +#define cashField [goodiesForm cellAtIndex:0] +#define killsField [goodiesForm cellAtIndex:1] #define prefixField [timeForm cellAtIndex:0] #define suffixField [timeForm cellAtIndex:1] +#define statusField1 [statusForm cellAtIndex:0] +#define statusField2 [statusForm cellAtIndex:1] +#define statusField3 [statusForm cellAtIndex:2] +#define statusField4 [statusForm cellAtIndex:3] @interface CharWindowController : NovaWindowController { + IBOutlet NSComboBox *shipField; + IBOutlet NSForm *goodiesForm; + IBOutlet NSTextField *dayField; IBOutlet NSTextField *monthField; IBOutlet NSTextField *yearField; @@ -14,19 +23,46 @@ IBOutlet NSStepper *yearStepper; IBOutlet NSForm *timeForm; + IBOutlet NSComboBox *startField1; + IBOutlet NSComboBox *startField2; + IBOutlet NSComboBox *startField3; + IBOutlet NSComboBox *startField4; + + IBOutlet NSForm *statusForm; + IBOutlet NSComboBox *governmentField1; + IBOutlet NSComboBox *governmentField2; + IBOutlet NSComboBox *governmentField3; + IBOutlet NSComboBox *governmentField4; + // Initial Goodies - NSDecimalNumber *ship; - NSDecimalNumber *cash; - NSDecimalNumber *kills; + NSNumber *ship; + NSNumber *cash; + NSNumber *kills; // Beginning Of Time NSCalendarDate *date; NSString *prefix; NSString *suffix; + + // Starting Location + NSNumber *start1; + NSNumber *start2; + NSNumber *start3; + NSNumber *start4; + + // Governments + NSNumber *status1; + NSNumber *status2; + NSNumber *status3; + NSNumber *status4; + NSNumber *government1; + NSNumber *government2; + NSNumber *government3; + NSNumber *government4; } - (void)update; -- (IBAction)stepDate:(id)sender; - (IBAction)editDate:(id)sender; +- (IBAction)stepDate:(id)sender; @end diff --git a/NovaTools/char/CharWindowController.m b/NovaTools/char/CharWindowController.m index a7f91e7..8ccb9c9 100644 --- a/NovaTools/char/CharWindowController.m +++ b/NovaTools/char/CharWindowController.m @@ -8,14 +8,28 @@ if( !self ) return nil; // load data from resource - ship = [[NSDecimalNumber alloc] initWithShort:128]; - cash = [[NSDecimalNumber alloc] initWithLong:10000]; - kills = [[NSDecimalNumber alloc] initWithUnsignedLong:0]; + ship = [[NSNumber alloc] initWithShort:128]; + cash = [[NSNumber alloc] initWithLong:10000]; + kills = [[NSNumber alloc] initWithUnsignedLong:0]; date = [[NSCalendarDate date] retain]; prefix = [[NSString alloc] init]; suffix = [[NSString alloc] init]; + start1 = [[NSNumber alloc] initWithShort:128]; + start2 = [[NSNumber alloc] initWithShort:129]; + start3 = [[NSNumber alloc] initWithShort:130]; + start4 = [[NSNumber alloc] initWithShort:131]; + + status1 = [[NSNumber alloc] initWithShort:0]; + status2 = [[NSNumber alloc] initWithShort:0]; + status3 = [[NSNumber alloc] initWithShort:0]; + status4 = [[NSNumber alloc] initWithShort:0]; + government1 = [[NSNumber alloc] initWithShort:128]; + government2 = [[NSNumber alloc] initWithShort:129]; + government3 = [[NSNumber alloc] initWithShort:130]; + government4 = [[NSNumber alloc] initWithShort:131]; + // load the window from the nib file and set it's title [self window]; // implicitly loads nib if( [newResource name] && ![[newResource name] isEqualToString:@""] ) @@ -24,28 +38,72 @@ return self; } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; +} + +- (void)windowDidLoad +{ + [super windowDidLoad]; + + // set combo box data sources + [shipField setDelegate:shipDataSource]; + [shipField setDataSource:shipDataSource]; + [startField1 setDelegate:planetDataSource]; + [startField1 setDataSource:planetDataSource]; + [startField2 setDelegate:planetDataSource]; + [startField2 setDataSource:planetDataSource]; + [startField3 setDelegate:planetDataSource]; + [startField3 setDataSource:planetDataSource]; + [startField4 setDelegate:planetDataSource]; + [startField4 setDataSource:planetDataSource]; + [governmentField1 setDelegate:governmentDataSource]; + [governmentField1 setDataSource:governmentDataSource]; + [governmentField2 setDelegate:governmentDataSource]; + [governmentField2 setDataSource:governmentDataSource]; + [governmentField3 setDelegate:governmentDataSource]; + [governmentField3 setDataSource:governmentDataSource]; + [governmentField4 setDelegate:governmentDataSource]; + [governmentField4 setDataSource:governmentDataSource]; + + // set notifications for ending editing on a combo box + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:shipField]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:startField1]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:startField2]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:startField3]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:startField4]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:governmentField1]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:governmentField2]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:governmentField3]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controlTextDidEndEditing:) name:NSControlTextDidEndEditingNotification object:governmentField4]; + + // finally, show the window + [self showWindow:self]; +} + - (void)update { - // update some stuff in the catchall box + // initial goodies + [shipField setObjectValue:[shipDataSource stringValueForResID:ship]]; + [shipDataSource parseForString:[shipField stringValue] sorted:NO]; + [cashField setObjectValue:cash]; + [killsField setObjectValue:kills]; - - // update Beginning Of Time - [dayField setIntValue:[date dayOfMonth]]; - [monthField setIntValue:[date monthOfYear]]; - [yearField setIntValue:[date yearOfCommonEra]]; + // beginning of time + [dayField setObjectValue:date]; + [monthField setObjectValue:date]; + [yearField setObjectValue:date]; [dayStepper setIntValue:[date dayOfMonth]]; [monthStepper setIntValue:[date monthOfYear]]; [yearStepper setIntValue:[date yearOfCommonEra]]; [prefixField setStringValue:prefix]; [suffixField setStringValue:suffix]; -} - -- (IBAction)stepDate:(id)sender -{ - id old = date; - date = [[NSCalendarDate alloc] initWithYear:[yearStepper intValue] month:[monthStepper intValue] day:[dayStepper intValue] hour:0 minute:0 second:0 timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; - [old release]; - [self update]; + + // starting location + [startField1 setObjectValue:[shipDataSource stringValueForResID:start1]]; + [shipDataSource parseForString:[shipField stringValue] sorted:NO]; } - (IBAction)editDate:(id)sender @@ -56,4 +114,46 @@ [self update]; } +- (IBAction)stepDate:(id)sender +{ + id old = date; + date = [[NSCalendarDate alloc] initWithYear:[yearStepper intValue] month:[monthStepper intValue] day:[dayStepper intValue] hour:0 minute:0 second:0 timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + [old release]; + [self update]; +} + +- (void)controlTextDidEndEditing:(NSNotification *)notification +{ + if( [notification object] == shipField ) + { + id old = ship; + NSString *string = [[notification object] stringValue]; + NSRange range = [string rangeOfString:@"{" options:NSBackwardsSearch]; + range.length = [string length] - range.location++ - 2; + ship = [[NSNumber alloc] initWithInt:[[string substringWithRange:range] intValue]]; + NSLog( @"Old ship: %@ New ship: %@", old, ship ); + [old release]; + } + else if( [notification object] == startField1 ) + { + id old = start1; + NSString *string = [[notification object] stringValue]; + NSRange range = [string rangeOfString:@"{" options:NSBackwardsSearch]; + range.length = [string length] - range.location++ - 2; + start1 = [[NSNumber alloc] initWithInt:[[string substringWithRange:range] intValue]]; + NSLog( @"Old start1: %@ New start1: %@", old, start1 ); + [old release]; + } + else if( [notification object] == startField2 ) + { + id old = start2; + NSString *string = [[notification object] stringValue]; + NSRange range = [string rangeOfString:@"{" options:NSBackwardsSearch]; + range.length = [string length] - range.location++ - 2; + start2 = [[NSNumber alloc] initWithInt:[[string substringWithRange:range] intValue]]; + NSLog( @"Old start2: %@ New start2: %@", old, start2 ); + [old release]; + } +} + @end diff --git a/NovaTools/char/English.lproj/char.nib/classes.nib b/NovaTools/char/English.lproj/char.nib/classes.nib index 748a16b..b83b264 100644 --- a/NovaTools/char/English.lproj/char.nib/classes.nib +++ b/NovaTools/char/English.lproj/char.nib/classes.nib @@ -7,8 +7,19 @@ OUTLETS = { dayField = NSTextField; dayStepper = NSStepper; + goodiesForm = NSForm; + governmentField1 = NSComboBox; + governmentField2 = NSComboBox; + governmentField3 = NSComboBox; + governmentField4 = NSComboBox; monthField = NSTextField; monthStepper = NSStepper; + shipField = NSComboBox; + startField1 = NSComboBox; + startField2 = NSComboBox; + startField3 = NSComboBox; + startField4 = NSComboBox; + statusForm = NSForm; timeForm = NSForm; yearField = NSTextField; yearStepper = NSStepper; diff --git a/NovaTools/char/English.lproj/char.nib/info.nib b/NovaTools/char/English.lproj/char.nib/info.nib index 39dd71b..4b922bf 100644 --- a/NovaTools/char/English.lproj/char.nib/info.nib +++ b/NovaTools/char/English.lproj/char.nib/info.nib @@ -20,6 +20,10 @@ IBLastGroupID 3 + IBOpenObjects + + 137 + IBSystem Version 5Q125 diff --git a/NovaTools/char/English.lproj/char.nib/objects.nib b/NovaTools/char/English.lproj/char.nib/objects.nib index 9e2434b..3910144 100644 Binary files a/NovaTools/char/English.lproj/char.nib/objects.nib and b/NovaTools/char/English.lproj/char.nib/objects.nib differ diff --git a/NovaTools/colr/ColrWindowController.m b/NovaTools/colr/ColrWindowController.m index 9843486..46d8469 100644 --- a/NovaTools/colr/ColrWindowController.m +++ b/NovaTools/colr/ColrWindowController.m @@ -14,4 +14,10 @@ return self; } +- (void)windowDidLoad +{ + [super windowDidLoad]; + [self showWindow:self]; +} + @end diff --git a/NovaTools/cron/CronWindowController.h b/NovaTools/cron/CronWindowController.h index a57edba..152fee7 100644 --- a/NovaTools/cron/CronWindowController.h +++ b/NovaTools/cron/CronWindowController.h @@ -1,7 +1,38 @@ #import #import "NovaWindowController.h" +#define startField [activationForm cellAtIndex:0] +#define endField [activationForm cellAtIndex:1] + @interface CronWindowController : NovaWindowController { + IBOutlet NSTextField *startDayField; + IBOutlet NSTextField *startMonthField; + IBOutlet NSTextField *startYearField; + IBOutlet NSStepper *startDayStepper; + IBOutlet NSStepper *startMonthStepper; + IBOutlet NSStepper *startYearStepper; + + IBOutlet NSTextField *endDayField; + IBOutlet NSTextField *endMonthField; + IBOutlet NSTextField *endYearField; + IBOutlet NSStepper *endDayStepper; + IBOutlet NSStepper *endMonthStepper; + IBOutlet NSStepper *endYearStepper; + + IBOutlet NSForm *activationForm; + + // data values + NSCalendarDate *startDate; + NSCalendarDate *endDate; } + +- (void)update; +- (IBAction)editStart:(id)sender; +- (IBAction)stepStart:(id)sender; +- (IBAction)editEnd:(id)sender; +- (IBAction)stepEnd:(id)sender; +- (IBAction)editStartField:(id)sender; +- (IBAction)editEndField:(id)sender; + @end diff --git a/NovaTools/cron/CronWindowController.m b/NovaTools/cron/CronWindowController.m index f55f167..ba4b302 100644 --- a/NovaTools/cron/CronWindowController.m +++ b/NovaTools/cron/CronWindowController.m @@ -7,14 +7,94 @@ self = [self initWithWindowNibName:@"cron"]; if( !self ) return nil; + // init fields with data from resource + startDate = [[NSCalendarDate date] retain]; + endDate = [[[NSCalendarDate date] dateByAddingYears:0 months:1 days:0 hours:0 minutes:0 seconds:0] retain]; + // load the window from the nib file and set it's title [self window]; // implicitly loads nib if( [newResource name] && ![[newResource name] isEqualToString:@""] ) [[self window] setTitle:[NSString stringWithFormat:@"%@: %@", [[self window] title], [newResource name]]]; + [self update]; return self; } -// date format for start and end: +- (void)windowDidLoad +{ + [super windowDidLoad]; + [self showWindow:self]; +} + +// date format to get month as single digit: // %e/%1m/%Y == 1/1/2000 +- (void)update +{ + // activation + [startDayField setObjectValue:startDate]; + [startMonthField setObjectValue:startDate]; + [startYearField setObjectValue:startDate]; + [startDayStepper setIntValue:[startDate dayOfMonth]]; + [startMonthStepper setIntValue:[startDate monthOfYear]]; + [startYearStepper setIntValue:[startDate yearOfCommonEra]]; + + [endDayField setObjectValue:startDate]; + [endMonthField setObjectValue:startDate]; + [endYearField setObjectValue:startDate]; + [endDayStepper setIntValue:[endDate dayOfMonth]]; + [endMonthStepper setIntValue:[endDate monthOfYear]]; + [endYearStepper setIntValue:[endDate yearOfCommonEra]]; + + [startField setObjectValue:startDate]; + [endField setObjectValue:startDate]; +} + +- (IBAction)editStart:(id)sender +{ + id old = startDate; + startDate = [[NSCalendarDate alloc] initWithYear:[startYearField intValue] month:[startMonthField intValue] day:[startDayField intValue] hour:0 minute:0 second:0 timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + [old release]; + [self update]; +} + +- (IBAction)stepStart:(id)sender +{ + id old = startDate; + startDate = [[NSCalendarDate alloc] initWithYear:[startYearStepper intValue] month:[startMonthStepper intValue] day:[startDayStepper intValue] hour:0 minute:0 second:0 timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + [old release]; + [self update]; +} + +- (IBAction)editEnd:(id)sender +{ + id old = endDate; + endDate = [[NSCalendarDate alloc] initWithYear:[endYearField intValue] month:[endMonthField intValue] day:[endDayField intValue] hour:0 minute:0 second:0 timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + [old release]; + [self update]; +} + +- (IBAction)stepEnd:(id)sender +{ + id old = endDate; + endDate = [[NSCalendarDate alloc] initWithYear:[endYearStepper intValue] month:[endMonthStepper intValue] day:[endDayStepper intValue] hour:0 minute:0 second:0 timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + [old release]; + [self update]; +} + +- (IBAction)editStartField:(id)sender +{ + id old = startDate; + startDate = [[NSCalendarDate dateWithNaturalLanguageString:[startField stringValue]] retain]; + [old release]; + [self update]; +} + +- (IBAction)editEndField:(id)sender +{ + id old = endDate; + endDate = [[NSCalendarDate dateWithNaturalLanguageString:[endField stringValue]] retain]; + [old release]; + [self update]; +} + @end diff --git a/NovaTools/cron/English.lproj/cron.nib/classes.nib b/NovaTools/cron/English.lproj/cron.nib/classes.nib index 4d5e42c..007296c 100644 --- a/NovaTools/cron/English.lproj/cron.nib/classes.nib +++ b/NovaTools/cron/English.lproj/cron.nib/classes.nib @@ -1,8 +1,31 @@ { IBClasses = ( { + ACTIONS = { + editEnd = id; + editEndField = id; + editStart = id; + editStartField = id; + stepEnd = id; + stepStart = id; + }; CLASS = CronWindowController; LANGUAGE = ObjC; + OUTLETS = { + activationForm = NSForm; + endDayField = NSTextField; + endDayStepper = NSStepper; + endMonthField = NSTextField; + endMonthStepper = NSStepper; + endYearField = NSTextField; + endYearStepper = NSStepper; + startDayField = NSTextField; + startDayStepper = NSStepper; + startMonthField = NSTextField; + startMonthStepper = NSStepper; + startYearField = NSTextField; + startYearStepper = NSStepper; + }; SUPERCLASS = NovaWindowController; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, diff --git a/NovaTools/cron/English.lproj/cron.nib/info.nib b/NovaTools/cron/English.lproj/cron.nib/info.nib index 9febf57..7286153 100644 --- a/NovaTools/cron/English.lproj/cron.nib/info.nib +++ b/NovaTools/cron/English.lproj/cron.nib/info.nib @@ -3,9 +3,9 @@ IBDocumentLocation - 92 580 356 240 0 0 1152 848 + 50 125 356 240 0 0 1152 848 IBFramework Version - 248.0 + 263.2 IBGroupedObjects 0 @@ -30,6 +30,6 @@ IBLastGroupID 2 IBSystem Version - 5Q110 + 5Q125 diff --git a/NovaTools/cron/English.lproj/cron.nib/objects.nib b/NovaTools/cron/English.lproj/cron.nib/objects.nib index bb13d90..d1cf3d1 100644 Binary files a/NovaTools/cron/English.lproj/cron.nib/objects.nib and b/NovaTools/cron/English.lproj/cron.nib/objects.nib differ diff --git a/NovaTools/desc/DescWindowController.m b/NovaTools/desc/DescWindowController.m index db13771..044ad04 100644 --- a/NovaTools/desc/DescWindowController.m +++ b/NovaTools/desc/DescWindowController.m @@ -14,4 +14,10 @@ return self; } +- (void)windowDidLoad +{ + [super windowDidLoad]; + [self showWindow:self]; +} + @end diff --git a/ResKnife.pbproj/project.pbxproj b/ResKnife.pbproj/project.pbxproj index 0a9d2ad..770fa83 100644 --- a/ResKnife.pbproj/project.pbxproj +++ b/ResKnife.pbproj/project.pbxproj @@ -19,6 +19,7 @@ F5EDC618025BFB8601A8010C, F5EDC61B025BFB8E01A8010C, F5EDC61E025BFBB501A8010C, + F543AFEF027C716E01A8010C, ); isa = PBXGroup; name = Resources; @@ -245,39 +246,50 @@ settings = { }; }; - F543B8790274842E01A8010C = { + F543AFDB027B2A5001A8010C = { isa = PBXFileReference; - name = ShipDataSource.m; - path = NovaTools/ship/ShipDataSource.m; - refType = 2; - }; - F543B87A0274842E01A8010C = { - isa = PBXFileReference; - name = ShipDataSource.h; - path = NovaTools/ship/ShipDataSource.h; - refType = 2; - }; - F543B87B0274842E01A8010C = { - fileRef = F543B8790274842E01A8010C; - isa = PBXBuildFile; - settings = { - }; - }; - F543B87C0274842E01A8010C = { - fileRef = F543B87A0274842E01A8010C; - isa = PBXBuildFile; - settings = { - }; - }; - F543B87D0274845501A8010C = { - children = ( - F543B87A0274842E01A8010C, - F543B8790274842E01A8010C, - ); - isa = PBXGroup; - name = "Data Sources"; + path = DataSource.h; refType = 4; }; + F543AFDC027B2A5001A8010C = { + isa = PBXFileReference; + path = DataSource.m; + refType = 4; + }; + F543AFDD027B2A5001A8010C = { + fileRef = F543AFDB027B2A5001A8010C; + isa = PBXBuildFile; + settings = { + }; + }; + F543AFDE027B2A5001A8010C = { + fileRef = F543AFDC027B2A5001A8010C; + isa = PBXBuildFile; + settings = { + }; + }; + F543AFEF027C716E01A8010C = { + children = ( + F543AFF0027C716E01A8010C, + ); + isa = PBXVariantGroup; + name = "Resource Types.strings"; + path = ""; + refType = 4; + }; + F543AFF0027C716E01A8010C = { + fileEncoding = 10; + isa = PBXFileReference; + name = English; + path = "English.lproj/Resource Types.strings"; + refType = 4; + }; + F543AFF1027C716E01A8010C = { + fileRef = F543AFEF027C716E01A8010C; + isa = PBXBuildFile; + settings = { + }; + }; F54E6220021B6A0801A80001 = { isa = PBXFileReference; path = FindSheetController.h; @@ -598,6 +610,8 @@ }; F58A183F0278353501A8010C = { children = ( + F543AFDB027B2A5001A8010C, + F543AFDC027B2A5001A8010C, F58A18410278355D01A8010C, F58A18400278355D01A8010C, ); @@ -1023,6 +1037,7 @@ F5B5885C0156D40B01000001, F5B5885E0156D40B01000001, F5B5885F0156D40B01000001, + F51C71F60269C7E701A8010C, F5B588600156D40B01000001, F5B588610156D40B01000001, F5730B940159528A01000001, @@ -1035,7 +1050,6 @@ F577A8FF0211E4D401A80001, F577A8F50211D05E01A80001, F577A8F90211DC1E01A80001, - F51C71F60269C7E701A8010C, ); isa = PBXResourcesBuildPhase; }; @@ -3151,8 +3165,8 @@ F58F6B94025BD97701A8010C, F58F6BAC025BE14801A8010C, F58F6BAD025BE14801A8010C, - F543B87C0274842E01A8010C, F58A18430278355D01A8010C, + F543AFDD027B2A5001A8010C, ); isa = PBXHeadersBuildPhase; }; @@ -3165,6 +3179,7 @@ F5EDC61A025BFB8601A8010C, F5EDC61D025BFB8E01A8010C, F5EDC620025BFBB501A8010C, + F543AFF1027C716E01A8010C, ); isa = PBXResourcesBuildPhase; }; @@ -3177,8 +3192,8 @@ F58F6B8D025BC7C001A8010C, F58F6B91025BCF5901A8010C, F58F6B95025BD97801A8010C, - F543B87B0274842E01A8010C, F58A18420278355D01A8010C, + F543AFDE027B2A5001A8010C, ); isa = PBXSourcesBuildPhase; }; @@ -3209,7 +3224,6 @@ F58F6B8F025BCF5901A8010C, F58F6B93025BD97701A8010C, F58F6B92025BD97701A8010C, - F543B87D0274845501A8010C, F58A183F0278353501A8010C, F51FB38E0256057F01A80001, );