-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObject.m
60 lines (45 loc) · 1.21 KB
/
Object.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
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// Object.m
// hiddenObjectTest
//
// Created by Jonathan Langens on 28/03/15.
// Copyright (c) 2015 Jonathan Langens. All rights reserved.
//
#import "Object.h"
@implementation Object
-(instancetype) initWithName:(NSString*)name
{
self = [super init];
self.name = name;
self.instances = [[NSMutableArray alloc] init];
self.selInstance = nil;
self.nameNL = nil;
self.contentMode = UIViewContentModeRedraw;
self.opaque = NO;
return self;
}
-(NSString*)getNameForLocale:(NSString *)locale
{
if([locale isEqualToString:@"NL"])return self.nameNL;
return self.name;
}
-(NSString*)nameNL
{
if(!_nameNL)
return self.name;
return _nameNL;
}
-(void)setSelectedInstance:(ObjectInstance*)instance
{
if(![self.instances containsObject:instance])
return;
self.selInstance = instance;
CGRect rect = CGRectMake(0, 0, instance.rect.size.width, instance.rect.size.height);
self.frame = instance.rect;
UIImageView *backgroundView =
[[UIImageView alloc] initWithImage:[UIImage imageNamed:instance.imageName]];
backgroundView.frame = rect;
[self addSubview:backgroundView];
[self setNeedsDisplay];
}
@end