static unsigned Scale_ = 0;
+static unsigned $getScale$(NSString *path) {
+ NSString *name(path);
+
+ #define StripName(strip) \
+ if ([name hasSuffix:@ strip]) \
+ name = [name substringWithRange:NSMakeRange(0, [name length] - sizeof(strip) - 1)];
+
+ StripName(".png");
+ StripName(".jpg");
+ StripName("~iphone");
+ StripName("~ipad");
+
+ return [name hasSuffix:@"@2x"] ? 2 : 1;
+}
+
static NSString *$getTheme$(NSArray *files, bool rescale = false) {
if (NSString *path = [Themed_ objectForKey:files])
return reinterpret_cast<id>(path) == [NSNull null] ? nil : path;
for (NSString *theme in Themes_)
for (NSString *file in files) {
+ if (rescale && /*$getScale$(file) == 1 &&*/ Scale_ == 2) {
+ path = [NSString stringWithFormat:@"%@/%@@2x.%@", theme, [file stringByDeletingPathExtension], [file pathExtension]];
+ if ([Manager_ fileExistsAtPath:path])
+ goto set;
+ }
+
path = [NSString stringWithFormat:@"%@/%@", theme, file];
if ([Manager_ fileExistsAtPath:path])
goto set;
@implementation NSString (WinterBoard)
- (NSString *) wb$themedPath {
+ if ([self hasPrefix:@"/Library/Themes/"])
+ return self;
+
if (Debug_)
NSLog(@"WB:Debug:Bypass(\"%@\")", self);
} while (false)
static UIImage *$getImage$(NSString *path) {
- NSString *name(path);
-
- #define StripName(strip) \
- if ([name hasSuffix:@ strip]) \
- name = [name substringWithRange:NSMakeRange(0, [name length] - sizeof(strip) - 1)];
-
- StripName(".png");
- StripName(".jpg");
- StripName("~iphone");
- StripName("~ipad");
-
- unsigned scale([name hasSuffix:@"@2x"] ? 2 : 1);
-
UIImage *image([UIImage imageWithContentsOfFile:path]);
+ unsigned scale($getScale$(path));
if (scale != 1 && [image respondsToSelector:@selector(setScale)])
[image setScale:scale];