]> git.saurik.com Git - winterboard.git/blobdiff - Library.mm
Add new icons from Surenix.
[winterboard.git] / Library.mm
index 591373076e150dcea381b7c1b9d71d85b2a2633c..fd5a6d5b17e3bab0c2b67bd9d28779c2ab9148e8 100644 (file)
@@ -131,10 +131,12 @@ MSClassHook(SBApplicationIcon)
 MSClassHook(SBAwayView)
 MSClassHook(SBBookmarkIcon)
 MSClassHook(SBButtonBar)
+MSClassHook(SBCalendarApplicationIcon)
 MSClassHook(SBCalendarIconContentsView)
 MSClassHook(SBDockIconListView)
 MSClassHook(SBIcon)
 MSClassHook(SBIconBadge)
+MSClassHook(SBIconBadgeFactory)
 MSClassHook(SBIconController)
 MSClassHook(SBIconLabel)
 MSClassHook(SBIconList)
@@ -149,6 +151,8 @@ MSClassHook(SBStatusBarTimeView)
 MSClassHook(SBUIController)
 MSClassHook(SBWidgetApplicationIcon)
 
+extern "C" void WKSetCurrentGraphicsContext(CGContextRef);
+
 __attribute__((__constructor__))
 static void MSFixClass() {
     if ($SBIcon == nil)
@@ -624,6 +628,81 @@ MSInstanceMessageHook2(NSString *, NSBundle, pathForResource,ofType, NSString *,
 }
 // }}}
 
+static struct WBStringDrawingState {
+    WBStringDrawingState *next_;
+    NSString *extra_;
+    NSString *key_;
+} *stringDrawingState_;
+
+MSInstanceMessageHook4(CGSize, NSString, drawAtPoint,forWidth,withFont,lineBreakMode, CGPoint, point, float, width, UIFont *, font, int, mode) {
+    if (stringDrawingState_ == NULL)
+        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];
+
+    stringDrawingState_ = stringDrawingState_->next_;
+
+    [self drawAtPoint:point withStyle:style];
+    return CGSizeZero;
+}
+
+MSInstanceMessageHook2(CGSize, NSString, drawAtPoint,withFont, CGPoint, point, UIFont *, font) {
+    if (stringDrawingState_ == NULL)
+        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];
+
+    stringDrawingState_ = stringDrawingState_->next_;
+
+    [self drawAtPoint:point withStyle:style];
+    return CGSizeZero;
+}
+
+MSInstanceMessageHook1(UIImage *, SBIconBadgeFactory, checkoutBadgeImageForText, NSString *, text) {
+    WBStringDrawingState badgeState = {NULL, @""
+        "color: white;"
+    , @"BadgeStyle"};
+
+    stringDrawingState_ = &badgeState;
+
+    UIImage *image(MSOldCall(text));
+
+    stringDrawingState_ = NULL;
+    return image;
+}
+
+MSInstanceMessageHook1(UIImage *, SBCalendarApplicationIcon, generateIconImage, int, type) {
+    WBStringDrawingState dayState = {NULL, @""
+        "color: white;"
+        "text-shadow: rgba(0, 0, 0, 0.2) -1px -1px 2px;"
+    , @"CalendarIconDayStyle"};
+
+    WBStringDrawingState dateState = {&dayState, @""
+        "color: #333333;"
+    , @"CalendarIconDateStyle"};
+
+    stringDrawingState_ = &dateState;
+
+    UIImage *image(MSOldCall(type));
+
+    stringDrawingState_ = NULL;
+    return image;
+}
+
 MSHook(void, SBCalendarIconContentsView$drawRect$, SBCalendarIconContentsView *self, SEL sel, CGRect rect) {
     NSBundle *bundle([NSBundle mainBundle]);
 
@@ -891,7 +970,7 @@ MSInstanceMessageHook0(id, SBUIController, init) {
             [indirect addSubview:video];
         }
 
-        if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"Wallpaper@2x.png", @"Wallpaper@2x.jpg", @"Wallpaper.png", @"Wallpaper.jpg", nil], themes)) {
+        if (NSString *path = $getTheme$($useScale$([NSArray arrayWithObjects:@"Wallpaper.png", @"Wallpaper.jpg", nil]), themes)) {
             if (UIImage *image = $getImage$(path)) {
                 WallpaperFile_ = [path retain];
                 WallpaperImage_ = [[UIImageView alloc] initWithImage:image];
@@ -901,7 +980,7 @@ MSInstanceMessageHook0(id, SBUIController, init) {
             }
         }
 
-        if (NSString *path = $getTheme$([NSArray arrayWithObject:@"Wallpaper@.html"], themes)) {
+        if (NSString *path = $getTheme$([NSArray arrayWithObject:@"Wallpaper.html"], themes)) {
             CGRect bounds = [indirect bounds];
 
             UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
@@ -1579,8 +1658,6 @@ MSHook(void *, CGImageReadCreateWithFile, NSString *path, int flag) {
 }
 // }}}
 
-extern "C" void WKSetCurrentGraphicsContext(CGContextRef);
-
 static void NSString$drawAtPoint$withStyle$(NSString *self, SEL _cmd, CGPoint point, NSString *style) {
     WKSetCurrentGraphicsContext(UIGraphicsGetCurrentContext());
     if (style == nil || [style length] == 0)