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
@since v0.8
*/
// AVAudioSessionDelegate not available on tvOS
#if defined(CC_TARGET_OS_TVOS)
@interface CDAudioManager : NSObject <CDLongAudioSourceDelegate, CDAudioInterruptProtocol> {
#else
@interface CDAudioManager : NSObject <CDLongAudioSourceDelegate, CDAudioInterruptProtocol, AVAudioSessionDelegate> {
#endif
CDSoundEngine *soundEngine;
CDLongAudioSource *backgroundMusic;
NSMutableArray *audioSourceChannels;

View File

@ -415,13 +415,11 @@ static BOOL configured = FALSE;
- (id) init: (tAudioManagerMode) mode {
if ((self = [super init])) {
// 'delegate' not supported on tvOS
#if !defined(CC_TARGET_OS_TVOS)
//Initialise the audio session
AVAudioSession* session = [AVAudioSession sharedInstance];
session.delegate = self;
#endif
[[NSNotificationCenter defaultCenter] addObserver: self
selector: NSSelectorFromString(@"handleInterruption")
name: AVAudioSessionInterruptionNotification
object: [AVAudioSession sharedInstance]];
_mode = mode;
backgroundMusicCompletionSelector = nil;
@ -730,27 +728,31 @@ static BOOL configured = FALSE;
if (backgroundMusicCompletionSelector != nil) {
[backgroundMusicCompletionListener performSelector:backgroundMusicCompletionSelector];
}
}
-(void) beginInterruption {
CDLOGINFO(@"Denshion::CDAudioManager - begin interruption");
[self audioSessionInterrupted];
}
-(void) endInterruption {
CDLOGINFO(@"Denshion::CDAudioManager - end interruption");
[self audioSessionResumed];
- (void) handleInterruption:(NSNotification*) notification {
if (notification.name != AVAudioSessionInterruptionNotification ||
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
{
if (!_interrupted) {

View File

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

View File

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

View File

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

View File

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