summary refs log tree commit diff stats
path: root/libs/cocos2d/CCNotifications.h
blob: 8609801b08c12e0cc39e66b3adb580223d218d60 (plain) (blame)
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
/*
 * CCNotifications
 *
 * Copyright (c) 2010 ForzeField Studios S.L.
 * http://forzefield.com
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

#import <Foundation/Foundation.h>
#import "cocos2d.h"

#define KNOTIFICATIONMIN_SCALE 0.0001f

@interface ccNotificationData : NSObject
{
	NSString *title_;
	NSString *message_;
	id media_;
	int mediaType_;
	int tag_;
	BOOL animated_;
}
@property(nonatomic, retain) NSString *title;
@property(nonatomic, retain) NSString *message;
@property(nonatomic, retain) id media;
@property(nonatomic, readwrite, assign) int mediaType;
@property(nonatomic, readwrite, assign) int tag;
@property(nonatomic, readwrite, assign) BOOL animated;

@end

@protocol CCNotificationsDelegate <NSObject>
@optional
- (void) notification:(ccNotificationData*)notification newState:(char)state;
- (BOOL) touched:(int)tag;
- (void) notificationChangeState:(char)state tag:(int)tag DEPRECATED_ATTRIBUTE;
@end

@protocol CCNotificationDesignProtocol <NSObject>
- (void) setTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture;
@end

enum
{
	kCCNotificationStateHide,
	kCCNotificationStateAnimationOut,
	kCCNotificationStateShowing,
	kCCNotificationStateAnimationIn,
};

enum
{
	kCCNotificationPositionBottom,
	kCCNotificationPositionTop,
};

enum
{
	kCCNotificationAnimationMovement,
	kCCNotificationAnimationScale,
};

enum
{
	kCCNotificationMediaPath,
	kCCNotificationMediaTexture,
};

#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
@interface CCNotifications : NSObject <CCStandardTouchDelegate>
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
@interface CCNotifications : NSObject
#endif
{
	id <CCNotificationsDelegate>			delegate_;
	CCNode <CCNotificationDesignProtocol>	*template_;
	char									state_;
	char									position_;
	ccTime									showingTime_;
	ccTime									timeAnimationIn_;
	ccTime									timeAnimationOut_;
	char									typeAnimationIn_;
	char									typeAnimationOut_;
	
	//Caching
	CCArray									*cachedNotifications_;
	ccNotificationData						*currentNotification_;
	
	CCActionInterval						*animationIn_;
	CCActionInterval						*animationOut_;
}
@property(nonatomic, retain) id <CCNotificationsDelegate> delegate;
@property(nonatomic, retain) CCNode <CCNotificationDesignProtocol> *notificationDesign;
@property(nonatomic, retain) CCActionInterval *animationIn;
@property(nonatomic, retain) CCActionInterval *animationOut;
@property(nonatomic, retain) ccNotificationData *currentNotification;
@property(nonatomic, readwrite, assign) char position;
@property(nonatomic, readwrite, assign) ccTime showingTime;

+ (CCNotifications *) sharedManager;
+ (void) purgeSharedManager;
+ (id) systemWithTemplate:(CCNode <CCNotificationDesignProtocol> *)notifications;

- (id) initWithTemplate:(CCNode <CCNotificationDesignProtocol> *)templates;
- (void) setAnimationIn:(char)type time:(ccTime)time;
- (void) setAnimationOut:(char)type time:(ccTime)time;
- (void) setAnimation:(char)type time:(ccTime)time;
- (void) updateAnimations;

- (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate waitUntilDone:(BOOL)isCached;
- (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture tag:(int)tag animate:(BOOL)animate waitUntilDone:(BOOL)isCached;

- (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate;
- (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture tag:(int)tag animate:(BOOL)animate;

- (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image;
- (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture;

- (void) addSafelyWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate DEPRECATED_ATTRIBUTE;


- (void) visit;
@end