X-Git-Url: https://git.saurik.com/winterboard.git/blobdiff_plain/bcb4613200b76180dd6a7e9c7b111f3f66bfe011..895006e2139cda492033879692323b4b329b9271:/Library.mm diff --git a/Library.mm b/Library.mm index 42c4309..505851f 100644 --- a/Library.mm +++ b/Library.mm @@ -123,6 +123,7 @@ MSClassHook(UIToolbar) MSClassHook(CKMessageCell) MSClassHook(CKTimestampView) +MSClassHook(CKTranscriptCell) MSClassHook(CKTranscriptController) MSClassHook(CKTranscriptTableView) @@ -192,6 +193,7 @@ static BOOL (*_GSFontGetUseLegacyFontMetrics)(); (_GSFontGetUseLegacyFontMetrics == NULL ? YES : _GSFontGetUseLegacyFontMetrics()) static bool Debug_ = false; +static bool UIDebug_ = false; static bool Engineer_ = false; static bool SummerBoard_ = true; static bool SpringBoard_; @@ -235,9 +237,6 @@ static unsigned $getScale$(NSString *path) { } static NSArray *$useScale$(NSArray *files, bool use = true) { - if (!use) - return files; - if (Scale_ == 0) { UIScreen *screen([UIScreen mainScreen]); if ([screen respondsToSelector:@selector(scale)]) @@ -252,7 +251,10 @@ static NSArray *$useScale$(NSArray *files, bool use = true) { NSMutableArray *scaled([NSMutableArray arrayWithCapacity:([files count] * 2)]); for (NSString *file in files) { - [scaled addObject:[NSString stringWithFormat:@"%@@2x.%@", [file stringByDeletingPathExtension], [file pathExtension]]]; + if (use && Scale_ == 2) + [scaled addObject:[NSString stringWithFormat:@"%@@2x.%@", [file stringByDeletingPathExtension], [file pathExtension]]]; + if ([file hasSuffix:@"@2x~iphone.png"]) + [scaled addObject:[[file substringWithRange:NSMakeRange(0, [file length] - 11)] stringByAppendingPathExtension:@"png"]]; [scaled addObject:file]; } @@ -630,45 +632,37 @@ MSInstanceMessageHook2(NSString *, NSBundle, pathForResource,ofType, NSString *, static struct WBStringDrawingState { WBStringDrawingState *next_; - NSString *extra_; - NSString *key_; + NSString *base_; + NSString *info_; } *stringDrawingState_; MSInstanceMessageHook4(CGSize, NSString, drawAtPoint,forWidth,withFont,lineBreakMode, CGPoint, point, float, width, UIFont *, font, int, mode) { - if (stringDrawingState_ == NULL) + if (stringDrawingState_ == NULL || stringDrawingState_->info_ == nil) return MSOldCall(point, width, font, mode); - NSString *style([[font markupDescription] stringByAppendingString:@";"]); - - if (NSString *extra = stringDrawingState_->extra_) - style = [style stringByAppendingString:extra]; - - if (stringDrawingState_->key_ != nil) - if (NSString *extra = [Info_ objectForKey:stringDrawingState_->key_]) - style = [style stringByAppendingString:extra]; + NSString *info([Info_ objectForKey:stringDrawingState_->info_]); + if (info == nil) + return MSOldCall(point, width, font, mode); + NSString *base(stringDrawingState_->base_ ?: @""); stringDrawingState_ = stringDrawingState_->next_; - [self drawAtPoint:point withStyle:style]; + [self drawAtPoint:point withStyle:[NSString stringWithFormat:@"%@;%@;%@", [font markupDescription], base, info]]; return CGSizeZero; } MSInstanceMessageHook2(CGSize, NSString, drawAtPoint,withFont, CGPoint, point, UIFont *, font) { - if (stringDrawingState_ == NULL) + if (stringDrawingState_ == NULL || stringDrawingState_->info_ == nil) return MSOldCall(point, font); - NSString *style([[font markupDescription] stringByAppendingString:@";"]); - - if (NSString *extra = stringDrawingState_->extra_) - style = [style stringByAppendingString:extra]; - - if (stringDrawingState_->key_ != nil) - if (NSString *extra = [Info_ objectForKey:stringDrawingState_->key_]) - style = [style stringByAppendingString:extra]; + NSString *info([Info_ objectForKey:stringDrawingState_->info_]); + if (info == nil) + return MSOldCall(point, font); + NSString *base(stringDrawingState_->base_ ?: @""); stringDrawingState_ = stringDrawingState_->next_; - [self drawAtPoint:point withStyle:style]; + [self drawAtPoint:point withStyle:[NSString stringWithFormat:@"%@;%@;%@", [font markupDescription], base, info]]; return CGSizeZero; } @@ -688,6 +682,7 @@ MSInstanceMessageHook1(UIImage *, SBIconBadgeFactory, checkoutBadgeImageForText, MSInstanceMessageHook1(UIImage *, SBCalendarApplicationIcon, generateIconImage, int, type) { WBStringDrawingState dayState = {NULL, @"" "color: white;" + // XXX: this is only correct on an iPod dock "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px;" , @"CalendarIconDayStyle"}; @@ -1423,7 +1418,7 @@ MSInstanceMessageHook1(void, SBIconLabel, drawRect, CGRect, rect) { style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "]; bool ellipsis(false); - float max = 75, width; + float max = [self frame].size.width - 11, width; width: width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width; @@ -1456,6 +1451,17 @@ MSInstanceMessageHook1(void, CKMessageCell, addBalloonView, CKBalloonView *, bal [balloon setBackgroundColor:[UIColor clearColor]]; } +MSInstanceMessageHook1(void, CKTranscriptCell, setBackgroundColor, UIColor *, color) { + MSOldCall([UIColor clearColor]); +} + +MSInstanceMessageHook2(id, CKTranscriptCell, initWithStyle,reuseIdentifier, int, style, NSString *, reuse) { + if ((self = MSOldCall(style, reuse)) != nil) { + [self setBackgroundColor:[UIColor clearColor]]; + [[self contentView] setBackgroundColor:[UIColor clearColor]]; + } return self; +} + MSInstanceMessageHook2(id, CKMessageCell, initWithStyle,reuseIdentifier, int, style, NSString *, reuse) { if ((self = MSOldCall(style, reuse)) != nil) { [self setBackgroundColor:[UIColor clearColor]]; @@ -1541,7 +1547,18 @@ MSHook(UIImage *, _UIImageWithName, NSString *name) { if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) image = $getImage$(path); [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast(image)) forKey:key]; - return image == nil ? __UIImageWithName(name) : image; + if (image != nil) + return image; + + image = __UIImageWithName(name); + + if (UIDebug_) { + NSString *path([@"/tmp/UIImages/" stringByAppendingString:name]); + if (![Manager_ fileExistsAtPath:path]) + [UIImagePNGRepresentation(image) writeToFile:path atomically:YES]; + } + + return image; } } // }}} @@ -1850,5 +1867,8 @@ MSInitialize { } // }}} + if (Debug_ && [Manager_ fileExistsAtPath:@"/tmp/UIImages"]) + UIDebug_ = true; + [pool release]; }