1009 directory: (NSString*) directory
1010 pageNumber: (
int)page
1011 highlightName: (NSString *)highlightName
1012{
1013 NSFileManager *cdrFileManager=[NSFileManager defaultManager];
1015 unsigned lastIndex;
1016 unsigned i;
1018
1019
1020 NSArray *cdrArray=[cdrFileManager commanderContentsOfPath: directory];
1021
1022
1023
1024 if (!cdrDetailArray)
1025 cdrDetailArray=[[NSMutableArray alloc] init];
1026 else
1027 [cdrDetailArray removeAllObjects];
1028
1029 [cdrDetailArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
1030 @"YES", @"isParentFolder",
1031 [directory stringByDeletingLastPathComponent], @"saved_game_path", nil]];
1032
1033 for(i = 0; i < [cdrArray count]; i++)
1034 {
1035 NSString* path = [cdrArray objectAtIndex:i];
1036 BOOL exists, isDirectory = NO;
1037
1038 exists = [cdrFileManager fileExistsAtPath:path isDirectory:&isDirectory];
1039
1040 if (exists)
1041 {
1042 if (!isDirectory && [[[path pathExtension] lowercaseString] isEqualToString:@"oolite-save"])
1043 {
1045 if(cdr)
1046 {
1047
1048 NSMutableDictionary* cdr1 = [NSMutableDictionary dictionaryWithDictionary:cdr];
1049 [cdr1 setObject: @"YES" forKey:@"isSavedGame"];
1050 [cdr1 setObject: path forKey:@"saved_game_path"];
1051 [cdrDetailArray addObject: cdr1];
1052 }
1053 }
1054 if (isDirectory && ![[path lastPathComponent] hasPrefix:@"."])
1055 {
1056 [cdrDetailArray addObject: [NSDictionary dictionaryWithObjectsAndKeys: @"YES", @"isFolder", path, @"saved_game_path", nil]];
1057 }
1058 }
1059 }
1060
1061 if(![cdrDetailArray
count])
1062 {
1063
1064 [gui
setText:DESC(@"loadsavescreen-no-commanders-found")
forRow:STARTROW
align:GUI_ALIGN_CENTER];
1065 return;
1066 }
1067
1068 [cdrDetailArray sortUsingFunction:sortCommanders context:NULL];
1069
1070
1072 int highlightIdx=0;
1073 if(highlightName)
1074 {
1075 highlightIdx=[self findIndexOfCommander: highlightName];
1076 if(highlightIdx < 0)
1077 {
1078 OOLog(
@"save.list.commanders.commanderNotFound",
@"Commander %@ doesn't exist, very bad", highlightName);
1079 highlightIdx=0;
1080 }
1081
1082
1085 }
1086
1087
1088
1089 unsigned firstIndex=page *
NUMROWS;
1090
1091
1093 tabStop[0]=0;
1094 tabStop[1]=160;
1095 tabStop[2]=270;
1097
1098
1100 {
1104 }
1105
1107 [gui
setArray: [NSArray arrayWithObjects: DESC(@"loadsavescreen-commander-name"), DESC(@"loadsavescreen-rating"), nil]
1109
1110 if (page)
1111 {
1113 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil]
1117 }
1118
1119 if ([self status] == STATUS_START_GAME)
1120 {
1121 [gui
setArray:[NSArray arrayWithObjects:DESC(@"oolite-loadsave-exit"), @" <----- ", nil]
forRow:EXITROW];
1125 }
1126
1127
1129 {
1130 lastIndex=[cdrDetailArray count];
1132 }
1133 else
1134 {
1137 [gui
setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil]
1141 }
1142
1143 for (i=firstIndex; i < lastIndex; i++)
1144 {
1145 NSDictionary *cdr=[cdrDetailArray objectAtIndex: i];
1146 if ([cdr oo_boolForKey:@"isSavedGame"])
1147 {
1149 [gui
setArray:[NSArray arrayWithObjects:
1150 [NSString stringWithFormat:@" %@ ",[cdr oo_stringForKey:@"player_save_name" defaultValue:[cdr oo_stringForKey:@"player_name"]]],
1151 [NSString stringWithFormat:@" %@ ",ratingDesc],
1152 nil]
1154 if ([[self lastsaveName] isEqualToString:[cdr oo_stringForKey:@"player_save_name" defaultValue:[cdr oo_stringForKey:@"player_name"]]])
1155 {
1156 highlightRowOnPage = row;
1157 }
1158
1160 row++;
1161 }
1162 if ([cdr oo_boolForKey:@"isParentFolder"])
1163 {
1164 [gui
setArray:[NSArray arrayWithObjects:
1165 [NSString stringWithFormat:@" (..) %@ ", [[cdr oo_stringForKey:@"saved_game_path"] lastPathComponent]],
1166 @"",
1167 nil]
1171 row++;
1172 }
1173 if ([cdr oo_boolForKey:@"isFolder"])
1174 {
1175 [gui
setArray:[NSArray arrayWithObjects:
1176 [NSString stringWithFormat:@" >> %@ ", [[cdr oo_stringForKey:@"saved_game_path"] lastPathComponent]],
1177 @"",
1178 nil]
1182 row++;
1183 }
1184 }
1186 highlightIdx = (highlightRowOnPage -
STARTROW) + (currentPage *
NUMROWS);
1187
1188 [self showCommanderShip: highlightIdx];
1189}
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
#define OOLog(class, format,...)
NSDictionary * OODictionaryFromFile(NSString *path)
NSString * OODisplayRatingStringFromKillCount(unsigned kills)
BOOL setSelectedRow:(OOGUIRow row)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setSelectableRange:(NSRange range)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setTabStops:(OOGUITabSettings stops)
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque