| 1 | /* |
|---|
| 2 | * SapphireSettings.m |
|---|
| 3 | * Sapphire |
|---|
| 4 | * |
|---|
| 5 | * Created by pnmerrill on Jun. 23, 2007. |
|---|
| 6 | * Copyright 2007 Sapphire Development Team and/or www.nanopi.net |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
|---|
| 10 | * General Public License as published by the Free Software Foundation; either version 3 of the License, |
|---|
| 11 | * or (at your option) any later version. |
|---|
| 12 | * |
|---|
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
|---|
| 14 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|---|
| 15 | * Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License along with this program; if not, |
|---|
| 18 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | #import <BackRow/BackRow.h> |
|---|
| 23 | #import "SapphireApplianceController.h" |
|---|
| 24 | #import "SapphireSettings.h" |
|---|
| 25 | #import "SapphireTheme.h" |
|---|
| 26 | #import "SapphireMediaPreview.h" |
|---|
| 27 | #import "SapphireAllFileDataImporter.h" |
|---|
| 28 | #import "SapphireTVShowImporter.h" |
|---|
| 29 | #import "SapphireMovieImporter.h" |
|---|
| 30 | #import "SapphirePosterChooser.h" |
|---|
| 31 | #import "SapphireCollectionSettings.h" |
|---|
| 32 | #import <SapphireCompatClasses/SapphireFrontRowCompat.h> |
|---|
| 33 | |
|---|
| 34 | static SapphireSettings *sharedInstance = nil; |
|---|
| 35 | |
|---|
| 36 | @interface SapphireSettings(private) |
|---|
| 37 | - (void)processFiles:(NSArray *)files; |
|---|
| 38 | - (void)filesProcessed:(NSDictionary *)files; |
|---|
| 39 | @end |
|---|
| 40 | |
|---|
| 41 | @implementation SapphireSettings |
|---|
| 42 | |
|---|
| 43 | #define HIDE_FAVORITE_KEY @"HideFavorites" |
|---|
| 44 | #define HIDE_TOP_SHOWS_KEY @"HideTopShows" |
|---|
| 45 | #define HIDE_UNWATCHED_KEY @"HideUnwatched" |
|---|
| 46 | #define HIDE_SPOILERS_KEY @"HideSpoilers" |
|---|
| 47 | #define HIDE_AUDIO_KEY @"HideAudio" |
|---|
| 48 | #define HIDE_VIDEO_KEY @"HideVideo" |
|---|
| 49 | #define HIDE_POSTER_CHOOSER_KEY @"PosterChooserOptOut" |
|---|
| 50 | #define HIDE_UI_QUIT_KEY @"HideUIQuit" |
|---|
| 51 | #define ENABLE_FAST_SWITCHING_KEY @"EnableFastSwitching" |
|---|
| 52 | #define USE_AC3_PASSTHROUGH @"EnableAC3Passthrough" |
|---|
| 53 | #define DISABLE_ANON_KEY @"DisableAnonymousReporting" |
|---|
| 54 | #define LAST_PREDICATE @"LastPredicate" |
|---|
| 55 | |
|---|
| 56 | + (SapphireSettings *)sharedSettings |
|---|
| 57 | { |
|---|
| 58 | return sharedInstance; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | + (void)relinquishSettings |
|---|
| 62 | { |
|---|
| 63 | [sharedInstance release]; |
|---|
| 64 | sharedInstance = nil; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | - (id) initWithScene: (BRRenderScene *) scene settingsPath:(NSString *)dictionaryPath metaDataCollection:(SapphireMetaDataCollection *)collection |
|---|
| 68 | { |
|---|
| 69 | if(sharedInstance != nil) |
|---|
| 70 | return sharedInstance; |
|---|
| 71 | |
|---|
| 72 | self = [super initWithScene:scene]; |
|---|
| 73 | |
|---|
| 74 | /*Setup display*/ |
|---|
| 75 | metaCollection = [collection retain]; |
|---|
| 76 | names = [[NSArray alloc] initWithObjects: BRLocalizedString(@" Populate File Data", @"Populate File Data menu item"), |
|---|
| 77 | BRLocalizedString(@" Fetch TV Show Data", @"Fetch TV Show Data menu item"), |
|---|
| 78 | BRLocalizedString(@" Fetch Movie Data", @"Fetch Movie Data menu item"), |
|---|
| 79 | /* BRLocalizedString(@" Choose Movie Posters", @"Start Poster Chooser menu item"),*/ |
|---|
| 80 | BRLocalizedString(@" Hide Collections", @"Hide Collections menu item"), |
|---|
| 81 | BRLocalizedString(@" Don't Import Collections", @"Don't Import Collections menu item"), |
|---|
| 82 | BRLocalizedString(@" Skip \"Favorite Shows\" filter", @"Skip Favorite shows menu item"), |
|---|
| 83 | /* BRLocalizedString(@" Skip \"Top Shows\" filter", @"Skip Top shows menu item"),*/ |
|---|
| 84 | BRLocalizedString(@" Skip \"Unwatched Shows\" filter", @"Skip Unwatched shows menu item"), |
|---|
| 85 | BRLocalizedString(@" Hide Show Spoilers", @"Hide show summarys menu item"), |
|---|
| 86 | BRLocalizedString(@" Hide Audio Info", @"Hide perian audio info menu item"), |
|---|
| 87 | BRLocalizedString(@" Hide Video Info", @"Hide perian video info menu item"), |
|---|
| 88 | BRLocalizedString(@" Hide Poster Chooser", @"Hide poster chooser menu item"), |
|---|
| 89 | BRLocalizedString(@" Hide UI Quit", @"Hide the ui quitter menu item"), |
|---|
| 90 | BRLocalizedString(@" Fast Directory Switching", @"Don't rescan directories upon entry and used cached data"), |
|---|
| 91 | BRLocalizedString(@" Enable AC3 Passthrough", @"Enable AC3 Passthrough menu item"), |
|---|
| 92 | BRLocalizedString(@" Disable Anonymous Reporting", @"Disable the anonymous reporting for aid in future features"), nil]; |
|---|
| 93 | |
|---|
| 94 | settingDescriptions=[[NSArray alloc] initWithObjects: |
|---|
| 95 | BRLocalizedString(@"tells Sapphire to examine all files, and remember the file size, length and other information that can be gathered from the file itself.", @"Populate File Data description"), |
|---|
| 96 | BRLocalizedString(@"tells Sapphire that for every TV episode, gather more information about this episode from the internet.", @"Fetch TV Show Data description"), |
|---|
| 97 | BRLocalizedString(@"tells Sapphire that for every Movie, gather more information from the internet.", @"Fetch Movie Data description"), |
|---|
| 98 | /* BRLocalizedString(@"Choose Movie Posters", @"Start Poster Chooser description"),*/ |
|---|
| 99 | BRLocalizedString(@"allows the user to specify which collections should be hidden from Sapphire's main menu.", @"Hide Collections description"), |
|---|
| 100 | BRLocalizedString(@"allows to user to specify which collections should be skipped when importing meta data.", @"Don't Import Collections description"), |
|---|
| 101 | BRLocalizedString(@"tells Sapphire that when changing filter settings, skip over the favorite shows filter.", @"Skip Favorite shows description"), |
|---|
| 102 | /* BRLocalizedString(@"Skip \"Top Shows\" filter", @"Skip Top shows description"),*/ |
|---|
| 103 | BRLocalizedString(@"tells Sapphire that when changing filter settings, skip over the unwatched shows filter.", @"Skip Unwatched shows description"), |
|---|
| 104 | BRLocalizedString(@"tells Sapphire to disable the display of the show's synopsis.", @"Hide show summarys description"), |
|---|
| 105 | BRLocalizedString(@"tells Sapphire to disable the display of audio codec and sample rate information.", @"Hide perian audio info description"), |
|---|
| 106 | BRLocalizedString(@"tells Sapphire to disable the display of video codec, resolution, and color depth information.", @"Hide perian video info description"), |
|---|
| 107 | BRLocalizedString(@"tells Sapphire to automatically choose posters for movies instead of asking the user to choose one.", @"Hide poster chooser description"), |
|---|
| 108 | BRLocalizedString(@"tells Sapphire to hide the main menu element forcing frontrow to quit.", @"Hide the ui quitter description"), |
|---|
| 109 | BRLocalizedString(@"tells Sapphire that when using a filter, use the cached data to setup directories rather than scanning the directories themselves for new files.", @"Fast Directory Switching description"), |
|---|
| 110 | BRLocalizedString(@"tells Sapphire that you have an AC3 decoder and to enable passthrough of the full audio information to the decoder. This is how you get 5.1 output.", @"Enable AC3 Passthrough description"), |
|---|
| 111 | BRLocalizedString(@"tells Sapphire to not report any anonymous information on how you use Sapphire. Anonymous reporting enables us to improve the plugin for future use.", @"Disable the anonymous reporting description"), nil]; |
|---|
| 112 | |
|---|
| 113 | keys = [[NSArray alloc] initWithObjects: @"", |
|---|
| 114 | @"", |
|---|
| 115 | @"", |
|---|
| 116 | /* @"",*/ |
|---|
| 117 | @"", |
|---|
| 118 | @"", |
|---|
| 119 | HIDE_FAVORITE_KEY, |
|---|
| 120 | /*HIDE_TOP_SHOWS_KEY, */ |
|---|
| 121 | HIDE_UNWATCHED_KEY, |
|---|
| 122 | HIDE_SPOILERS_KEY, |
|---|
| 123 | HIDE_AUDIO_KEY, |
|---|
| 124 | HIDE_VIDEO_KEY, |
|---|
| 125 | HIDE_POSTER_CHOOSER_KEY, |
|---|
| 126 | HIDE_UI_QUIT_KEY, |
|---|
| 127 | ENABLE_FAST_SWITCHING_KEY, |
|---|
| 128 | USE_AC3_PASSTHROUGH, |
|---|
| 129 | DISABLE_ANON_KEY, nil]; |
|---|
| 130 | SapphireTheme *theme = [SapphireTheme sharedTheme]; |
|---|
| 131 | gems = [[NSArray alloc] initWithObjects: [theme gem:IMPORT_GEM_KEY], |
|---|
| 132 | [theme gem:TVR_GEM_KEY], |
|---|
| 133 | [theme gem:IMDB_GEM_KEY], |
|---|
| 134 | /*[theme gem:GREEN_GEM_KEY],*/ |
|---|
| 135 | [theme gem:FILE_GEM_KEY], |
|---|
| 136 | [theme gem:FILE_GEM_KEY], |
|---|
| 137 | [theme gem:YELLOW_GEM_KEY], |
|---|
| 138 | /*[theme gem:GREEN_GEM_KEY],*/ |
|---|
| 139 | [theme gem:BLUE_GEM_KEY], |
|---|
| 140 | [theme gem:NOTE_GEM_KEY], |
|---|
| 141 | [theme gem:AUDIO_GEM_KEY], |
|---|
| 142 | [theme gem:VIDEO_GEM_KEY], |
|---|
| 143 | [theme gem:IMPORT_GEM_KEY], |
|---|
| 144 | [theme gem:FRONTROW_GEM_KEY], |
|---|
| 145 | [theme gem:FAST_GEM_KEY], |
|---|
| 146 | [theme gem:AC3_GEM_KEY], |
|---|
| 147 | [theme gem:REPORT_GEM_KEY], nil]; |
|---|
| 148 | |
|---|
| 149 | path = [dictionaryPath retain]; |
|---|
| 150 | options = [[NSDictionary dictionaryWithContentsOfFile:dictionaryPath] mutableCopy]; |
|---|
| 151 | /*Set deaults*/ |
|---|
| 152 | defaults = [[NSDictionary alloc] initWithObjectsAndKeys: |
|---|
| 153 | [NSNumber numberWithBool:NO], HIDE_FAVORITE_KEY, |
|---|
| 154 | [NSNumber numberWithBool:YES], HIDE_TOP_SHOWS_KEY, |
|---|
| 155 | [NSNumber numberWithBool:NO], HIDE_UNWATCHED_KEY, |
|---|
| 156 | [NSNumber numberWithBool:NO], HIDE_SPOILERS_KEY, |
|---|
| 157 | [NSNumber numberWithBool:NO], HIDE_AUDIO_KEY, |
|---|
| 158 | [NSNumber numberWithBool:NO], HIDE_VIDEO_KEY, |
|---|
| 159 | [NSNumber numberWithBool:NO], HIDE_POSTER_CHOOSER_KEY, |
|---|
| 160 | [NSNumber numberWithBool:YES], HIDE_UI_QUIT_KEY, |
|---|
| 161 | [NSNumber numberWithBool:YES], ENABLE_FAST_SWITCHING_KEY, |
|---|
| 162 | [NSNumber numberWithBool:NO], USE_AC3_PASSTHROUGH, |
|---|
| 163 | [NSNumber numberWithBool:NO], DISABLE_ANON_KEY, |
|---|
| 164 | [NSNumber numberWithInt:NSNotFound], LAST_PREDICATE, |
|---|
| 165 | nil]; |
|---|
| 166 | if(options == nil) |
|---|
| 167 | options = [[NSMutableDictionary alloc] init]; |
|---|
| 168 | |
|---|
| 169 | /*display*/ |
|---|
| 170 | BRListControl *list = [self list]; |
|---|
| 171 | [list setDatasource:self]; |
|---|
| 172 | [SapphireFrontRowCompat addDividerAtIndex:5 toList:list]; |
|---|
| 173 | /*Save our instance*/ |
|---|
| 174 | sharedInstance = [self retain]; |
|---|
| 175 | |
|---|
| 176 | return self; |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | /*! |
|---|
| 180 | * @brief Writes settings to disk |
|---|
| 181 | */ |
|---|
| 182 | - (void)writeSettings |
|---|
| 183 | { |
|---|
| 184 | [options writeToFile:path atomically:YES]; |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | - (void)dealloc |
|---|
| 188 | { |
|---|
| 189 | [names release]; |
|---|
| 190 | [options release]; |
|---|
| 191 | [gems release]; |
|---|
| 192 | [path release]; |
|---|
| 193 | [defaults release]; |
|---|
| 194 | [metaCollection release]; |
|---|
| 195 | [super dealloc]; |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | /*! |
|---|
| 199 | * @brief Get a setting |
|---|
| 200 | * |
|---|
| 201 | * @param key The setting to retrieve |
|---|
| 202 | * @return The setting in an NSNumber |
|---|
| 203 | */ |
|---|
| 204 | - (NSNumber *)numberForKey:(NSString *)key |
|---|
| 205 | { |
|---|
| 206 | /*Check the user's setting*/ |
|---|
| 207 | NSNumber *num = [options objectForKey:key]; |
|---|
| 208 | if(!num) |
|---|
| 209 | /*User hasn't set yet, use default then*/ |
|---|
| 210 | num = [defaults objectForKey:key]; |
|---|
| 211 | return num; |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | /*! |
|---|
| 215 | * @brief Get a setting |
|---|
| 216 | * |
|---|
| 217 | * @param key The setting to retrieve |
|---|
| 218 | * @return YES if set, NO otherwise |
|---|
| 219 | */ |
|---|
| 220 | - (BOOL)boolForKey:(NSString *)key |
|---|
| 221 | { |
|---|
| 222 | /*Check the user's setting*/ |
|---|
| 223 | NSNumber *num = [options objectForKey:key]; |
|---|
| 224 | if(!num) |
|---|
| 225 | /*User hasn't set yet, use default then*/ |
|---|
| 226 | num = [defaults objectForKey:key]; |
|---|
| 227 | return [num boolValue]; |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | - (BOOL)displayUnwatched |
|---|
| 231 | { |
|---|
| 232 | return ![self boolForKey:HIDE_UNWATCHED_KEY]; |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | - (BOOL)displayFavorites |
|---|
| 236 | { |
|---|
| 237 | return ![self boolForKey:HIDE_FAVORITE_KEY]; |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | - (BOOL)displayTopShows |
|---|
| 241 | { |
|---|
| 242 | return ![self boolForKey:HIDE_TOP_SHOWS_KEY]; |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | - (BOOL)displaySpoilers |
|---|
| 246 | { |
|---|
| 247 | return ![self boolForKey:HIDE_SPOILERS_KEY]; |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | - (BOOL)displayAudio |
|---|
| 251 | { |
|---|
| 252 | return ![self boolForKey:HIDE_AUDIO_KEY]; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | - (BOOL)displayVideo |
|---|
| 256 | { |
|---|
| 257 | return ![self boolForKey:HIDE_VIDEO_KEY]; |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | - (BOOL)displayPosterChooser |
|---|
| 261 | { |
|---|
| 262 | return ![self boolForKey:HIDE_POSTER_CHOOSER_KEY]; |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | - (BOOL)disableUIQuit |
|---|
| 266 | { |
|---|
| 267 | return [self boolForKey:HIDE_UI_QUIT_KEY]; |
|---|
| 268 | } |
|---|
| 269 | |
|---|
| 270 | - (BOOL)disableAnonymousReporting; |
|---|
| 271 | { |
|---|
| 272 | return [self boolForKey:DISABLE_ANON_KEY]; |
|---|
| 273 | } |
|---|
| 274 | |
|---|
| 275 | - (BOOL)useAC3Passthrough |
|---|
| 276 | { |
|---|
| 277 | return [self boolForKey:USE_AC3_PASSTHROUGH]; |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | - (BOOL)fastSwitching |
|---|
| 281 | { |
|---|
| 282 | return [self boolForKey:ENABLE_FAST_SWITCHING_KEY]; |
|---|
| 283 | |
|---|
| 284 | } |
|---|
| 285 | |
|---|
| 286 | - (int)indexOfLastPredicate |
|---|
| 287 | { |
|---|
| 288 | return [[self numberForKey:LAST_PREDICATE] intValue]; |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | - (void)setIndexOfLastPredicate:(int)index |
|---|
| 292 | { |
|---|
| 293 | [options setObject:[NSNumber numberWithInt:index] forKey:LAST_PREDICATE]; |
|---|
| 294 | /*Save our settings*/ |
|---|
| 295 | [self writeSettings]; |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | - (void) willBePushed |
|---|
| 299 | { |
|---|
| 300 | // We're about to be placed on screen, but we're not yet there |
|---|
| 301 | |
|---|
| 302 | // always call super |
|---|
| 303 | [super willBePushed]; |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | - (void) wasPushed |
|---|
| 307 | { |
|---|
| 308 | // We've just been put on screen, the user can see this controller's content now |
|---|
| 309 | |
|---|
| 310 | // always call super |
|---|
| 311 | [super wasPushed]; |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | - (void) willBePopped |
|---|
| 315 | { |
|---|
| 316 | // The user pressed Menu, but we've not been removed from the screen yet |
|---|
| 317 | |
|---|
| 318 | // always call super |
|---|
| 319 | [super willBePopped]; |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | - (void) wasPopped |
|---|
| 323 | { |
|---|
| 324 | // The user pressed Menu, removing us from the screen |
|---|
| 325 | |
|---|
| 326 | // always call super |
|---|
| 327 | [super wasPopped]; |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | - (void) willBeBuried |
|---|
| 331 | { |
|---|
| 332 | // The user just chose an option, and we will be taken off the screen |
|---|
| 333 | |
|---|
| 334 | // always call super |
|---|
| 335 | [super willBeBuried]; |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | - (void) wasBuriedByPushingController: (BRLayerController *) controller |
|---|
| 339 | { |
|---|
| 340 | // The user chose an option and this controller is no longer on screen |
|---|
| 341 | |
|---|
| 342 | // always call super |
|---|
| 343 | [super wasBuriedByPushingController: controller]; |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | - (void) willBeExhumed |
|---|
| 347 | { |
|---|
| 348 | // the user pressed Menu, but we've not been revealed yet |
|---|
| 349 | |
|---|
| 350 | // always call super |
|---|
| 351 | [super willBeExhumed]; |
|---|
| 352 | } |
|---|
| 353 | |
|---|
| 354 | - (void) wasExhumedByPoppingController: (BRLayerController *) controller |
|---|
| 355 | { |
|---|
| 356 | // handle being revealed when the user presses Menu |
|---|
| 357 | |
|---|
| 358 | // always call super |
|---|
| 359 | [super wasExhumedByPoppingController: controller]; |
|---|
| 360 | } |
|---|
| 361 | |
|---|
| 362 | - (long) itemCount |
|---|
| 363 | { |
|---|
| 364 | // return the number of items in your menu list here |
|---|
| 365 | return ( [ names count]); |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | - (id<BRMenuItemLayer>) itemForRow: (long) row |
|---|
| 369 | { |
|---|
| 370 | /* |
|---|
| 371 | // build a BRTextMenuItemLayer or a BRAdornedMenuItemLayer, etc. here |
|---|
| 372 | // return that object, it will be used to display the list item. |
|---|
| 373 | return ( nil ); |
|---|
| 374 | */ |
|---|
| 375 | if( row >= [names count] ) return ( nil ) ; |
|---|
| 376 | |
|---|
| 377 | BRAdornedMenuItemLayer * result = nil ; |
|---|
| 378 | NSString *name = [names objectAtIndex:row]; |
|---|
| 379 | result = [SapphireFrontRowCompat textMenuItemForScene:[self scene] folder:NO]; |
|---|
| 380 | |
|---|
| 381 | if( row > 4 && [self boolForKey:[keys objectAtIndex:row]]) |
|---|
| 382 | { |
|---|
| 383 | [SapphireFrontRowCompat setLeftIcon:[SapphireFrontRowCompat selectedSettingImageForScene:[self scene]] forMenu:result]; |
|---|
| 384 | } |
|---|
| 385 | [SapphireFrontRowCompat setRightIcon:[gems objectAtIndex:row] forMenu:result]; |
|---|
| 386 | |
|---|
| 387 | // add text |
|---|
| 388 | [SapphireFrontRowCompat setTitle:name forMenu:result]; |
|---|
| 389 | |
|---|
| 390 | return ( result ) ; |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | - (NSString *) titleForRow: (long) row |
|---|
| 394 | { |
|---|
| 395 | |
|---|
| 396 | if ( row >= [ names count] ) return ( nil ); |
|---|
| 397 | |
|---|
| 398 | NSString *result = [ names objectAtIndex: row] ; |
|---|
| 399 | return ( result ) ; |
|---|
| 400 | /* |
|---|
| 401 | // return the title for the list item at the given index here |
|---|
| 402 | return ( @"Sapphire" ); |
|---|
| 403 | */ |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | - (long) rowForTitle: (NSString *) title |
|---|
| 407 | { |
|---|
| 408 | long result = -1; |
|---|
| 409 | long i, count = [self itemCount]; |
|---|
| 410 | for ( i = 0; i < count; i++ ) |
|---|
| 411 | { |
|---|
| 412 | if ( [title isEqualToString: [self titleForRow: i]] ) |
|---|
| 413 | { |
|---|
| 414 | result = i; |
|---|
| 415 | break; |
|---|
| 416 | } |
|---|
| 417 | } |
|---|
| 418 | |
|---|
| 419 | return ( result ); |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | - (void) itemSelected: (long) row |
|---|
| 423 | { |
|---|
| 424 | // This is called when the user changed a setting |
|---|
| 425 | |
|---|
| 426 | /*Check for populate show data*/ |
|---|
| 427 | if(row==0) |
|---|
| 428 | { |
|---|
| 429 | SapphireAllFileDataImporter *importer = [[SapphireAllFileDataImporter alloc] init]; |
|---|
| 430 | SapphireImporterDataMenu *menu = [[SapphireImporterDataMenu alloc] initWithScene:[self scene] metaDataCollection:metaCollection importer:importer]; |
|---|
| 431 | [[self stack] pushController:menu]; |
|---|
| 432 | [menu release]; |
|---|
| 433 | [importer release]; |
|---|
| 434 | } |
|---|
| 435 | /*Check for import of TV data*/ |
|---|
| 436 | else if(row == 1) |
|---|
| 437 | { |
|---|
| 438 | SapphireTVShowImporter *importer = [[SapphireTVShowImporter alloc] initWithSavedSetting:[[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"tvdata.plist"]]; |
|---|
| 439 | SapphireImporterDataMenu *menu = [[SapphireImporterDataMenu alloc] initWithScene:[self scene] metaDataCollection:metaCollection importer:importer]; |
|---|
| 440 | [[self stack] pushController:menu]; |
|---|
| 441 | [menu release]; |
|---|
| 442 | [importer release]; |
|---|
| 443 | } |
|---|
| 444 | /*Start Importing Movie Data*/ |
|---|
| 445 | else if(row == 2) |
|---|
| 446 | { |
|---|
| 447 | SapphireMovieImporter *importer = [[SapphireMovieImporter alloc] initWithSavedSetting:[[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"movieData.plist"]]; |
|---|
| 448 | SapphireImporterDataMenu *menu = [[SapphireImporterDataMenu alloc] initWithScene:[self scene] metaDataCollection:metaCollection importer:importer]; |
|---|
| 449 | [[self stack] pushController:menu]; |
|---|
| 450 | [menu release]; |
|---|
| 451 | [importer release]; |
|---|
| 452 | } |
|---|
| 453 | /* |
|---|
| 454 | Start Movie Poster Chooser |
|---|
| 455 | else if(row == 3) |
|---|
| 456 | { |
|---|
| 457 | // SapphirePosterBrowse *chooser = [[SapphirePosterChooser alloc] initWithScene:[self scene] metaDataPath:[[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"movieData.plist"]]; |
|---|
| 458 | // [[self stack] pushController:chooser]; |
|---|
| 459 | // [chooser release]; |
|---|
| 460 | } |
|---|
| 461 | */ |
|---|
| 462 | else if(row == 3) |
|---|
| 463 | { |
|---|
| 464 | SapphireCollectionSettings *colSettings = [[SapphireCollectionSettings alloc] initWithScene:[self scene] collection:metaCollection]; |
|---|
| 465 | [colSettings setGettingSelector:@selector(hideCollection:)]; |
|---|
| 466 | [colSettings setSettingSelector:@selector(setHide:forCollection:)]; |
|---|
| 467 | [colSettings setListTitle:BRLocalizedString(@"Hide Collections", @"Hide Collections Menu Title")] ; |
|---|
| 468 | [[self stack] pushController:colSettings]; |
|---|
| 469 | [colSettings release]; |
|---|
| 470 | } |
|---|
| 471 | else if(row == 4) |
|---|
| 472 | { |
|---|
| 473 | SapphireCollectionSettings *colSettings = [[SapphireCollectionSettings alloc] initWithScene:[self scene] collection:metaCollection]; |
|---|
| 474 | [colSettings setGettingSelector:@selector(skipCollection:)]; |
|---|
| 475 | [colSettings setSettingSelector:@selector(setSkip:forCollection:)]; |
|---|
| 476 | [colSettings setListTitle:BRLocalizedString(@"Skip Collections", @"Skip Collections Menu Title")] ; |
|---|
| 477 | [[self stack] pushController:colSettings]; |
|---|
| 478 | [colSettings release]; |
|---|
| 479 | } |
|---|
| 480 | /*Change setting*/ |
|---|
| 481 | else |
|---|
| 482 | { |
|---|
| 483 | NSString *key = [keys objectAtIndex:row]; |
|---|
| 484 | BOOL setting = [self boolForKey:key]; |
|---|
| 485 | [options setObject:[NSNumber numberWithBool:!setting] forKey:key]; |
|---|
| 486 | } |
|---|
| 487 | |
|---|
| 488 | /*Save our settings*/ |
|---|
| 489 | [self writeSettings]; |
|---|
| 490 | |
|---|
| 491 | /*Redraw*/ |
|---|
| 492 | [[self list] reload] ; |
|---|
| 493 | [SapphireFrontRowCompat renderScene:[self scene]]; |
|---|
| 494 | |
|---|
| 495 | } |
|---|
| 496 | |
|---|
| 497 | - (id<BRMediaPreviewController>) previewControlForItem: (long) row |
|---|
| 498 | { |
|---|
| 499 | return [self previewControllerForItem:row]; |
|---|
| 500 | } |
|---|
| 501 | |
|---|
| 502 | - (id<BRMediaPreviewController>) previewControllerForItem: (long) item |
|---|
| 503 | { |
|---|
| 504 | // If subclassing BRMediaMenuController, this function is called when the selection cursor |
|---|
| 505 | // passes over an item. |
|---|
| 506 | if(item >= [names count]) |
|---|
| 507 | return nil; |
|---|
| 508 | else |
|---|
| 509 | { |
|---|
| 510 | /* Get setting name & kill the gem cushion */ |
|---|
| 511 | NSString *settingName = [[names objectAtIndex:item]substringFromIndex:2]; |
|---|
| 512 | NSString *settingDescription=[settingDescriptions objectAtIndex:item]; |
|---|
| 513 | /* Construct a gerneric metadata asset for display */ |
|---|
| 514 | NSMutableDictionary *settingMeta=[[NSMutableDictionary alloc] init]; |
|---|
| 515 | [settingMeta setObject:settingName forKey:META_TITLE_KEY]; |
|---|
| 516 | [settingMeta setObject:[NSNumber numberWithInt:FILE_CLASS_UTILITY] forKey:FILE_CLASS_KEY]; |
|---|
| 517 | [settingMeta setObject:settingDescription forKey:META_DESCRIPTION_KEY]; |
|---|
| 518 | SapphireMediaPreview *preview = [[SapphireMediaPreview alloc] initWithScene:[self scene]]; |
|---|
| 519 | [preview setUtilityData:settingMeta]; |
|---|
| 520 | [preview setShowsMetadataImmediately:YES]; |
|---|
| 521 | /*And go*/ |
|---|
| 522 | return [preview autorelease]; |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | return ( nil ); |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | @end |
|---|
| 529 | |
|---|