]> git.saurik.com Git - winterboard.git/commitdiff
Released font hooking and stuff.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 3 Jan 2009 20:24:50 +0000 (20:24 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 3 Jan 2009 20:24:50 +0000 (20:24 +0000)
Library.mm
Saurik.theme/Info.plist
control
makefile

index 6015fd80dc0bdab9ba23a4afe71aaa27d1f3bfc9..dccc2194f31db39ffc75287cf75d5da7af7663fa 100644 (file)
 #import <Foundation/Foundation.h>
 #import <CoreGraphics/CoreGraphics.h>
 
+#import <Celestial/AVController.h>
+#import <Celestial/AVItem.h>
+#import <Celestial/AVQueue.h>
+
 #include <substrate.h>
 
 #import <UIKit/UIKit.h>
@@ -65,6 +69,7 @@
 
 #import <MobileSMS/mSMSMessageTranscriptController.h>
 
+#import <MediaPlayer/MPMoviePlayerController.h>
 #import <MediaPlayer/MPVideoView.h>
 #import <MediaPlayer/MPVideoView-PlaybackControl.h>
 
@@ -76,6 +81,7 @@ extern "C" void __clear_cache (char *beg, char *end);
 - (void *) _node;
 @end
 
+Class $MPMoviePlayerController;
 Class $MPVideoView;
 Class $WebCoreFrameBridge;
 
@@ -335,9 +341,11 @@ MSHook(UIImage *, SBApplicationIcon$icon, SBApplicationIcon *self, SEL sel) {
 }
 
 MSHook(UIImage *, SBWidgetApplicationIcon$icon, SBWidgetApplicationIcon *self, SEL sel) {
-    if (NSString *path = $pathForIcon$([self application]))
+    if (Debug_)
+        NSLog(@"WB:Debug:Widget(%@:%@)", [self displayIdentifier], [self displayName]);
+    if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Icons/%@.png", [self displayName]]]))
         return [UIImage imageWithContentsOfFile:path];
-    return _SBApplicationIcon$icon(self, sel);
+    return _SBWidgetApplicationIcon$icon(self, sel);
 }
 
 MSHook(UIImage *, SBBookmarkIcon$icon, SBBookmarkIcon *self, SEL sel) {
@@ -579,12 +587,38 @@ MSHook(id, SBContentLayer$initWithSize$, SBContentLayer *self, SEL sel, CGSize s
     if (NSString *theme = $getTheme$(Wallpapers_, true)) {
         NSString *mp4 = [theme stringByAppendingPathComponent:@"Wallpaper.mp4"];
         if ([Manager_ fileExistsAtPath:mp4]) {
+#if UseAVController
+            NSError *error;
+
+            static AVController *controller_(nil);
+            if (controller_ == nil) {
+                AVQueue *queue([AVQueue avQueue]);
+                controller_ = [[AVController avControllerWithQueue:queue error:&error] retain];
+            }
+
+            AVQueue *queue([controller_ queue]);
+
+            UIView *video([[[UIView alloc] initWithFrame:[self bounds]] autorelease]);
+            [controller_ setLayer:[video _layer]];
+
+            AVItem *item([[[AVItem alloc] initWithPath:mp4 error:&error] autorelease]);
+            [queue appendItem:item error:&error];
+
+            [controller_ play:&error];
+#elif UseMPMoviePlayerController
+            NSURL *url([NSURL fileURLWithPath:mp4]);
+            MPMoviePlayerController *controller = [[MPMoviePlayerController alloc] initWithContentURL:url];
+           controller.movieControlMode = MPMovieControlModeHidden;
+           [controller play];
+#else
             MPVideoView *video = [[[$MPVideoView alloc] initWithFrame:[self bounds]] autorelease];
             [video setMovieWithPath:mp4];
             [video setRepeatMode:1];
-            [video setRepeatGap:0];
-            [self addSubview:video];
+            [video setRepeatGap:-1];
             [video playFromBeginning];;
+#endif
+
+            [self addSubview:video];
         }
 
         NSString *png = [theme stringByAppendingPathComponent:@"Wallpaper.png"];
@@ -897,9 +931,28 @@ MSHook(void, SBIconLabel$drawRect$, SBIconLabel *self, SEL sel, CGRect rect) {
 
     if (docked)
         style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
-    float max = 75, width = [label sizeWithStyle:style forWidth:320].width;
-    if (width > max)
-        style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", ((width - max) / ([label length] - 1))]];
+
+    bool ellipsis(false);
+    float max = 75, width;
+  width:
+    width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
+
+    if (width > max) {
+        size_t length([label length]);
+        float spacing((width - max) / (length - 1));
+
+        if (spacing > 1.25) {
+            ellipsis = true;
+            label = [label substringToIndex:(length - 1)];
+            goto width;
+        }
+
+        style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", spacing]];
+    }
+
+    if (ellipsis)
+        label = [label stringByAppendingString:@"..."];
+
     if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")])
         style = [style stringByAppendingString:custom];
 
@@ -963,6 +1016,12 @@ MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
     return image;
 }
 
+MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
+    if (NSString *font = [Info_ objectForKey:[NSString stringWithFormat:@"FontName-%s", name]])
+        name = [font UTF8String];
+    return _GSFontCreateWithName(name, traits, size);
+}
+
 #define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
 #define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
 
@@ -1052,6 +1111,8 @@ extern "C" void WBInitialize() {
     MSHookFunction(_UIImageWithName, &$_UIImageWithName, &__UIImageWithName);
     MSHookFunction(_UIImageWithNameInDomain, &$_UIImageWithNameInDomain, &__UIImageWithNameInDomain);
 
+    MSHookFunction(&GSFontCreateWithName, &$GSFontCreateWithName, &_GSFontCreateWithName);
+
     if (dlopen(AudioToolbox, RTLD_LAZY | RTLD_NOLOAD) != NULL) {
         struct nlist nl[2];
         memset(nl, 0, sizeof(nl));
@@ -1150,6 +1211,7 @@ extern "C" void WBInitialize() {
         if (MediaPlayer != nil)
             [MediaPlayer load];
 
+        $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
         $MPVideoView = objc_getClass("MPVideoView");
         $WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");
 
index 431521767d9e4c78240c38f402a3341c4a16777d..a62553c1aff07b251707d5251eec627868b5f837 100644 (file)
@@ -2,6 +2,9 @@
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0"><dict>
 
+<key>FontName-Helvetica</key>
+<string>Courier New</string>
+
 <key>UndockedIconLabelStyle</key>
 <string>/*font-family: monospace; font-size: 13px;*/ color: white</string>
 
diff --git a/control b/control
index 92c207bb3296dd17cdd8184974e3fc85317802d8..dc08c5dd3a7d54b5ea316cbc8ed6596fe9663120 100644 (file)
--- a/control
+++ b/control
@@ -3,7 +3,7 @@ Priority: optional
 Section: System
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.2691-1
+Version: 0.9.2692-1
 Description: more powerful, open-source SummerBoard
 Name: WinterBoard
 Depends: mobilesubstrate (>= 0.9.2660-1)
index ed1c9b9551fd0407181e6d023f9245e7d4fe8827..b23bf2cb4bf420d852323eb5492edf1a2b66f4d9 100644 (file)
--- a/makefile
+++ b/makefile
@@ -10,7 +10,7 @@ clean:
        rm -f WinterBoard WinterBoard.dylib UIImages
 
 WinterBoard.dylib: Library.mm makefile ../mobilesubstrate/substrate.h
-       $(target)g++ -dynamiclib -g0 -O2 -Wall -o $@ $(filter %.mm,$^) -framework CoreFoundation -framework Foundation -lobjc -init _WBInitialize -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics -I../mobilesubstrate -L../mobilesubstrate -lsubstrate -framework UIKit -multiply_defined suppress
+       $(target)g++ -dynamiclib -g0 -O2 -Wall -o $@ $(filter %.mm,$^) -framework CoreFoundation -framework Foundation -lobjc -init _WBInitialize -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics -framework GraphicsServices -framework Celestial -I../mobilesubstrate -L../mobilesubstrate -lsubstrate -framework UIKit -multiply_defined suppress -F$(PKG_ROOT)/System/Library/PrivateFrameworks
 
 UIImages: UIImages.mm makefile
        $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc -I/apl/inc/iPhoneOS-2.0 -multiply_defined suppress