@@ -421,6 +421,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
centerDebugView . backgroundColor = [ [ UIColor blueColor ] colorWithAlphaComponent : 0.3 ] ;
centerDebugView . frame = [ self getCenterZone ] ;
centerDebugView . userInteractionEnabled = NO ;
centerDebugView . tag = 999 ; // 设 置 debug 视 图 tag
[ self . bannerContainer addSubview : centerDebugView ] ;
// 左 侧 区 域 - 半 透 明 红 色
@@ -428,6 +429,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
leftDebugView . backgroundColor = [ [ UIColor redColor ] colorWithAlphaComponent : 0.3 ] ;
leftDebugView . frame = [ self getLeftZone ] ;
leftDebugView . userInteractionEnabled = NO ;
leftDebugView . tag = 999 ; // 设 置 debug 视 图 tag
[ self . bannerContainer addSubview : leftDebugView ] ;
// 右 侧 区 域 - 半 透 明 绿 色
@@ -435,6 +437,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
rightDebugView . backgroundColor = [ [ UIColor greenColor ] colorWithAlphaComponent : 0.3 ] ;
rightDebugView . frame = [ self getRightZone ] ;
rightDebugView . userInteractionEnabled = NO ;
rightDebugView . tag = 999 ; // 设 置 debug 视 图 tag
[ self . bannerContainer addSubview : rightDebugView ] ;
NSLog ( @ "🎨 区域调试视图已添加" ) ;
@@ -451,6 +454,24 @@ XPRoomGraffitiGiftAnimationViewDelegate
# endif
}
- ( void ) ensureDebugViewsExist {
# ifdef DEBUG
// 检 查 是 否 已 经 有 debug 视 图
BOOL hasDebugViews = NO ;
for ( UIView * subview in self . bannerContainer . subviews ) {
if ( subview . tag = = 999 ) {
hasDebugViews = YES ;
break ;
}
}
if ( ! hasDebugViews ) {
NSLog ( @ "🎨 重新添加debug视图" ) ;
[ self addZoneDebugViews ] ;
}
# endif
}
# pragma mark - UIGestureRecognizerDelegate
- ( BOOL ) gestureRecognizer : ( UIGestureRecognizer * ) gestureRecognizer shouldReceiveTouch : ( UITouch * ) touch {
@@ -814,7 +835,23 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
}
- ( void ) handleSwipeOutBanner {
NSLog ( @ "🚨 发送SwipeOutBanner通知 - 当前状态: isRoomBannerV2Displaying=%@" , self . isRoomBannerV2Displaying ? @ "YES" : @ "NO" ) ;
// 防 止 重 复 处 理
if ( ! self . isRoomBannerV2Displaying ) {
NSLog ( @ "🚨 警告: 尝试关闭banner但状态显示没有正在显示的banner" ) ;
return ;
}
// 立 即 设 置 状 态 为 NO , 防 止 重 复 处 理
self . isRoomBannerV2Displaying = NO ;
[ [ NSNotificationCenter defaultCenter ] postNotificationName : @ "SwipeOutBanner" object : nil ] ;
// 延 迟 处 理 下 一 个 banner , 确 保 当 前 banner 完 全 关 闭
dispatch_after ( dispatch_time ( DISPATCH_TIME _NOW , ( int64_t ) ( 0.3 * NSEC_PER _SEC ) ) , dispatch_get _main _queue ( ) , ^ {
[ self processNextRoomEffectAttachment ] ;
} ) ;
}
# pragma mark - Banner Interaction Management
@@ -1183,8 +1220,71 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
}
# pragma mark - Method : Banner
- ( void ) inserBannerModelToQueue : ( id ) obj {
- ( void ) inserBannerModelToQueue : ( AttachmentModel * ) obj {
// 参 数 验 证
if ( ! obj || ! [ obj isKindOfClass : [ AttachmentModel class ] ] ) {
NSLog ( @ "⚠️ 警告: inserBannerModelToQueue 接收到无效参数: %@" , obj ) ;
return ;
}
# ifdef DEBUG
// DEBUG 环 境 : 复 制 banner 数 据 用 于 测 试
BOOL enableBannerCopy = YES ; // 设 置 为 NO 可 以 禁 用 复 制 功 能
NSInteger copyCount = 10 ; // 可 以 调 整 这 个 数 字 来 改 变 复 制 数 量
if ( enableBannerCopy ) {
NSLog ( @ "🧪 DEBUG环境: 收到banner数据, 复制%ld份用于测试" , ( long ) copyCount ) ;
NSLog ( @ "🧪 原始banner类型: %@" , NSStringFromClass ( [ obj class ] ) ) ;
// 添 加 原 始 数 据
[ self . roomBannertModelsQueueV2 addObject : obj ] ;
// 复 制 指 定 份 数
for ( int i = 1 ; i < copyCount ; i + + ) {
AttachmentModel * copiedObj = [ [ AttachmentModel alloc ] init ] ;
// 安 全 复 制 data
if ( [ obj . data respondsToSelector : @ selector ( mutableCopy ) ] ) {
copiedObj . data = [ obj . data mutableCopy ] ;
} else if ( [ obj . data respondsToSelector : @ selector ( copy ) ] ) {
copiedObj . data = [ obj . data copy ] ;
} else {
copiedObj . data = obj . data ; // 直 接 引 用 , 注 意 这 可 能 不 是 深 拷 贝
}
copiedObj . first = obj . first ;
copiedObj . second = obj . second ;
copiedObj . isBroadcast = obj . isBroadcast ;
copiedObj . seq = obj . seq ;
NSLog ( @ "🧪 复制第%d份banner数据" , i + 1 ) ;
[ self . roomBannertModelsQueueV2 addObject : copiedObj ] ;
}
NSLog ( @ "🧪 队列中banner总数: %ld" , ( long ) self . roomBannertModelsQueueV2 . count ) ;
// 显 示 队 列 中 banner 类 型 的 分 布
NSMutableDictionary * typeCount = [ NSMutableDictionary dictionary ] ;
for ( AttachmentModel * banner in self . roomBannertModelsQueueV2 ) {
NSString * typeKey = [ NSString stringWithFormat : @ "%d" , banner . second ] ;
NSNumber * count = typeCount [ typeKey ] ;
typeCount [ typeKey ] = @ ( count . integerValue + 1 ) ;
}
NSLog ( @ "🧪 队列中banner类型分布:" ) ;
for ( NSString * typeKey in typeCount . allKeys ) {
NSLog ( @ " - 类型%@: %@个" , typeKey , typeCount [ typeKey ] ) ;
}
} else {
// 禁 用 复 制 功 能 , 正 常 添 加
NSLog ( @ "🧪 DEBUG环境: 复制功能已禁用, 正常添加banner" ) ;
[ self . roomBannertModelsQueueV2 addObject : obj ] ;
}
# else
// 生 产 环 境 : 正 常 添 加
[ self . roomBannertModelsQueueV2 addObject : obj ] ;
# endif
if ( ! self . isRoomBannerV2Displaying ) {
[ self processNextRoomEffectAttachment ] ;
}
@@ -1224,13 +1324,18 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
}
- ( void ) processNextRoomEffectAttachment {
NSLog ( @ "🔄 processNextRoomEffectAttachment 被调用 - 当前状态: isRoomBannerV2Displaying=%@, 队列数量: %ld" ,
self . isRoomBannerV2Displaying ? @ "YES" : @ "NO" , ( long ) self . roomBannertModelsQueueV2 . count ) ;
// 检 查 队 列 是 否 有 元 素
if ( self . roomBannertModelsQueueV2 . count = = 0 ) {
// 如 果 队 列 为 空 , 停 止 处 理
self . isRoomBannerV2Displaying = NO ;
NSLog ( @ "🔄 队列为空,停止处理" ) ;
return ;
}
if ( self . isRoomBannerV2Displaying ) {
NSLog ( @ "🔄 已有banner正在显示, 跳过处理" ) ;
return ;
}
@@ -1244,6 +1349,29 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
// 设 置 为 正 在 显 示 的 状 态
self . isRoomBannerV2Displaying = YES ;
NSLog ( @ "🔄 设置状态为正在显示: %@" , NSStringFromClass ( [ nextAttachment class ] ) ) ;
// 清 理 之 前 的 banner , 防 止 多 个 banner 同 时 显 示 ( 保 留 debug 视 图 )
NSMutableArray * viewsToRemove = [ NSMutableArray array ] ;
for ( UIView * subview in self . bannerContainer . subviews ) {
// 保 留 debug 视 图 ( tag 为 999 的 视 图 )
if ( subview . tag = = 999 ) {
NSLog ( @ "🔄 保留debug视图: %@" , NSStringFromClass ( [ subview class ] ) ) ;
} else {
// 其 他 视 图 都 是 banner , 需 要 移 除
[ viewsToRemove addObject : subview ] ;
NSLog ( @ "🔄 标记移除banner: %@" , NSStringFromClass ( [ subview class ] ) ) ;
}
}
for ( UIView * view in viewsToRemove ) {
[ view removeFromSuperview ] ;
}
NSLog ( @ "🔄 清理了 %ld 个banner视图, 保留debug视图" , ( long ) viewsToRemove . count ) ;
// 确 保 debug 视 图 存 在
[ self ensureDebugViewsExist ] ;
switch ( nextAttachment . second ) {
case Custom_Message _Sub _General _Floating _Screen _One _Room :
@@ -1291,6 +1419,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with : obj
complete : ^ {
@ kStrongify ( self ) ;
NSLog ( @ "🔄 BravoGiftBannerView complete 回调被调用" ) ;
self . isRoomBannerV2Displaying = NO ;
[ self processNextRoomEffectAttachment ] ;
} exitCurrentRoom : ^ {
@@ -1306,6 +1435,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break ;
}
}
// 确 保 debug 视 图 存 在
[ self ensureDebugViewsExist ] ;
} ) ;
}
@@ -1323,6 +1455,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with : obj
complete : ^ {
@ kStrongify ( self ) ;
NSLog ( @ "🔄 LuckyPackageBannerView complete 回调被调用" ) ;
self . isRoomBannerV2Displaying = NO ;
[ self processNextRoomEffectAttachment ] ;
} exitCurrentRoom : ^ {
@@ -1338,6 +1471,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break ;
}
}
// 确 保 debug 视 图 存 在
[ self ensureDebugViewsExist ] ;
} ) ;
}
@@ -1357,6 +1493,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with : obj
complete : ^ {
@ kStrongify ( self ) ;
NSLog ( @ "🔄 RoomHighValueGiftBannerAnimation complete 回调被调用" ) ;
self . isRoomBannerV2Displaying = NO ;
[ self processNextRoomEffectAttachment ] ;
} ] ;
@@ -1369,6 +1506,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break ;
}
}
// 确 保 debug 视 图 存 在
[ self ensureDebugViewsExist ] ;
} ) ;
}
@@ -1393,6 +1533,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with : attachMent
complete : ^ {
@ kStrongify ( self ) ;
NSLog ( @ "🔄 CPGiftBanner complete 回调被调用" ) ;
self . isRoomBannerV2Displaying = NO ;
[ self processNextRoomEffectAttachment ] ;
} ] ;
@@ -1405,6 +1546,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break ;
}
}
// 确 保 debug 视 图 存 在
[ self ensureDebugViewsExist ] ;
} ) ;
}
@@ -1570,6 +1714,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with : nextAttachment
complete : ^ {
@ kStrongify ( self ) ;
NSLog ( @ "🔄 LuckyGiftWinningBannerView complete 回调被调用" ) ;
self . isRoomBannerV2Displaying = NO ;
[ self processNextRoomEffectAttachment ] ;
} exitCurrentRoom : ^ {
@@ -1585,6 +1730,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break ;
}
}
// 确 保 debug 视 图 存 在
[ self ensureDebugViewsExist ] ;
} ) ;
}
@@ -1618,6 +1766,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
with : attachment
complete : ^ {
@ kStrongify ( self ) ;
NSLog ( @ "🔄 GameUniversalBannerView complete 回调被调用" ) ;
self . isRoomBannerV2Displaying = NO ;
[ self processNextRoomEffectAttachment ] ;
} goToGame : ^ ( NSInteger gameID ) {
@@ -1662,6 +1811,9 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break ;
}
}
// 确 保 debug 视 图 存 在
[ self ensureDebugViewsExist ] ;
} ) ;
}