diff --git a/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/Contents.json b/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/Contents.json new file mode 100644 index 00000000..1df64416 --- /dev/null +++ b/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ms_room_game_button@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ms_room_game_button@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/ms_room_game_button@2x.png b/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/ms_room_game_button@2x.png new file mode 100644 index 00000000..db614274 Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/ms_room_game_button@2x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/ms_room_game_button@3x.png b/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/ms_room_game_button@3x.png new file mode 100644 index 00000000..0065903e Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_game_button.imageset/ms_room_game_button@3x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/Contents.json b/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/Contents.json new file mode 100644 index 00000000..4a8c81e5 --- /dev/null +++ b/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ms_room_game_switch_button@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ms_room_game_switch_button@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/ms_room_game_switch_button@2x.png b/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/ms_room_game_switch_button@2x.png new file mode 100644 index 00000000..9d6e13b9 Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/ms_room_game_switch_button@2x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/ms_room_game_switch_button@3x.png b/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/ms_room_game_switch_button@3x.png new file mode 100644 index 00000000..5e4014a7 Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_game_switch_button.imageset/ms_room_game_switch_button@3x.png differ diff --git a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m index 3af1738a..bf70e1d6 100644 --- a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m +++ b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m @@ -69,7 +69,6 @@ } cancelHandler:^{ }]; - } } showLoading:NO errorToast:NO] uid:roomUid intoUid:uid]; } diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.h b/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.h index b7c06412..fae724b0 100644 --- a/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.h +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.h @@ -11,16 +11,19 @@ #import "XPRedPacketModel.h" #import "RoomInfoModel.h" #import "ActivityInfoModel.h" +#import "LittleGameInfoModel.h" typedef void(^OpenRedPacketHandle)(XPRedPacketModel *_Nullable,RoomType type ,BOOL isChangeRoom); NS_ASSUME_NONNULL_BEGIN @interface XPRoomActivityContainerView : UIView -@property(nonatomic,strong) NSMutableArray *redPacketList; @property(nonatomic,copy)OpenRedPacketHandle openRedPacketHandle; +@property(nonatomic,strong) NSMutableArray *redPacketList; @property(nonatomic,strong) NSMutableArray *playList; -- (instancetype)initWithdelegate:(id)delegate; +@property(nonatomic,strong) NSMutableArray *littleGameList; +- (instancetype)initWithDelegate:(id)delegate; +- (void)updateView; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m b/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m index 843632ef..6f61123b 100644 --- a/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m +++ b/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m @@ -14,6 +14,7 @@ #import "AccountInfoStorage.h" #import "Api+Room.h" #import "Api+TreasureFairy.h" +#import "Api+LittleGame.h" #import "ClientConfig.h" #import "NetImageView.h" #import "TTPopup.h" @@ -26,6 +27,7 @@ #import "FirstRechargeModel.h" #import "TreasureFairyLimitModel.h" #import "XPRedPacketResultModel.h" + ///View #import "XPRoomHalfWebView.h" #import "XPCandyTreeViewController.h" @@ -41,6 +43,8 @@ #import "PIRoomActivityWebView.h" #import "PIRoomActivityClickView.h" #import "PIRoomActivityChoosePlayView.h" +#import "MSRoomMenuGameVC.h" + UIKIT_EXTERN NSString *kShowFirstRechargeView; @interface XPRoomActivityContainerView () ///容器 @@ -50,8 +54,9 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; ///红包 @property(nonatomic,strong) PIRoomEnterRedPacketView *redPacketView; -///玩法 -@property(nonatomic,strong) PIRoomActivityClickView *clickPlayView; + +///游戏菜单按钮 +@property(nonatomic, strong) UIButton *gameMenuButton; ///参加相亲 @property (nonatomic,strong) UIImageView *joinDatingView; @@ -68,18 +73,24 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; -(void)dealloc{ [[NSNotificationCenter defaultCenter]removeObserver:self]; } -- (instancetype)initWithdelegate:(id)delegate { +- (instancetype)initWithDelegate:(id)delegate { self = [super init]; if (self) { self.hostDelegate = delegate; [self initSubViews]; [self initSubViewConstraints]; - [self requestActivityList]; - } return self; } +- (void)updateView { + if (self.isLoadActivity) { + [self configLittleGameActivity]; + } else { + [self requestActivityList]; + } +} + #pragma mark - Private Method - (void)initSubViews { [self addSubview:self.stackView]; @@ -88,9 +99,7 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; [self.stackView addArrangedSubview:emptyView]; [self.stackView addArrangedSubview:self.redPacketView]; [self.stackView addArrangedSubview:self.joinDatingView]; - [self.stackView addArrangedSubview:self.clickPlayView]; - - + [self.stackView addArrangedSubview:self.gameMenuButton]; } - (void)initSubViewConstraints { @@ -102,68 +111,76 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; [self.pi_cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(itemWidth , itemWidth)); }]; + [self.redPacketView mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(kGetScaleWidth(58)); }]; - - [self.clickPlayView mas_makeConstraints:^(MASConstraintMaker *make) { + [self.gameMenuButton mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(0); - make.size.mas_equalTo(CGSizeMake(81, 66)); + make.size.mas_equalTo(CGSizeMake(76, 76)); }]; - + [self.joinDatingView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(35 * kScreenHeightScale); }]; - } - (void)requestActivityList { - - - RACSubject* list = [RACSubject subject]; - RACSubject* play = [RACSubject subject]; - [[RACSignal combineLatest:@[list, play] reduce:^id(NSArray * listModel, NSArray * playModel){ - self.activityList = [NSMutableArray arrayWithArray:listModel]; - self.playList = [NSMutableArray arrayWithArray:playModel]; - [self dealWithData]; + @kWeakify(self); + RACSubject* playRAC = [RACSubject subject]; + RACSubject* littleGameRAC = [RACSubject subject]; + [[RACSignal combineLatest:@[playRAC, littleGameRAC] + reduce:^id(NSArray *playModels, NSArray *littleGameModels){ + @kStrongify(self); + self.playList = [NSMutableArray arrayWithArray:playModels]; + self.littleGameList = [NSMutableArray arrayWithArray:littleGameModels]; return nil; - }] subscribeError:^(NSError * _Nullable error) { - - }]; - NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; - [Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - NSArray * array = [ActivityInfoModel modelsWithArray:data.data]; - [list sendNext:array]; - [list sendCompleted]; - return; - } - [list sendError:nil]; - } roomId:roomId]; - - + }] subscribeError:^(NSError * _Nullable error) {}]; + + NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; + [Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + @kStrongify(self); + if (code == 200) { + NSArray * array = [ActivityInfoModel modelsWithArray:data.data]; + self.activityList = [NSMutableArray arrayWithArray:array]; + [self dealWithData]; + } + } roomId:roomId]; + [Api getPlayList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { NSArray * array = [ActivityInfoModel modelsWithArray:data.data]; - [play sendNext:array]; - [play sendCompleted]; - return; + [playRAC sendNext:array]; + [playRAC sendCompleted]; + } else { + [playRAC sendError:nil]; } - [play sendError:nil]; } roomId:roomId]; - - - + [Api getLittleGameList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + NSArray * array = [LittleGameInfoModel modelsWithArray:data.data]; + [littleGameRAC sendNext:array]; + [littleGameRAC sendCompleted]; + } else { + [littleGameRAC sendError:nil]; + } + }]; } -(void)dealWithData{ self.isLoadActivity = YES; self.pi_cycleScrollView.hidden = NO; + + if (self.hostDelegate.getRoomInfo.type == RoomType_Anchor) { + [self.gameMenuButton removeFromSuperview]; + } else { + self.gameMenuButton.hidden = NO; + } + if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { [self configLittleGameActivity]; } else { - NSMutableArray *picArray = [NSMutableArray array]; for (ActivityInfoModel *model in self.activityList) { [picArray addObject:model.icon]; @@ -175,25 +192,10 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; } else { [self.pi_cycleScrollView setAutoScroll:NO]; } - - if(self.playList.count > 0){ - ActivityInfoModel *playModel = self.playList.firstObject; - self.clickPlayView.model = playModel; -// if(self.isShowChoosePlayView == NO){ -// self.clickPlayView.hidden = NO; -// } - }else{ - self.clickPlayView.hidden = YES; - } } } - - - - (void)configLittleGameActivity { - - NSMutableArray *list = [NSMutableArray array]; [list addObjectsFromArray:self.activityList]; @@ -232,8 +234,7 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; }]; } self.redPacketView.hidden = YES; - self.clickPlayView.hidden = YES; - + if (self.isLoadActivity) { [self configLittleGameActivity]; } else { @@ -252,16 +253,7 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; } else { [self.pi_cycleScrollView setAutoScroll:NO]; } - - if(self.playList.count > 0){ - ActivityInfoModel *playModel = self.playList.firstObject; - self.clickPlayView.model = playModel; -// if(self.isShowChoosePlayView == NO){ -// self.clickPlayView.hidden = NO; -// } - }else{ - self.clickPlayView.hidden = YES; - } + if (roomInfo.roomModeType == RoomModeType_Open_Blind || roomInfo.roomModeType == RoomModeType_Open_PK_Mode || roomInfo.roomModeType == RoomModeType_Open_Micro_Mode) { if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode ) { self.joinDatingView.image = [UIImage getLanguageImage:@"room_pk_normal_member_enter"]; @@ -284,9 +276,6 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; } else { self.joinDatingView.hidden = YES; } - - - } if(self.openRedPacketHandle){ @@ -375,7 +364,7 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; fairyVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight); [[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:fairyVC]; - [fairyVC.navigationController setNavigationBarHidden:YES animated:NO]; +// [fairyVC.navigationController setNavigationBarHidden:YES animated:NO]; [[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:fairyVC.view]; [UIView animateWithDuration:0.2 animations:^{ @@ -409,12 +398,10 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; } -(void)jumpPlayActionWithIndex:(NSInteger)index imageUrlList:(NSArray *)imageUrlList{ - if (imageUrlList.count > index) { NSString *pic = imageUrlList[index]; NSMutableArray *inftList = [NSMutableArray array]; NSMutableArray *modelList = [NSMutableArray array]; - [modelList addObjectsFromArray:self.playList]; [modelList addObjectsFromArray:self.activityList]; ActivityInfoModel * info; for (int i = 0 ; i < modelList.count; i++) { @@ -422,7 +409,7 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; if([getInfo.icon isEqualToString:pic]){ info = getInfo; } - if(getInfo.skipType == 3 && i > self.playList.count){ + if(getInfo.skipType == 3){ [inftList addObject:getInfo]; } } @@ -449,25 +436,22 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; }]; }else { - - if(index < self.playList.count){ - - if(info.showType == ActivityShowType_Half){ - XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init]; - webView.isPlayView = YES; - webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; - webView.url = info.skipContent; - [TTPopup popupView:webView style:TTPopupStyleActionSheet]; - return; - } - XPWebViewController * webVC = [[XPWebViewController alloc] init]; - webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; - webVC.url = info.skipContent; - [self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES]; - return; - } - - +// if(index < self.playList.count){ +// if(info.showType == ActivityShowType_Half){ +// XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init]; +// webView.isPlayView = YES; +// webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; +// webView.url = info.skipContent; +// [TTPopup popupView:webView style:TTPopupStyleActionSheet]; +// return; +// } +// XPWebViewController * webVC = [[XPWebViewController alloc] init]; +// webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; +// webVC.url = info.skipContent; +// [self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES]; +// return; +// } + if (info.skipType == ActivitySkipType_Room) { [self.hostDelegate exitRoom]; @@ -504,7 +488,6 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; }completion:^(BOOL finished) { }]; - } - (void)firstRechargeTapRecognizer { @@ -544,20 +527,25 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid]; [self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil]; } + +- (void)didTapGameMenuButton { + MSRoomMenuGameVC *vc = [[MSRoomMenuGameVC alloc] initWithDelegate:self.hostDelegate roomMenuType:MSRoomMenuTypeLittleGame]; + vc.modalPresentationStyle = UIModalPresentationOverFullScreen; + [self.hostDelegate.getCurrentNav presentViewController:vc animated:YES completion:nil]; +} + #pragma mark- PIRoomEnterRedPacketViewDelegate --(void)openRedPacketWtihModel:(XPRedPacketModel *)redModel{ +-(void)openRedPacketWithModel:(XPRedPacketModel *)redModel{ if(self.openRedPacketHandle){ self.openRedPacketHandle(redModel,self.hostDelegate.getRoomInfo.type,NO); } } #pragma mark - PIRoomActivityClickViewDelegate - (void)showChoosePlayViewAction{ - self.clickPlayView.hidden = YES; - self.isShowChoosePlayView = YES; +// self.isShowChoosePlayView = YES; PIRoomActivityChoosePlayView *choosePlayView = [[PIRoomActivityChoosePlayView alloc]initWithFrame:CGRectZero]; choosePlayView.delegate = self; - choosePlayView.playList = self.playList; CGFloat y = self.frame.size.height + self.frame.origin.y - 124; choosePlayView.tag = 98021; [self.hostDelegate.getSuperView addSubview:choosePlayView]; @@ -612,7 +600,6 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; [UIView animateWithDuration:0.1 animations:^{ view.frame = isMSRTL() ? CGRectMake(-201, y, 201, 124) : CGRectMake(KScreenWidth, y, 201, 124); }completion:^(BOOL finished) { -// self.clickPlayView.hidden = NO; [view removeFromSuperview]; }]; } @@ -637,14 +624,10 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; for (UIView *subView in _pi_cycleScrollView.subviews) { subView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight; } - } return _pi_cycleScrollView; } - - - - (UIStackView *)stackView { if (!_stackView) { _stackView = [[UIStackView alloc] init]; @@ -652,14 +635,10 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; _stackView.distribution = UIStackViewDistributionFill; _stackView.alignment = UIStackViewAlignmentCenter; _stackView.spacing = 0; - } return _stackView; } - - - - (UIImageView *)joinDatingView { if (!_joinDatingView) { _joinDatingView = [[UIImageView alloc] init]; @@ -680,10 +659,6 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; return _activityList; } - - - - - (PIRoomEnterRedPacketView *)redPacketView{ if(!_redPacketView){ _redPacketView = [[PIRoomEnterRedPacketView alloc]initWithFrame:CGRectZero]; @@ -692,13 +667,17 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView; } return _redPacketView; } -- (PIRoomActivityClickView *)clickPlayView{ - if(!_clickPlayView){ - _clickPlayView = [[PIRoomActivityClickView alloc]initWithFrame:CGRectZero]; - _clickPlayView.hidden = YES; - _clickPlayView.delegate = self; + +- (UIButton *)gameMenuButton { + if (!_gameMenuButton) { + UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom]; + [b setImage:[UIImage imageNamed:@"ms_room_game_button"] forState:UIControlStateNormal]; + [b addTarget:self action:@selector(didTapGameMenuButton) forControlEvents:UIControlEventTouchUpInside]; + b.hidden = YES; + _gameMenuButton = b; } - return _clickPlayView; + return _gameMenuButton; } @end + diff --git a/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.h b/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.h index 85c070ad..2c892c8c 100644 --- a/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.h +++ b/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @interface XPRoomFunctionContainerView : UIView ///是否第一次更新在线人数 @property(nonatomic,assign) BOOL isFirstUpdate; -- (instancetype)initWithdelegate:(id)delegate; +- (instancetype)initWithDelegate:(id)delegate; - (void)hiddenSudGamePostionView; ///获取当前的音乐 - (Music *)getCurrentMusic; diff --git a/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.m index 70ee766b..d2e7ab5e 100644 --- a/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/YuMi/Modules/YMRoom/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -176,7 +176,7 @@ [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (instancetype)initWithdelegate:(id)delegate { +- (instancetype)initWithDelegate:(id)delegate { self = [super init]; if (self) { self.delegate = delegate; @@ -1857,6 +1857,7 @@ } return _gameListView; } + - (XPAnchorPkPanelView *)anchorPKPanelView { if (!_anchorPKPanelView) { _anchorPKPanelView = [[XPAnchorPkPanelView alloc] init]; diff --git a/YuMi/Modules/YMRoom/View/LittleGame/View/XPLittleGameRoomListView.m b/YuMi/Modules/YMRoom/View/LittleGame/View/XPLittleGameRoomListView.m index 1d754a4a..bbbd7b11 100644 --- a/YuMi/Modules/YMRoom/View/LittleGame/View/XPLittleGameRoomListView.m +++ b/YuMi/Modules/YMRoom/View/LittleGame/View/XPLittleGameRoomListView.m @@ -17,8 +17,6 @@ @interface XPLittleGameRoomListView () ///容器 @property (nonatomic,strong) UIStackView *stackView; -///当前游戏的类型 -@property (nonatomic,strong) UIButton *gamePlayButton; ///列表 @property (nonatomic,strong) UITableView *tableView; ///原始数据源 @@ -37,7 +35,6 @@ if (self) { [self initSubViews]; [self initSubViewConstraints]; - } return self; } @@ -50,7 +47,6 @@ self.layer.borderColor = UIColorRGBAlpha(0xffffff, 0.6).CGColor; self.backgroundColor = UIColorRGBAlpha(0x000000, 0.2); [self addSubview:self.stackView]; - [self.stackView addArrangedSubview:self.gamePlayButton]; [self.stackView addArrangedSubview:self.tableView]; } @@ -64,10 +60,6 @@ make.leading.trailing.top.mas_equalTo(self); }]; - [self.gamePlayButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(25); - }]; - [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(25); }]; @@ -111,7 +103,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (self.datasource.count > 0) { self.tableView.hidden = YES; - self.gamePlayButton.selected = NO; LittleGameInfoModel *info = [self.datasource safeObjectAtIndex1:indexPath.row]; if (info.mgId.integerValue != self.mgId.integerValue) { if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomLittleGameListView:didSelectItem:)]) { @@ -121,19 +112,11 @@ } } -#pragma mark - Event Response -- (void)gamePlayButtonAction:(UIButton *)sender { - if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomLittleGameListView:didSelectChooseType:)]) { - [self.delegate xPRoomLittleGameListView:self didSelectChooseType:sender]; - } -} - #pragma mark - Getters And Setters - (void)setMgId:(NSString *)mgId { _mgId = mgId; if (self.gameList.count > 0) { self.datasource = [self handleGameListData:self.gameList]; - [self.gamePlayButton setTitle:self.gameInfo.name forState:UIControlStateNormal]; } else { [Api getLittleGameList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { @@ -146,7 +129,6 @@ [dataArray addObject:gameInfo]; self.gameList = [dataArray copy]; self.datasource = [self handleGameListData:self.gameList]; - [self.gamePlayButton setTitle:self.gameInfo.name forState:UIControlStateNormal]; } }]; } @@ -188,20 +170,4 @@ return _tableView; } -- (UIButton *)gamePlayButton { - if (!_gamePlayButton) { - _gamePlayButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_gamePlayButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; - [_gamePlayButton setImage:[UIImage imageNamed:@"room_info_little_game_down_arrow"] forState:UIControlStateNormal]; - [_gamePlayButton setImage:[UIImage imageNamed:@"room_info_little_game_up_arrow"] forState:UIControlStateSelected]; - _gamePlayButton.titleLabel.font = [UIFont systemFontOfSize:12]; - [_gamePlayButton setTitle:YMLocalizedString(@"XPLittleGameRoomListView1") forState:UIControlStateNormal]; - _gamePlayButton.selected = NO; - [_gamePlayButton addTarget:self action:@selector(gamePlayButtonAction:) forControlEvents:UIControlEventTouchUpInside]; - _gamePlayButton.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft; - _gamePlayButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0); - } - return _gamePlayButton; -} - @end diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.h b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.h index 3c55ad17..046bc60d 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.h +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.h @@ -7,10 +7,12 @@ #import #import "ActivityInfoModel.h" +#import "LittleGameInfoModel.h" NS_ASSUME_NONNULL_BEGIN @interface MSRoomMenuGameCell : UICollectionViewCell @property(nonatomic,strong) ActivityInfoModel *model; +@property(nonatomic,strong) LittleGameInfoModel *littleGameModel; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.m b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.m index 498108e2..e67b3422 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.m +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.m @@ -35,6 +35,7 @@ make.leading.trailing.equalTo(self.contentView).inset(kGetScaleWidth(5)); }]; } + - (void)setModel:(ActivityInfoModel *)model{ _model = model; _gameView.image = nil; @@ -42,9 +43,17 @@ self.gameView.image = image; }]; _textView.text = _model.name; - - } + +- (void)setLittleGameModel:(LittleGameInfoModel *)littleGameModel{ + _littleGameModel = littleGameModel; + _gameView.image = nil; + [_gameView loadImageWithUrl:littleGameModel.pic completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) { + self.gameView.image = image; + }]; + _textView.text = littleGameModel.name; +} + #pragma mark - 懒加载 - (NetImageView *)gameView{ if(!_gameView){ diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameVC.h b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameVC.h index 6c945a71..c87a7981 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameVC.h +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameVC.h @@ -10,8 +10,15 @@ #import "RoomGuestDelegate.h" NS_ASSUME_NONNULL_BEGIN +typedef NS_ENUM(NSInteger, MSRoomMenuType) { + MSRoomMenuTypeGame, + MSRoomMenuTypeLittleGame, +}; + + @interface MSRoomMenuGameVC : MvpViewController -- (instancetype)initWithDelegate:(id)delegate; +- (instancetype)initWithDelegate:(id)delegate roomMenuType:(MSRoomMenuType)type; +//- (instancetype)initWithDelegate:(id)delegate; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameVC.m b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameVC.m index 4bf2fdc3..325b47e2 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameVC.m +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameVC.m @@ -15,8 +15,13 @@ #import "XPRoomViewController.h" #import "MSRoomGameWebVC.h" #import "XPRoomAnimationView.h" + +#import "Api+LittleGame.h" +#import "Api+RoomSetting.h" + @interface MSRoomMenuGameVC () @property(nonatomic,strong) MSRoomMenuGameView *gameView; +@property(nonatomic, assign) MSRoomMenuType type; ///host 代理 @property (nonatomic,weak) idhostDelegate; @end @@ -25,6 +30,7 @@ -(void)dealloc{ } + - (instancetype)initWithDelegate:(id)delegate{ self = [super init]; if(self){ @@ -32,6 +38,17 @@ } return self; } + +- (instancetype)initWithDelegate:(id)delegate + roomMenuType:(MSRoomMenuType)type { + self = [super init]; + if(self){ + self.type = type; + self.hostDelegate = delegate; + } + return self; +} + - (BOOL)isHiddenNavBar { return YES; } @@ -39,23 +56,57 @@ [super viewDidLoad]; [self installUI]; [self installConstraints]; - [self getGameData]; + [self loadMenuData]; } + +- (void)loadMenuData { + switch (self.type) { + case MSRoomMenuTypeGame: + [self getGameData]; + break; + case MSRoomMenuTypeLittleGame: + [self getLittleGameList]; + break; + default: + break; + } +} + -(void)getGameData{ - NSMutableArray *playList = [self.hostDelegate getPlayList]; - if(playList.count > 0){ - _gameView.playList = playList; - return; - } - NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; - [Api getPlayList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - NSArray * array = [ActivityInfoModel modelsWithArray:data.data]; + NSMutableArray *resourceList = [self.hostDelegate getPlayList]; + if(resourceList.count > 0){ + _gameView.playList = resourceList; + return; + } + + NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; + @kWeakify(self); + [Api getPlayList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + @kStrongify(self); + NSArray * array = [ActivityInfoModel modelsWithArray:data.data]; self.gameView.playList = [[NSMutableArray alloc]initWithArray:array]; - - } - } roomId:roomId]; + } + } roomId:roomId]; } + +- (void)getLittleGameList { + NSMutableArray *resourceList = [self.hostDelegate getLittleGameList]; + if(resourceList.count > 0){ + _gameView.littleGameList = resourceList; + return; + } + + @kWeakify(self); + [Api getLittleGameList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + @kStrongify(self); + NSArray * array = [LittleGameInfoModel modelsWithArray:data.data]; + self.gameView.littleGameList = array.mutableCopy; + } + }]; +} + -(void)installUI{ self.view.backgroundColor = [UIColor clearColor]; [self.view addSubview:self.gameView]; @@ -70,7 +121,62 @@ - (void)didClickBackBtnAction{ [self dismissViewControllerAnimated:YES completion:nil]; } --(void)ms_didSelectItemAtIndexPath:(ActivityInfoModel *)model{ + +-(void)ms_didSelectLittleGameItemAtIndexPath:(LittleGameInfoModel *)model { + if (self.hostDelegate.isManagerOrOwner) { + @kWeakify(self); + [TTPopup alertWithMessage:@"确认开启游戏?" confirmHandler:^{ + @kStrongify(self); + [self startLittleGameWith:model]; + } cancelHandler:^{}]; + } else { + [XNDJTDDLoadingTool showErrorWithMessage:@"无权发起该游戏,请联系房主或管理员~"]; + } +} + +- (void)startLittleGameWith:(LittleGameInfoModel *)model { + RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; + NSMutableDictionary * params = [NSMutableDictionary dictionary]; + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * ticket = [AccountInfoStorage instance].getTicket; + [params setObject:ticket forKey:@"ticket"]; + [params setObject:uid forKey:@"uid"]; + [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"]; + if (roomInfo.title.length > 0) { + [params setObject:roomInfo.title forKey:@"title"]; + } + + if (roomInfo.roomPwd.length > 0) { + [params setObject:roomInfo.roomPwd forKey:@"roomPwd"]; + } else{ + [params setObject:@"" forKey:@"roomPwd"]; + } + + if (roomInfo.tagId > 0) { + [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"]; + } + if ([model.mgId isEqualToString:@"0"]) { + [params setObject:@(RoomType_Game) forKey:@"type"]; + [params setObject:@"0" forKey:@"mgId"]; + } else { + [params setObject:@(RoomType_MiniGame) forKey:@"type"]; + [params setObject:model.mgId forKey:@"mgId"]; + } + [params setObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"]; + + @kWeakify(self); + [Api ownerUpdateRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + @kStrongify(self); + [self dismissViewControllerAnimated:YES completion:nil]; + if (code == 200) { + + } else { + [XNDJTDDLoadingTool showErrorWithMessage:msg]; + } + } params:params]; +} + +-(void)ms_didSelectItemAtIndexPath:(ActivityInfoModel *)model { self.gameView.hidden = YES; if ([model.code isEqualToString:@"FIND_LOVE"]) { [self lookLoveTapRecognizer]; @@ -88,9 +194,7 @@ [fairyVC.navigationController setNavigationBarHidden:YES animated:NO]; [vc.view addSubview:fairyVC.view]; [UIView animateWithDuration:0.2 animations:^{ - fairyVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight); - }completion:^(BOOL finished) { }]; @@ -128,10 +232,9 @@ [self.hostDelegate.getSuperView addSubview:vc.view]; [self.hostDelegate.getSuperView bringSubviewToFront:animationView]; } - } + - (void)lookLoveTapRecognizer { - if ([self.hostDelegate isKindOfClass:[XPRoomViewController class]]){ XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate]; candyTreeVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight); @@ -145,14 +248,14 @@ }]; } - - } + - (void)sailTapRecognizer { NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid]; [self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil]; } + #pragma mark - 懒加载 - (MSRoomMenuGameView *)gameView{ if(!_gameView){ diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameView.h b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameView.h index ea5cda01..f177c203 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameView.h +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameView.h @@ -7,17 +7,20 @@ #import #import "ActivityInfoModel.h" +#import "LittleGameInfoModel.h" NS_ASSUME_NONNULL_BEGIN @protocol MSRoomMenuGameViewDelegate -(void)didClickBackBtnAction; +-(void)ms_didSelectLittleGameItemAtIndexPath:(LittleGameInfoModel *)model; -(void)ms_didSelectItemAtIndexPath:(ActivityInfoModel *)model; @end @interface MSRoomMenuGameView : UIView @property(nonatomic,strong) NSMutableArray *playList; +@property(nonatomic,strong) NSMutableArray *littleGameList; @property(nonatomic,weak) iddelegate; @end diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameView.m b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameView.m index 12494fbb..bffdbe4e 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameView.m +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameView.m @@ -7,7 +7,11 @@ #import "MSRoomMenuGameView.h" #import "MSRoomMenuGameCell.h" +#import "XNDJTDDLoadingTool.h" #import "MSRoomMenuGameEmptyCell.h" + +static const NSInteger kItemsPerRow = 5; + @interface MSRoomMenuGameView() @property(nonatomic,strong) UIButton *backBtn; @property(nonatomic,strong) UIView *ms_bgView; @@ -35,8 +39,8 @@ }]; [self.ms_bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.leading.trailing.equalTo(self).inset(kGetScaleWidth(0)); - make.height.mas_equalTo(kGetScaleWidth(247)); - + make.height.mas_equalTo(kGetScaleWidth(246)); + }]; [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.ms_bgView); @@ -49,40 +53,71 @@ } -(void)setPlayList:(NSMutableArray *)playList{ _playList = playList; - if(_playList.count < 6 && _playList.count > 0){ - [self.ms_bgView mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(kGetScaleWidth(130)); - - }]; - } + [self updateViewHeightWithItemCount:playList.count]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.collectionView reloadData]; - }); + }); } + +- (void)setLittleGameList:(NSMutableArray *)littleGameList { + _littleGameList = littleGameList; + [self updateViewHeightWithItemCount:littleGameList.count]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.collectionView reloadData]; + }); +} + +- (void)updateViewHeightWithItemCount:(NSInteger)count { +// 调整这里,确认间距 + NSInteger lineNum = (count + kItemsPerRow - 1)/kItemsPerRow; + CGFloat height = 20 + 56 * lineNum + 44 * (lineNum - 1) + 70; + [self.ms_bgView mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(kGetScaleWidth(height)); + }]; +} + +- (NSInteger)countOfCurrentType { + return self.littleGameList.count > 0 ? self.littleGameList.count : self.playList.count; +} + #pragma mark- UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ CGFloat width = (KScreenWidth-kGetScaleWidth(6))/5; - return self.playList.count > 0 ? CGSizeMake(width, kGetScaleWidth(100)): CGSizeMake(KScreenWidth, kGetScaleWidth(200)); + return [self countOfCurrentType] > 0 ? CGSizeMake(width, kGetScaleWidth(100)): CGSizeMake(KScreenWidth, kGetScaleWidth(200)); } - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ - return self.playList.count > 0 ? UIEdgeInsetsMake(0, kGetScaleWidth(3), 0, kGetScaleWidth(3)): UIEdgeInsetsMake(0, 0, 0, 0); + return [self countOfCurrentType] > 0 ? UIEdgeInsetsMake(0, kGetScaleWidth(3), 0, kGetScaleWidth(3)): UIEdgeInsetsMake(0, 0, 0, 0); } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ - return self.playList.count > 0 ? self.playList.count : 1; + return [self countOfCurrentType] > 0 ? [self countOfCurrentType] : 1; } - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ - if (self.playList.count == 0){ + if ([self countOfCurrentType] == 0){ MSRoomMenuGameEmptyCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([MSRoomMenuGameEmptyCell class]) forIndexPath:indexPath]; return cell; } MSRoomMenuGameCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([MSRoomMenuGameCell class]) forIndexPath:indexPath]; - cell.model = [self.playList safeObjectAtIndex1:indexPath.row]; + if (_littleGameList.count > 0){ + cell.littleGameModel = [self.littleGameList safeObjectAtIndex1:indexPath.row]; + } else { + cell.model = [self.playList safeObjectAtIndex1:indexPath.row]; + } + return cell; } -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ - if (self.delegate && [self.delegate respondsToSelector:@selector(ms_didSelectItemAtIndexPath:)]){ - [self.delegate ms_didSelectItemAtIndexPath:[self.playList safeObjectAtIndex1:indexPath.row]]; + if (self.delegate) { + if (self.littleGameList != nil && + self.littleGameList.count > 0 && + [self.delegate respondsToSelector:@selector(ms_didSelectLittleGameItemAtIndexPath:)]) { + [self.delegate ms_didSelectLittleGameItemAtIndexPath:[self.littleGameList safeObjectAtIndex1:indexPath.row]]; + } + else if (self.playList != nil && + self.playList.count > 0 && + [self.delegate respondsToSelector:@selector(ms_didSelectItemAtIndexPath:)]) { + [self.delegate ms_didSelectItemAtIndexPath:[self.playList safeObjectAtIndex1:indexPath.row]]; + } } } #pragma mark - 懒加载 @@ -104,8 +139,7 @@ - (UICollectionView *)collectionView{ if (!_collectionView) { MSBaseRTLFlowLayout *layout = [[MSBaseRTLFlowLayout alloc] init]; - - + layout.minimumLineSpacing = 0; layout.minimumInteritemSpacing = 0; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.m b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.m index 757281d7..4cba71a0 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.m +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.m @@ -200,7 +200,7 @@ break; case MSRoomMenuItemType_Game: { - MSRoomMenuGameVC *vc = [[MSRoomMenuGameVC alloc]initWithDelegate:self.delegate]; + MSRoomMenuGameVC *vc = [[MSRoomMenuGameVC alloc]initWithDelegate:self.delegate roomMenuType:MSRoomMenuTypeGame]; vc.modalPresentationStyle = UIModalPresentationOverFullScreen; [self.delegate.getCurrentNav presentViewController:vc animated:YES completion:nil]; break; @@ -375,7 +375,7 @@ - (void)onRoomUpdate { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; - UserInfoModel * userInfo = self.delegate.getUserInfo; +// UserInfoModel * userInfo = self.delegate.getUserInfo; // if (userInfo.isFirstCharge) { // [self.giftButton setImage:[UIImage getLanguageImage:@"room_menu_gift_first_recharge"] forState:UIControlStateNormal]; diff --git a/YuMi/Modules/YMRoom/View/RoomHostDelegate.h b/YuMi/Modules/YMRoom/View/RoomHostDelegate.h index d5d01366..c8bf65d7 100644 --- a/YuMi/Modules/YMRoom/View/RoomHostDelegate.h +++ b/YuMi/Modules/YMRoom/View/RoomHostDelegate.h @@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN - (RoomInfoModel*)getRoomInfo; - (UserInfoModel*)getUserInfo; +- (BOOL)isManagerOrOwner; - (void)exitRoom; - (void)miniRoom; - (UINavigationController *)getCurrentNav; @@ -40,7 +41,13 @@ NS_ASSUME_NONNULL_BEGIN -(BOOL)getIsMiniEnter; ///屏蔽 -(void)requesstShieldingAction; --(NSMutableArray *)getPlayList;; + +///获取活动列表 +-(NSMutableArray *)getPlayList; + +///获取小游戏列表 +-(NSMutableArray *)getLittleGameList; + -(NSInteger)getPublicScreenType; @end diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m index a7cbf2c0..c31377af 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m @@ -202,7 +202,7 @@ return itemCell; } - XPGiftItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class]) forIndexPath:indexPath]; + XPGiftItemCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class]) forIndexPath:indexPath]; cell.usingplaceType = self.usingplaceType; cell.curUserNobleLevel = self.curUserNobleLevel; diff --git a/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.h b/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.h index 85d6ad56..9cdcca5e 100644 --- a/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.h +++ b/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol PIRoomEnterRedPacketViewDelegate --(void)openRedPacketWtihModel:(XPRedPacketModel *_Nullable)redModel; +-(void)openRedPacketWithModel:(XPRedPacketModel *_Nullable)redModel; @end diff --git a/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.m b/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.m index 710203b6..ed862337 100644 --- a/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.m +++ b/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.m @@ -203,8 +203,8 @@ self.redPacketModel = self.redPacketList.firstObject; self.hidden = NO; self.pi_redNum = @(self.redPacketList.count).stringValue; - if(self.delegate && [self.delegate respondsToSelector:@selector(openRedPacketWtihModel:)]){ - [self.delegate openRedPacketWtihModel:self.redPacketModel]; + if(self.delegate && [self.delegate respondsToSelector:@selector(openRedPacketWithModelopenRedPacketWithModelopenRedPacketWithModel:)]){ + [self.delegate openRedPacketWithModel:self.redPacketModel]; } return; } @@ -226,8 +226,8 @@ } [self.redPacketList replaceObjectAtIndex:[self.redPacketList indexOfObject:self.redPacketModel] withObject:redModel]; self.redPacketModel = redModel; - if(self.delegate && [self.delegate respondsToSelector:@selector(openRedPacketWtihModel:)]){ - [self.delegate openRedPacketWtihModel:self.redPacketModel]; + if(self.delegate && [self.delegate respondsToSelector:@selector(openRedPacketWithModelopenRedPacketWithModelopenRedPacketWithModel:)]){ + [self.delegate openRedPacketWithModel:self.redPacketModel]; } } } redEnvelopeId:self.redPacketModel.redEnvelopeId]; diff --git a/YuMi/Modules/YMRoom/View/StageView/AnchorPKStageView.m b/YuMi/Modules/YMRoom/View/StageView/AnchorPKStageView.m index 7e2f6e22..add3ad1b 100644 --- a/YuMi/Modules/YMRoom/View/StageView/AnchorPKStageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/AnchorPKStageView.m @@ -94,7 +94,7 @@ return self; } -- (NSInteger)countOfMircoView { +- (NSInteger)countOfMicroView { return 2; } diff --git a/YuMi/Modules/YMRoom/View/StageView/AnchorStageView.m b/YuMi/Modules/YMRoom/View/StageView/AnchorStageView.m index 20883ceb..11f7e24f 100644 --- a/YuMi/Modules/YMRoom/View/StageView/AnchorStageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/AnchorStageView.m @@ -41,7 +41,7 @@ @implementation AnchorStageView -- (NSInteger)countOfMircoView { +- (NSInteger)countOfMicroView { return 4; } diff --git a/YuMi/Modules/YMRoom/View/StageView/DatingStageView.m b/YuMi/Modules/YMRoom/View/StageView/DatingStageView.m index 5fa5073d..c8219403 100644 --- a/YuMi/Modules/YMRoom/View/StageView/DatingStageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/DatingStageView.m @@ -70,7 +70,7 @@ return self; } -- (NSInteger)countOfMircoView { +- (NSInteger)countOfMicroView { return 10; } diff --git a/YuMi/Modules/YMRoom/View/StageView/LittleGameScrollStageView.m b/YuMi/Modules/YMRoom/View/StageView/LittleGameScrollStageView.m index 06c6f36e..8302ab02 100644 --- a/YuMi/Modules/YMRoom/View/StageView/LittleGameScrollStageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/LittleGameScrollStageView.m @@ -26,7 +26,7 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; @interface LittleGameScrollStageView () -@property (nonatomic, strong) UIScrollView *scrolView; +@property (nonatomic, strong) UIScrollView *scrollView; @end @@ -37,50 +37,70 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (instancetype)initWithDelegate:(id)delegate { - if (self = [super initWithDelegate:delegate]) { - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeViewState:) name:kRoomRoomLittleGameMiniStageNotificationKey object:nil]; - NSInteger microCount = self.countOfMircoView; - for (UIView *microView in self.subviews) { - [microView removeFromSuperview]; +- (void)setupObserver { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeViewState:) name:kRoomRoomLittleGameMiniStageNotificationKey object:nil]; +} + +- (CGFloat)widthOfMic { + return 70; +} + +- (CGFloat)spaceOfMic { + return 16; + // 下面的方法是用来适配屏幕的计算,不滚动,全部在屏幕内显示 +// return (KScreenWidth - mcWidth * [self countOfMicroView] - paddingH * 2) / ([self countOfMicroView] - 1); +} + +- (void)setupMicroScrollView { + NSInteger microCount = self.countOfMicroView; + for (UIView *microView in self.subviews) { + [microView removeFromSuperview]; + } + [self addSubview:self.scrollView]; + [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self); + }]; + + CGFloat spaceWidth = [self spaceOfMic]; + self.scrollView.contentSize = CGSizeMake((microCount - 1) * spaceWidth + paddingH * 2 + mcWidth * microCount, mcHeight); + for (int i = 0; i < microCount; i++) { + UIView* microView = [self microViewForIndex:i]; + if (microView) { + microView.tag = i; + microView.frame = [self rectForViewAtIndex:i]; + [self.scrollView addSubview:microView]; } - [self addSubview:self.scrolView]; - [self.scrolView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self); - }]; - CGFloat spaceWidth = (KScreenWidth - mcWidth * 6 - paddingH * 2) / 5; - self.scrolView.contentSize = CGSizeMake((microCount - 1) * spaceWidth + paddingH * 2 + mcWidth * microCount, mcHeight); - for (int i = 0; i < microCount; i++) { - UIView* microView = [self microViewForIndex:i]; - if (microView) { - microView.tag = i; - microView.frame = [self rectForViewAtIndex:i]; - [self.scrolView addSubview:microView]; + } + if (isMSRTL()) { + self.scrollView.transform = CGAffineTransformMakeRotation(M_PI); + NSArray *subViews = self.scrollView.subviews; + for (UIView *subView in subViews) { + if ([subView isKindOfClass:[LittleGameMicroView class]]) { + subView.transform = CGAffineTransformMakeRotation(M_PI); } } - if (isMSRTL()) { - self.scrolView.transform = CGAffineTransformMakeRotation(M_PI); - NSArray *subViews = self.scrolView.subviews; - for (UIView *subView in subViews) { - if ([subView isKindOfClass:[LittleGameMicroView class]]) { - subView.transform = CGAffineTransformMakeRotation(M_PI); - } - } - }else{ - self.scrolView.transform = CGAffineTransformIdentity; - NSArray *subViews = self.scrolView.subviews; - for (UIView *subView in subViews) { - if ([subView isKindOfClass:[LittleGameMicroView class]]) { - subView.transform = CGAffineTransformIdentity; - } - } + }else{ + self.scrollView.transform = CGAffineTransformIdentity; + NSArray *subViews = self.scrollView.subviews; + for (UIView *subView in subViews) { + if ([subView isKindOfClass:[LittleGameMicroView class]]) { + subView.transform = CGAffineTransformIdentity; + } } } +} + +- (instancetype)initWithDelegate:(id)delegate { + if (self = [super initWithDelegate:delegate]) { + + [self setupObserver]; + [self setupMicroScrollView]; + } return self; } -- (NSInteger)countOfMircoView { - return self.hostDelegate.getRoomInfo.mgMicNum ? self.hostDelegate.getRoomInfo.mgMicNum : 6; +- (NSInteger)countOfMicroView { + return 9; //self.hostDelegate.getRoomInfo.mgMicNum ? self.hostDelegate.getRoomInfo.mgMicNum : 6; } - (UIView *)microViewForIndex:(NSInteger)index { @@ -88,14 +108,11 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; if (microView) { return microView; } - return [[LittleGameMicroView alloc]init]; + return [[LittleGameMicroView alloc] init]; } -/** - ◯ ◯ ◯ ◯ ◯ ◯ - */ - (CGRect)rectForViewAtIndex:(NSInteger)index { - CGFloat spaceWidth = (KScreenWidth - mcWidth * 6 - paddingH * 2) / 5; + CGFloat spaceWidth = [self spaceOfMic]; return CGRectMake(paddingH + index * (mcWidth + spaceWidth), 0, mcWidth, mcHeight); } @@ -107,9 +124,9 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; - (CGPoint)animationPointAtStageViewByUid:(NSString *)uid { NSInteger index = [self getIndexByUid:uid]; CGPoint point = CGPointZero; - CGFloat spaceWidth = (KScreenWidth - mcWidth * 6 - paddingH * 2) / 5; + CGFloat spaceWidth = [self spaceOfMic]; point= CGPointMake(paddingH + index * (mcWidth + spaceWidth) + mcWidth / 2, mcHeight / 2 - 10); - point = [self.scrolView convertPoint:point toView:nil]; + point = [self.scrollView convertPoint:point toView:nil]; if (point.x > KScreenWidth) { point = CGPointZero; } @@ -128,21 +145,20 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; [super didSelectAtIndex:index]; } - #pragma mark - 通知 - (void)changeViewState:(NSNotification *)notification { NSDictionary * dic = notification.object; self.hidden = [[dic objectForKey:@"isMini"] boolValue]; } -- (UIScrollView *)scrolView { - if (!_scrolView) { - _scrolView = [[UIScrollView alloc] init]; - _scrolView.scrollEnabled = YES; - _scrolView.showsHorizontalScrollIndicator = NO; - _scrolView.clipsToBounds = NO; +- (UIScrollView *)scrollView { + if (!_scrollView) { + _scrollView = [[UIScrollView alloc] init]; + _scrollView.scrollEnabled = YES; + _scrollView.showsHorizontalScrollIndicator = NO; + _scrollView.clipsToBounds = NO; } - return _scrolView; + return _scrollView; } diff --git a/YuMi/Modules/YMRoom/View/StageView/LittleGameStageView.m b/YuMi/Modules/YMRoom/View/StageView/LittleGameStageView.m index 4542c3f2..90752a25 100644 --- a/YuMi/Modules/YMRoom/View/StageView/LittleGameStageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/LittleGameStageView.m @@ -41,7 +41,7 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey; return self; } -- (NSInteger)countOfMircoView { +- (NSInteger)countOfMicroView { return 6; } diff --git a/YuMi/Modules/YMRoom/View/StageView/SocialStageView.m b/YuMi/Modules/YMRoom/View/StageView/SocialStageView.m index f0e19ab0..3c814ab1 100644 --- a/YuMi/Modules/YMRoom/View/StageView/SocialStageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/SocialStageView.m @@ -35,7 +35,7 @@ @implementation SocialStageView -- (NSInteger)countOfMircoView { +- (NSInteger)countOfMicroView { return 9; } diff --git a/YuMi/Modules/YMRoom/View/StageView/StageView.h b/YuMi/Modules/YMRoom/View/StageView/StageView.h index 7ce872dd..29981a4d 100644 --- a/YuMi/Modules/YMRoom/View/StageView/StageView.h +++ b/YuMi/Modules/YMRoom/View/StageView/StageView.h @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN /** * 坑位数目 */ -- (NSInteger)countOfMircoView; +- (NSInteger)countOfMicroView; /** * 坑位区域的高度(宽度默认屏幕宽度) */ diff --git a/YuMi/Modules/YMRoom/View/StageView/StageView.m b/YuMi/Modules/YMRoom/View/StageView/StageView.m index df37221c..5a3fadd7 100644 --- a/YuMi/Modules/YMRoom/View/StageView/StageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/StageView.m @@ -87,7 +87,7 @@ } } - NSInteger microCount = self.countOfMircoView; + NSInteger microCount = self.countOfMicroView; for (int i = 0; i < microCount; i++) { UIView* microView = [self microViewForIndex:i]; if (microView) { @@ -267,7 +267,7 @@ RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; BOOL leaveMode = roomInfo.leaveMode; NSMutableArray *statisMicArray = [NSMutableArray array]; - for (int i = 0; i < self.countOfMircoView; i++) { + for (int i = 0; i < self.countOfMicroView; i++) { MicroQueueModel * model = [self.micQueue objectForKey:[self indexToPosition:i]]; UIView * view = [self findMicroViewByIndex:i]; @@ -445,7 +445,7 @@ - (void)onRoomUpdate { self.isMiniEnter = NO; RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; - for (int i = 0; i < self.countOfMircoView; i++) { + for (int i = 0; i < self.countOfMicroView; i++) { UIView * view = [self findMicroViewByIndex:i]; [view showGiftValueMode:roomInfo.showGiftValue]; if(roomInfo.showGiftValue == NO){ @@ -453,7 +453,7 @@ } } if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_Blind && self.hostDelegate.getRoomInfo.blindDateState == RoomPlayDateingType_Pick) { - for (int i = 0; i < self.countOfMircoView; i++) { + for (int i = 0; i < self.countOfMicroView; i++) { MicroQueueModel * model = [self.micQueue objectForKey:[self indexToPosition:i]]; UIView * view = [self findMicroViewByIndex:i]; [view configRoomInfo:roomInfo]; @@ -565,7 +565,7 @@ } } if(userInfo.isNoProhibitMic == YES){ - for (int i = 0; i < self.countOfMircoView; i++) { + for (int i = 0; i < self.countOfMicroView; i++) { UIView * view = [self findMicroViewByIndex:i]; [view configPkBtn:userInfo]; } @@ -918,7 +918,7 @@ }]; } -- (NSInteger)countOfMircoView { +- (NSInteger)countOfMicroView { return 0; } @@ -961,7 +961,7 @@ } - (UIView *)findMicroViewByUid:(NSString *)uid { - for (int i = 0; i < self.countOfMircoView; i++) { + for (int i = 0; i < self.countOfMicroView; i++) { MicroQueueModel* model = [self.micQueue objectForKey:[self indexToPosition:i]]; if (model.userInfo && model.userInfo.uid == uid.intValue) { return [self findMicroViewByIndex:i]; @@ -1009,7 +1009,7 @@ - (NSMutableArray *)microViews { if (!_microViews) { - _microViews = [NSMutableArray arrayWithCapacity:self.countOfMircoView]; + _microViews = [NSMutableArray arrayWithCapacity:self.countOfMicroView]; } return _microViews; } @@ -1017,7 +1017,7 @@ - (NSMutableDictionary *)micQueue { if (!_micQueue) { _micQueue= [NSMutableDictionary dictionary]; - for (int i = 0; i < self.countOfMircoView; i++) { + for (int i = 0; i < self.countOfMicroView; i++) { NSString* position = [self indexToPosition:i]; MicroQueueModel *micSequence = [[MicroQueueModel alloc]init]; micSequence.userInfo = nil; diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 543697c8..6c4a01f4 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -62,6 +62,7 @@ #import "XPWebViewController.h" #import "SessionViewController.h" #import "XPFreeGiftsObtainView.h" +#import "MSRoomMenuGameVC.h" ///P #import "XPRoomPresenter.h" @@ -162,6 +163,9 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 @property(nonatomic,assign) BOOL isShowRedPacket; @property(nonatomic,copy) NSString *releaseCoins; @property(nonatomic,copy) NSString *myCoins; + +@property(nonatomic,strong) UIButton *exitGameButton; + @end @implementation XPRoomViewController @@ -290,6 +294,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self exitOldRoom]; [self initSubViews]; [self initSubViewConstraints]; + [self handleActivityContainerViewEvents]; + if (self.isMiniEnter) { [XNDJTDDLoadingTool showAnchorLoading:self.navigationController.view]; [self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid]; @@ -416,29 +422,6 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self.view addSubview:self.roomHeaderView]; [self.view addSubview:self.functionView]; [self.view addSubview:self.animationView]; - - @kWeakify(self); - self.activityContainerView.openRedPacketHandle = ^(XPRedPacketModel * _Nullable redModel,RoomType type,BOOL isChangeRoom) { - @kStrongify(self); - if(isChangeRoom == YES){ - self.redPacketView.type = type; - self.redPacketView.redPacketList = self.activityContainerView.redPacketList; - return; - } - - XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - view.delegate = self; - self.isShowRedPacket = YES; - view.receiveModel = redModel; - for (UIView *subView in self.view.subviews) { - if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { - view.alphaView.backgroundColor = [UIColor clearColor]; - break; - } - } - [self.view addSubview:view]; - [self.view bringSubviewToFront:view]; - }; } - (void)initSubViewConstraints { @@ -543,12 +526,36 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 make.width.mas_equalTo(87); }]; - [self.functionView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self.anchorScrollView.middleImageView); }]; } +- (void)handleActivityContainerViewEvents { + @kWeakify(self); + self.activityContainerView.openRedPacketHandle = ^(XPRedPacketModel * _Nullable redModel,RoomType type,BOOL isChangeRoom) { + @kStrongify(self); + if(isChangeRoom == YES){ + self.redPacketView.type = type; + self.redPacketView.redPacketList = self.activityContainerView.redPacketList; + return; + } + + XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + view.delegate = self; + self.isShowRedPacket = YES; + view.receiveModel = redModel; + for (UIView *subView in self.view.subviews) { + if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { + view.alphaView.backgroundColor = [UIColor clearColor]; + break; + } + } + [self.view addSubview:view]; + [self.view bringSubviewToFront:view]; + }; +} + - (void)exitOldRoom { NSString * roomUid = [NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.uid]; if (roomUid.integerValue > 0 && roomUid.integerValue != self.roomUid.integerValue) { @@ -612,15 +619,9 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 self.stageView = [[AnchorStageView alloc] initWithDelegate:self]; } }else if(self.roomInfo.type == RoomType_MiniGame) { - if (self.roomInfo.mgMicNum > 6 && ![self.stageView isKindOfClass:[LittleGameScrollStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[LittleGameScrollStageView alloc] initWithDelegate:self]; - } else if (self.roomInfo.mgMicNum <= 6 && ![self.stageView isKindOfClass:[LittleGameStageView class]]) { - [self.stageView removeFromSuperview]; - self.stageView = nil; - self.stageView = [[LittleGameStageView alloc] initWithDelegate:self]; - } + [self.stageView removeFromSuperview]; + self.stageView = nil; + self.stageView = [[LittleGameScrollStageView alloc] initWithDelegate:self]; }else if(self.roomInfo.hadChangeRoomType && ![self.stageView isKindOfClass:[SocialStageView class]]) { [self.stageView removeFromSuperview]; self.stageView = nil; @@ -628,13 +629,13 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } else { return; } - - + if (!self.stageView.superview) { [self.view insertSubview:self.stageView belowSubview:self.roomHeaderView]; } - - + + [self addExitGameButton]; + if (self.roomInfo.type == RoomType_MiniGame) { [self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) { make.leading.trailing.mas_equalTo(self.view); @@ -740,15 +741,97 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 make.bottom.mas_equalTo(self.quickMessageContainerView.mas_top).mas_offset(-5); make.width.mas_equalTo(87); }]; - } + +- (void)setRoomInfo:(RoomInfoModel *)roomInfo { + if (_roomInfo == roomInfo) { + return; + } + _roomInfo = roomInfo; + [self.activityContainerView updateView]; +} + +#pragma mark - Game Switch +- (void)addExitGameButton { + [self removeExitGameButton]; + + if (self.roomInfo.type != RoomType_MiniGame) { + return; + } + + if (_exitGameButton == nil) { + _exitGameButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_exitGameButton setTitle:@"切换" forState:UIControlStateNormal]; + [_exitGameButton setImage:[UIImage imageNamed:@"ms_room_game_switch_button"] forState:UIControlStateNormal]; + [_exitGameButton addTarget:self action:@selector(didTapExitGameButton) forControlEvents:UIControlEventTouchUpInside]; + } + [self.view addSubview:self.exitGameButton]; + [self.exitGameButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.stageView.mas_bottom).offset(10); + make.left.mas_equalTo(self.view).offset(12); + make.width.height.equalTo(@21); + }]; +} + +- (void)removeExitGameButton { + [self.exitGameButton removeFromSuperview]; +} + +- (void)didTapExitGameButton { + if ([self.littleGameView isInSudGame]) { + [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomFunctionContainerView19")]; + } else { + @kWeakify(self); + [TTPopup alertWithMessage:YMLocalizedString(@"XPRoomFunctionContainerView20") confirmHandler:^{ + @kStrongify(self); + [XNDJTDDLoadingTool showLoading]; + [self exitLittleGame]; + } cancelHandler:^{ }]; + } +} + +- (void)exitLittleGame { + RoomInfoModel * roomInfo = self.getRoomInfo; + NSMutableDictionary * params = [NSMutableDictionary dictionary]; + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * ticket = [AccountInfoStorage instance].getTicket; + [params setObject:ticket forKey:@"ticket"]; + [params setObject:uid forKey:@"uid"]; + [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"]; + if (roomInfo.title.length > 0) { + [params setObject:roomInfo.title forKey:@"title"]; + } + + if (roomInfo.roomPwd.length > 0) { + [params setObject:roomInfo.roomPwd forKey:@"roomPwd"]; + } else{ + [params setObject:@"" forKey:@"roomPwd"]; + } + + if (roomInfo.tagId > 0) { + [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"]; + } + + [params setObject:@(RoomType_Game) forKey:@"type"]; + [params setObject:@"0" forKey:@"mgId"]; + [params setObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"]; + + [Api ownerUpdateRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + [XNDJTDDLoadingTool hideHUD]; + } else { + [XNDJTDDLoadingTool showErrorWithMessage:msg]; + } + } params:params]; +} + #pragma mark- XPReceiveRedPacketViewDelegate - (void)closeViewAction{ self.isShowRedPacket = NO; } #pragma mark- PIRoomEnterRedPacketViewDelegate -- (void)openRedPacketWtihModel:(XPRedPacketModel *)redModel{ +- (void)openRedPacketWithModel:(XPRedPacketModel *)redModel{ XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; view.receiveModel = redModel; view.delegate = self; @@ -1027,14 +1110,11 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 self.roomInfo = roomInfo; self.userInfo = userInfo; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ //获取一下红包信息 [self.presenter getRedPacket:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; }); - - - + if (roomInfo.type == RoomType_Anchor) {//个播房,获取下一个房间 [self handleInitAnchorRoom]; [self showAnchorScrollTipView]; @@ -1878,10 +1958,20 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 - (UserInfoModel *)getUserInfo { return self.userInfo; } + +- (BOOL)isManagerOrOwner { + return self.roomUid.integerValue == self.userInfo.uid || + [self.superMangerList filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"uid == %d", self.userInfo.uid]] > 0; +} + -(NSMutableArray *)getPlayList{ return self.activityContainerView.playList; } +-(NSMutableArray *)getLittleGameList { + return self.activityContainerView.littleGameList; +} + - (void)exitRoom { [self.stageView exitRoom]; [self.menuContainerView menuResignFirstResponder]; @@ -2296,7 +2386,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 - (XPRoomActivityContainerView *)activityContainerView { if (!_activityContainerView) { - _activityContainerView = [[XPRoomActivityContainerView alloc] initWithdelegate:self]; + _activityContainerView = [[XPRoomActivityContainerView alloc] initWithDelegate:self]; } return _activityContainerView; @@ -2311,7 +2401,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 - (XPRoomFunctionContainerView *)functionView { if (!_functionView) { - _functionView = [[XPRoomFunctionContainerView alloc] initWithdelegate:self]; + _functionView = [[XPRoomFunctionContainerView alloc] initWithDelegate:self]; } return _functionView; } diff --git a/YuMi/ar.lproj/Localizable.strings b/YuMi/ar.lproj/Localizable.strings index db6b2081..6eff6076 100644 --- a/YuMi/ar.lproj/Localizable.strings +++ b/YuMi/ar.lproj/Localizable.strings @@ -1723,6 +1723,8 @@ ineHeadView12" = "الحمل"; "XPRoomFunctionContainerView12" = "لم يتم تحديد موضوع بعد"; "XPRoomFunctionContainerView13" = "ابدأ الاختيار>"; "XPRoomFunctionContainerView18" = "غير مسموح بتغيير اللعبة أو وضع اللعبة وأنت في اللعبة!"; +"XPRoomFunctionContainerView19" = "اللعبة جارية ولا يمكن إيقافها!"; +"XPRoomFunctionContainerView20" = "هل أنت متأكد من التبديل إلى غرفة مشتركة؟"; "XPRoomBackContainerView0" = "فشل تحميل صورة الخلفية الخاصة بالVIP"; "XPRoomBackContainerView1" = "فشل تحميل صورة الخلفية الخاصة بالمشغل"; diff --git a/YuMi/en.lproj/Localizable.strings b/YuMi/en.lproj/Localizable.strings index 460d7e23..fc9c9423 100644 --- a/YuMi/en.lproj/Localizable.strings +++ b/YuMi/en.lproj/Localizable.strings @@ -1465,6 +1465,8 @@ "XPRoomFunctionContainerView12" = "Topic not set"; "XPRoomFunctionContainerView13" = "Start Selection>"; "XPRoomFunctionContainerView18" = "Cannot switch games or gameplay during the game!"; +"XPRoomFunctionContainerView19" = "The game is in progress and cannot be stopped!"; +"XPRoomFunctionContainerView20" = "Are you sure you want to switch to a normal room?"; "XPRoomBackContainerView0" = "Exclusive background image for VIP failed to load"; "XPRoomBackContainerView1" = "Personal broadcast background image failed to load"; diff --git a/YuMi/zh-Hans.lproj/Localizable.strings b/YuMi/zh-Hans.lproj/Localizable.strings index 64ed0643..3ae5fee1 100644 --- a/YuMi/zh-Hans.lproj/Localizable.strings +++ b/YuMi/zh-Hans.lproj/Localizable.strings @@ -1076,6 +1076,8 @@ "XPRoomFunctionContainerView12" = "暂未设置话题"; "XPRoomFunctionContainerView13" = "开始选择>"; "XPRoomFunctionContainerView18" = "游戏中不可切换游戏或玩法!"; +"XPRoomFunctionContainerView19" = "游戏进行中,不可中止!"; +"XPRoomFunctionContainerView20" = "確認切換成普通房嗎?"; "XPRoomBackContainerView0" = "VIP专属背景图加载失败"; "XPRoomBackContainerView1" = "个播背景图加载失败"; diff --git a/YuMi/zh-Hant.lproj/Localizable.strings b/YuMi/zh-Hant.lproj/Localizable.strings index e1b4dc7b..c114bce1 100644 --- a/YuMi/zh-Hant.lproj/Localizable.strings +++ b/YuMi/zh-Hant.lproj/Localizable.strings @@ -1079,6 +1079,8 @@ "XPRoomFunctionContainerView12" = "暫未設置話題"; "XPRoomFunctionContainerView13" = "開始選擇>"; "XPRoomFunctionContainerView18" = "遊戲中不可切換遊戲或玩法!"; +"XPRoomFunctionContainerView19" = "遊戲進行中,不可中止!"; +"XPRoomFunctionContainerView20" = "确认切换成普通房吗?"; "XPRoomBackContainerView0" = "VIP專屬背景圖加載失敗"; "XPRoomBackContainerView1" = "個播背景圖加載失敗";