|
From: Geisschaes <gei...@us...> - 2005-07-20 19:31:45
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19864 Modified Files: PlayerList.h PlayerList.m PlayerTableController.h PlayerTableController.m Team.m Added Files: PlayerTableView.h PlayerTableView.m Log Message: removing players using backspace is working. but everything is still rather instable --- NEW FILE: PlayerTableView.m --- //---- license ---------------------------------------------------------------// // // // Macattrick: a Manager Assistant Tool for the online Game Hattrick.org // // Copyright (C) 2004 Roman Bertolami // // // // this file is part of Macattrick application // // http://sourceforge.net/macattrick // // // // Macattrick is free software; you can redistribute it and/or // // modify it under the terms of the GNU General Public License // // as published by the Free Software Foundation; either version 2 // // of the License, or (at your option) any later version. // // // // Macattrick 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 General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place - Suite 330, // // Boston, MA 02111-1307, USA. // // // // Macattrick, Copyright (C) 2004 Roman Bertolami // // Macattrick comes with ABSOLUTELY NO WARRANTY! // // // //---- eo licence ------------------------------------------------------------// #import "PlayerTableView.h" @implementation PlayerTableView - (void)keyDown:(NSEvent*)event { unichar key = [[event charactersIgnoringModifiers] characterAtIndex:0]; if (key == NSDeleteCharacter) { if(controller && [controller respondsToSelector:NSSelectorFromString(@"removeSelectedPlayers")]) { [controller removeSelectedPlayers]; } } } - (id) controller { return controller; } - (void) setController: (id) newController { [newController retain]; [controller release]; controller = newController; } @end --- NEW FILE: PlayerTableView.h --- //---- license ---------------------------------------------------------------// // // // Macattrick: a Manager Assistant Tool for the online Game Hattrick.org // // Copyright (C) 2004 Roman Bertolami // // // // this file is part of Macattrick application // // http://sourceforge.net/macattrick // // // // Macattrick is free software; you can redistribute it and/or // // modify it under the terms of the GNU General Public License // // as published by the Free Software Foundation; either version 2 // // of the License, or (at your option) any later version. // // // // Macattrick 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 General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place - Suite 330, // // Boston, MA 02111-1307, USA. // // // // Macattrick, Copyright (C) 2004 Roman Bertolami // // Macattrick comes with ABSOLUTELY NO WARRANTY! // // // //---- eo licence ------------------------------------------------------------// #import <Cocoa/Cocoa.h> @interface PlayerTableView : NSTableView { id controller; } - (id) controller; - (void) setController: (id) newController; @end Index: PlayerList.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PlayerList.h 19 Jul 2005 17:58:57 -0000 1.11 --- PlayerList.h 20 Jul 2005 19:30:57 -0000 1.12 *************** *** 133,135 **** --- 133,137 ---- - (BOOL) addPlayersWithIDs: (NSArray*) ids; - (BOOL) removePlayersWithIDs: (NSArray*) ids; + - (BOOL) removePlayerWithID: (int) aPlayerID; + - (BOOL) removePlayers: (NSArray*) players; @end Index: PlayerTableController.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableController.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PlayerTableController.h 4 Jun 2005 10:26:27 -0000 1.5 --- PlayerTableController.h 20 Jul 2005 19:30:58 -0000 1.6 *************** *** 29,32 **** --- 29,33 ---- #import <Cocoa/Cocoa.h> #import "Player.h" + #import "PlayerTableView.h" #import "TeamController.h" *************** *** 34,38 **** NSString* selectedDate; IBOutlet NSView *playerTableView; ! IBOutlet NSTableView *playerTable; IBOutlet NSArrayController *playerListController; NSColor *positiveDifferenceColor; --- 35,39 ---- NSString* selectedDate; IBOutlet NSView *playerTableView; ! IBOutlet PlayerTableView *playerTable; IBOutlet NSArrayController *playerListController; NSColor *positiveDifferenceColor; *************** *** 49,52 **** -(int) differenceFontSize; ! @end --- 50,53 ---- -(int) differenceFontSize; ! -(void) removeSelectedPlayers; @end Index: PlayerList.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.m,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PlayerList.m 19 Jul 2005 17:58:57 -0000 1.13 --- PlayerList.m 20 Jul 2005 19:30:58 -0000 1.14 *************** *** 155,163 **** Player *p = [[[Team currentTeam] allPlayersList] playerWithID:aPlayerID]; if(p) { ! [playerList addObject:p] ; } } ! } - (BOOL) removePlayersWithIDs: (NSArray*) ids { PlayerList *mainList = [[Team currentTeam] allPlayersList]; --- 155,179 ---- Player *p = [[[Team currentTeam] allPlayersList] playerWithID:aPlayerID]; if(p) { ! [playerList addObject:p]; ! return YES; } } ! return NO; ! } ! - (BOOL) removePlayerWithID: (int) aPlayerID { ! PlayerList *mainList = [[Team currentTeam] allPlayersList]; ! if(self !=mainList) { ! Player *p = [mainList playerWithID:aPlayerID]; ! if(p) { ! [playerList removeObject:p]; ! return YES; ! } ! else { ! return NO; ! } ! } ! return NO; } + - (BOOL) removePlayersWithIDs: (NSArray*) ids { PlayerList *mainList = [[Team currentTeam] allPlayersList]; *************** *** 178,181 **** --- 194,211 ---- return YES; } + - (BOOL) removePlayers: (NSArray*) players { + PlayerList *mainList = [[Team currentTeam] allPlayersList]; + if(self == mainList) { + return NO; + } + else { + NSEnumerator *en = [players objectEnumerator]; + NSNumber *p = nil; + while(p = [en nextObject]) { + [playerList removeObject:p] ; + } + } + return YES; + } - (void) loadStatesFromFormerPlayerList: (PlayerList*) formerPlayerList date: (NSString*) date{ Index: PlayerTableController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableController.m,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PlayerTableController.m 18 Jul 2005 19:12:37 -0000 1.9 --- PlayerTableController.m 20 Jul 2005 19:30:58 -0000 1.10 *************** *** 47,50 **** --- 47,51 ---- [playerTable setDoubleAction:@selector(doubleClicked)]; [playerTable registerForDraggedTypes:[NSArray arrayWithObject:NSDragPboard]]; + [playerTable setController: self]; positiveDifferenceColor = [NSColor greenColor]; differenceFontSize = 9; *************** *** 55,58 **** --- 56,64 ---- + -(void) removeSelectedPlayers { + NSArray *selected = [playerListController selectedObjects]; + [[team playerList] removePlayers:selected]; + [playerTable setNeedsDisplay:YES]; + } - (NSView *) playerTableView { return playerTableView; } Index: Team.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Team.m,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Team.m 19 Jul 2005 17:58:57 -0000 1.28 --- Team.m 20 Jul 2005 19:30:58 -0000 1.29 *************** *** 168,172 **** NSEnumerator *en2 = [items objectEnumerator]; NSString *currentID = [en2 nextObject]; - NSLog(currentID); PlayerList *l = [[PlayerList alloc] initWithListName:currentID]; while(currentID = [en2 nextObject]) { --- 168,171 ---- |