/
GameID.m
47 lines (38 loc) · 1.01 KB
/
GameID.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#import "GameID.h"
@interface GameID ()
@end
@implementation GameID
+(instancetype)gameIDFromRepresentation:(NSDictionary *)dict
{
GameID *gameID = [[GameID alloc] init];
gameID.title = dict[@"title"];
gameID.identifier = dict[@"identifier"];
gameID.engine = dict[@"engine"];
return gameID;
}
-(NSDictionary *)representation
{
return @{
@"title": self.title,
@"identifier": self.identifier,
@"engine": self.engine
};
}
-(NSString *)fullTitle
{
return [NSString stringWithFormat:@"%@ (%@)", self.title, self.identifier];
}
-(NSURL *)iconURL
{
return [NSURL URLWithString:[NSString stringWithFormat:@"https://github.com/scummvm/scummvm-icons/raw/master/icons/%@-%@.png", self.engine, self.identifier]];
}
-(NSURL *)fallbackIconURL
{
return [NSURL URLWithString:[NSString stringWithFormat:@"https://github.com/scummvm/scummvm-icons/raw/master/icons/%@.png", self.engine]];
}
-(NSString *)defaultBoxName
{
//TODO: sanitize?
return [self.title stringByReplacingOccurrencesOfString:@":" withString:@","];
}
@end