From 48053bc2c9c7899c48e32b3b243c0022e0498e7f Mon Sep 17 00:00:00 2001 From: edwinQQQ Date: Fri, 22 Aug 2025 14:19:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=88=BF=E9=97=B4=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=8F=98=E5=8C=96=E9=80=9A=E7=9F=A5=E7=9A=84=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=92=8C=E7=9B=91=E5=90=AC=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20RoomAnimationView=20=E7=9A=84=E6=89=8B?= =?UTF-8?q?=E5=8A=BF=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C=E3=80=82=E5=90=8C?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=A7=A6=E6=91=B8=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=EF=BC=8C=E4=BE=BF?= =?UTF-8?q?=E4=BA=8E=E8=B0=83=E8=AF=95=E5=92=8C=E5=88=86=E6=9E=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/AnimationView/RoomAnimationView.m | 83 +++++++++++++++++++ .../StageView/LittleGameScrollStageView.m | 25 ++++++ .../YMRoom/View/XPRoomViewController.m | 5 ++ 3 files changed, 113 insertions(+) diff --git a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m index c6df1383..5875d963 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m @@ -176,6 +176,9 @@ BannerSchedulerDelegate // Banner 手势相关属性 @property(nonatomic, assign) CGPoint savedTapPoint; @property(nonatomic, assign) BOOL hasSavedTapPoint; + +@property (nonatomic, strong) UISwipeGestureRecognizer *swipeWhenPlayGame; + @end @implementation RoomAnimationView @@ -360,6 +363,12 @@ BannerSchedulerDelegate [self setupOldMethods]; [self addBnnerContainGesture]; + + // 🔧 新增:监听房间类型变化 + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(handleRoomTypeChanged:) + name:@"RoomTypeChanged" + object:nil]; } - (void)setupUI { @@ -2306,6 +2315,27 @@ BannerSchedulerDelegate } #pragma mark - Gesture +- (void)addBannerContainGestureWhenPlayGame { + _swipeWhenPlayGame = [[UISwipeGestureRecognizer alloc] initWithTarget:self + action:@selector(handleSwipe)]; + if (isMSRTL()) { + _swipeWhenPlayGame.direction = UISwipeGestureRecognizerDirectionRight; + } else { + _swipeWhenPlayGame.direction = UISwipeGestureRecognizerDirectionLeft; + } + + [self.bannerContainer addGestureRecognizer:_swipeWhenPlayGame]; +} + +- (void)removeBannerContainGestureWhenPlayGame { + [self.bannerContainer removeGestureRecognizer:self.swipeWhenPlayGame]; + _swipeWhenPlayGame = nil; +} + +- (void)handleSwipeWhenPlayGame { + [[NSNotificationCenter defaultCenter] postNotificationName:@"SwipeOutBanner" object:nil]; +} + - (void)addBnnerContainGesture { [self insertSubview:self.bannerSwipeGestureContainer aboveSubview:self.bannerContainer]; [self insertSubview:self.bannerLeftTapGestureContainer aboveSubview:self.bannerContainer]; @@ -3727,6 +3757,9 @@ BannerSchedulerDelegate [[NSNotificationCenter defaultCenter] removeObserver:self name:@"TapBanner" object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:@"BannerTapToFunctionContainer" object:nil]; + // 🔧 新增:移除房间类型变化通知监听 + [[NSNotificationCenter defaultCenter] removeObserver:self name:@"RoomTypeChanged" object:nil]; + // 移除其他可能添加的通知监听 [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -3823,4 +3856,54 @@ BannerSchedulerDelegate } } +#pragma mark - 房间类型手势容器控制 + +// 处理房间类型变化 +- (void)handleRoomTypeChanged:(NSNotification *)notification { + NSDictionary *userInfo = notification.userInfo; + NSInteger roomType = [userInfo[@"roomType"] integerValue]; + + if (roomType == RoomType_MiniGame) { + NSLog(@"🎯 RoomAnimationView: 检测到小游戏房间,设置 banner 手势穿透模式"); + [self setBannerGesturePassthroughMode]; + [self addBannerContainGestureWhenPlayGame]; + } else { + NSLog(@"🎯 RoomAnimationView: 检测到非小游戏房间,恢复 banner 手势正常模式"); + [self restoreBannerGestureNormalMode]; + [self removeBannerContainGestureWhenPlayGame]; + } +} + +// 设置 banner 手势为穿透模式(用于 LittleGameScrollStageView) +- (void)setBannerGesturePassthroughMode { + // 隐藏手势容器 + self.bannerSwipeGestureContainer.hidden = YES; + self.bannerLeftTapGestureContainer.hidden = YES; + self.bannerRightTapGestureContainer.hidden = YES; + + // 禁用用户交互 + self.bannerSwipeGestureContainer.userInteractionEnabled = NO; + self.bannerLeftTapGestureContainer.userInteractionEnabled = NO; + self.bannerRightTapGestureContainer.userInteractionEnabled = NO; + + NSLog(@"🎯 RoomAnimationView: Banner 手势容器已隐藏(小游戏模式)"); +} + +// 恢复 banner 手势正常模式 +- (void)restoreBannerGestureNormalMode { + // 显示手势容器 + self.bannerSwipeGestureContainer.hidden = NO; + self.bannerLeftTapGestureContainer.hidden = NO; + self.bannerRightTapGestureContainer.hidden = NO; + + // 启用用户交互 + self.bannerSwipeGestureContainer.userInteractionEnabled = YES; + self.bannerLeftTapGestureContainer.userInteractionEnabled = YES; + self.bannerRightTapGestureContainer.userInteractionEnabled = YES; + + NSLog(@"🎯 RoomAnimationView: Banner 手势容器已恢复显示(非小游戏模式)"); +} + + + @end diff --git a/YuMi/Modules/YMRoom/View/StageView/LittleGameScrollStageView.m b/YuMi/Modules/YMRoom/View/StageView/LittleGameScrollStageView.m index caff58f3..fc074771 100644 --- a/YuMi/Modules/YMRoom/View/StageView/LittleGameScrollStageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/LittleGameScrollStageView.m @@ -161,5 +161,30 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; return _scrollView; } +#pragma mark - 触摸事件日志 + +// 触摸开始 +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + NSLog(@"🎯 LittleGameScrollStageView: touchesBegan 被调用"); + [super touchesBegan:touches withEvent:event]; +} + +// 触摸移动 +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + NSLog(@"🎯 LittleGameScrollStageView: touchesMoved 被调用"); + [super touchesMoved:touches withEvent:event]; +} + +// 触摸结束 +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + NSLog(@"🎯 LittleGameScrollStageView: touchesEnded 被调用"); + [super touchesEnded:touches withEvent:event]; +} + +// 触摸取消 +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { + NSLog(@"🎯 LittleGameScrollStageView: touchesCancelled 被调用"); + [super touchesCancelled:touches withEvent:event]; +} @end diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 0848578d..62fc5e37 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -932,6 +932,11 @@ XPCandyTreeInsufficientBalanceViewDelegate> if (![self updateStageView]) { return; } + + // 🔧 新增:发送房间类型变化通知 + [[NSNotificationCenter defaultCenter] postNotificationName:@"RoomTypeChanged" + object:nil + userInfo:@{@"roomType": @(self.roomInfo.type)}]; if (!self.stageView.superview) { [self.view insertSubview:self.stageView