source: trunk/SapphireSettings.m @ 20

Revision 20, 5.1 KB checked in by pmerrill, 7 years ago (diff)

Added Controller for Populating Show Data
Added icon update to settings menu options
Code Cleanup

Line 
1//
2//  SapphireSettings.m
3//  Sapphire
4//
5//  Created by pnmerrill on 6/23/07.
6//  Copyright 2007 __MyCompanyName__. All rights reserved.
7//
8
9
10#import <BackRow/BackRow.h>
11#import "SapphireApplianceController.h"
12#import "SapphireSettings.h"
13
14
15@interface SapphireSettings(private)
16- (void)processFiles:(NSArray *)files;
17- (void)filesProcessed:(NSDictionary *)files;
18@end
19
20@implementation SapphireSettings
21
22
23- (id) initWithScene: (BRRenderScene *) scene
24{
25        self = [super initWithScene:scene];
26        BOOL populateShowData = TRUE ;
27        BOOL showFavoriteShows = TRUE ;
28        BOOL showTopShows= TRUE ;
29        BOOL showUnwatchedShows= TRUE ;
30        BOOL showSpoilers= TRUE ;
31        BOOL disableReporting= FALSE ;
32       
33        names = [[NSArray alloc] initWithObjects:       @"   Populate Show Data",
34                                                                                                @"   Hide \"Favorite Shows\"",
35                                                                                                @"   Hide \"Top Shows\"",
36                                                                                                @"   Hide \"Unwatched Shows\"",
37                                                                                                @"   Hide Show Spoilers",
38                                                                                                @"   Disable Anonymous Reporting", nil];
39
40        options = [[NSMutableArray alloc] initWithObjects:      [NSNumber numberWithBool:populateShowData],
41                                                                                                                [NSNumber numberWithBool:showFavoriteShows],
42                                                                                                                [NSNumber numberWithBool:showTopShows],
43                                                                                                                [NSNumber numberWithBool:showUnwatchedShows],
44                                                                                                                [NSNumber numberWithBool:showSpoilers],
45                                                                                                                [NSNumber numberWithBool:disableReporting],nil];
46       
47        populateShowDataController=[[SapphirePopulateDataMenu alloc] initWithScene: scene];
48
49       
50        [[self list] setDatasource:self];
51
52        return self;
53}
54
55- (void)dealloc
56{
57        [names release];
58        [options release];
59        [super dealloc];
60}
61
62- (void) willBePushed
63{
64    // We're about to be placed on screen, but we're not yet there
65   
66    // always call super
67    [super willBePushed];
68}
69
70- (void) wasPushed
71{
72    // We've just been put on screen, the user can see this controller's content now
73   
74    // always call super
75    [super wasPushed];
76}
77
78- (void) willBePopped
79{
80    // The user pressed Menu, but we've not been removed from the screen yet
81   
82    // always call super
83    [super willBePopped];
84}
85
86- (void) wasPopped
87{
88    // The user pressed Menu, removing us from the screen
89   
90    // always call super
91    [super wasPopped];
92}
93
94- (void) willBeBuried
95{
96    // The user just chose an option, and we will be taken off the screen
97   
98    // always call super
99    [super willBeBuried];
100}
101
102- (void) wasBuriedByPushingController: (BRLayerController *) controller
103{
104    // The user chose an option and this controller os no longer on screen
105   
106    // always call super
107    [super wasBuriedByPushingController: controller];
108}
109
110- (void) willBeExhumed
111{
112    // the user pressed Menu, but we've not been revealed yet
113   
114    // always call super
115    [super willBeExhumed];
116}
117
118- (void) wasExhumedByPoppingController: (BRLayerController *) controller
119{
120    // handle being revealed when the user presses Menu
121   
122    // always call super
123    [super wasExhumedByPoppingController: controller];
124}
125
126- (long) itemCount
127{
128    // return the number of items in your menu list here
129        return ( [ names count]);
130}
131
132- (id<BRMenuItemLayer>) itemForRow: (long) row
133{
134/*
135    // build a BRTextMenuItemLayer or a BRAdornedMenuItemLayer, etc. here
136    // return that object, it will be used to display the list item.
137    return ( nil );
138*/
139        if( row > [names count] ) return ( nil ) ;
140       
141        BRAdornedMenuItemLayer * result = nil ;
142        NSString *name = [names objectAtIndex:row];
143        result = [BRAdornedMenuItemLayer adornedMenuItemWithScene: [self scene]] ;
144
145        if(row==0)      [result setLeftIcon:[[BRThemeInfo sharedTheme] gearImageForScene:[self scene]]];
146        else if( row > 0 && [[options objectAtIndex:row] boolValue])
147        {
148                [result setLeftIcon:[[BRThemeInfo sharedTheme] selectedSettingImageForScene:[self scene]]];
149        }
150
151
152        // add text
153        [[result textItem] setTitle: name] ;
154                               
155        return ( result ) ;
156}
157
158- (NSString *) titleForRow: (long) row
159{
160
161        if ( row > [ names count] ) return ( nil );
162       
163        NSString *result = [ names objectAtIndex: row] ;
164        return ( result ) ;
165/*
166    // return the title for the list item at the given index here
167    return ( @"Sapphire" );
168*/
169}
170
171- (long) rowForTitle: (NSString *) title
172{
173    long result = -1;
174    long i, count = [self itemCount];
175    for ( i = 0; i < count; i++ )
176    {
177        if ( [title isEqualToString: [self titleForRow: i]] )
178        {
179            result = i;
180            break;
181        }
182    }
183   
184    return ( result );
185}
186
187- (void) itemSelected: (long) row
188{
189    // This is called when the user presses play/pause on a list item
190
191        NSNumber *setting = [options objectAtIndex:row];
192        if(row==0)
193        {
194                id controller = populateShowDataController;
195                [[self stack] pushController:controller];
196//              [[self stack] pushController:populateShowDataController];
197//              [[self stack] popController] ;
198
199               
200        }
201        if(row>0)
202        {
203                [options replaceObjectAtIndex:row withObject:[NSNumber numberWithBool:![setting boolValue]]];
204//              [[self stack] pushController: self] ;
205//              [[self stack] pushController:self] ;
206//              [[self stack] popController] ;
207//              [[self stack] popController] ;
208        }
209
210
211        [[self list] reload] ;
212
213}
214
215- (id<BRMediaPreviewController>) previewControllerForItem: (long) item
216{
217    // If subclassing BRMediaMenuController, this function is called when the selection cursor
218    // passes over an item.
219    return ( nil );
220}
221
222@end
223
Note: See TracBrowser for help on using the repository browser.