X-Git-Url: https://git.saurik.com/winterboard.git/blobdiff_plain/e079e414fcad2c8b9e164698162e2e3f62d35f61..5b9ea3d9d7b8169038b52f9da80a8a910958f90e:/Library.mm?ds=sidebyside diff --git a/Library.mm b/Library.mm index bd88130..cd2e5d0 100644 --- a/Library.mm +++ b/Library.mm @@ -212,6 +212,21 @@ static NSMutableDictionary *Themed_ = [[NSMutableDictionary alloc] initWithCapac 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(path) == [NSNull null] ? nil : path; @@ -231,6 +246,12 @@ static NSString *$getTheme$(NSArray *files, bool rescale = false) { 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; @@ -362,6 +383,9 @@ static NSString *$pathForIcon$(SBApplication *self, NSString *suffix = @"") { @implementation NSString (WinterBoard) - (NSString *) wb$themedPath { + if ([self hasPrefix:@"/Library/Themes/"]) + return self; + if (Debug_) NSLog(@"WB:Debug:Bypass(\"%@\")", self); @@ -716,21 +740,9 @@ static NSURL *WallpaperURL_; } 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];