70 return listOfWeapons; |
70 return listOfWeapons; |
71 } |
71 } |
72 |
72 |
73 -(NSArray *)listOfScripts { |
73 -(NSArray *)listOfScripts { |
74 if (listOfScripts == nil) |
74 if (listOfScripts == nil) |
75 self.listOfScripts = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SCRIPTS_DIRECTORY() error:NULL]; |
75 self.listOfScripts = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:SCRIPTS_DIRECTORY() error:NULL] |
|
76 filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF ENDSWITH '.lua'"]]; |
76 return listOfScripts; |
77 return listOfScripts; |
77 } |
78 } |
78 |
79 |
79 -(UISegmentedControl *)topControl { |
80 -(UISegmentedControl *)topControl { |
80 if (topControl == nil) { |
81 if (topControl == nil) { |
200 cell.accessoryView = checkbox; |
201 cell.accessoryView = checkbox; |
201 [checkbox release]; |
202 [checkbox release]; |
202 self.lastIndexPath_we = indexPath; |
203 self.lastIndexPath_we = indexPath; |
203 } |
204 } |
204 } else { |
205 } else { |
205 cell.textLabel.text = [[self.listOfScripts objectAtIndex:row] stringByDeletingPathExtension]; |
206 cell.textLabel.text = [[[self.listOfScripts objectAtIndex:row] stringByDeletingPathExtension] |
206 NSString *str = [NSString stringWithFormat:@"%@/%@",SCRIPTS_DIRECTORY(),[self.listOfScripts objectAtIndex:row]]; |
207 stringByReplacingOccurrencesOfString:@"_" withString:@" "]; |
207 NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:str]; |
208 //cell.detailTextLabel.text = ; |
208 cell.detailTextLabel.text = [dict objectForKey:@"description"]; |
|
209 [dict release]; |
|
210 if ([[self.listOfScripts objectAtIndex:row] isEqualToString:self.selectedScript]) { |
209 if ([[self.listOfScripts objectAtIndex:row] isEqualToString:self.selectedScript]) { |
211 UIImageView *checkbox = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"checkbox.png"]]; |
210 UIImageView *checkbox = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"checkbox.png"]]; |
212 cell.accessoryView = checkbox; |
211 cell.accessoryView = checkbox; |
213 [checkbox release]; |
212 [checkbox release]; |
214 self.lastIndexPath_lu = indexPath; |
213 self.lastIndexPath_lu = indexPath; |
285 } else { |
284 } else { |
286 self.lastIndexPath_lu = indexPath; |
285 self.lastIndexPath_lu = indexPath; |
287 self.selectedScript = [self.listOfScripts objectAtIndex:newRow]; |
286 self.selectedScript = [self.listOfScripts objectAtIndex:newRow]; |
288 |
287 |
289 // some styles disable or force the choice of a particular scheme/weaponset |
288 // some styles disable or force the choice of a particular scheme/weaponset |
290 NSString *path = [[NSString alloc] initWithFormat:@"%@/%@",SCRIPTS_DIRECTORY(),self.selectedScript]; |
289 NSString *path = [[NSString alloc] initWithFormat:@"%@/%@.cfg",SCRIPTS_DIRECTORY(),[self.selectedScript stringByDeletingPathExtension]]; |
291 NSDictionary *scriptDict = [[NSDictionary alloc] initWithContentsOfFile:path]; |
290 NSString *configFile = [[NSString alloc] initWithContentsOfFile:path]; |
292 [path release]; |
291 [path release]; |
293 self.scriptCommand = [scriptDict objectForKey:@"command"]; |
292 NSArray *scriptOptions = [configFile componentsSeparatedByString:@"\n"]; |
294 NSString *scheme = [scriptDict objectForKey:@"scheme"]; |
293 [configFile release]; |
295 if ([scheme isEqualToString:@""]) { |
294 |
|
295 self.scriptCommand = [NSString stringWithFormat:@"escript Scripts/Multiplayer/%@",self.selectedScript]; |
|
296 NSString *scheme = [scriptOptions objectAtIndex:0]; |
|
297 if ([scheme isEqualToString:@"locked"]) { |
296 self.selectedScheme = @"Default.plist"; |
298 self.selectedScheme = @"Default.plist"; |
297 [self.topControl setEnabled:NO forSegmentAtIndex:0]; |
299 [self.topControl setEnabled:NO forSegmentAtIndex:0]; |
298 } else { |
300 } else { |
299 self.selectedScheme = scheme; |
301 self.selectedScheme = [NSString stringWithFormat:@"%@.plist",scheme]; |
300 [self.topControl setEnabled:YES forSegmentAtIndex:0]; |
302 [self.topControl setEnabled:YES forSegmentAtIndex:0]; |
301 } |
303 } |
302 |
304 |
303 NSString *weapon = [scriptDict objectForKey:@"weapon"]; |
305 NSString *weapon = [scriptOptions objectAtIndex:1]; |
304 if ([weapon isEqualToString:@""]) { |
306 if ([weapon isEqualToString:@"locked"]) { |
305 self.selectedWeapon = @"Default.plist"; |
307 self.selectedWeapon = @"Default.plist"; |
306 [self.topControl setEnabled:NO forSegmentAtIndex:1]; |
308 [self.topControl setEnabled:NO forSegmentAtIndex:1]; |
307 } else { |
309 } else { |
308 self.selectedWeapon = weapon; |
310 self.selectedWeapon = [NSString stringWithFormat:@"%@.plist",weapon]; |
309 [self.topControl setEnabled:YES forSegmentAtIndex:1]; |
311 [self.topControl setEnabled:YES forSegmentAtIndex:1]; |
310 } |
312 } |
311 |
|
312 [scriptDict release]; |
|
313 } |
313 } |
314 |
314 |
315 [aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
315 [aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
316 } |
316 } |
317 [aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
317 [aTableView deselectRowAtIndexPath:indexPath animated:YES]; |