个播PK入口状态调整,异常结束弹窗逻辑处理

This commit is contained in:
chenguilong
2022-04-18 18:12:57 +08:00
parent ab14c922bc
commit 4c56587ca8
12 changed files with 174 additions and 55 deletions

View File

@@ -115,6 +115,7 @@
9B060B5827BCAEE20001B767 /* AnchorGiftValueView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */; };
9B0997A127F19D8A00EB8F14 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 9B0997A027F19D8900EB8F14 /* README.md */; };
9B0997A327F19DE500EB8F14 /* QGHWDShaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9B0997A227F19DE500EB8F14 /* QGHWDShaders.metal */; };
9B0AABDE280D4CD20025269D /* anchorPK_vs.svga in Resources */ = {isa = PBXBuildFile; fileRef = 9B0AABDD280D4CD20025269D /* anchorPK_vs.svga */; };
9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; };
9B16A34827E17D9B00E13A98 /* XPRoomTrumpetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B16A34727E17D9B00E13A98 /* XPRoomTrumpetViewController.m */; };
9B16A34B27E1915A00E13A98 /* XPTrumpetPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B16A34A27E1915A00E13A98 /* XPTrumpetPresenter.m */; };
@@ -845,6 +846,7 @@
9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorGiftValueView.m; sourceTree = "<group>"; };
9B0997A027F19D8900EB8F14 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
9B0997A227F19DE500EB8F14 /* QGHWDShaders.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; name = QGHWDShaders.metal; path = Pods/QGVAPlayer/iOS/QGVAPlayer/QGVAPlayer/Shaders/QGHWDShaders.metal; sourceTree = SOURCE_ROOT; };
9B0AABDD280D4CD20025269D /* anchorPK_vs.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = anchorPK_vs.svga; sourceTree = "<group>"; };
9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = "<group>"; };
9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = "<group>"; };
9B16A34627E17D9B00E13A98 /* XPRoomTrumpetViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomTrumpetViewController.h; sourceTree = "<group>"; };
@@ -4441,6 +4443,7 @@
E8A1E45C276220B100B294CA /* Sources */ = {
isa = PBXGroup;
children = (
9B0AABDD280D4CD20025269D /* anchorPK_vs.svga */,
E88863C2278E7BCC004BCFAB /* crossRoomPk_progress.svga */,
9B85F34F2806A34B006EDF51 /* anchorPK_progress.svga */,
E8937ABF276C3ECF00B2C7E1 /* enterroom */,
@@ -5324,6 +5327,7 @@
186A52E726FC559700D67B2C /* yw_1222_0769.jpg in Resources */,
E8937ACB276C3EDE00B2C7E1 /* svga_member_in_lv60.svga in Resources */,
186A52E326FC559200D67B2C /* RPSDK.bundle in Resources */,
9B0AABDE280D4CD20025269D /* anchorPK_vs.svga in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -7,6 +7,7 @@
#import "NSObject+MJExtension.h"
#import "XPEnum.h"
#import "AcrossRoomPKPanelModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, RoomType) {
@@ -60,6 +61,8 @@ typedef NS_ENUM(NSInteger, RoomDatingStateChangeType) {
@property(nonatomic, copy) NSString *openBoxIcon;
@end
@class AcrossRoomPKPanelModel;
@interface RoomInfoModel : NSObject
@property (nonatomic , copy) NSString * nick;
@property (nonatomic , assign) NSInteger uid;
@@ -128,6 +131,10 @@ typedef NS_ENUM(NSInteger, RoomDatingStateChangeType) {
@property (nonatomic, copy) NSString *mgName;
///pk场次id(本地字段)
@property (nonatomic, assign) NSInteger roundId;
//PK进行状态(1pk中 2惩罚中
@property (nonatomic, assign) AcrossRoomPkStateType pkState;
///个播PK赢方uid
@property (nonatomic, copy) NSString *winUid;
///PK中的对方UID(本地字段)
@property (nonatomic, copy) NSString *pkUid;
///PK中的对方房间roomId(本地字段)

View File

@@ -17,6 +17,7 @@ typedef NS_ENUM(NSUInteger, AcrossRoomPkType) {
typedef NS_ENUM(NSUInteger, AcrossRoomPkStateType) {
AcrossRoomPkStateTypePking = 1,//PK中
AcrossRoomPkStateTypePenalty, //惩罚阶段
AcrossRoomPkStateTypePenaltyEnd,//惩罚结束
};
@class AcrossRoomPkRankModel;

View File

@@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)xPAnchorPKPanelView:(XPAnchorPkPanelView *)view onlookRoom:(NSString *)roomUid;
///关注房主成功
- (void)xPAnchorPKPanelViewAttentionSuccess;
///惩罚时间倒计时结束
- (void)xPAnchorPKPanelViewPenaltyCountDownEnd;
@end

View File

@@ -129,14 +129,14 @@
[self.progressView addSubview:self.progressContentView];
[self.progressContentView addSubview:self.redCountImageView];
[self.progressContentView addSubview:self.blueCountImageView];
[self.progressContentView addSubview:self.redStarImageView];
[self.progressContentView addSubview:self.blueStarImageView];
[self.progressContentView addSubview:self.svgDisplayView];
///
[self.backImageView addSubview:self.redContributeStackView];
[self.backImageView addSubview:self.blueContributeStackView];
[self.progressContentView addSubview:self.redCountLabel];
[self.progressContentView addSubview:self.blueCountLabel];
[self.backImageView addSubview:self.redStarImageView];
[self.backImageView addSubview:self.blueStarImageView];
[self addSubview:self.redResultImageView];
[self addSubview:self.otherAvatarImageView];
@@ -198,7 +198,7 @@
[self.redStarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.backImageView).mas_offset(15);
make.left.mas_equalTo(-30);
make.left.mas_equalTo(self.backImageView.mas_left).mas_offset(-30);
make.width.height.mas_equalTo(26);
}];
[self.blueStarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -317,6 +317,9 @@
self.timeLabel.text = @"结果计算中";
} else {
self.timeLabel.text = @"00:00";
if (self.delegate && [self.delegate respondsToSelector:@selector(xPAnchorPKPanelViewPenaltyCountDownEnd)]) {
[self.delegate xPAnchorPKPanelViewPenaltyCountDownEnd];
}
}
});
} else {
@@ -476,9 +479,14 @@
if (_pkPanelInfo.aPercent > 1) {
_pkPanelInfo.aPercent = 1;
}
CGFloat width = 305;
CGFloat width = 305 * _pkPanelInfo.aPercent;
if (width <= 6.5) {
width = 6.5;
} else if (width >= 305 - 5.5) {
width = 305 - 5.5;
}
[self.blueCountImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width * _pkPanelInfo.aPercent);
make.width.mas_equalTo(width);
}];
self.otherAvatarImageView.imageUrl = pkPanelInfo.aAvatar;
self.otherNickLabel.text = pkPanelInfo.aTitle;

View File

@@ -179,8 +179,6 @@
[self receiveBroadcastGift:attachment];
} else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Noble_LevelUp_Suspend) {///
[self receiveNobleLevelUp:attachment];
} else if (attachment.first == CustomMessageType_Anchor_Hour_Rank && attachment.second == Custom_Message_Sub_Anchor_Hour_Rank) {///
[self receiveAnchorHourRank:attachment];
}
}
}
@@ -221,6 +219,8 @@
[self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_Across_Room_PK && attachment.second == Custom_Message_Sub_AnchorPK_Result) {//PK
[self acrossRoomPKBannerAnimation:attachment];
} else if (attachment.first == CustomMessageType_Anchor_Hour_Rank && attachment.second == Custom_Message_Sub_Anchor_Hour_Rank) {///
[self receiveAnchorHourRank:attachment];
}
}
}

View File

@@ -329,9 +329,7 @@
[Api getAcrossRoomPKDetail:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:data.data];
self.delegate.getRoomInfo.roundId = acrossPKPanelInfo.roundId;
self.delegate.getRoomInfo.pkUid = acrossPKPanelInfo.aUid;
self.delegate.getRoomInfo.pkRoomId = acrossPKPanelInfo.aRoomId;
[self updateAnchorPkInfo:acrossPKPanelInfo];
if (acrossPKPanelInfo.pkType == AcrossRoomPkTypeAnchor) {
if (acrossPKPanelInfo.aUid.integerValue > 0) {
if (!self.anchorPKPanelView.superview) {
@@ -547,7 +545,7 @@
});
AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:attachment.data];
[[RtcManager instance] connectOtherRoom:acrossPKPanelInfo.aRoomId userId:acrossPKPanelInfo.aUid];
self.delegate.getRoomInfo.roundId = acrossPKPanelInfo.roundId;
[self updateAnchorPkInfo:acrossPKPanelInfo];
}
}
}];
@@ -589,7 +587,7 @@
}
AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:attachment.data];
self.anchorPKPanelView.pkPanelInfo = acrossPKPanelInfo;
self.delegate.getRoomInfo.roundId = acrossPKPanelInfo.roundId;
[self updateAnchorPkInfo:acrossPKPanelInfo];
}
break;
case Custom_Message_Sub_AnchorPK_End://PK
@@ -603,9 +601,16 @@
}
AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:attachment.data];
self.anchorPKPanelView.pkPanelInfo = acrossPKPanelInfo;
XPAnchorPKResultView *view = [[XPAnchorPKResultView alloc] initWithFrame:CGRectMake(0, 0, 300, 472)];
view.data = acrossPKPanelInfo;
[TTPopup popupView:view style:TTPopupStyleAlert];
[self updateAnchorPkInfo:acrossPKPanelInfo];
if (acrossPKPanelInfo.isForce) {
XPAnchorPKFinishView *view = [[XPAnchorPKFinishView alloc] init];
view.data = acrossPKPanelInfo;
[TTPopup popupView:view style:TTPopupStyleAlert];
} else {
XPAnchorPKResultView *view = [[XPAnchorPKResultView alloc] initWithFrame:CGRectMake(0, 0, 300, 472)];
view.data = acrossPKPanelInfo;
[TTPopup popupView:view style:TTPopupStyleAlert];
}
}
break;
case Custom_Message_Sub_AnchorPK_Finish://PK
@@ -613,11 +618,8 @@
[self.anchorPKPanelView resetAcrossPKViewData];
[self.anchorPKPanelView removeFromSuperview];
self.anchorPKPanelView = nil;
[self resetAnchorPkInfo];
[[RtcManager instance] disconnectOtherRoom];
AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:attachment.data];
XPAnchorPKFinishView *view = [[XPAnchorPKFinishView alloc] init];
view.data = acrossPKPanelInfo;
[TTPopup popupView:view style:TTPopupStyleAlert];
}
break;
default:
@@ -766,6 +768,10 @@
}
}
- (void)xPAnchorPKPanelViewPenaltyCountDownEnd {
self.delegate.getRoomInfo.pkState = AcrossRoomPkStateTypePenaltyEnd;
}
#pragma mark - Event Response
- (void)contributionButtonAction:(UIButton *)sender {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid];
@@ -1037,6 +1043,22 @@
}
}
- (void)updateAnchorPkInfo:(AcrossRoomPKPanelModel *)acrossPKPanelInfo {
self.delegate.getRoomInfo.roundId = acrossPKPanelInfo.roundId;
self.delegate.getRoomInfo.pkUid = acrossPKPanelInfo.aUid;
self.delegate.getRoomInfo.pkRoomId = acrossPKPanelInfo.aRoomId;
self.delegate.getRoomInfo.pkState = acrossPKPanelInfo.pkState;
self.delegate.getRoomInfo.winUid = acrossPKPanelInfo.winUid;
}
- (void)resetAnchorPkInfo {
self.delegate.getRoomInfo.roundId = nil;
self.delegate.getRoomInfo.pkUid = nil;
self.delegate.getRoomInfo.pkRoomId = nil;
self.delegate.getRoomInfo.pkState = nil;
self.delegate.getRoomInfo.winUid = nil;
}
#pragma mark - XPRoomLittleGameListViewDelegate
- (void)xPRoomLittleGameListView:(XPLittleGameRoomListView *)view didSelectItem:(LittleGameInfoModel *)itemInfo {
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;

View File

@@ -52,6 +52,17 @@
anchorRoomPK.imageName = roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode ? @"room_more_menu_anchorPK_close" : @"room_more_menu_anchorPK_open";
anchorRoomPK.type = roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode ? RoomMoreMenuType_Room_Anchor_PK_Close : RoomMoreMenuType_Room_Anchor_PK_Open;
anchorRoomPK.titleColor = roomInfo.isCloseScreen ? nil : [ThemeColor roomMoreMenuTextColor];
if (roomInfo.pkState == AcrossRoomPkStateTypePenalty) {
if ([roomInfo.winUid isEqualToString:[AccountInfoStorage instance].getUid]) {
anchorRoomPK.title = @"结束PK";
} else if ([roomInfo.winUid isEqualToString:roomInfo.pkUid]) {
anchorRoomPK.title = @"主播PK中";
} else {
anchorRoomPK.title = @"结束PK";
}
} else if (roomInfo.pkState == AcrossRoomPkStateTypePenaltyEnd) {
anchorRoomPK.title = @"结束PK";
}
XPRoomMoreItemModel * messageScreen = [[XPRoomMoreItemModel alloc] init];
messageScreen.title = roomInfo.isCloseScreen ? @"开启公屏" : @"关闭公屏";

View File

@@ -12,6 +12,7 @@
#import "XPMacro.h"
#import "TTPopup.h"
#import "XPConstant.h"
#import "AccountInfoStorage.h"
///Model
#import "XPRoomMoreItemModel.h"
#import "RoomInfoModel.h"
@@ -312,9 +313,24 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
break;
case RoomMoreMenuType_Room_Anchor_PK_Close:
{
if (self.roomInfo.roundId) {
[self.presenter requestFinishAnchorPK:[NSString stringWithFormat:@"%ld", self.roomInfo.roundId]];
if (self.roomInfo.pkState == AcrossRoomPkStateTypePenalty) {
if ([self.roomInfo.winUid isEqualToString:[AccountInfoStorage instance].getUid]) {//
if (self.roomInfo.roundId) {
[self.presenter requestFinishAnchorPK:[NSString stringWithFormat:@"%ld", self.roomInfo.roundId]];
}
} else if ([self.roomInfo.winUid isEqualToString:self.roomInfo.pkUid]) {//
} else {//
if (self.roomInfo.roundId) {
[self.presenter requestFinishAnchorPK:[NSString stringWithFormat:@"%ld", self.roomInfo.roundId]];
}
}
} else {
if (self.roomInfo.roundId) {
[self.presenter requestFinishAnchorPK:[NSString stringWithFormat:@"%ld", self.roomInfo.roundId]];
}
}
}
break;

View File

@@ -9,6 +9,7 @@
///Third
#import <Masonry/Masonry.h>
#import <NIMSDK/NIMSDK.h>
#import <SVGA.h>
///Tool
#import "AccountInfoStorage.h"
#import "XPMacro.h"
@@ -52,20 +53,23 @@
@interface AnchorPKStageView()<RtcDelegate>
///vs
@property (nonatomic, strong) UIImageView *vsImageView;
///
@property (nonatomic, strong) UIButton *ruleButton;
///
@property (strong, nonatomic) SVGAParser *parser;
///
@property (nonatomic, strong) SVGAImageView *svgDisplayView;
@end
@implementation AnchorPKStageView
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
if (self = [super initWithDelegate:delegate]) {
[self addSubview:self.vsImageView];
[self addSubview:self.svgDisplayView];
[self addSubview:self.ruleButton];
[self.vsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.svgDisplayView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(64);
make.height.mas_equalTo(74);
make.centerX.mas_equalTo(self);
@@ -75,7 +79,16 @@
make.width.mas_equalTo(46);
make.height.mas_equalTo(18);
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.vsImageView.mas_bottom).mas_offset(7);
make.top.mas_equalTo(self.svgDisplayView.mas_bottom).mas_offset(7);
}];
[self.parser parseWithNamed:@"anchorPK_vs" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
self.svgDisplayView.loops = INT_MAX;
self.svgDisplayView.clearsAfterStop = NO;
self.svgDisplayView.videoItem = videoItem;
[self.svgDisplayView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
}];
}
return self;
@@ -258,37 +271,10 @@
#pragma mark - RtcDelegate -
- (void)usersSpeaking:(NSMutableArray *)uids {
if ([RtcManager instance].isRemoteMuted) {
return;
}
for (NSString* uid in uids) {
if ([RtcManager instance].isLocalMuted && uid.integerValue == self.hostDelegate.getUserInfo.uid) {
continue;
}
UIView<MicroViewProtocol>* microView = [self findMicroViewByUid:uid];
if (microView) {
[microView userSpeaking];
} else {
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
if ([uid isEqualToString:roomInfo.pkUid]) {
UIView<MicroViewProtocol>* microView = [self findMicroViewByIndex:1];
if (microView) {
[microView userSpeaking];
}
}
}
}
return;
}
#pragma mark - getter
- (UIImageView *)vsImageView {
if (!_vsImageView) {
_vsImageView = [[UIImageView alloc] init];
_vsImageView.image = [UIImage imageNamed:@"anchorPk_panel_vs"];
}
return _vsImageView;
}
- (UIButton *)ruleButton {
if (!_ruleButton) {
_ruleButton = [[UIButton alloc] init];
@@ -301,4 +287,21 @@
return _ruleButton;
}
- (SVGAImageView *)svgDisplayView {
if (_svgDisplayView == nil) {
_svgDisplayView = [[SVGAImageView alloc]init];
_svgDisplayView.contentMode = UIViewContentModeScaleToFill;
_svgDisplayView.userInteractionEnabled = NO;
_svgDisplayView.backgroundColor = [UIColor clearColor];
}
return _svgDisplayView;
}
- (SVGAParser *)parser {
if (!_parser) {
_parser = [[SVGAParser alloc]init];
}
return _parser;
}
@end

View File

@@ -6,12 +6,18 @@
//
#import "AnchorPKMicroView.h"
///Third
#import <Masonry/Masonry.h>
#import <SVGA.h>
#import "SVGAParserManager.h"
#import <ReactiveObjC/ReactiveObjC.h>
@interface AnchorPKMicroView ()
///
@property (nonatomic, strong) SVGAImageView *svgDisplayView;
@property (nonatomic, strong) SVGAParserManager *parserManager;
///
@property (nonatomic, assign) NSInteger position;
@@ -21,10 +27,15 @@
- (void)initSubViews {
[super initSubViews];
[self insertSubview:self.svgDisplayView belowSubview:self.avatarImageView];
}
- (void)initSubViewConstraints {
[super initSubViewConstraints];
[self.svgDisplayView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(85 * 1.5);
make.center.equalTo(self.avatarImageView);
}];
}
#pragma mark - MicroViewProtocol
@@ -83,6 +94,21 @@
[self.stackView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarImageView.mas_bottom).mas_offset(17);
}];
///
self.svgDisplayView.hidden = NO;
@weakify(self);
NSString *bgString = [[NSBundle mainBundle] pathForResource:@"anchor_room_speak" ofType:@"svga"];
NSURL *bgUrl = [NSURL fileURLWithPath:bgString];
[self.parserManager loadSvgaWithURL:bgUrl completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
@strongify(self);
self.svgDisplayView.loops = INT_MAX;
self.svgDisplayView.clearsAfterStop = NO;
self.svgDisplayView.videoItem = videoItem;
[self.svgDisplayView startAnimation];
} failureBlock:^(NSError * _Nullable error) {
}];
}
- (void)configUser:(UserInfoModel *)userInfo {
@@ -90,4 +116,23 @@
self.sexImageView.hidden = YES;
}
#pragma mark - getter
- (SVGAParserManager *)parserManager {
if (!_parserManager) {
_parserManager = [[SVGAParserManager alloc]init];
}
return _parserManager;
}
- (SVGAImageView *)svgDisplayView {
if (_svgDisplayView == nil) {
_svgDisplayView = [[SVGAImageView alloc]init];
_svgDisplayView.contentMode = UIViewContentModeScaleToFill;
_svgDisplayView.userInteractionEnabled = NO;
_svgDisplayView.frame = CGRectMake(0, 0, 384, 384);
_svgDisplayView.hidden = YES;
_svgDisplayView.backgroundColor = [UIColor clearColor];
}
return _svgDisplayView;
}
@end

Binary file not shown.