MSClassHook(SBIconBadge)
MSClassHook(SBIconBadgeFactory)
MSClassHook(SBIconBadgeImage)
+MSClassHook(SBIconBadgeView)
+MSMetaClassHook(SBIconBadgeView)
MSClassHook(SBIconContentView)
MSClassHook(SBIconController)
MSClassHook(SBIconLabel)
Scale_ = 1;
}
- if (Scale_ == 1)
- return files;
-
NSString *idiom(IsWild_ ? @"ipad" : @"iphone");
NSMutableArray *scaled([NSMutableArray arrayWithCapacity:([files count] * 4)]);
// %hook -[NSBundle pathForResource:ofType:] {{{
MSInstanceMessageHook2(NSString *, NSBundle, pathForResource,ofType, NSString *, resource, NSString *, type) {
NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type];
+ if ([file isEqualToString:@"Info.plist"])
+ return MSOldCall(resource, type);
if (Debug_)
NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file);
if (NSString *path = $pathForFile$inBundle$(file, self, false, false))
extern "C" CGColorSpaceRef CGContextGetFillColorSpace(CGContextRef);
extern "C" void CGContextGetFillColor(CGContextRef, CGFloat[]);
-static NSString *WBColorMarkup() {
- CGContextRef context(UIGraphicsGetCurrentContext());
- //NSLog(@"XXX:1:%p", context);
- if (context == NULL)
- return @"";
-
- CGColorSpaceRef space(CGContextGetFillColorSpace(context));
- //NSLog(@"XXX:2:%p", space);
- if (space == NULL)
- return @"";
-
- size_t number(CGColorSpaceGetNumberOfComponents(space));
- //NSLog(@"XXX:3:%u", number);
- if (number == 0)
- return @"";
-
- CGFloat components[number + 1];
- CGContextGetFillColor(context, components);
-
+static NSString *WBColorMarkup(size_t number, const CGFloat *components) {
CGFloat r, g, b, a;
switch (number) {
return [NSString stringWithFormat:@"color: rgba(%g, %g, %g, %g)", r * 255, g * 255, b * 255, a];
}
+static NSString *WBColorMarkup() {
+ CGContextRef context(UIGraphicsGetCurrentContext());
+ //NSLog(@"XXX:1:%p", context);
+ if (context == NULL)
+ return @"";
+
+ CGColorSpaceRef space(CGContextGetFillColorSpace(context));
+ //NSLog(@"XXX:2:%p", space);
+ if (space == NULL)
+ return @"";
+
+ size_t number(CGColorSpaceGetNumberOfComponents(space));
+ //NSLog(@"XXX:3:%u", number);
+ if (number == 0)
+ return @"";
+
+ CGFloat components[number + 1];
+ CGContextGetFillColor(context, components);
+ return WBColorMarkup(number, components);
+}
+
+static NSString *WBColorMarkup(UIColor *uicolor) {
+ if (uicolor == nil)
+ return @"";
+ CGColorRef cgcolor([uicolor CGColor]);
+ if (cgcolor == NULL)
+ return @"";
+
+ CGColorSpaceRef space(CGColorGetColorSpace(cgcolor));
+ //NSLog(@"XXX:2:%p", space);
+ if (space == NULL)
+ return @"";
+
+ size_t number(CGColorGetNumberOfComponents(cgcolor));
+ //NSLog(@"XXX:3:%u", number);
+ if (number == 0)
+ return @"";
+
+ const CGFloat *components(CGColorGetComponents(cgcolor));
+ return WBColorMarkup(number, components);
+}
+
extern "C" NSString *NSStringFromCGPoint(CGPoint rect);
MSInstanceMessage6(CGSize, NSString, drawAtPoint,forWidth,withFont,lineBreakMode,letterSpacing,includeEmoji, CGPoint, point, CGFloat, width, UIFont *, font, UILineBreakMode, mode, CGFloat, spacing, BOOL, emoji) {
return CGSizeZero;
}
-MSInstanceMessageHook4(CGSize, NSString, sizeWithFont,forWidth,lineBreakMode,letterSpacing, UIFont *, font, float, width, UILineBreakMode, mode, float, spacing) {
+MSInstanceMessage2(void, NSString, drawInRect,withAttributes, CGRect, rect, NSDictionary *, attributes) {
+ //NSLog(@"XXX: *\"%@\" %@", self, attributes);
+
+ WBStringDrawingState *state(stringDrawingState_);
+ if (state == NULL)
+ return MSOldCall(rect, attributes);
+
+ if (state->count_ != 0 && --state->count_ == 0)
+ stringDrawingState_ = state->next_;
+ if (state->info_ == nil)
+ return MSOldCall(rect, attributes);
+
+ NSString *info([Info_ objectForKey:state->info_]);
+ if (info == nil)
+ return MSOldCall(rect, attributes);
+
+ NSString *base(state->base_ ?: @"");
+
+ UIFont *font([attributes objectForKey:@"NSFont"]);
+ UIColor *color([attributes objectForKey:@"NSColor"]);
+
+ [self drawInRect:rect withStyle:[NSString stringWithFormat:@"%@;%@;%@;%@", [font markupDescription], WBColorMarkup(color), base, info]];
+}
+
+extern "C" NSString *NSStringFromCGSize(CGSize size);
+
+MSInstanceMessage4(CGRect, NSString, boundingRectWithSize,options,attributes,context, CGSize, size, NSInteger, options, NSDictionary *, attributes, id, context) {
+ //NSLog(@"XXX: $\"%@\" %@ 0x%x %@ %@", self, NSStringFromCGSize(size), unsigned(options), attributes, context);
+
+ WBStringDrawingState *state(stringDrawingState_);
+ if (state == NULL)
+ return MSOldCall(size, options, attributes, context);
+
+ if (state->count_ != 0 && --state->count_ == 0)
+ stringDrawingState_ = state->next_;
+ if (state->info_ == nil)
+ return MSOldCall(size, options, attributes, context);
+
+ NSString *info([Info_ objectForKey:state->info_]);
+ if (info == nil)
+ return MSOldCall(size, options, attributes, context);
+
+ NSString *base(state->base_ ?: @"");
+
+ UIFont *font([attributes objectForKey:@"NSFont"]);
+ UIColor *color([attributes objectForKey:@"NSColor"]);
+
+ return (CGRect) {{0, 0}, [self sizeWithStyle:[NSString stringWithFormat:@"%@;%@;%@;%@", [font markupDescription], WBColorMarkup(color), base, info] forWidth:size.width]};
+}
+
+MSInstanceMessage4(CGSize, NSString, sizeWithFont,forWidth,lineBreakMode,letterSpacing, UIFont *, font, CGFloat, width, UILineBreakMode, mode, CGFloat, spacing) {
//NSLog(@"XXX: #\"%@\" \"%@\" %g %u %g", self, font, width, mode, spacing);
WBStringDrawingState *state(stringDrawingState_);
return [self sizeWithStyle:[NSString stringWithFormat:@"%@;%@;%@;%@;%@", [font markupDescription], WBColorMarkup(), extra, base, info] forWidth:width];
}
-MSInstanceMessageHook1(CGSize, NSString, sizeWithFont, UIFont *, font) {
+MSInstanceMessage1(CGSize, NSString, sizeWithFont, UIFont *, font) {
//NSLog(@"XXX: ?\"%@\"", self);
WBStringDrawingState *state(stringDrawingState_);
return [self sizeWithStyle:[NSString stringWithFormat:@"%@;%@;%@;%@", [font markupDescription], WBColorMarkup(), base, info] forWidth:65535];
}
+MSClassMessageHook2(id, SBIconBadgeView, checkoutAccessoryImagesForIcon,location, id, icon, int, location) {
+ WBStringDrawingState badgeState = {NULL, 0, @""
+ , @"BadgeStyle"};
+
+ stringDrawingState_ = &badgeState;
+
+ id images(MSOldCall(icon, location));
+
+ stringDrawingState_ = NULL;
+ return images;
+}
+
MSClassMessageHook2(UIImage *, SBIconAccessoryImage, checkoutAccessoryImageForIcon,location, id, icon, int, location) {
if ([self _imageClassForIcon:icon location:location] != $SBIconBadgeImage)
return MSOldCall(icon, location);
"text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px;"
, @"CalendarIconDayStyle"};
- WBStringDrawingState wtfState = {&dayState, 1, nil, nil};
-
- WBStringDrawingState sizeState = {
- kCFCoreFoundationVersionNumber > 800 ? &wtfState : &dayState
- , 7, nil, nil};
+ WBStringDrawingState skipState = {&dayState,
+ unsigned(kCFCoreFoundationVersionNumber > 800 ? 16 : 7)
+ , nil, nil};
- WBStringDrawingState dateState = {&sizeState, 2, @""
+ WBStringDrawingState dateState = {&skipState, 2, @""
, @"CalendarIconDateStyle"};
stringDrawingState_ = &dateState;
/* }}} */
// IconAlpha {{{
-MSInstanceMessageHook1(void, SBIcon, setIconImageAlpha, float, alpha) {
+MSInstanceMessageHook1(void, SBIcon, setIconImageAlpha, CGFloat, alpha) {
if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
alpha = [number floatValue];
return MSOldCall(alpha);
}
-MSInstanceMessageHook1(void, SBIcon, setIconLabelAlpha, float, alpha) {
+MSInstanceMessageHook1(void, SBIcon, setIconLabelAlpha, CGFloat, alpha) {
if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
alpha = [number floatValue];
return MSOldCall(alpha);
} return self;
}
-MSInstanceMessageHook1(void, SBIcon, setAlpha, float, alpha) {
+MSInstanceMessageHook1(void, SBIcon, setAlpha, CGFloat, alpha) {
if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"])
alpha = [number floatValue];
return MSOldCall(alpha);
if (SummerBoard_)
English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
+
+ if (kCFCoreFoundationVersionNumber >= 800) {
+ WBRename(NSString, drawInRect:withAttributes:, drawInRect$withAttributes$);
+ WBRename(NSString, boundingRectWithSize:options:attributes:context:, boundingRectWithSize$options$attributes$context$);
+ }
}
/*MSHook(int, open, const char *path, int oflag, mode_t mode) {
if (![@"" respondsToSelector:includeEmoji])
includeEmoji = @selector(drawAtPoint:forWidth:withFont:lineBreakMode:letterSpacing:includeEmoji:);
MSHookMessage($NSString, includeEmoji, MSHake(NSString$drawAtPoint$forWidth$withFont$lineBreakMode$letterSpacing$includeEmoji$));
+
+ SEL letterSpacing(@selector(_legacy_sizeWithFont:forWidth:lineBreakMode:letterSpacing:));
+ if (![@"" respondsToSelector:letterSpacing])
+ letterSpacing = @selector(sizeWithFont:forWidth:lineBreakMode:letterSpacing:);
+ MSHookMessage($NSString, letterSpacing, MSHake(NSString$sizeWithFont$forWidth$lineBreakMode$letterSpacing$));
+
+ SEL sizeWithFont(@selector(_legacy_sizeWithFont:));
+ if (![@"" respondsToSelector:sizeWithFont])
+ sizeWithFont = @selector(sizeWithFont:);
+ MSHookMessage($NSString, sizeWithFont, MSHake(NSString$sizeWithFont$));
}
// }}}