Listing Icons now working. Nothing to select

This commit is contained in:
michael starke
2013-03-11 03:22:17 +01:00
parent 46636445a4
commit e573e461f1
7 changed files with 261 additions and 110 deletions

View File

@@ -11,7 +11,7 @@
@implementation MPIconHelper
+ (NSImage *)icon:(MPIconType)type {
NSDictionary *icons = [MPIconHelper availableIcons];
NSDictionary *icons = [MPIconHelper availableIconNames];
if(type >= [icons count]) {
return [NSImage imageNamed:NSImageNameActionTemplate];
}
@@ -19,7 +19,17 @@
return [[NSBundle mainBundle] imageForResource:imageName];
}
+ (NSDictionary *)availableIcons {
+ (NSArray *)availableIcons {
NSDictionary *imageNames = [MPIconHelper availableIconNames];
NSMutableArray *icons = [[NSMutableArray alloc] initWithCapacity:[imageNames count]];
for(NSNumber *iconNumber in [imageNames allKeys]) {
MPIconType iconType = (MPIconType)[iconNumber integerValue];
[icons addObject:[MPIconHelper icon:iconType]];
}
return icons;
}
+ (NSDictionary *)availableIconNames {
NSDictionary *imageNames = @{ @(MPIconKlipper): @"04_KlipperTemplate",
@(MPIconLanguages): @"05_LanguagesTemplate",
@(MPIconPackageNetwork): @"01_PackageNetworkTemplate",
@@ -41,7 +51,7 @@
srandom([[NSDate date] timeIntervalSince1970]);
});
NSArray *types = [[MPIconHelper availableIcons] allKeys];
NSArray *types = [[MPIconHelper availableIconNames] allKeys];
NSUInteger randomIndex = random() % [types count];
return [MPIconHelper icon:(MPIconType)randomIndex];
}