50 -(void) setImageRounded:(UIImage *)image { |
50 -(void) setImageRounded:(UIImage *)image { |
51 [self setImageRounded:image forState:UIControlStateNormal]; |
51 [self setImageRounded:image forState:UIControlStateNormal]; |
52 } |
52 } |
53 |
53 |
54 #pragma mark - |
54 #pragma mark - |
55 #pragma mark preview |
55 #pragma mark preview |
56 -(int) sendToEngine:(NSString *)string { |
56 -(int) sendToEngine:(NSString *)string { |
57 unsigned char length = [string length]; |
57 unsigned char length = [string length]; |
58 |
58 |
59 SDLNet_TCP_Send(csd, &length, 1); |
59 SDLNet_TCP_Send(csd, &length, 1); |
60 return SDLNet_TCP_Send(csd, [string UTF8String], length); |
60 return SDLNet_TCP_Send(csd, [string UTF8String], length); |
155 withObject:nil |
155 withObject:nil |
156 waitUntilDone:NO]; |
156 waitUntilDone:NO]; |
157 [self performSelectorOnMainThread:@selector(removeIndicator) |
157 [self performSelectorOnMainThread:@selector(removeIndicator) |
158 withObject:nil |
158 withObject:nil |
159 waitUntilDone:NO]; |
159 waitUntilDone:NO]; |
160 |
160 |
161 [pool release]; |
161 [pool release]; |
162 } |
162 } |
163 |
163 |
164 -(void) updatePreviewWithSeed:(NSString *)seed { |
164 -(void) updatePreviewWithSeed:(NSString *)seed { |
165 // remove the current preview and title |
165 // remove the current preview and title |
166 [self setImage:nil forState:UIControlStateNormal]; |
166 [self setImage:nil forState:UIControlStateNormal]; |
167 [self setTitle:nil forState:UIControlStateNormal]; |
167 [self setTitle:nil forState:UIControlStateNormal]; |
168 |
168 |
169 // don't display preview on slower device, too slow and memory hog |
169 // don't display preview on slower device, too slow and memory hog |
170 if (IS_NOT_POWERFUL([HWUtils modelType])) { |
170 if (IS_NOT_POWERFUL([HWUtils modelType])) { |
171 [self setTitle:NSLocalizedString(@"Preview not available",@"") forState:UIControlStateNormal]; |
171 [self setTitle:NSLocalizedString(@"Preview not available",@"") forState:UIControlStateNormal]; |
172 [self turnOnWidgets]; |
172 [self turnOnWidgets]; |
173 } else { |
173 } else { |
174 // add a very nice spinning wheel |
174 // add a very nice spinning wheel |
175 UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] |
175 UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] |
176 initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
176 initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
177 indicator.center = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2); |
177 indicator.center = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2); |
178 indicator.tag = INDICATOR_TAG; |
178 indicator.tag = INDICATOR_TAG; |
179 [indicator startAnimating]; |
179 [indicator startAnimating]; |
180 [self addSubview:indicator]; |
180 [self addSubview:indicator]; |
181 [indicator release]; |
181 [indicator release]; |
182 |
182 |
183 // let's draw in a separate thread so the gui can work; at the end it restore other widgets |
183 // let's draw in a separate thread so the gui can work; at the end it restore other widgets |
184 [NSThread detachNewThreadSelector:@selector(drawingThread) toTarget:self withObject:nil]; |
184 [NSThread detachNewThreadSelector:@selector(drawingThread) toTarget:self withObject:nil]; |
185 } |
185 } |
186 } |
186 } |
187 |
187 |