From bb8b9a374320fe390c97740ad03cbecba5bf5f10 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 4 Dec 2014 01:03:56 -0800 Subject: [PATCH] Always prioritize "native" scale images, even @1x. --- Library.mm | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Library.mm b/Library.mm index b902d4a..573a9dd 100644 --- a/Library.mm +++ b/Library.mm @@ -304,25 +304,23 @@ static NSArray *$useScale$(NSArray *files, bool use = true) { NSString *base([file stringByDeletingPathExtension]); NSString *extension([file pathExtension]); - if (use) { - if (Scale_ != 1) { - [scaled addObject:[NSString stringWithFormat:@"%@@%ux~%@.%@", base, Scale_, idiom, extension]]; - [scaled addObject:[NSString stringWithFormat:@"%@@%ux.%@", base, Scale_, extension]]; - } - - for (unsigned scale(3); scale >= 2; --scale) - if (scale != Scale_) { - [scaled addObject:[NSString stringWithFormat:@"%@@%ux~%@.%@", base, scale, idiom, extension]]; - [scaled addObject:[NSString stringWithFormat:@"%@@%ux.%@", base, scale, extension]]; - } +#define WBScaleImage(scale) \ + if (scale == 1) { \ + [scaled addObject:[NSString stringWithFormat:@"%@~%@.%@", base, idiom, extension]]; \ + [scaled addObject:file]; \ + } else { \ + [scaled addObject:[NSString stringWithFormat:@"%@@%ux~%@.%@", base, scale, idiom, extension]]; \ + [scaled addObject:[NSString stringWithFormat:@"%@@%ux.%@", base, scale, extension]]; \ + } - [scaled addObject:[NSString stringWithFormat:@"%@~%@.%@", base, idiom, extension]]; + if (use) { + WBScaleImage(Scale_); - // if (!IsWild_) <- support old themes - [scaled addObject:file]; + for (unsigned scale(3); scale >= 1; --scale) + if (scale != Scale_) + WBScaleImage(scale); } else if ([base hasSuffix: @"@2x"] || [base hasSuffix:@"@3x"]) { - [scaled addObject:[NSString stringWithFormat:@"%@~%@.%@", base, idiom, extension]]; - [scaled addObject:file]; + WBScaleImage(1); // XXX: this actually can't be used, as the person loading the file doesn't realize that the @2x changed /*NSString *rest([base substringWithRange:NSMakeRange(0, [base length] - 3)]); -- 2.45.2