|
From: Geisschaes <gei...@us...> - 2005-07-18 19:13:23
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11790 Modified Files: PlayerList.h PlayerList.m PlayerTableController.m Team.h Team.m Log Message: started saving userdefinedplayerlists Index: PlayerList.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PlayerList.h 15 Jul 2005 18:29:31 -0000 1.9 --- PlayerList.h 18 Jul 2005 19:12:37 -0000 1.10 *************** *** 63,66 **** --- 63,72 ---- - (void) loadFormerPlayerStates; + /*! + @method playerIDsAsString + @abstract ids separated by | + */ + -(NSString*) playerIDsAsString; + - (NSString *) listName; - (void) setListName: (NSString *) newListName; *************** *** 126,128 **** --- 132,135 ---- - (BOOL) addPlayersWithIDs: (NSArray*) ids; + - (BOOL) removePlayersWithIDs: (NSArray*) ids; @end Index: Team.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Team.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Team.h 3 Jul 2005 19:52:13 -0000 1.15 --- Team.h 18 Jul 2005 19:12:37 -0000 1.16 *************** *** 82,85 **** --- 82,86 ---- - (NSString *) teamName; + - (BOOL) saveUserDefinedPlayerLists: (NSString*) filename; - (NSMutableArray *) userDefinedPlayerLists; Index: PlayerList.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.m,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PlayerList.m 15 Jul 2005 18:29:31 -0000 1.11 --- PlayerList.m 18 Jul 2005 19:12:37 -0000 1.12 *************** *** 77,80 **** --- 77,94 ---- } + + -(NSString*) playerIDsAsString { + NSMutableString *str = [[NSMutableString alloc] init]; + NSEnumerator *en = [playerList objectEnumerator]; + Player *current = nil; + while(current = [en nextObject]) { + if([str length] > 0) { + [str appendString:@"|"]; + } + [str appendFormat:@"%d", [current playerID]]; + } + return str; + } + - (void) loadFormerPlayerStates { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; *************** *** 125,128 **** --- 139,162 ---- } } + return YES; + } + + - (BOOL) removePlayersWithIDs: (NSArray*) ids { + PlayerList *mainList = [[Team currentTeam] allPlayersList]; + if(self == mainList) { + return NO; + } + else { + NSEnumerator *en = [ids objectEnumerator]; + NSNumber *currentID = nil; + while(currentID = [en nextObject]) { + int curId = [currentID intValue]; + Player *p = [self playerWithID:curId]; + if(p) { + [playerList removeObject:p] ; + } + } + } + return YES; } Index: PlayerTableController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableController.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PlayerTableController.m 15 Jul 2005 18:29:31 -0000 1.8 --- PlayerTableController.m 18 Jul 2005 19:12:37 -0000 1.9 *************** *** 55,58 **** --- 55,59 ---- + - (NSView *) playerTableView { return playerTableView; } Index: Team.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Team.m,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Team.m 3 Jul 2005 19:52:13 -0000 1.25 --- Team.m 18 Jul 2005 19:12:37 -0000 1.26 *************** *** 156,159 **** --- 156,174 ---- + - (BOOL) saveUserDefinedPlayerLists: (NSString*) filename { + NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; + NSEnumerator *en = [userDefinedPlayerLists objectEnumerator]; + PlayerList *current = nil; + while(current = [en nextObject]) { + if([dic objectForKey:[current listName]]) { + return NO; + } + NSString *ids = [current playerIDsAsString]; + [dic setObject:ids forKey:[current listName]]; + } + NSLog(filename); + return ([dic writeToFile:filename atomically:YES] == 0); + + } - (Economy *) economy { return economy; } |