|
From: Geisschaes <gei...@us...> - 2005-06-01 18:14:30
|
Update of /cvsroot/macattrick/macattrick In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22790 Modified Files: MainController.m Player.h Player.m PlayerList.m PlayerTableController.h PlayerTableController.m Added Files: DateStringTransformer.h DateStringTransformer.m IgnoreZeroTransformer.h IgnoreZeroTransformer.m Log Message: player changes are now displayed (alpha state) --- NEW FILE: IgnoreZeroTransformer.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 IgnoreZeroTransformer : NSObject { } + (Class)transformedValueClass; + (BOOL)allowsReverseTransformation; - (id)transformedValue:(id)value; @end Index: MainController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/MainController.m,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** MainController.m 6 Feb 2005 19:36:18 -0000 1.14 --- MainController.m 1 Jun 2005 18:13:35 -0000 1.15 *************** *** 39,43 **** #import "SkillToListIndexTransformer.h" #import "PercentageTransformer.h" ! static MainController *mainController; --- 39,45 ---- #import "SkillToListIndexTransformer.h" #import "PercentageTransformer.h" ! #import "IgnoreZeroTransformer.h" ! #import "DateStringTransformer.h" ! static MainController *mainController; *************** *** 167,170 **** --- 169,175 ---- [NSValueTransformer setValueTransformer:[[[SkillToListIndexTransformer alloc] init] autorelease] forName:@"SkillToListIndexTransformer"]; [NSValueTransformer setValueTransformer:[[[PercentageTransformer alloc] init] autorelease] forName:@"PercentageTransformer"]; + [NSValueTransformer setValueTransformer:[[[IgnoreZeroTransformer alloc] init] autorelease] forName:@"IgnoreZeroTransformer"]; + [NSValueTransformer setValueTransformer:[[[DateStringTransformer alloc] init] autorelease] forName:@"DateStringTransformer"]; + } Index: Player.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/Player.m,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Player.m 30 May 2005 17:46:31 -0000 1.25 --- Player.m 1 Jun 2005 18:13:35 -0000 1.26 *************** *** 69,72 **** --- 69,74 ---- currentState = [[PlayerState alloc] init]; formerStates = [[NSMutableDictionary alloc] init]; + selectedDate = nil; + differenceToSelectedDate = [[PlayerState alloc] init]; } return self; *************** *** 84,92 **** } ! - (PlayerState*) stateChangeToDate: (NSString*)date { PlayerState *former = [self stateAtDate:date]; ! return [[PlayerState alloc] initWithChangesFrom: former to: currentState]; } // NSCopying Protocal --- 86,96 ---- } ! - (PlayerState*) differenceToDate: (NSString*)date { PlayerState *former = [self stateAtDate:date]; ! PlayerState *difference = [[PlayerState alloc] initWithChangesFrom: former to: currentState]; ! return difference; } + // NSCopying Protocal *************** *** 123,126 **** --- 127,151 ---- + - (PlayerState *) differenceToSelectedDate { return differenceToSelectedDate; } + - (void) setDifferenceToSelectedDate: (PlayerState *) newDifferenceToSelectedDate { + [newDifferenceToSelectedDate retain]; + [differenceToSelectedDate release]; + differenceToSelectedDate = newDifferenceToSelectedDate; + } + + + - (NSString *) selectedDate { return selectedDate; } + - (void) setSelectedDate: (NSString *) newSelectedDate { + [newSelectedDate retain]; + [selectedDate release]; + selectedDate = newSelectedDate; + // updating differences + PlayerState *newDifference = [self differenceToDate: selectedDate]; + [self setDifferenceToSelectedDate:newDifference]; + [newDifference release]; + } + + + - (int)playerID { return playerID;} *************** *** 387,390 **** --- 412,417 ---- [currentState release]; [formerStates release]; + [differenceToSelectedDate release]; + [selectedDate release]; [playerName release]; [super dealloc]; --- NEW FILE: IgnoreZeroTransformer.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 "IgnoreZeroTransformer.h" @implementation IgnoreZeroTransformer + (Class)transformedValueClass { return [NSString class]; } + (BOOL)allowsReverseTransformation { return YES; } - (id)transformedValue:(id)value { if (value == nil) return nil; int inputValue = [value intValue]; if(inputValue) { return [NSString stringWithFormat:@"%d", inputValue];} else return @""; } -(id)reverseTransformedValue:(id)value { if (value == nil) return nil; if([value isEqualToString:@""]) { return [NSNumber numberWithInt:0];} return [NSNumber numberWithInt:[value intValue]]; } @end Index: Player.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/Player.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Player.h 30 May 2005 17:46:31 -0000 1.21 --- Player.h 1 Jun 2005 18:13:35 -0000 1.22 *************** *** 37,40 **** --- 37,42 ---- PlayerState *currentState; NSMutableDictionary *formerStates; + PlayerState *differenceToSelectedDate; + NSString *selectedDate; int countryID; int leadership; *************** *** 124,127 **** --- 126,135 ---- - (PlayerState*) differenceToDate: (NSString*)date; + - (PlayerState *) differenceToSelectedDate; + - (void) setDifferenceToSelectedDate: (PlayerState *) newDifferenceToSelectedDate; + - (NSString *) selectedDate; + - (void) setSelectedDate: (NSString *) newSelectedDate; + + -(NSArray*) possiblePlayerSkillsAbilities; -(NSArray*) possiblePlayerStaminaAbilities; Index: PlayerTableController.h =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableController.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PlayerTableController.h 30 May 2005 19:59:59 -0000 1.3 --- PlayerTableController.h 1 Jun 2005 18:13:35 -0000 1.4 *************** *** 36,39 **** --- 36,40 ---- IBOutlet NSTableView *playerTable; IBOutlet NSArrayController *playerListController; + NSColor *positiveDifferenceColor; } - (NSView *) playerTableView; *************** *** 43,46 **** --- 44,49 ---- - (NSString *) selectedDate; + -(NSColor*) positiveDifferenceColor; + @end --- NEW FILE: DateStringTransformer.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 "DateStringTransformer.h" #import "Properties.h" @implementation DateStringTransformer + (Class)transformedValueClass { return [NSString class]; } + (BOOL)allowsReverseTransformation { return YES; } - (id)transformedValue:(id)value { if (value == nil) return nil; NSCalendarDate *date = [NSCalendarDate dateWithString:value calendarFormat:[Properties dateFormat]]; return [date description]; } -(id)reverseTransformedValue:(id)value { if (value == nil) return nil; NSCalendarDate *date = [NSCalendarDate dateWithString:value]; return [date descriptionWithCalendarFormat:[Properties dateFormat]]; } @end Index: PlayerList.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerList.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PlayerList.m 30 May 2005 19:59:59 -0000 1.7 --- PlayerList.m 1 Jun 2005 18:13:35 -0000 1.8 *************** *** 63,67 **** NSString *date = [currentPath lastPathComponent]; [formerDates addObject:date]; ! PlayerList *formerPlayerList = [[PlayerList alloc] initFromXML:[NSURL URLWithString:filename]]; if(formerPlayerList) { [self loadStatesFromFormerPlayerList:formerPlayerList date:date]; --- 63,69 ---- NSString *date = [currentPath lastPathComponent]; [formerDates addObject:date]; ! NSURL *url = [[NSURL alloc] initFileURLWithPath:filename]; ! PlayerList *formerPlayerList = [[PlayerList alloc] initFromXML:url]; ! [url release]; if(formerPlayerList) { [self loadStatesFromFormerPlayerList:formerPlayerList date:date]; *************** *** 76,85 **** - (void) loadStatesFromFormerPlayerList: (PlayerList*) formerPlayerList date: (NSString*) date{ NSEnumerator *en = [[self playerList] objectEnumerator]; ! Player *currentPlayer = nil; ! while(currentPlayer = [en nextObject]) { ! int playerID = [currentPlayer playerID]; Player *formerPlayer = [formerPlayerList playerWithID:playerID]; if(formerPlayer) { ! [currentPlayer addState:[formerPlayer currentState] forDate:date]; } } --- 78,87 ---- - (void) loadStatesFromFormerPlayerList: (PlayerList*) formerPlayerList date: (NSString*) date{ NSEnumerator *en = [[self playerList] objectEnumerator]; ! Player *current = nil; ! while(current = [en nextObject]) { ! int playerID = [current playerID]; Player *formerPlayer = [formerPlayerList playerWithID:playerID]; if(formerPlayer) { ! [current addState:[formerPlayer currentState] forDate:date]; } } Index: PlayerTableController.m =================================================================== RCS file: /cvsroot/macattrick/macattrick/PlayerTableController.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PlayerTableController.m 30 May 2005 19:59:59 -0000 1.4 --- PlayerTableController.m 1 Jun 2005 18:13:35 -0000 1.5 *************** *** 45,48 **** --- 45,49 ---- [playerTable setTarget:self]; [playerTable setDoubleAction:@selector(doubleClicked)]; + positiveDifferenceColor = [NSColor greenColor]; } return self; *************** *** 68,74 **** [selectedDate release]; selectedDate = newSelectedDate; } ! -(void) doubleClicked { --- 69,84 ---- [selectedDate release]; selectedDate = newSelectedDate; + // update all the dates of the players + NSArray *playerList = [[[self team] playerList] playerList]; + NSEnumerator *en = [playerList objectEnumerator]; + Player *current = nil; + while(current = [en nextObject]) { + [current setSelectedDate:[self selectedDate]]; + } } ! -(NSColor*) positiveDifferenceColor { ! return positiveDifferenceColor; ! } -(void) doubleClicked { --- NEW FILE: DateStringTransformer.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 DateStringTransformer : NSObject { } + (Class)transformedValueClass; + (BOOL)allowsReverseTransformation; - (id)transformedValue:(id)value; @end |