fix warnings (#17970)

This commit is contained in:
minggo 2017-06-23 17:46:37 +08:00 committed by GitHub
parent 0e26309602
commit 61839e7a5b
7 changed files with 123 additions and 113 deletions

View File

@ -146,13 +146,7 @@ typedef enum {
- Frameworks: OpenAL, AudioToolbox, AVFoundation - Frameworks: OpenAL, AudioToolbox, AVFoundation
@since v0.8 @since v0.8
*/ */
// AVAudioSessionDelegate not available on tvOS
#if defined(CC_TARGET_OS_TVOS)
@interface CDAudioManager : NSObject <CDLongAudioSourceDelegate, CDAudioInterruptProtocol> { @interface CDAudioManager : NSObject <CDLongAudioSourceDelegate, CDAudioInterruptProtocol> {
#else
@interface CDAudioManager : NSObject <CDLongAudioSourceDelegate, CDAudioInterruptProtocol, AVAudioSessionDelegate> {
#endif
CDSoundEngine *soundEngine; CDSoundEngine *soundEngine;
CDLongAudioSource *backgroundMusic; CDLongAudioSource *backgroundMusic;
NSMutableArray *audioSourceChannels; NSMutableArray *audioSourceChannels;

View File

@ -415,13 +415,11 @@ static BOOL configured = FALSE;
- (id) init: (tAudioManagerMode) mode { - (id) init: (tAudioManagerMode) mode {
if ((self = [super init])) { if ((self = [super init])) {
// 'delegate' not supported on tvOS [[NSNotificationCenter defaultCenter] addObserver: self
#if !defined(CC_TARGET_OS_TVOS) selector: NSSelectorFromString(@"handleInterruption")
//Initialise the audio session name: AVAudioSessionInterruptionNotification
AVAudioSession* session = [AVAudioSession sharedInstance]; object: [AVAudioSession sharedInstance]];
session.delegate = self;
#endif
_mode = mode; _mode = mode;
backgroundMusicCompletionSelector = nil; backgroundMusicCompletionSelector = nil;
@ -730,27 +728,31 @@ static BOOL configured = FALSE;
if (backgroundMusicCompletionSelector != nil) { if (backgroundMusicCompletionSelector != nil) {
[backgroundMusicCompletionListener performSelector:backgroundMusicCompletionSelector]; [backgroundMusicCompletionListener performSelector:backgroundMusicCompletionSelector];
} }
}
-(void) beginInterruption {
CDLOGINFO(@"Denshion::CDAudioManager - begin interruption");
[self audioSessionInterrupted];
} }
-(void) endInterruption { - (void) handleInterruption:(NSNotification*) notification {
CDLOGINFO(@"Denshion::CDAudioManager - end interruption"); if (notification.name != AVAudioSessionInterruptionNotification ||
[self audioSessionResumed]; notification.userInfo == nil)
return;
NSDictionary *interuptionDict = notification.userInfo;
NSInteger interuptionType = [[interuptionDict valueForKey:AVAudioSessionInterruptionTypeKey] integerValue];
// decide what to do based on interruption type here...
switch (interuptionType) {
case AVAudioSessionInterruptionTypeBegan:
[self audioSessionInterrupted];
break;
case AVAudioSessionInterruptionTypeEnded:
[self audioSessionResumed];
break;
default:
NSLog(@"Audio Session Interruption Notification case default.");
break;
}
} }
#if __CC_PLATFORM_IOS >= 40000
-(void) endInterruptionWithFlags:(NSUInteger)flags {
CDLOGINFO(@"Denshion::CDAudioManager - interruption ended with flags %i",flags);
if (flags == AVAudioSessionInterruptionFlags_ShouldResume) {
[self audioSessionResumed];
}
}
#endif
-(void)audioSessionInterrupted -(void)audioSessionInterrupted
{ {
if (!_interrupted) { if (!_interrupted) {

View File

@ -455,26 +455,26 @@ static bool parseBoolean(const std::string& value)
return (value.compare("true")==0); return (value.compare("true")==0);
} }
static int parseInt(const std::string& value) //static int parseInt(const std::string& value)
{ //{
// Android NDK 10 doesn't support std::stoi a/ std::stoul // // Android NDK 10 doesn't support std::stoi a/ std::stoul
#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID //#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
return std::stoi(value); // return std::stoi(value);
#else //#else
return atoi(value.c_str()); // return atoi(value.c_str());
#endif //#endif
} //}
//
static unsigned int parseUInt(const std::string& value) //static unsigned int parseUInt(const std::string& value)
{ //{
// Android NDK 10 doesn't support std::stoi a/ std::stoul // // Android NDK 10 doesn't support std::stoi a/ std::stoul
#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID //#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
return (unsigned int)std::stoul(value); // return (unsigned int)std::stoul(value);
#else //#else
return (unsigned int)atoi(value.c_str()); // return (unsigned int)atoi(value.c_str());
#endif //#endif
//
} //}
static RenderState::Blend parseBlend(const std::string& value) static RenderState::Blend parseBlend(const std::string& value)
{ {
@ -576,61 +576,61 @@ static RenderState::FrontFace parseFrontFace(const std::string& value)
} }
} }
static RenderState::StencilFunction parseStencilFunc(const std::string& value) //static RenderState::StencilFunction parseStencilFunc(const std::string& value)
{ //{
// Convert string to uppercase for comparison // // Convert string to uppercase for comparison
std::string upper(value); // std::string upper(value);
std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper); // std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper);
if (upper == "NEVER") // if (upper == "NEVER")
return RenderState::STENCIL_NEVER; // return RenderState::STENCIL_NEVER;
else if (upper == "LESS") // else if (upper == "LESS")
return RenderState::STENCIL_LESS; // return RenderState::STENCIL_LESS;
else if (upper == "EQUAL") // else if (upper == "EQUAL")
return RenderState::STENCIL_EQUAL; // return RenderState::STENCIL_EQUAL;
else if (upper == "LEQUAL") // else if (upper == "LEQUAL")
return RenderState::STENCIL_LEQUAL; // return RenderState::STENCIL_LEQUAL;
else if (upper == "GREATER") // else if (upper == "GREATER")
return RenderState::STENCIL_GREATER; // return RenderState::STENCIL_GREATER;
else if (upper == "NOTEQUAL") // else if (upper == "NOTEQUAL")
return RenderState::STENCIL_NOTEQUAL; // return RenderState::STENCIL_NOTEQUAL;
else if (upper == "GEQUAL") // else if (upper == "GEQUAL")
return RenderState::STENCIL_GEQUAL; // return RenderState::STENCIL_GEQUAL;
else if (upper == "ALWAYS") // else if (upper == "ALWAYS")
return RenderState::STENCIL_ALWAYS; // return RenderState::STENCIL_ALWAYS;
else // else
{ // {
CCLOG("Unsupported stencil function value (%s). Will default to STENCIL_ALWAYS if errors are treated as warnings)", value.c_str()); // CCLOG("Unsupported stencil function value (%s). Will default to STENCIL_ALWAYS if errors are treated as warnings)", value.c_str());
return RenderState::STENCIL_ALWAYS; // return RenderState::STENCIL_ALWAYS;
} // }
} //}
//
static RenderState::StencilOperation parseStencilOp(const std::string& value) //static RenderState::StencilOperation parseStencilOp(const std::string& value)
{ //{
// Convert string to uppercase for comparison // // Convert string to uppercase for comparison
std::string upper(value); // std::string upper(value);
std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper); // std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper);
if (upper == "KEEP") // if (upper == "KEEP")
return RenderState::STENCIL_OP_KEEP; // return RenderState::STENCIL_OP_KEEP;
else if (upper == "ZERO") // else if (upper == "ZERO")
return RenderState::STENCIL_OP_ZERO; // return RenderState::STENCIL_OP_ZERO;
else if (upper == "REPLACE") // else if (upper == "REPLACE")
return RenderState::STENCIL_OP_REPLACE; // return RenderState::STENCIL_OP_REPLACE;
else if (upper == "INCR") // else if (upper == "INCR")
return RenderState::STENCIL_OP_INCR; // return RenderState::STENCIL_OP_INCR;
else if (upper == "DECR") // else if (upper == "DECR")
return RenderState::STENCIL_OP_DECR; // return RenderState::STENCIL_OP_DECR;
else if (upper == "INVERT") // else if (upper == "INVERT")
return RenderState::STENCIL_OP_INVERT; // return RenderState::STENCIL_OP_INVERT;
else if (upper == "INCR_WRAP") // else if (upper == "INCR_WRAP")
return RenderState::STENCIL_OP_INCR_WRAP; // return RenderState::STENCIL_OP_INCR_WRAP;
else if (upper == "DECR_WRAP") // else if (upper == "DECR_WRAP")
return RenderState::STENCIL_OP_DECR_WRAP; // return RenderState::STENCIL_OP_DECR_WRAP;
else // else
{ // {
CCLOG("Unsupported stencil operation value (%s). Will default to STENCIL_OP_KEEP if errors are treated as warnings)", value.c_str()); // CCLOG("Unsupported stencil operation value (%s). Will default to STENCIL_OP_KEEP if errors are treated as warnings)", value.c_str());
return RenderState::STENCIL_OP_KEEP; // return RenderState::STENCIL_OP_KEEP;
} // }
} //}
void RenderState::StateBlock::setState(const std::string& name, const std::string& value) void RenderState::StateBlock::setState(const std::string& name, const std::string& value)
{ {

View File

@ -355,7 +355,19 @@ void EditBoxImplCommon::editBoxEditingDidEnd(const std::string& text, EditBoxDel
if (pDelegate != nullptr) if (pDelegate != nullptr)
{ {
pDelegate->editBoxEditingDidEndWithAction(_editBox, action); pDelegate->editBoxEditingDidEndWithAction(_editBox, action);
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (push)
#pragma warning (disable: 4996)
#endif
pDelegate->editBoxEditingDidEnd(_editBox); pDelegate->editBoxEditingDidEnd(_editBox);
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (pop)
#endif
pDelegate->editBoxReturn(_editBox); pDelegate->editBoxReturn(_editBox);
} }

View File

@ -53,6 +53,8 @@
- (void)setTextHorizontalAlignment:(cocos2d::TextHAlignment)alignment; - (void)setTextHorizontalAlignment:(cocos2d::TextHAlignment)alignment;
- (void)setPlaceHolder:(NSString *)text; - (void)setPlaceHolder:(NSString *)text;
- (void)setPlaceholderFont:(UIFont *)font;
- (void)setPlaceholderTextColor:(UIColor *)color;
- (void)setVisible:(BOOL)visible; - (void)setVisible:(BOOL)visible;
- (void)setTextColor:(UIColor*)color; - (void)setTextColor:(UIColor*)color;
- (void)setFont:(UIFont *)font; - (void)setFont:(UIFont *)font;

View File

@ -78,7 +78,7 @@
- (UIColor *)ccui_placeholderTextColor - (UIColor *)ccui_placeholderTextColor
{ {
SEL selector = @selector(placeholderTextColor); SEL selector = NSSelectorFromString(@"placeholderTextColor");
if ([self respondsToSelector:selector]) { if ([self respondsToSelector:selector]) {
return [self performSelector:selector]; return [self performSelector:selector];
} }
@ -87,7 +87,7 @@
- (void)ccui_setPlaceholderTextColor:(UIColor *)ccui_placeholderTextColor - (void)ccui_setPlaceholderTextColor:(UIColor *)ccui_placeholderTextColor
{ {
SEL selector = @selector(setPlaceholderTextColor:); SEL selector = NSSelectorFromString(@"placeholderTextColor");
if ([self respondsToSelector:selector]) { if ([self respondsToSelector:selector]) {
[self performSelector:selector withObject:ccui_placeholderTextColor]; [self performSelector:selector withObject:ccui_placeholderTextColor];
} }
@ -95,7 +95,7 @@
- (UIFont *)ccui_placeholderFont - (UIFont *)ccui_placeholderFont
{ {
SEL selector = @selector(placeholderFont); SEL selector = NSSelectorFromString(@"placeholderTextColor");
if ([self respondsToSelector:selector]) { if ([self respondsToSelector:selector]) {
return [self performSelector:selector]; return [self performSelector:selector];
} }
@ -104,7 +104,7 @@
- (void)ccui_setPlaceholderFont:(UIFont *)ccui_placeholderFont - (void)ccui_setPlaceholderFont:(UIFont *)ccui_placeholderFont
{ {
SEL selector = @selector(setPlaceholderFont:); SEL selector = NSSelectorFromString(@"placeholderTextColor");
if ([self respondsToSelector:selector]) { if ([self respondsToSelector:selector]) {
[self performSelector:selector withObject:ccui_placeholderFont]; [self performSelector:selector withObject:ccui_placeholderFont];
} }

View File

@ -86,7 +86,7 @@
- (UIColor *)ccui_placeholderTextColor - (UIColor *)ccui_placeholderTextColor
{ {
SEL selector = @selector(placeHolderLabel); SEL selector = NSSelectorFromString(@"placeHolderLabel");
if ([self respondsToSelector:selector]) { if ([self respondsToSelector:selector]) {
return ((UILabel *)[self performSelector:selector]).textColor; return ((UILabel *)[self performSelector:selector]).textColor;
} }
@ -95,7 +95,7 @@
- (void)ccui_setPlaceholderTextColor:(UIColor *)ccui_placeholderTextColor - (void)ccui_setPlaceholderTextColor:(UIColor *)ccui_placeholderTextColor
{ {
SEL selector = @selector(placeHolderLabel); SEL selector = NSSelectorFromString(@"placeHolderLabel");
if ([self respondsToSelector:selector]) { if ([self respondsToSelector:selector]) {
((UILabel *)[self performSelector:selector]).textColor = ccui_placeholderTextColor; ((UILabel *)[self performSelector:selector]).textColor = ccui_placeholderTextColor;
} }
@ -103,7 +103,7 @@
- (UIFont *)ccui_placeholderFont - (UIFont *)ccui_placeholderFont
{ {
SEL selector = @selector(placeHolderLabel); SEL selector = NSSelectorFromString(@"placeHolderLabel");
if ([self respondsToSelector:selector]) { if ([self respondsToSelector:selector]) {
return ((UILabel *)[self performSelector:selector]).font; return ((UILabel *)[self performSelector:selector]).font;
} }
@ -112,7 +112,7 @@
- (void)ccui_setPlaceholderFont:(UIFont *)ccui_placeholderFont - (void)ccui_setPlaceholderFont:(UIFont *)ccui_placeholderFont
{ {
SEL selector = @selector(placeHolderLabel); SEL selector = NSSelectorFromString(@"placeHolderLabel");
if ([self respondsToSelector:selector]) { if ([self respondsToSelector:selector]) {
((UILabel *)[self performSelector:selector]).font = ccui_placeholderFont; ((UILabel *)[self performSelector:selector]).font = ccui_placeholderFont;
} }