forked from darkfall/GKAchievementNotification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGKAchievementNotification.h
executable file
·201 lines (154 loc) · 6.34 KB
/
GKAchievementNotification.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//
// GKAchievementNotification.h
//
// Created by Benjamin Borowski on 9/30/10.
// Copyright 2010 Typeoneerror Studios. All rights reserved.
// $Id$
//
#import <UIKit/UIKit.h>
@class GKAchievementDescription;
@class GKAchievementNotification;
#define kGKAchievementAnimeTime 0.4f
#define kGKAchievementDisplayTime 1.75f
#define kGKAchievementDefaultiPhoneSize CGSizeMake(284.f, 52.f);
#define kGKAchievementDefaultiPadSize CGSizeMake(426.f, 52.f);
#define kGKAchievementDefaultBackground @"GKAchievementNotification.bundle/gk-notification.png"
/*
#define kGKAchievementDefaultSize CGRectMake(0.0f, 0.0f, 284.0f, 52.0f);
#define kGKAchievementFrameStart CGRectMake(18.0f, -53.0f, 284.0f, 52.0f);
#define kGKAchievementFrameEnd CGRectMake(18.0f, 10.0f, 284.0f, 52.0f);
#define kGKAchievementText1 CGRectMake(10.0, 6.0f, 264.0f, 22.0f);
#define kGKAchievementText2 CGRectMake(10.0, 20.0f, 264.0f, 22.0f);
#define kGKAchievementText1WLogo CGRectMake(45.0, 6.0f, 229.0f, 22.0f);
#define kGKAchievementText2WLogo CGRectMake(45.0, 20.0f, 229.0f, 22.0f);
*/
#pragma mark -
/**
* The handler delegate responds to hiding and showing
* of the game center notifications.
*/
@protocol GKAchievementHandlerDelegate <NSObject>
@optional
/**
* Called on delegate when notification is hidden.
* @param nofification The notification view that was hidden.
*/
- (void)didHideAchievementNotification:(GKAchievementNotification *)notification;
/**
* Called on delegate when notification is shown.
* @param nofification The notification view that was shown.
*/
- (void)didShowAchievementNotification:(GKAchievementNotification *)notification;
/**
* Called on delegate when notification is about to be hidden.
* @param nofification The notification view that will be hidden.
*/
- (void)willHideAchievementNotification:(GKAchievementNotification *)notification;
/**
* Called on delegate when notification is about to be shown.
* @param nofification The notification view that will be shown.
*/
- (void)willShowAchievementNotification:(GKAchievementNotification *)notification;
@end
#pragma mark -
/**
* The GKAchievementNotification is a view for showing the achievement earned.
*/
@interface GKAchievementNotification : UIView
{
GKAchievementDescription *_achievement; /**< Description of achievement earned. */
NSString *_message; /**< Optional custom achievement message. */
NSString *_title; /**< Optional custom achievement title. */
UIImageView *_background; /**< Stretchable background view. */
UIImageView *_logo; /**< Logo that is displayed on the left. */
UILabel *_textLabel; /**< Text label used to display achievement title. */
UILabel *_detailLabel; /**< Text label used to display achievement description. */
CGPoint _position; /* center, automatically changes according to device orientation, normally you don't need to change this */
CGSize _size; /* notification window size */
CGPoint _iconPosition; /* position of the icon */
CGSize _iconSize; /* size of the icon, default = 34 * 34 */
CGPoint _titlePosition; /* position of the title */
CGSize _titleSize; /* size of the title textbox, default = 229 * 22 */
CGPoint _descriptionPosition; /* position of the description */
CGSize _descriptionSize; /* size of the description box, default = 229 * 22 */
/*
background image
*/
UIImage* _backgroundImage;
/*
Strech coordinates of the background image,
default (8.0f, 0.0f);
*/
CGPoint _backgroundStretch;
id<GKAchievementHandlerDelegate> _handlerDelegate; /**< Reference to nofification handler. */
}
/** Description of achievement earned. */
@property (nonatomic, retain) GKAchievementDescription *achievement;
/** Optional custom achievement message. */
@property (nonatomic, retain) NSString *message;
/** Optional custom achievement title. */
@property (nonatomic, retain) NSString *title;
/** Stretchable background view. */
@property (nonatomic, retain) UIImageView *background;
/** Logo that is displayed on the left. */
@property (nonatomic, retain) UIImageView *logo;
/** Text label used to display achievement title. */
@property (nonatomic, retain) UILabel *textLabel;
/** Text label used to display achievement description. */
@property (nonatomic, retain) UILabel *detailLabel;
/** Reference to nofification handler. */
@property (nonatomic, retain) id<GKAchievementHandlerDelegate> handlerDelegate;
/* notification position, automatically adjusted according to device orientation(center horizontally) */
@property (nonatomic, readonly) CGPoint position;
/* notification view size, changing this will also cause @iconSize, @titleSize and @descriptionSize to be adjusted automatically */
@property (nonatomic, readonly) CGSize size;
@property (nonatomic, readwrite) CGSize iconSize;
@property (nonatomic, readwrite) CGSize titleSize;
@property (nonatomic, readwrite) CGPoint titlePosition;
@property (nonatomic, readwrite) CGSize descriptionSize;
@property (nonatomic, readwrite) CGPoint descriptionPosition;
/* position of the icon */
@property (nonatomic, readwrite) CGPoint iconPosition;
@property (nonatomic, readwrite) CGPoint backgroundStrech;
-(void) setBackgroundImage:(NSString *)imageName;
-(UIImage *) backgroundImage;
#pragma mark -
/**
* Create a notification with an achievement description.
* @param achievement Achievement description to notify user of earning.
* @return a GKAchievementNoficiation view.
*/
- (id)initWithAchievementDescription:(GKAchievementDescription *)achievement;
/**
* Create a notification with a custom title and description.
* @param title Title to display in notification.
* @param message Descriotion to display in notification.
* @return a GKAchievementNoficiation view.
*/
- (id)initWithTitle:(NSString *)title andMessage:(NSString *)message;
/**
* Show the notification.
*/
- (void)animateIn;
/**
* Hide the notificaiton.
*/
- (void)animateOut;
/**
* Change the logo that appears on the left.
* @param image The image to display.
*/
- (void)setImage:(UIImage *)image;
/**
* Set the position of the notification
*/
- (void)setPosition:(CGPoint)position;
/**
* Set the size of the notification view
*/
- (void)setSize:(CGSize)size;
/*
* Set the background image
*/
- (void)setBackgroundImage:(NSString*)background;
@end