#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>
#import <MobileSMS/mSMSMessageTranscriptController.h>
+#import <MediaPlayer/MPMoviePlayerController.h>
#import <MediaPlayer/MPVideoView.h>
#import <MediaPlayer/MPVideoView-PlaybackControl.h>
- (void *) _node;
@end
+Class $MPMoviePlayerController;
Class $MPVideoView;
Class $WebCoreFrameBridge;
}
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) {
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"];
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];
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"
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));
if (MediaPlayer != nil)
[MediaPlayer load];
+ $MPMoviePlayerController = objc_getClass("MPMoviePlayerController");
$MPVideoView = objc_getClass("MPVideoView");
$WebCoreFrameBridge = objc_getClass("WebCoreFrameBridge");