From d56f5845fca1b9af776d45b471bda0d4042ff9de Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Tue, 15 Feb 2022 17:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E4=B8=AD=E5=90=84=E7=A7=8D?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/XPLittleGameMiniStageView.m | 2 +- .../View/XPLittleGameRoomListView.h | 6 +- .../View/XPLittleGameRoomListView.m | 5 +- .../View/XPRoomLittleGameContainerView.h | 3 + .../View/XPRoomLittleGameContainerView.m | 29 +++--- .../Room/View/RoomHeaderView/RoomHeaderView.m | 30 +++++++ .../Room/View/StageView/LittleGameStageView.m | 2 +- .../UserCard/View/XPUserCardViewController.m | 90 +++++++++++++++---- .../Main/Room/View/XPRoomViewController.m | 7 +- 9 files changed, 140 insertions(+), 34 deletions(-) diff --git a/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameMiniStageView.m b/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameMiniStageView.m index 69df4674..79f26176 100644 --- a/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameMiniStageView.m +++ b/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameMiniStageView.m @@ -114,7 +114,7 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; self.foldButton.transform = CGAffineTransformIdentity; } }]; - [[NSNotificationCenter defaultCenter] postNotificationName:kRoomRoomLittleGameMiniStageNotificationKey object:@{@"isMini": @(!self.foldButton.selected)}]; + [[NSNotificationCenter defaultCenter] postNotificationName:kRoomRoomLittleGameMiniStageNotificationKey object:@{@"isMini": @(self.foldButton.selected)}]; } #pragma mark - Getters And Setters diff --git a/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameRoomListView.h b/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameRoomListView.h index aae9ee50..07bf723a 100644 --- a/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameRoomListView.h +++ b/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameRoomListView.h @@ -11,9 +11,12 @@ NS_ASSUME_NONNULL_BEGIN @class LittleGameInfoModel, XPLittleGameRoomListView; @protocol XPRoomLittleGameListViewDelegate -///选择了礼物 +///选择某一个类型 - (void)xPRoomLittleGameListView:(XPLittleGameRoomListView *)view didSelectItem:(LittleGameInfoModel *)itemInfo; +///选择类型 +- (void)xPRoomLittleGameListView:(XPLittleGameRoomListView *)view didSelectChooseType:(UIButton *)sender; + @end @interface XPLittleGameRoomListView : UIView @@ -24,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN ///列表 @property (nonatomic,strong,readonly) UITableView *tableView; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameRoomListView.m b/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameRoomListView.m index 8e2552c7..a14f55de 100644 --- a/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameRoomListView.m +++ b/xplan-ios/Main/Room/View/LittleGame/View/XPLittleGameRoomListView.m @@ -124,8 +124,9 @@ #pragma mark - Event Response - (void)gamePlayButtonAction:(UIButton *)sender { - sender.selected = !sender.selected; - self.tableView.hidden = !sender.selected; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomLittleGameListView:didSelectChooseType:)]) { + [self.delegate xPRoomLittleGameListView:self didSelectChooseType:sender]; + } } #pragma mark - Getters And Setters diff --git a/xplan-ios/Main/Room/View/LittleGame/View/XPRoomLittleGameContainerView.h b/xplan-ios/Main/Room/View/LittleGame/View/XPRoomLittleGameContainerView.h index fa3a31c0..612137a5 100644 --- a/xplan-ios/Main/Room/View/LittleGame/View/XPRoomLittleGameContainerView.h +++ b/xplan-ios/Main/Room/View/LittleGame/View/XPRoomLittleGameContainerView.h @@ -25,6 +25,9 @@ NS_ASSUME_NONNULL_BEGIN ///销毁游戏的引擎 - (void)destroyMG; +/// 退出游戏 +- (void)handleSelfInExitEvent; + //自己是否在游戏中 - (BOOL)isInSudGame; diff --git a/xplan-ios/Main/Room/View/LittleGame/View/XPRoomLittleGameContainerView.m b/xplan-ios/Main/Room/View/LittleGame/View/XPRoomLittleGameContainerView.m index 94b89d68..82491bbb 100644 --- a/xplan-ios/Main/Room/View/LittleGame/View/XPRoomLittleGameContainerView.m +++ b/xplan-ios/Main/Room/View/LittleGame/View/XPRoomLittleGameContainerView.m @@ -243,15 +243,17 @@ //自己是否在游戏中 - (BOOL)isInSudGame { BOOL isGamePlaying = NO; - for (int i = -1; i<5; i++) { - NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; - MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; - if (micSequence == nil || micSequence.userInfo == nil) { - continue; - } - if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) { - isGamePlaying = YES; - break; + if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { + for (int i = -1; i<5; i++) { + NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; + MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; + if (micSequence == nil || micSequence.userInfo == nil) { + continue; + } + if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) { + isGamePlaying = YES; + break; + } } } return isGamePlaying; @@ -483,8 +485,11 @@ /// 退出游戏 - (void)handleSelfInExitEvent { + if (self.hostDelegate.getRoomInfo.type != RoomType_MiniGame) { + return; + } /// 正在游戏中,只退出游戏 - if ([self isInSudGame]) { + if ([self getCurrentUserSudGameStatus] == LittleGamePlayStatus_Plying) { [self notifyIsPlayingState:false]; [self nofityPlayerPlaying:NO]; [self notifySetReady:false]; @@ -762,7 +767,9 @@ /// 销毁MG - (void)destroyMG { if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { - [self.fsmAPP2MG destroyMG]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.fsmAPP2MG destroyMG]; + }); } } diff --git a/xplan-ios/Main/Room/View/RoomHeaderView/RoomHeaderView.m b/xplan-ios/Main/Room/View/RoomHeaderView/RoomHeaderView.m index cfcd33e8..673a952e 100644 --- a/xplan-ios/Main/Room/View/RoomHeaderView/RoomHeaderView.m +++ b/xplan-ios/Main/Room/View/RoomHeaderView/RoomHeaderView.m @@ -32,6 +32,7 @@ #import "UserInfoModel.h" #import "AttachMentModel.h" #import "LittleGameInfoModel.h" +#import "MicroQueueModel.h" ///View #import "XPShareView.h" #import "XPLittleGameRoomListView.h" @@ -205,6 +206,25 @@ } } +//自己是否在游戏中 +- (BOOL)isInSudGame { + BOOL isGamePlaying = NO; + if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { + for (int i = -1; i<5; i++) { + NSMutableDictionary * micQueue = self.hostDelegate.getMicroQueue; + MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; + if (micSequence == nil || micSequence.userInfo == nil) { + continue; + } + if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) { + isGamePlaying = YES; + break; + } + } + } + return isGamePlaying; +} + #pragma mark - RoomGuestDelegate - (void)onRoomEntered { RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo; @@ -283,6 +303,16 @@ } } params:params]; } + +- (void)xPRoomLittleGameListView:(XPLittleGameRoomListView *)view didSelectChooseType:(UIButton *)sender { + if ([self isInSudGame]) { + [XCHUDTool showErrorWithMessage:@"游戏中不可切换游戏或玩法!"]; + } else { + sender.selected = !sender.selected; + view.tableView.hidden = !sender.selected; + } +} + #pragma mark - Event Response - (void)showSharePanel { XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagMoments title:@"朋友圈" imageName:@"share_wechat_circle_normal" disableImageName:@"share_wechat_circle_disable"]; diff --git a/xplan-ios/Main/Room/View/StageView/LittleGameStageView.m b/xplan-ios/Main/Room/View/StageView/LittleGameStageView.m index 0f0aaa6f..bfd90d36 100644 --- a/xplan-ios/Main/Room/View/StageView/LittleGameStageView.m +++ b/xplan-ios/Main/Room/View/StageView/LittleGameStageView.m @@ -67,7 +67,7 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; #pragma mark - 通知 - (void)changeViewState:(NSNotification *)notification { NSDictionary * dic = notification.object; - self.hidden = ![[dic objectForKey:@"isMini"] boolValue]; + self.hidden = [[dic objectForKey:@"isMini"] boolValue]; } @end diff --git a/xplan-ios/Main/Room/View/UserCard/View/XPUserCardViewController.m b/xplan-ios/Main/Room/View/UserCard/View/XPUserCardViewController.m index df82ce3a..d7b7d2b7 100644 --- a/xplan-ios/Main/Room/View/UserCard/View/XPUserCardViewController.m +++ b/xplan-ios/Main/Room/View/UserCard/View/XPUserCardViewController.m @@ -465,6 +465,25 @@ return array; } +//自己是否在游戏中 +- (BOOL)isInSudGame { + BOOL isGamePlaying = NO; + if (self.cardInfo.roomInfo.type == RoomType_MiniGame) { + for (int i = -1; i<5; i++) { + NSMutableDictionary * micQueue = self.cardInfo.micQueue; + MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; + if (micSequence == nil || micSequence.userInfo == nil) { + continue; + } + if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) { + isGamePlaying = YES; + break; + } + } + } + return isGamePlaying; +} + #pragma mark - XPUserCardProtocol - (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo { @@ -682,26 +701,47 @@ break; case UserCardItemType_KickOut: { - NSString *message = [NSString stringWithFormat:@"是否需要将%@踢出房间?",self.targetUserInfo.nick]; - TTAlertConfig *config = [[TTAlertConfig alloc] init]; - config.title = @"操作提醒"; - config.message = message; - [TTPopup alertWithConfig:config confirmHandler:^{ - [self.presenter makeKickUser:self.cardInfo.uid roomId:roomId]; - } cancelHandler:^{ - }]; + if ([self isInSudGame]) { + NSString *message = [NSString stringWithFormat:@"游戏模式下默认该玩家退出游戏是否要将此用户踢出房间?"]; + TTAlertConfig *config = [[TTAlertConfig alloc] init]; + config.title = @""; + config.message = message; + [TTPopup alertWithConfig:config confirmHandler:^{ + [self.presenter makeKickUser:self.cardInfo.uid roomId:roomId]; + } cancelHandler:^{ + }]; + } else { + NSString *message = [NSString stringWithFormat:@"是否需要将%@踢出房间?",self.targetUserInfo.nick]; + TTAlertConfig *config = [[TTAlertConfig alloc] init]; + config.title = @"操作提醒"; + config.message = message; + [TTPopup alertWithConfig:config confirmHandler:^{ + [self.presenter makeKickUser:self.cardInfo.uid roomId:roomId]; + } cancelHandler:^{ + }]; + } } break; case UserCardItemType_Black: { - NSString *title = [NSString stringWithFormat:@"你正在拉黑%@",self.targetUserInfo.nick]; - TTAlertConfig *config = [[TTAlertConfig alloc] init]; - config.title = title; - config.message = @"拉黑后他将无法加入此房间"; - [TTPopup alertWithConfig:config confirmHandler:^{ - [self.presenter makeUserBlack:self.cardInfo.uid roomId:roomId]; - } cancelHandler:^{ - }]; + if ([self isInSudGame]) { + TTAlertConfig *config = [[TTAlertConfig alloc] init]; + config.title = @""; + config.message = [NSString stringWithFormat: @"是否将%@加入黑名单?加入后他将无法进入此房间游戏模式下默认该玩家退出游戏", self.targetUserInfo.nick]; + [TTPopup alertWithConfig:config confirmHandler:^{ + [self.presenter makeUserBlack:self.cardInfo.uid roomId:roomId]; + } cancelHandler:^{ + }]; + } else { + NSString *title = [NSString stringWithFormat:@"你正在拉黑%@",self.targetUserInfo.nick]; + TTAlertConfig *config = [[TTAlertConfig alloc] init]; + config.title = title; + config.message = @"拉黑后他将无法加入此房间"; + [TTPopup alertWithConfig:config confirmHandler:^{ + [self.presenter makeUserBlack:self.cardInfo.uid roomId:roomId]; + } cancelHandler:^{ + }]; + } } break; case UserCardItemType_Manager: @@ -755,7 +795,23 @@ case UserCardMicroType_UpDown: { if (sender.selected) { - [self.presenter kickDownMicro:self.cardInfo.position roomId:roomId]; + if ([self isInSudGame]) { + if (self.cardInfo.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) { + [self showErrorToast:@"游戏中不可主动下麦!"]; + [self dismissViewControllerAnimated:YES completion:nil]; + } else { + TTAlertConfig *config = [[TTAlertConfig alloc] init]; + config.message = @"抱Ta下麦后默认该玩家退出游戏,是否继续?"; + [TTPopup alertWithConfig:config confirmHandler:^{ + [self.presenter kickDownMicro:self.cardInfo.position roomId:roomId]; + } cancelHandler:^{ + }]; + } + + return; + }else { + [self.presenter kickDownMicro:self.cardInfo.position roomId:roomId]; + } } else { self.operaStackView.hidden = YES; int micCount = self.cardInfo.roomInfo.type == RoomType_Anchor ? 4 : 9; diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index d754c470..6321683b 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -285,11 +285,12 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; } else { return; } + if (!self.stageView.superview) { [self.view insertSubview:self.stageView belowSubview:self.roomHeaderView]; } - + if (self.roomInfo.type == RoomType_MiniGame) { [self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) { @@ -712,6 +713,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; [[RtcManager instance] exitRoom]; + [self.littleGameView handleSelfInExitEvent]; [self.littleGameView destroyMG]; [self dismissViewControllerAnimated:YES completion:nil]; }); @@ -720,6 +722,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; } else { [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; [[RtcManager instance] exitRoom]; + [self.littleGameView handleSelfInExitEvent]; [self.littleGameView destroyMG]; [self dismissViewControllerAnimated:YES completion:nil]; } @@ -743,6 +746,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; [[RtcManager instance] exitRoom]; + [self.littleGameView handleSelfInExitEvent]; [self.littleGameView destroyMG]; [self dismissViewControllerAnimated:YES completion:nil]; }); @@ -751,6 +755,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; } else { [self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]; [[RtcManager instance] exitRoom]; + [self.littleGameView handleSelfInExitEvent]; [self.littleGameView destroyMG]; [self dismissViewControllerAnimated:YES completion:nil]; }