equal
deleted
inserted
replaced
22 |
22 |
23 |
23 |
24 @implementation SquareButtonView |
24 @implementation SquareButtonView |
25 @synthesize ownerDictionary, colorIndex, selectedColor, colorArray; |
25 @synthesize ownerDictionary, colorIndex, selectedColor, colorArray; |
26 |
26 |
27 -(id) initWithFrame:(CGRect)frame { |
27 - (id)initWithFrame:(CGRect)frame { |
28 if ((self = [super initWithFrame:frame])) { |
28 if ((self = [super initWithFrame:frame])) { |
29 self.colorIndex = 0; |
29 self.colorIndex = 0; |
30 self.selectedColor = 0; |
30 self.selectedColor = 0; |
31 |
31 |
32 self.colorArray = [HWUtils teamColors]; |
32 self.colorArray = [HWUtils teamColors]; |
44 [self addTarget:self action:@selector(nextColor) forControlEvents:UIControlEventTouchUpInside]; |
44 [self addTarget:self action:@selector(nextColor) forControlEvents:UIControlEventTouchUpInside]; |
45 } |
45 } |
46 return self; |
46 return self; |
47 } |
47 } |
48 |
48 |
49 -(void) nextColor { |
49 - (void)nextColor { |
50 self.colorIndex++; |
50 self.colorIndex++; |
51 |
51 |
52 if (self.colorIndex >= [self.colorArray count]) |
52 if (self.colorIndex >= [self.colorArray count]) |
53 self.colorIndex = 0; |
53 self.colorIndex = 0; |
54 |
54 |
56 [self.ownerDictionary setObject:colorNumber forKey:@"color"]; |
56 [self.ownerDictionary setObject:colorNumber forKey:@"color"]; |
57 NSUInteger color = [colorNumber unsignedIntValue]; |
57 NSUInteger color = [colorNumber unsignedIntValue]; |
58 [self selectColor:color]; |
58 [self selectColor:color]; |
59 } |
59 } |
60 |
60 |
61 -(void) selectColor:(NSUInteger) color { |
61 - (void)selectColor:(NSUInteger) color { |
62 if (color != self.selectedColor) { |
62 if (color != self.selectedColor) { |
63 self.selectedColor = color; |
63 self.selectedColor = color; |
64 self.colorIndex = [self.colorArray indexOfObject:[NSNumber numberWithUnsignedInteger:color]]; |
64 self.colorIndex = [self.colorArray indexOfObject:[NSNumber numberWithUnsignedInteger:color]]; |
65 |
65 |
66 self.backgroundColor = [UIColor colorWithRed:((color & 0x00FF0000) >> 16)/255.0f |
66 self.backgroundColor = [UIColor colorWithRed:((color & 0x00FF0000) >> 16)/255.0f |
68 blue: (color & 0x000000FF)/255.0f |
68 blue: (color & 0x000000FF)/255.0f |
69 alpha:1.0f]; |
69 alpha:1.0f]; |
70 } |
70 } |
71 } |
71 } |
72 |
72 |
73 -(void) dealloc { |
|
74 releaseAndNil(ownerDictionary); |
|
75 releaseAndNil(colorArray); |
|
76 [super dealloc]; |
|
77 } |
|
78 |
73 |
79 |
74 |
80 @end |
75 @end |