房间游戏

This commit is contained in:
liyuhua
2024-05-31 19:56:25 +08:00
parent a58cee448b
commit 37e7dbf183
58 changed files with 1401 additions and 913 deletions

View File

@@ -289,6 +289,8 @@
237701122BCF742C00D661F1 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 237701112BCF742C00D661F1 /* libz.tbd */; }; 237701122BCF742C00D661F1 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 237701112BCF742C00D661F1 /* libz.tbd */; };
237701192BD6143700D661F1 /* pi_happy_egg_smash.svga in Resources */ = {isa = PBXBuildFile; fileRef = 237701182BD6143700D661F1 /* pi_happy_egg_smash.svga */; }; 237701192BD6143700D661F1 /* pi_happy_egg_smash.svga in Resources */ = {isa = PBXBuildFile; fileRef = 237701182BD6143700D661F1 /* pi_happy_egg_smash.svga */; };
237852A12C072D8D00E360AC /* MSRoomGameModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A02C072D8D00E360AC /* MSRoomGameModel.m */; }; 237852A12C072D8D00E360AC /* MSRoomGameModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A02C072D8D00E360AC /* MSRoomGameModel.m */; };
237852A42C082A9800E360AC /* MSRoomGameSendTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A32C082A9800E360AC /* MSRoomGameSendTextView.m */; };
237852A72C08764B00E360AC /* MSRoomGameResultsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237852A62C08764B00E360AC /* MSRoomGameResultsModel.m */; };
237B94BC2A984DA7007853E3 /* XPTrumpetPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */; }; 237B94BC2A984DA7007853E3 /* XPTrumpetPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */; };
237B94BD2A984DA7007853E3 /* XPNobleTrumpetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B32A984DA7007853E3 /* XPNobleTrumpetModel.m */; }; 237B94BD2A984DA7007853E3 /* XPNobleTrumpetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B32A984DA7007853E3 /* XPNobleTrumpetModel.m */; };
237B94BE2A984DA7007853E3 /* XPRoomTrumpetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B72A984DA7007853E3 /* XPRoomTrumpetViewController.m */; }; 237B94BE2A984DA7007853E3 /* XPRoomTrumpetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 237B94B72A984DA7007853E3 /* XPRoomTrumpetViewController.m */; };
@@ -2110,6 +2112,10 @@
237701182BD6143700D661F1 /* pi_happy_egg_smash.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_happy_egg_smash.svga; sourceTree = "<group>"; }; 237701182BD6143700D661F1 /* pi_happy_egg_smash.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_happy_egg_smash.svga; sourceTree = "<group>"; };
2378529F2C072D8D00E360AC /* MSRoomGameModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSRoomGameModel.h; sourceTree = "<group>"; }; 2378529F2C072D8D00E360AC /* MSRoomGameModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSRoomGameModel.h; sourceTree = "<group>"; };
237852A02C072D8D00E360AC /* MSRoomGameModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRoomGameModel.m; sourceTree = "<group>"; }; 237852A02C072D8D00E360AC /* MSRoomGameModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRoomGameModel.m; sourceTree = "<group>"; };
237852A22C082A9800E360AC /* MSRoomGameSendTextView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSRoomGameSendTextView.h; sourceTree = "<group>"; };
237852A32C082A9800E360AC /* MSRoomGameSendTextView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRoomGameSendTextView.m; sourceTree = "<group>"; };
237852A52C08764B00E360AC /* MSRoomGameResultsModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSRoomGameResultsModel.h; sourceTree = "<group>"; };
237852A62C08764B00E360AC /* MSRoomGameResultsModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSRoomGameResultsModel.m; sourceTree = "<group>"; };
237B94AD2A984DA7007853E3 /* XPTrumpetPresenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPTrumpetPresenter.h; sourceTree = "<group>"; }; 237B94AD2A984DA7007853E3 /* XPTrumpetPresenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPTrumpetPresenter.h; sourceTree = "<group>"; };
237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPTrumpetPresenter.m; sourceTree = "<group>"; }; 237B94AE2A984DA7007853E3 /* XPTrumpetPresenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPTrumpetPresenter.m; sourceTree = "<group>"; };
237B94B02A984DA7007853E3 /* XPRoomTrumpetProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPRoomTrumpetProtocol.h; sourceTree = "<group>"; }; 237B94B02A984DA7007853E3 /* XPRoomTrumpetProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPRoomTrumpetProtocol.h; sourceTree = "<group>"; };
@@ -6063,6 +6069,8 @@
239D0FD72C047DD8002977CE /* MSTabbarRoomGameModel.m */, 239D0FD72C047DD8002977CE /* MSTabbarRoomGameModel.m */,
2378529F2C072D8D00E360AC /* MSRoomGameModel.h */, 2378529F2C072D8D00E360AC /* MSRoomGameModel.h */,
237852A02C072D8D00E360AC /* MSRoomGameModel.m */, 237852A02C072D8D00E360AC /* MSRoomGameModel.m */,
237852A52C08764B00E360AC /* MSRoomGameResultsModel.h */,
237852A62C08764B00E360AC /* MSRoomGameResultsModel.m */,
); );
path = Model; path = Model;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -6118,6 +6126,8 @@
239D0FF62C05BD2A002977CE /* MSRoomGameVictoryView.m */, 239D0FF62C05BD2A002977CE /* MSRoomGameVictoryView.m */,
239D0FFB2C05D086002977CE /* MSRoomGameQuitGameView.h */, 239D0FFB2C05D086002977CE /* MSRoomGameQuitGameView.h */,
239D0FFC2C05D086002977CE /* MSRoomGameQuitGameView.m */, 239D0FFC2C05D086002977CE /* MSRoomGameQuitGameView.m */,
237852A22C082A9800E360AC /* MSRoomGameSendTextView.h */,
237852A32C082A9800E360AC /* MSRoomGameSendTextView.m */,
); );
path = SubView; path = SubView;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -11322,6 +11332,7 @@
E87A24F1272935920086A794 /* XPMessageRemoteExtModel.m in Sources */, E87A24F1272935920086A794 /* XPMessageRemoteExtModel.m in Sources */,
E8D34D5028080362009C4835 /* XPMineDataGiftTableViewCell.m in Sources */, E8D34D5028080362009C4835 /* XPMineDataGiftTableViewCell.m in Sources */,
E87C54BE2823CC5B0051AA11 /* XPMineResetLoginPwdPresenter.m in Sources */, E87C54BE2823CC5B0051AA11 /* XPMineResetLoginPwdPresenter.m in Sources */,
237852A42C082A9800E360AC /* MSRoomGameSendTextView.m in Sources */,
E85E7B322A4EB0D300B6D00A /* XPGuildAnchorIncomeSectionView.m in Sources */, E85E7B322A4EB0D300B6D00A /* XPGuildAnchorIncomeSectionView.m in Sources */,
E87C0AA027D9DE6400CB2241 /* RoomFaceSendInfoModel.m in Sources */, E87C0AA027D9DE6400CB2241 /* RoomFaceSendInfoModel.m in Sources */,
1464C5F629A4CA8C00AF7C94 /* XPIAPRechargeCollectionViewCell.m in Sources */, 1464C5F629A4CA8C00AF7C94 /* XPIAPRechargeCollectionViewCell.m in Sources */,
@@ -12058,6 +12069,7 @@
239D0FDB2C047F24002977CE /* MSTabbarRoomGameCell.m in Sources */, 239D0FDB2C047F24002977CE /* MSTabbarRoomGameCell.m in Sources */,
239D0FB02BFD8C4D002977CE /* MSRoomSetingBackdropVC.m in Sources */, 239D0FB02BFD8C4D002977CE /* MSRoomSetingBackdropVC.m in Sources */,
235714982BEDF54E004C81D6 /* MsRoomMessageMainView.m in Sources */, 235714982BEDF54E004C81D6 /* MsRoomMessageMainView.m in Sources */,
237852A72C08764B00E360AC /* MSRoomGameResultsModel.m in Sources */,
9BE9F10227FEE5C200667200 /* XPAnchorFansTaskDetailModel.m in Sources */, 9BE9F10227FEE5C200667200 /* XPAnchorFansTaskDetailModel.m in Sources */,
E8E0DAE6285C280E00566A2F /* XPSessionFindNewAlertView.m in Sources */, E8E0DAE6285C280E00566A2F /* XPSessionFindNewAlertView.m in Sources */,
E85E7B1A2A4EB0D200B6D00A /* XPMineGoldIncomeRecordVC.m in Sources */, E85E7B1A2A4EB0D200B6D00A /* XPMineGoldIncomeRecordVC.m in Sources */,

View File

@@ -88,6 +88,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
} }
- (void)applicationDidBecomeActive:(UIApplication *)application { - (void)applicationDidBecomeActive:(UIApplication *)application {
[self getAdvertisingTrackingAuthority]; [self getAdvertisingTrackingAuthority];
[[NSNotificationCenter defaultCenter]postNotificationName:@"kAppDidBecomeActive" object:nil];
} }
- (void)getAdvertisingTrackingAuthority { - (void)getAdvertisingTrackingAuthority {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 902 B

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1013 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 647 B

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 B

After

Width:  |  Height:  |  Size: 773 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 557 B

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 945 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -22,7 +22,7 @@ NSString * const URLWithType(URLType type) {
@(kGoldEarningsRecord) : @"modules/myincome/index.html#/GoldLog",/// @(kGoldEarningsRecord) : @"modules/myincome/index.html#/GoldLog",///
@(kCandyTreeRuleURL) : @"modules/rule/newWishingWellRule.html",/// modules/rank/index.html#/wishingWellRule @(kCandyTreeRuleURL) : @"modules/rule/newWishingWellRule.html",/// modules/rank/index.html#/wishingWellRule
@(kChannelUrl) : @"modules/%@/index.html?channelType=%@&deviceId=%@", @(kChannelUrl) : @"modules/%@/index.html?channelType=%@&deviceId=%@",
@(kLUDOUrl) : @"molistar/modules/gameRank/index.html"///LUDO @(kLUDOUrl) : @"modules/gameRank/index.html"///LUDO
}; };
NSString * newUrl = [newDic objectForKey:@(type)]; NSString * newUrl = [newDic objectForKey:@(type)];
if(newUrl != nil){ if(newUrl != nil){

View File

@@ -671,7 +671,7 @@ typedef NS_ENUM(NSUInteger, CustomMessageTypeRoomGame) {
Custom_Message_Sub_Room_Game_Match_Success = 1091,//匹配成功 Custom_Message_Sub_Room_Game_Match_Success = 1091,//匹配成功
Custom_Message_Sub_Room_Game_Match_Fail = 1092,//匹配失败 Custom_Message_Sub_Room_Game_Match_Fail = 1092,//匹配失败
Custom_Message_Sub_Room_Game_Early_Exit = 1093,//提前退出游戏
}; };
///家族新协议 ///家族新协议

View File

@@ -90,7 +90,10 @@
_itemList = itemList; _itemList = itemList;
self.collectionView.scrollEnabled = _itemList.count > 2; self.collectionView.scrollEnabled = _itemList.count > 2;
self.collectionView.hidden = _itemList.count == 0; self.collectionView.hidden = _itemList.count == 0;
[self.collectionView reloadData]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.collectionView reloadData];
});
if (_itemList.count == 0){ if (_itemList.count == 0){
[self.collectionView mas_remakeConstraints:^(MASConstraintMaker *make) { [self.collectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(0); make.leading.mas_equalTo(0);

View File

@@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
+(void)startMatchGame:(HttpRequestHelperCompletion)completion roomId:(NSString *)roomId mgId:(NSString *)mgId gameMode:(NSString *)gameMode; +(void)startMatchGame:(HttpRequestHelperCompletion)completion roomId:(NSString *)roomId mgId:(NSString *)mgId gameMode:(NSString *)gameMode;
///得到房间详情 ///得到房间详情
+(void)getRoomGameDetails:(HttpRequestHelperCompletion)completion roomType:(NSString *)roomType; +(void)getRoomGameDetails:(HttpRequestHelperCompletion)completion roomType:(NSString *)roomType;
///退出房间
+(void)closeRoomGame:(HttpRequestHelperCompletion)completion roomId:(NSString *)roomId;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -20,4 +20,8 @@
+(void)getRoomGameDetails:(HttpRequestHelperCompletion)completion roomType:(NSString *)roomType{ +(void)getRoomGameDetails:(HttpRequestHelperCompletion)completion roomType:(NSString *)roomType{
[self makeRequest:@"chatRoom/getByType" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,roomType,nil]; [self makeRequest:@"chatRoom/getByType" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,roomType,nil];
} }
///退
+(void)closeRoomGame:(HttpRequestHelperCompletion)completion roomId:(NSString *)roomId{
[self makeRequest:@"miniGame/nav/close" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,roomId,nil];
}
@end @end

View File

@@ -48,6 +48,7 @@ typedef enum : NSUInteger {
@property(nonatomic,copy) NSArray *scores; @property(nonatomic,copy) NSArray *scores;
@property(nonatomic,copy) NSString *configJson; @property(nonatomic,copy) NSString *configJson;
@property(nonatomic,assign) MSRoomGameInfoModelType matchStatus; @property(nonatomic,assign) MSRoomGameInfoModelType matchStatus;
@property(nonatomic,copy) NSString *matchRoundId;

View File

@@ -0,0 +1,20 @@
//
// MSRoomGameResultsModel.h
// YuMi
//
// Created by duoban on 2024/5/30.
//
#import "PIBaseModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface MSRoomGameResultsModel : PIBaseModel
@property(nonatomic,assign) int rank;
@property(nonatomic,copy) NSString *uid;
@property(nonatomic,copy) NSString *avatar;
@property(nonatomic,copy) NSString *nick;
@property(nonatomic,strong) NSNumber *winNum;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// MSRoomGameResultsModel.m
// YuMi
//
// Created by duoban on 2024/5/30.
//
#import "MSRoomGameResultsModel.h"
@implementation MSRoomGameResultsModel
@end

View File

@@ -26,5 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic,copy) NSString *modeName; @property(nonatomic,copy) NSString *modeName;
@property(nonatomic,copy) NSString *ruleUrl; @property(nonatomic,copy) NSString *ruleUrl;
@property(nonatomic,copy) NSString *ticket; @property(nonatomic,copy) NSString *ticket;
@property(nonatomic,copy) NSString *roomId;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -20,6 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)enterNIMRoom:(NSString *)roomId user:(UserInfoModel *)userInfo; - (void)enterNIMRoom:(NSString *)roomId user:(UserInfoModel *)userInfo;
///退出房间 ///退出房间
- (void)exitNIMRoom:(NSString *)roomId; - (void)exitNIMRoom:(NSString *)roomId;
///退出房间
-(void)closeRoomGameWithRoomId:(NSString *)roomId;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -118,4 +118,10 @@
[[NIMSDK sharedSDK].chatroomManager exitChatroom:roomId completion:nil]; [[NIMSDK sharedSDK].chatroomManager exitChatroom:roomId completion:nil];
} }
///退
-(void)closeRoomGameWithRoomId:(NSString *)roomId{
[Api closeRoomGame:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
} roomId:roomId];
}
@end @end

View File

@@ -6,11 +6,11 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "MSRoomGameResultsModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface MSRoomGameVictoryCell : UITableViewCell @interface MSRoomGameVictoryCell : UITableViewCell
@property(nonatomic,strong) MSRoomGameResultsModel *resultsModel;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -80,6 +80,18 @@
make.trailing.equalTo(self.coinView.mas_leading).mas_offset(-kGetScaleWidth(5)); make.trailing.equalTo(self.coinView.mas_leading).mas_offset(-kGetScaleWidth(5));
}]; }];
} }
- (void)setResultsModel:(MSRoomGameResultsModel *)resultsModel{
_resultsModel = resultsModel;
_rankView.image = _resultsModel.rank == 1 ? kImage(@"ms_room_game_victory_rank_first"):kImage(@"ms_room_game_victory_rank_second");
_avatarView.image = nil;
[_avatarView loadImageWithUrl:_resultsModel.avatar completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
self.avatarView.image = image;
}];
_nameView.text = _resultsModel.nick;
_bgImageView.image = _resultsModel.rank == 1 ? kImage(@"ms_room_game_victory_bg_first"):kImage(@"ms_room_game_victory_bg_second");
_bgCoinView.image = _resultsModel.rank == 1 ? kImage(@"ms_room_game_victory_coin_bg_first"):kImage(@"ms_room_game_victory_coin_bg_second");
_coinNumView.text = _resultsModel.rank == 1 ? [NSString stringWithFormat:@"+%@",_resultsModel.winNum.stringValue]:_resultsModel.winNum.stringValue;
}
#pragma mark - #pragma mark -
- (UIImageView *)bgImageView{ - (UIImageView *)bgImageView{
if(!_bgImageView){ if(!_bgImageView){

View File

@@ -10,14 +10,19 @@
#import "MsRoomMessagChatHallView.h" #import "MsRoomMessagChatHallView.h"
#import "MSRoomGameMsgView.h" #import "MSRoomGameMsgView.h"
#import "MSRoomGameSendMsgView.h" #import "MSRoomGameSendMsgView.h"
#import "XPRoomLittleGameContainerView.h" #import <AFNetworkReachabilityManager.h>
#import "MSRoomGameVictoryView.h" #import "MSRoomGameVictoryView.h"
#import "MSRoomGameQuitGameView.h" #import "MSRoomGameQuitGameView.h"
#import "MSRoomGamePresenter.h" #import "MSRoomGamePresenter.h"
#import "MSRoomGameProtocol.h" #import "MSRoomGameProtocol.h"
#import <NIMSDK/NIMSDK.h> #import <NIMSDK/NIMSDK.h>
#import "AttachmentModel.h" #import "AttachmentModel.h"
@interface MSRoomGameVC ()<MSRoomGameHeadViewDelegate,MSRoomGameQuitGameViewDelegate,MSRoomGameVictoryViewDelegate,NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMLoginManagerDelegate> #import "MSRoomGameSendTextView.h"
#import "MSRoomGameView.h"
#import "MSRoomGameResultsModel.h"
#import "Api.h"
#import "XPIAPRechargeViewController.h"
@interface MSRoomGameVC ()<MSRoomGameHeadViewDelegate,MSRoomGameQuitGameViewDelegate,MSRoomGameVictoryViewDelegate,NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMLoginManagerDelegate,MSRoomGameSendMsgViewDelegate,MSRoomGameViewDelegate,XPIAPRechargeViewControllerDelegate>
@property(nonatomic,strong) UIImageView *bgImageView; @property(nonatomic,strong) UIImageView *bgImageView;
@property(nonatomic,strong) MSRoomGameHeadView *headView; @property(nonatomic,strong) MSRoomGameHeadView *headView;
@property(nonatomic,strong) MsRoomMessagChatHallView *chatView; @property(nonatomic,strong) MsRoomMessagChatHallView *chatView;
@@ -25,7 +30,9 @@
@property(nonatomic,copy) NSString *roomId; @property(nonatomic,copy) NSString *roomId;
@property(nonatomic,strong) MSRoomGameSendMsgView *sendMsgView; @property(nonatomic,strong) MSRoomGameSendMsgView *sendMsgView;
/// ///
@property (nonatomic,strong) XPRoomLittleGameContainerView *littleGameView; @property(nonatomic,strong) MSRoomGameView *roomGameView;
@property(nonatomic,strong) WalletInfoModel *coinModel;
@property(nonatomic,assign) BOOL isShowResults;
@end @end
@implementation MSRoomGameVC @implementation MSRoomGameVC
@@ -37,7 +44,7 @@
[[NIMSDK sharedSDK].chatManager removeDelegate:self]; [[NIMSDK sharedSDK].chatManager removeDelegate:self];
[[NIMSDK sharedSDK].loginManager removeDelegate:self]; [[NIMSDK sharedSDK].loginManager removeDelegate:self];
[[NIMSDK sharedSDK].conversationManager removeDelegate:self]; [[NIMSDK sharedSDK].conversationManager removeDelegate:self];
[[NSNotificationCenter defaultCenter]removeObserver:self];
} }
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
@@ -48,22 +55,32 @@
[[NIMSDK sharedSDK].chatManager addDelegate:self]; [[NIMSDK sharedSDK].chatManager addDelegate:self];
[[NIMSDK sharedSDK].loginManager addDelegate:self]; [[NIMSDK sharedSDK].loginManager addDelegate:self];
[[NIMSDK sharedSDK].conversationManager addDelegate:self]; [[NIMSDK sharedSDK].conversationManager addDelegate:self];
[self getCoinNum];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(appDidBecomeActive) name:@"kAppDidBecomeActive" object:nil];
[self networkReachability];
}
-(void)getCoinNum{
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
[Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
WalletInfoModel * model = [WalletInfoModel modelWithDictionary:data.data];
self.coinModel = model;
} uid:uid ticket:ticket];
} }
-(void)installUI{ -(void)installUI{
[self.view addSubview:self.bgImageView]; [self.view addSubview:self.bgImageView];
[self.view addSubview:self.littleGameView];
[self.view addSubview:self.headView]; [self.view addSubview:self.headView];
[self.view addSubview:self.msgView]; [self.view addSubview:self.msgView];
[self.view addSubview:self.sendMsgView]; [self.view addSubview:self.sendMsgView];
} }
-(void)installConstraints{ -(void)installConstraints{
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view); make.edges.equalTo(self.view);
}]; }];
[self.littleGameView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
[self.headView mas_makeConstraints:^(MASConstraintMaker *make) { [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(22)); make.top.mas_equalTo(kGetScaleWidth(22));
make.leading.trailing.equalTo(self.view).inset(kGetScaleWidth(0)); make.leading.trailing.equalTo(self.view).inset(kGetScaleWidth(0));
@@ -82,48 +99,153 @@
- (BOOL)isHiddenNavBar { - (BOOL)isHiddenNavBar {
return YES; return YES;
} }
-(void)appDidBecomeActive{
if(self.headView.roomGameModel.data.roundStatus == 0 && self.headView.roomGameModel.data.matchStatus == 1){
[self.presenter getRoomGameDetailWithRoomType:@"0"];
}
}
///
-(void)networkReachability{
@kWeakify(self);
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
@kStrongify(self);
switch (status) {
case AFNetworkReachabilityStatusUnknown:
break;
case AFNetworkReachabilityStatusNotReachable:
break;
case AFNetworkReachabilityStatusReachableViaWWAN:
case AFNetworkReachabilityStatusReachableViaWiFi:
{
if(self.headView.roomGameModel.data.roundStatus == 0 && self.headView.roomGameModel.data.matchStatus == 1){
[self.presenter getRoomGameDetailWithRoomType:@"0"];
}
}
break;
default:
break;
}
}];
}
#pragma mark -MSRoomGameViewDelegate
- (void)getGameRsultsWithList:(NSArray *)list{
if(self.isShowResults == YES)return;
self.isShowResults = YES;
MSRoomGameVictoryView *victoryView = [[MSRoomGameVictoryView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
for (MSRoomGameResultsModel *obj in list) {
if([obj.uid isEqualToString:self.headView.mineModel.uid]){
obj.avatar = self.headView.mineModel.avatar;
obj.nick = self.headView.mineModel.nick;
}
if([obj.uid isEqualToString:self.headView.rivalModel.uid]){
obj.avatar = self.headView.rivalModel.avatar;
obj.nick = self.headView.rivalModel.nick;
}
obj.winNum = obj.rank == 1 ? self.chooseGameModel.scores.firstObject : self.chooseGameModel.scores.lastObject;
}
victoryView.delegate = self;
victoryView.resultsList = list;
[TTPopup popupView:victoryView style:TTPopupStyleAlert];
[self.presenter exitNIMRoom:self.roomId];
[self.roomGameView handleSelfInExitEvent];
[self.roomGameView destroyMG];
self.roomGameView = nil;
[self.headView setDataInNull];
}
#pragma mark- MSRoomGameSendMsgViewDelegate
- (void)clickSendMsgAction{
MSRoomGameSendTextView *sendTextView = [[MSRoomGameSendTextView alloc]initWithRoomId:self.roomId userInfo:self.userinfo];
[self.view addSubview:sendTextView];
}
#pragma mark - MSRoomGameProtocol #pragma mark - MSRoomGameProtocol
-(void)getRoomGameDetailsSuccessWithModel:(MSRoomGameModel *)model{ -(void)getRoomGameDetailsSuccessWithModel:(MSRoomGameModel *)model{
self.headView.roomGameModel = model; self.headView.roomGameModel = model;
self.headView.userInfo = self.userinfo;
self.roomId = model.roomId; self.roomId = model.roomId;
[self.presenter enterNIMRoom:model.roomId user:self.userinfo]; [self.presenter enterNIMRoom:model.roomId user:self.userinfo];
if(model.data.matchStatus == MSRoomGameInfoModelMatchSuccessfully && model.data.roundStatus == 0){
self.roomGameView.gameModel = model;
if(self.roomGameView.superview == nil){
[self.bgImageView addSubview:self.roomGameView];
[self.roomGameView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.bgImageView);
}];
[self.roomGameView onRoomEntered];
}
}else{
[self.roomGameView handleSelfInExitEvent];
[self.roomGameView destroyMG];
self.roomGameView = nil;
[self.headView setDataInNull];
}
} }
#pragma mark -MSRoomGameVictoryViewDelegate #pragma mark -MSRoomGameVictoryViewDelegate
- (void)closeGameAction{ - (void)closeGameAction{
self.isShowResults = NO;
[self quitGameActionWtihIsColse:YES];
} }
-(void)rematchGameAction{ -(void)rematchGameAction{
self.isShowResults = NO;
if(self.coinModel.diamonds.integerValue < self.chooseGameModel.ticket.integerValue){
TTAlertConfig * config = [[TTAlertConfig alloc] init];
config.message = YMLocalizedString(@"XPTreasureFairyViewController5");
config.confirmButtonConfig.title = YMLocalizedString(@"XPTreasureFairyViewController6");
[TTPopup alertWithConfig:config confirmHandler:^{
XPIAPRechargeViewController * rechargeVC = [[XPIAPRechargeViewController alloc] init];
rechargeVC.delegate = self;
[self.navigationController pushViewController:rechargeVC animated:YES];
} cancelHandler:^{
}];
return;
}
[self.presenter startMatchGameWithroomId:@"" mgId:self.headView.roomGameModel.data.mgId gameMode:self.chooseGameModel.gameMode];
}
-(void)startMatchGameSuccess{
[self.presenter getRoomGameDetailWithRoomType:@"0"];
}
#pragma mark -XPIAPRechargeViewControllerDelegate
-(void)paySuccess{
[self getCoinNum];
} }
#pragma mark - MSRoomGameQuitGameViewDelegate #pragma mark - MSRoomGameQuitGameViewDelegate
- (void)quitGameAction{ - (void)quitGameAction{
[self quitGameActionWtihIsColse:YES];
}
-(void)quitGameActionWtihIsColse:(BOOL)isColse{
self.isShowResults = YES;
if(isColse == YES){
[self.presenter closeRoomGameWithRoomId:self.roomId];
}
[self.presenter exitNIMRoom:self.roomId];
[self.roomGameView handleSelfInExitEvent];
[self.roomGameView destroyMG];
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
} }
#pragma mark -MSRoomGameHeadViewDelegate #pragma mark -MSRoomGameHeadViewDelegate
- (void)clickQuitGameAction{ - (void)clickQuitGameAction{
MSRoomGameQuitGameView *quitGameView = [[MSRoomGameQuitGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; MSRoomGameQuitGameView *quitGameView = [[MSRoomGameQuitGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
quitGameView.delegate = self; quitGameView.delegate = self;
[TTPopup popupView:quitGameView style:TTPopupStyleAlert]; [TTPopup popupView:quitGameView style:TTPopupStyleAlert];
// MSRoomGameVictoryView *victoryView = [[MSRoomGameVictoryView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
// victoryView.delegate = self;
// [TTPopup popupView:victoryView style:TTPopupStyleAlert];
} }
#pragma mark - NIMChatManagerDelegate #pragma mark - NIMChatManagerDelegate
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages { - (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
for (NIMMessage * message in messages) { for (NIMMessage * message in messages) {
// //
if (message.session.sessionType != NIMSessionTypeChatroom) { if (message.session.sessionType != NIMSessionTypeChatroom) {
continue; continue;
} }
if(![message.session.sessionId isEqualToString:self.roomId]){ if(![message.session.sessionId isEqualToString:self.roomId]){
continue; continue;
} }
if (message.messageType == NIMMessageTypeNotification) { if (message.messageType == NIMMessageTypeNotification) {
@@ -146,16 +268,44 @@
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel * attachment = (AttachmentModel *)obj.attachment; AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
if(attachment.first == CustomMessageType_Chat_Room_Game && attachment.second == Custom_Message_Sub_Room_Game_Match_Success){ if(attachment.first == CustomMessageType_Chat_Room_Game && attachment.second == Custom_Message_Sub_Room_Game_Match_Success){
[self.presenter exitNIMRoom:self.roomId];
MSRoomGameModel *model = [MSRoomGameModel modelWithJSON:attachment.data]; MSRoomGameModel *model = [MSRoomGameModel modelWithJSON:attachment.data];
[self.presenter exitNIMRoom:self.roomId];
self.roomId = model.roomId; self.roomId = model.roomId;
self.headView.roomGameModel = model; self.headView.roomGameModel = model;
[self.presenter enterNIMRoom:model.roomId user:self.userinfo];
[self.presenter enterNIMRoom:model.roomId user:self.userinfo];
self.roomGameView.gameModel = model;
if(self.roomGameView.superview == nil){
[self.bgImageView addSubview:self.roomGameView];
[self.roomGameView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.bgImageView);
}];
[self.roomGameView onRoomEntered];
}
}if(attachment.first == CustomMessageType_Chat_Room_Game && attachment.second == Custom_Message_Sub_Room_Game_Match_Fail){ }if(attachment.first == CustomMessageType_Chat_Room_Game && attachment.second == Custom_Message_Sub_Room_Game_Match_Fail){
MSRoomGameQuitGameView *quitGameView = [[MSRoomGameQuitGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
quitGameView.delegate = self;
quitGameView.isNormalFail = YES;
[TTPopup popupView:quitGameView style:TTPopupStyleAlert];
}if(attachment.first == CustomMessageType_Chat_Room_Game && attachment.second == Custom_Message_Sub_Room_Game_Early_Exit){
if(self.isShowResults == YES)return;
self.isShowResults = YES;
NSArray *list = [MSRoomGameResultsModel modelsWithArray:attachment.data[@"results"]];
MSRoomGameVictoryView *victoryView = [[MSRoomGameVictoryView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
victoryView.delegate = self;
victoryView.resultsList = list;
[TTPopup popupView:victoryView style:TTPopupStyleAlert];
[self.presenter exitNIMRoom:self.roomId]; [self.presenter exitNIMRoom:self.roomId];
[self showErrorToast:YMLocalizedString(@"MSRoomGameVC0")]; [self.roomGameView handleSelfInExitEvent];
[self dismissViewControllerAnimated:YES completion:nil]; [self.roomGameView destroyMG];
self.roomGameView = nil;
[self.headView setDataInNull];
} }
} }
@@ -168,7 +318,7 @@
// //
- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error { - (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error {
// //
if([message.session.sessionId isEqualToString:self.roomId]){ if(![message.session.sessionId isEqualToString:self.roomId]){
return;; return;;
} }
if (message.messageType == NIMMessageTypeText) { if (message.messageType == NIMMessageTypeText) {
@@ -203,14 +353,16 @@
- (MSRoomGameSendMsgView *)sendMsgView{ - (MSRoomGameSendMsgView *)sendMsgView{
if(!_sendMsgView){ if(!_sendMsgView){
_sendMsgView = [[MSRoomGameSendMsgView alloc]initWithFrame:CGRectZero]; _sendMsgView = [[MSRoomGameSendMsgView alloc]initWithFrame:CGRectZero];
_sendMsgView.delegate = self;
} }
return _sendMsgView; return _sendMsgView;
} }
- (XPRoomLittleGameContainerView *)littleGameView { - (MSRoomGameView *)roomGameView{
if (!_littleGameView) { if(!_roomGameView){
_littleGameView = [[XPRoomLittleGameContainerView alloc] initWithDelegate:self]; _roomGameView = [[MSRoomGameView alloc]initWithFrame:CGRectZero];
_littleGameView.delegate = self; _roomGameView.delegate = self;
} }
return _littleGameView; return _roomGameView;
} }
@end @end

View File

@@ -15,6 +15,7 @@
#import "MSRoomGameProtocol.h" #import "MSRoomGameProtocol.h"
#import "XPIAPRechargeViewController.h" #import "XPIAPRechargeViewController.h"
#import "XPWebViewController.h" #import "XPWebViewController.h"
#import "XPRoomHalfWebView.h"
@interface MSTabbarRoomGameVC ()<MSTabbarRoomGameViewDelegate,MSTabbarRoomGameHeadViewDelegate,MSTabbarBeginGameViewDelegate,XPIAPRechargeViewControllerDelegate> @interface MSTabbarRoomGameVC ()<MSTabbarRoomGameViewDelegate,MSTabbarRoomGameHeadViewDelegate,MSTabbarBeginGameViewDelegate,XPIAPRechargeViewControllerDelegate>
@property(nonatomic,strong) UIImageView *bgImageView; @property(nonatomic,strong) UIImageView *bgImageView;
@property(nonatomic,strong) MSTabbarRoomGameHeadView *headView; @property(nonatomic,strong) MSTabbarRoomGameHeadView *headView;
@@ -40,6 +41,7 @@
[self installConstraints]; [self installConstraints];
} }
-(void)installUI{ -(void)installUI{
[self.view addSubview:self.bgImageView]; [self.view addSubview:self.bgImageView];
[self.view addSubview:self.headView]; [self.view addSubview:self.headView];
@@ -79,6 +81,12 @@
} }
[self.presenter startMatchGameWithroomId:@"" mgId:self.gameModel.mgId gameMode:model.gameMode]; [self.presenter startMatchGameWithroomId:@"" mgId:self.gameModel.mgId gameMode:model.gameMode];
} }
///
-(void)clickRuleActionWithModel:(MSTabbarRoomGameItemModel *)model{
XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
webView.url = model.ruleUrl;
[TTPopup popupView:webView style:TTPopupStyleActionSheet];
}
#pragma mark - MSTabbarRoomGameHeadViewDelegate #pragma mark - MSTabbarRoomGameHeadViewDelegate
- (void)clickPayAction{ - (void)clickPayAction{
XPIAPRechargeViewController *iapVC = [XPIAPRechargeViewController new]; XPIAPRechargeViewController *iapVC = [XPIAPRechargeViewController new];
@@ -101,12 +109,14 @@
} }
-(void)startMatchGameSuccess{ -(void)startMatchGameSuccess{
[self.presenter getRoomGameConfig];
MSRoomGameVC *gameVC = [MSRoomGameVC new]; MSRoomGameVC *gameVC = [MSRoomGameVC new];
gameVC.chooseGameModel = self.chooseGameModel; gameVC.chooseGameModel = self.chooseGameModel;
gameVC.userinfo = self.headView.userModel; gameVC.userinfo = self.headView.userModel;
BaseNavigationController *nav = [[BaseNavigationController alloc]initWithRootViewController:gameVC]; BaseNavigationController *nav = [[BaseNavigationController alloc]initWithRootViewController:gameVC];
nav.modalPresentationStyle = UIModalPresentationFullScreen; nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:nav animated:YES completion:nil]; [self presentViewController:nav animated:YES completion:nil];
} }
#pragma mark - XPIAPRechargeViewControllerDelegate #pragma mark - XPIAPRechargeViewControllerDelegate
- (void)paySuccess{ - (void)paySuccess{
@@ -118,6 +128,7 @@
self.headView.coinModel= coinModel; self.headView.coinModel= coinModel;
self.gameView.gameModel = gameModel; self.gameView.gameModel = gameModel;
self.gameModel = gameModel; self.gameModel = gameModel;
} }
#pragma mark - #pragma mark -
- (UIImageView *)bgImageView{ - (UIImageView *)bgImageView{

View File

@@ -10,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface MSRoomGameHeadAvatarView : UIView @interface MSRoomGameHeadAvatarView : UIView
@property(nonatomic,copy) NSString *imageUrl; @property(nonatomic,copy) NSString *__nullable imageUrl;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -35,8 +35,12 @@
}]; }];
} }
-(void)setImageUrl:(NSString *)imageUrl{ -(void)setImageUrl:(NSString *__nullable)imageUrl{
_imageUrl = imageUrl; _imageUrl = imageUrl;
if(_imageUrl == nil){
_avatarView.imageUrl = nil;
return;
}
_avatarView.imageUrl = imageUrl; _avatarView.imageUrl = imageUrl;
} }
#pragma mark - #pragma mark -

View File

@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "MSRoomGameModel.h" #import "MSRoomGameModel.h"
#import "MSTabbarRoomGameModel.h" #import "MSTabbarRoomGameModel.h"
#import "UserInfoModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@protocol MSRoomGameHeadViewDelegate <NSObject> @protocol MSRoomGameHeadViewDelegate <NSObject>
@@ -15,9 +16,14 @@ NS_ASSUME_NONNULL_BEGIN
@end @end
@interface MSRoomGameHeadView : UIView @interface MSRoomGameHeadView : UIView
@property(nonatomic,copy) NSString *gainProfit;
@property(nonatomic,weak) id<MSRoomGameHeadViewDelegate>delegate; @property(nonatomic,weak) id<MSRoomGameHeadViewDelegate>delegate;
@property(nonatomic,strong) MSRoomGameModel *roomGameModel; @property(nonatomic,strong) MSRoomGameModel *__nullable roomGameModel;
@property(nonatomic,strong) MSTabbarRoomGameItemModel *chooseGameModel; @property(nonatomic,strong) MSTabbarRoomGameItemModel *chooseGameModel;
@property(nonatomic,strong) HomePlayMicUserModel *mineModel;
@property(nonatomic,strong) HomePlayMicUserModel *rivalModel;
@property(nonatomic,strong) UserInfoModel *userInfo;
-(void)setDataInNull;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -100,6 +100,16 @@
make.centerY.equalTo(self.bgCoinView); make.centerY.equalTo(self.bgCoinView);
}]; }];
} }
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
for (NSInteger i = (self.subviews.count - 1) ; i >= 0 ; i--) {
UIView * subView = [self.subviews safeObjectAtIndex1:i];
CGPoint convertPoint = [subView convertPoint:point fromView:self];
if (CGRectContainsPoint(subView.bounds, convertPoint)) {
return [subView hitTest:convertPoint withEvent:event];
}
}
return nil;
}
-(void)clickBackBtnAction{ -(void)clickBackBtnAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(clickQuitGameAction)]){ if(self.delegate && [self.delegate respondsToSelector:@selector(clickQuitGameAction)]){
[self.delegate clickQuitGameAction]; [self.delegate clickQuitGameAction];
@@ -110,19 +120,30 @@
id coin = _chooseGameModel.scores.firstObject; id coin = _chooseGameModel.scores.firstObject;
if(coin != nil){ if(coin != nil){
self.coinNumView.text = [NSString stringWithFormat:@"%@",coin]; self.coinNumView.text = [NSString stringWithFormat:@"%@",coin];
NSMutableAttributedString *attText = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:YMLocalizedString(@"MSRoomGameHeadView2"),self.coinNumView.text] attributes:@{NSFontAttributeName:kFontMedium(14),NSForegroundColorAttributeName:[UIColor whiteColor]}];
[attText addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xFF6629)} range:[attText.string rangeOfString:[NSString stringWithFormat:YMLocalizedString(@"MSRoomGameHeadView3"),self.coinNumView.text]]];
_hintView.attributedText = attText;
} }
} }
- (void)setRoomGameModel:(MSRoomGameModel *)roomGameModel{ -(void)setDataInNull{
self.titleView.text = YMLocalizedString(@"MSRoomGameHeadView0");
self.rivalView.imageUrl = nil;
}
- (void)setRoomGameModel:(MSRoomGameModel *__nullable)roomGameModel{
_roomGameModel = roomGameModel; _roomGameModel = roomGameModel;
if(_roomGameModel == nil){
return;
}
NSString *uid = [[AccountInfoStorage instance]getUid]; NSString *uid = [[AccountInfoStorage instance]getUid];
for (MSRoomGameMicModel *obj in _roomGameModel.roomMics) { for (MSRoomGameMicModel *obj in _roomGameModel.roomMics) {
if([obj.micUser.uid isEqualToString:uid]){ if(![obj.micUser.uid isEqualToString:uid]){
self.mineView.imageUrl = obj.micUser.avatar; self.rivalModel = obj.micUser;
}else{
self.rivalView.imageUrl = obj.micUser.avatar; self.rivalView.imageUrl = obj.micUser.avatar;
} }
} }
MSRoomGameInfoModel *data = _roomGameModel.data; MSRoomGameInfoModel *data = _roomGameModel.data;
if(data != nil){ if(data != nil){
_topImageView.imageUrl = data.gameRoomIcon; _topImageView.imageUrl = data.gameRoomIcon;
@@ -133,6 +154,15 @@
} }
} }
} }
- (void)setUserInfo:(UserInfoModel *)userInfo{
_userInfo = userInfo;
HomePlayMicUserModel *mineModel = [HomePlayMicUserModel new];
mineModel.uid = @(_userInfo.uid).stringValue;
mineModel.nick = _userInfo.nick;
mineModel.avatar = _userInfo.avatar;
self.mineView.imageUrl = mineModel.avatar;
self.mineModel = mineModel;
}
#pragma mark - #pragma mark -
- (NetImageView *)topImageView{ - (NetImageView *)topImageView{
if(!_topImageView){ if(!_topImageView){
@@ -177,9 +207,7 @@
- (UILabel *)hintView{ - (UILabel *)hintView{
if(!_hintView){ if(!_hintView){
_hintView = [UILabel new]; _hintView = [UILabel new];
NSMutableAttributedString *attText = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:YMLocalizedString(@"MSRoomGameHeadView0"),@"18"] attributes:@{NSFontAttributeName:kFontMedium(14),NSForegroundColorAttributeName:[UIColor whiteColor]}];
[attText addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xFF6629)} range:[attText.string rangeOfString:@"18金币"]];
_hintView.attributedText = attText;
_hintView.numberOfLines = 0; _hintView.numberOfLines = 0;
_hintView.textAlignment = NSTextAlignmentCenter; _hintView.textAlignment = NSTextAlignmentCenter;
} }

View File

@@ -8,12 +8,21 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class MSTabbarRoomGameItemModel;
@protocol MSRoomGameQuitGameViewDelegate <NSObject> @protocol MSRoomGameQuitGameViewDelegate <NSObject>
@optional
///退出游戏
- (void)quitGameAction; - (void)quitGameAction;
///继续游戏
-(void)rematchGameAction;
///强杀app打开后,是否重新玩游戏
-(void)replayTheGameWithModel:(MSTabbarRoomGameItemModel *)model;
///强杀app打开后,退出游戏
- (void)closeGameActionWithModel:(MSTabbarRoomGameItemModel *)model;
@end @end
@interface MSRoomGameQuitGameView : UIView @interface MSRoomGameQuitGameView : UIView
@property(nonatomic,strong) MSTabbarRoomGameItemModel *chooseGameModel;
@property(nonatomic,assign) BOOL isNormalFail;
@property(nonatomic,weak) id<MSRoomGameQuitGameViewDelegate>delegate; @property(nonatomic,weak) id<MSRoomGameQuitGameViewDelegate>delegate;
@end @end

View File

@@ -51,14 +51,41 @@
make.top.mas_equalTo(kGetScaleWidth(48)); make.top.mas_equalTo(kGetScaleWidth(48));
}]; }];
} }
-(void)setChooseGameModel:(MSTabbarRoomGameItemModel *)chooseGameModel{
_chooseGameModel = chooseGameModel;
_titleView.text = YMLocalizedString(@"MSRoomGameQuitGameView4");
}
- (void)setIsNormalFail:(BOOL)isNormalFail{
_isNormalFail = isNormalFail;
_titleView.text = YMLocalizedString(@"MSRoomGameQuitGameView3");
[_resumeBtn setTitle:YMLocalizedString(@"MSRoomGameVictoryView0") forState:UIControlStateNormal];
}
-(void)qutiBtnAction{ -(void)qutiBtnAction{
[TTPopup dismiss]; [TTPopup dismiss];
if(self.chooseGameModel != nil){
if(self.delegate && [self.delegate respondsToSelector:@selector(closeGameActionWithModel:)]){
[self.delegate closeGameActionWithModel:self.chooseGameModel];
}
return;
}
if(self.delegate && [self.delegate respondsToSelector:@selector(quitGameAction)]){ if(self.delegate && [self.delegate respondsToSelector:@selector(quitGameAction)]){
[self.delegate quitGameAction]; [self.delegate quitGameAction];
} }
} }
-(void)resumeBtnAction{ -(void)resumeBtnAction{
[TTPopup dismiss]; [TTPopup dismiss];
if(self.chooseGameModel != nil){
if(self.delegate && [self.delegate respondsToSelector:@selector(replayTheGameWithModel:)]){
[self.delegate replayTheGameWithModel:self.chooseGameModel];
}
return;
}
if(self.isNormalFail == NO)return;
if(self.delegate && [self.delegate respondsToSelector:@selector(rematchGameAction)]){
[self.delegate rematchGameAction];
}
} }
#pragma mark - #pragma mark -
- (UIView *)bgView{ - (UIView *)bgView{

View File

@@ -8,9 +8,13 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@protocol MSRoomGameSendMsgViewDelegate <NSObject>
- (void)clickSendMsgAction;
@end
@interface MSRoomGameSendMsgView : UIView @interface MSRoomGameSendMsgView : UIView
@property(nonatomic,weak) id<MSRoomGameSendMsgViewDelegate>delegate;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -38,6 +38,11 @@
make.centerY.equalTo(self.sendBtn); make.centerY.equalTo(self.sendBtn);
}]; }];
} }
-(void)clickSendBtnAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(clickSendMsgAction)]){
[self.delegate clickSendMsgAction];
}
}
#pragma mark - #pragma mark -
- (UIButton *)sendBtn{ - (UIButton *)sendBtn{
if(!_sendBtn){ if(!_sendBtn){
@@ -45,6 +50,7 @@
_sendBtn.backgroundColor = UIColorRGBAlpha(0x0B032D , 0.1); _sendBtn.backgroundColor = UIColorRGBAlpha(0x0B032D , 0.1);
_sendBtn.layer.cornerRadius = kGetScaleWidth(28)/2; _sendBtn.layer.cornerRadius = kGetScaleWidth(28)/2;
_sendBtn.layer.masksToBounds = YES; _sendBtn.layer.masksToBounds = YES;
[_sendBtn addTarget:self action:@selector(clickSendBtnAction) forControlEvents:UIControlEventTouchUpInside];
} }
return _sendBtn; return _sendBtn;
} }

View File

@@ -0,0 +1,19 @@
//
// MSRoomGameSendTextView.h
// YuMi
//
// Created by duoban on 2024/5/30.
//
#import <UIKit/UIKit.h>
#import "UserInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface MSRoomGameSendTextView : UIView
///输入框
@property (nonatomic, strong, readonly) UITextField *editTextFiled;
-(void)showInputView:(NSString *)text;
- (instancetype)initWithRoomId:(NSString *)roomId userInfo:(UserInfoModel *)userInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,285 @@
//
// MSRoomGameSendTextView.m
// YuMi
//
// Created by duoban on 2024/5/30.
//
#import <Masonry/Masonry.h>
#import <NIMSDK/NIMSDK.h>
#import "NSObject+MJExtension.h"
#import <IQKeyboardManager/IQKeyboardManager.h>
///Tool
#import "ThemeColor+Room.h"
#import "UIImage+Utils.h"
#import "AccountInfoStorage.h"
///Model
#import "XPMessageRemoteExtModel.h"
#import "UserInfoModel.h"
#import "RoomInfoModel.h"
#import "ClientConfig.h"
#import "MSRoomGameSendTextView.h"
#import "MSRoomGameSendTextView.h"
//
#define MAX_STARWORDS_LENGTH 300
@interface MSRoomGameSendTextView()
///
@property (nonatomic, strong) MSBaseTextField *editTextFiled;
@property (nonatomic, strong) UIView *bgEditTextFiled;
///
@property (nonatomic, strong) UIButton *sendButton;
///
@property (nonatomic,copy) NSString *inputMessage;
@property(nonatomic,strong) UserInfoModel * userInfo;
@property(nonatomic,copy) NSString *roomId;
@end
@implementation MSRoomGameSendTextView
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (instancetype)initWithRoomId:(NSString *)roomId userInfo:(UserInfoModel *)userInfo {
self = [super initWithFrame:CGRectMake(0, KScreenHeight - 60, KScreenWidth, 60)];
if (self) {
self.roomId = roomId;
self.userInfo = userInfo;
[self addNotification];
[self initSubViews];
[self initSubViewConstraints];
[IQKeyboardManager sharedManager].enable = NO;
[self.editTextFiled becomeFirstResponder];
}
return self;
}
#pragma mark - Response
- (void)sendButtonDidClick:(UIButton *)sender {
UserInfoModel * userInfo = self.userInfo;
XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init];
extModel.defUser = userInfo.defUser;
extModel.erbanNo = userInfo.erbanNo;
extModel.carName = userInfo.carName;
extModel.inRoomNameplatePic = userInfo.nameplatePic;
extModel.inRoomNameplateWord = userInfo.nameplateWord;
extModel.isCustomWord = userInfo.isCustomWord;
extModel.charmUrl = userInfo.userLevelVo.charmUrl;
extModel.experLevelSeq = userInfo.userLevelVo.experLevelSeq;
extModel.experUrl = userInfo.userLevelVo.experUrl;
extModel.newUser = userInfo.newUser;
extModel.vipIcon = userInfo.userVipInfoVO.vipIcon;
extModel.androidBubbleUrl = userInfo.androidBubbleUrl;
extModel.iosBubbleUrl = userInfo.iosBubbleUrl;
extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel;
NIMMessage * message = [[NIMMessage alloc] init];
message.text = self.inputMessage;
NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[AccountInfoStorage instance].getUid];
message.remoteExt = remoteExt;
///
NIMAntiSpamOption *option = [[NIMAntiSpamOption alloc]init];
option.yidunEnabled = YES;
option.businessId = KeyWithType(keyType_YiDunBussinessId);
message.antiSpamOption = option;
NSString * sessionId = self.roomId;
//
self.sendButton.enabled = NO;
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session completion:^(NSError * _Nullable error) {
self.editTextFiled.text = @"";
[self.editTextFiled resignFirstResponder];
self.inputMessage = nil;
}];
}
-(void)showSendheadlineBtnAction{
if(self.editTextFiled.text.length == 0){
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"MSSessionReleaseHeadlinesView0")];
return;
}
if(self.editTextFiled.text.length > 100){
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"MSSessionReleaseHeadlinesView0")];
return;
}
[self.editTextFiled resignFirstResponder];
[[NSNotificationCenter defaultCenter]postNotificationName:@"kShowSendheadlineView" object:self.editTextFiled.text];
self.editTextFiled.text = @"";
}
- (void)keyboardWillShow:(NSNotification *)notification {
[self.superview bringSubviewToFront:self];
NSDictionary *info = [notification userInfo];
NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGFloat keyBoardEndY = value.CGRectValue.origin.y;
NSNumber *curve = [info objectForKey:UIKeyboardAnimationCurveUserInfoKey];
CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
CGRect endKeyboardRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGFloat h = endKeyboardRect.size.height;
[UIView animateWithDuration:duration animations:^{
if(self.superview){
[self mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self.superview);
make.height.equalTo(@60);
make.bottom.equalTo(self.superview).offset(-h);
}];
}
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:[curve intValue]];
self.center = CGPointMake(self.center.x, keyBoardEndY - statusbarHeight - self.bounds.size.height/2.0);
}];
}
//
- (void)keyboardWillHidden:(NSNotification *)notification {
NSDictionary *info = [notification userInfo];
CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
[UIView animateWithDuration:duration animations:^{
[self mas_remakeConstraints:^(MASConstraintMaker *make) {
make.bottom.leading.trailing.equalTo(self.superview);
make.height.equalTo(@60);
}];
self.hidden = YES;
}];
}
-(void)textFieldEditChanged:(NSNotification *)notification{
UITextField *textField = (UITextField *)notification.object;
NSString *toBeString = textField.text;
NSString *lang = [textField.textInputMode primaryLanguage];
if ([lang isEqualToString:@"zh-Hans"]){//
//
UITextRange *selectedRange = [textField markedTextRange];
UITextPosition *position = [textField positionFromPosition:selectedRange.start offset:0];
//
if (!position){
if (toBeString.length > MAX_STARWORDS_LENGTH){
NSRange rangeIndex = [toBeString rangeOfComposedCharacterSequenceAtIndex:MAX_STARWORDS_LENGTH];
if (rangeIndex.length == 1){
textField.text = [toBeString substringToIndex:MAX_STARWORDS_LENGTH];
}else{
NSRange rangeRange = [toBeString rangeOfComposedCharacterSequencesForRange:NSMakeRange(0, MAX_STARWORDS_LENGTH)];
textField.text = [toBeString substringWithRange:rangeRange];
}
}
}
}else{ //
if (toBeString.length > MAX_STARWORDS_LENGTH){
NSRange rangeIndex = [toBeString rangeOfComposedCharacterSequenceAtIndex:MAX_STARWORDS_LENGTH];
if (rangeIndex.length == 1){
textField.text = [toBeString substringToIndex:MAX_STARWORDS_LENGTH];
}else{
NSRange rangeRange = [toBeString rangeOfComposedCharacterSequencesForRange:NSMakeRange(0, MAX_STARWORDS_LENGTH)];
textField.text = [toBeString substringWithRange:rangeRange];
}
}
}
self.inputMessage = textField.text;
if (self.inputMessage.length > 0) {
self.sendButton.enabled = YES;
} else {
self.sendButton.enabled = NO;
}
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = UIColorFromRGB(0x260159);
[self addSubview:self.bgEditTextFiled];
[self.bgEditTextFiled addSubview:self.editTextFiled];
[self addSubview:self.sendButton];
}
- (void)initSubViewConstraints {
[self.bgEditTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(6);
make.height.mas_equalTo(36);
make.top.mas_equalTo(12);
make.trailing.equalTo(self.sendButton.mas_leading).mas_offset(-8);
}];
[self.editTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(20);
make.trailing.mas_equalTo(-kGetScaleWidth(20));
make.top.bottom.mas_equalTo(0);
}];
[self.sendButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(58);
make.height.mas_equalTo(29);
make.trailing.mas_equalTo(-15);
make.centerY.equalTo(self);
}];
}
- (void)addNotification {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldEditChanged:) name:UITextFieldTextDidChangeNotification object:self.editTextFiled];
}
-(void)showInputView:(NSString *)text{
self.editTextFiled.text = text;
self.inputMessage = text;
if(text.length > 0){
self.sendButton.enabled = YES;
}
}
#pragma mark - Getters And Setters
- (MSBaseTextField *)editTextFiled{
if (!_editTextFiled) {
_editTextFiled = [[MSBaseTextField alloc] init];
NSAttributedString * attribute = [[NSAttributedString alloc] initWithString:YMLocalizedString(@"XPRoomSendTextView0") attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15], NSForegroundColorAttributeName : [UIColor colorWithWhite:1 alpha:0.5]}];
_editTextFiled.attributedPlaceholder = attribute;
_editTextFiled.borderStyle = UITextBorderStyleNone;
_editTextFiled.textColor = [UIColor whiteColor];
_editTextFiled.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
[_editTextFiled setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
}
return _editTextFiled;
}
- (UIButton *)sendButton{
if (!_sendButton) {
_sendButton = [[UIButton alloc] init];
[_sendButton setTitle:YMLocalizedString(@"XPRoomSendTextView1") forState:UIControlStateNormal];
_sendButton.titleLabel.textColor = [UIColor whiteColor];
_sendButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
[_sendButton setBackgroundImage:[UIImage imageWithColor:[DJDKMIMOMColor disableButtonColor] ]forState:UIControlStateDisabled];
[_sendButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x7E5AFF), UIColorFromRGB(0x52CAD3)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
_sendButton.enabled = NO;
_sendButton.layer.cornerRadius = 7.5;
_sendButton.layer.masksToBounds = YES;
[_sendButton addTarget:self action:@selector(sendButtonDidClick:) forControlEvents:UIControlEventTouchUpInside];
_sendButton.tag = 101;
}
return _sendButton;
}
- (UIView *)bgEditTextFiled{
if(!_bgEditTextFiled){
_bgEditTextFiled = [UIView new];
_bgEditTextFiled.backgroundColor = UIColorFromRGB(0x361661);
_bgEditTextFiled.layer.cornerRadius = 18;
_bgEditTextFiled.layer.masksToBounds = YES;
}
return _bgEditTextFiled;
}
@end

View File

@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
-(void)rematchGameAction; -(void)rematchGameAction;
@end @end
@interface MSRoomGameVictoryView : UIView @interface MSRoomGameVictoryView : UIView
@property(nonatomic,copy) NSArray *resultsList;
@property(nonatomic,weak) id<MSRoomGameVictoryViewDelegate>delegate; @property(nonatomic,weak) id<MSRoomGameVictoryViewDelegate>delegate;
@end @end

View File

@@ -7,6 +7,7 @@
#import "MSRoomGameVictoryView.h" #import "MSRoomGameVictoryView.h"
#import "MSRoomGameVictoryCell.h" #import "MSRoomGameVictoryCell.h"
#import "MSRoomGameResultsModel.h"
@interface MSRoomGameVictoryView()<UITableViewDelegate,UITableViewDataSource> @interface MSRoomGameVictoryView()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UIView *bgView; @property(nonatomic,strong) UIView *bgView;
@property(nonatomic,strong) UIView *bgSubView; @property(nonatomic,strong) UIView *bgSubView;
@@ -71,11 +72,11 @@
} }
#pragma mark- UITableViewDelegate,UITableViewDataSource #pragma mark- UITableViewDelegate,UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 2; return self.resultsList.count;
} }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MSRoomGameVictoryCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MSRoomGameVictoryCell class]) forIndexPath:indexPath]; MSRoomGameVictoryCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MSRoomGameVictoryCell class]) forIndexPath:indexPath];
cell.resultsModel = [self.resultsList safeObjectAtIndex1:indexPath.row];
return cell; return cell;
} }
-(void)closeBtnAction{ -(void)closeBtnAction{
@@ -90,6 +91,13 @@
[self.delegate rematchGameAction]; [self.delegate rematchGameAction];
} }
} }
-(void)setResultsList:(NSArray *)resultsList{
_resultsList = resultsList;
MSRoomGameResultsModel *resultsModel = _resultsList.firstObject;
NSString *uid = [AccountInfoStorage instance].getUid;
self.topView.image = [resultsModel.uid isEqualToString:[AccountInfoStorage instance].getUid] ? kImage(@"ms_room_game_victory_top_icon") : kImage(@"ms_room_game_victory_top_fail_icon");
[_tableView reloadData];
}
#pragma mark - #pragma mark -
- (UIView *)bgView{ - (UIView *)bgView{
if(!_bgView){ if(!_bgView){

View File

@@ -6,26 +6,25 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "RoomHostDelegate.h" #import "MSRoomGameModel.h"
#import "RoomGuestDelegate.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@protocol MSRoomGameViewDelegate <NSObject> @protocol MSRoomGameViewDelegate <NSObject>
- (void)hiddenSudGamePostionView; - (void)getGameRsultsWithList:(NSArray *)list;
@end @end
@interface MSRoomGameView : UIView @interface MSRoomGameView : UIView
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate; @property(nonatomic,strong) MSRoomGameModel *gameModel;
///代理 @property(nonatomic,weak) id<MSRoomGameViewDelegate>delegate;
@property (nonatomic,weak) id<MSRoomGameViewDelegate> delegate;
- (void)onRoomEntered;
///销毁游戏的引擎 ///销毁游戏的引擎
- (void)destroyMG; - (void)destroyMG;
/// 退出游戏 /// 退出游戏
- (void)handleSelfInExitEvent; - (void)handleSelfInExitEvent;
- (void)handleNIMNotificationMessage:(NIMMessage *)message;
//自己是否在游戏中 //自己是否在游戏中
- (BOOL)isInSudGame; - (BOOL)isInSudGame;

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
@protocol MSTabbarBeginGameViewDelegate <NSObject> @protocol MSTabbarBeginGameViewDelegate <NSObject>
//开始游戏 //开始游戏
-(void)startMatchGameActionWithModel:(MSTabbarRoomGameItemModel *)model; -(void)startMatchGameActionWithModel:(MSTabbarRoomGameItemModel *)model;
///规则
-(void)clickRuleActionWithModel:(MSTabbarRoomGameItemModel *)model;
@end @end
@interface MSTabbarBeginGameView : UIView @interface MSTabbarBeginGameView : UIView
@property(nonatomic,weak) id<MSTabbarBeginGameViewDelegate>delegate; @property(nonatomic,weak) id<MSTabbarBeginGameViewDelegate>delegate;

View File

@@ -98,7 +98,11 @@
_coinNumView.text = _itemModel.ticket; _coinNumView.text = _itemModel.ticket;
_titleView.text = _itemModel.modeName; _titleView.text = _itemModel.modeName;
} }
-(void)ruleBtnAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(clickRuleActionWithModel:)]){
[self.delegate clickRuleActionWithModel:self.itemModel];
}
}
#pragma mark - #pragma mark -
- (UIImageView *)bgImageView{ - (UIImageView *)bgImageView{
if(!_bgImageView){ if(!_bgImageView){
@@ -155,6 +159,7 @@
_ruleBtn = [UIButton new]; _ruleBtn = [UIButton new];
[_ruleBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10]; [_ruleBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_ruleBtn setBackgroundImage:kImage(@"ms_room_game_begin_rule_icon") forState:UIControlStateNormal]; [_ruleBtn setBackgroundImage:kImage(@"ms_room_game_begin_rule_icon") forState:UIControlStateNormal];
[_ruleBtn addTarget:self action:@selector(ruleBtnAction) forControlEvents:UIControlEventTouchUpInside];
} }
return _ruleBtn; return _ruleBtn;
} }

View File

@@ -34,7 +34,10 @@
#import "YYUtility.h" #import "YYUtility.h"
#import "XPWeakTimer.h" #import "XPWeakTimer.h"
#import "PLTimeUtil.h" #import "PLTimeUtil.h"
#import "Api+MSRoomGameApi.h"
///Model ///Model
#import "MSRoomGameModel.h"
#import "AccountModel.h" #import "AccountModel.h"
#import "RoomInfoModel.h" #import "RoomInfoModel.h"
#import "AttachmentModel.h" #import "AttachmentModel.h"
@@ -48,6 +51,7 @@
#import "XPRedPacketModel.h" #import "XPRedPacketModel.h"
#import "GiftReceiveInfoModel.h" #import "GiftReceiveInfoModel.h"
#import "XPVersionUpdateModel.h" #import "XPVersionUpdateModel.h"
#import "MSRoomGameQuitGameView.h"
///VC ///VC
#import "TabbarViewController.h" #import "TabbarViewController.h"
#import "XPBlankViewController.h" #import "XPBlankViewController.h"
@@ -66,6 +70,7 @@
#import "XPWebViewController.h" #import "XPWebViewController.h"
#import "XPMineUserInfoViewController.h" #import "XPMineUserInfoViewController.h"
#import "MSTabbarRoomGameVC.h" #import "MSTabbarRoomGameVC.h"
#import "MSRoomGameVC.h"
#import "XPMonentsRecommendViewController.h" #import "XPMonentsRecommendViewController.h"
#import "XPMonentsViewController.h" #import "XPMonentsViewController.h"
@@ -82,7 +87,7 @@
#import <SVGA.h> #import <SVGA.h>
#import "Api+Gift.h" #import "Api+Gift.h"
#import "UploadFile.h" #import "UploadFile.h"
#import "XPTabBar.h"
NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey"; NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey";
@@ -92,7 +97,7 @@ NSString * const kNetworkReachabilityKey = @"kNetworkReachabilityKey";
UIKIT_EXTERN NSString * kNewUserRechargeKey; UIKIT_EXTERN NSString * kNewUserRechargeKey;
UIKIT_EXTERN NSString *kTabShowAnchorCardKey; UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate,XPLoginAuthCodeVCDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate, XPRoomYearActivityViewDelegate> @interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate,XPLoginAuthCodeVCDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate, XPRoomYearActivityViewDelegate,MSRoomGameQuitGameViewDelegate>
{ {
NSTimer * timer; NSTimer * timer;
} }
@@ -136,7 +141,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// XPTabBar *tabbar = [[XPTabBar alloc]initWithFrame:CGRectMake(0, KScreenHeight - kTabBarHeight, KScreenWidth, kTabBarHeight)];
// [self setValue:tabbar forKey:@"tabBar"];
[self.presenter autoLogin]; [self.presenter autoLogin];
[self configTheme]; [self configTheme];
[self initTabs:NO]; [self initTabs:NO];
@@ -248,7 +254,41 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[[NSUserDefaults standardUserDefaults] synchronize]; [[NSUserDefaults standardUserDefaults] synchronize];
} }
} }
-(void)getRoomGameInfo{
[Api getRoomGameDetails:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
MSRoomGameModel *model = [MSRoomGameModel modelWithJSON:data.data];
if(model.data.matchStatus == 1 && model.data.roundStatus == 0){
MSTabbarRoomGameItemModel *chooseGameModel = [MSTabbarRoomGameItemModel new];
chooseGameModel.scores = model.data.scores;
chooseGameModel.roomId = model.roomId;
MSRoomGameQuitGameView *quitGameView = [[MSRoomGameQuitGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
quitGameView.chooseGameModel = chooseGameModel;
quitGameView.delegate = self;
[TTPopup popupView:quitGameView style:TTPopupStyleAlert];
}
}
} roomType:@"0"];
}
#pragma mark -MSRoomGameQuitGameViewDelegate
///退
- (void)closeGameActionWithModel:(MSTabbarRoomGameItemModel *)model{
[Api closeRoomGame:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
} roomId:model.roomId];
}
///app,
-(void)replayTheGameWithModel:(MSTabbarRoomGameItemModel *)model{
MSRoomGameVC *gameVC = [MSRoomGameVC new];
gameVC.chooseGameModel = model;
gameVC.userinfo = self.userInfo;
BaseNavigationController *nav = [[BaseNavigationController alloc]initWithRootViewController:gameVC];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:nav animated:YES completion:nil];
}
/// 12 /// 12
/// ticket /// ticket
/// BaseMvpPresenter1415 /// BaseMvpPresenter1415
@@ -261,6 +301,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
return; return;
} }
self.userInfo = userInfo; self.userInfo = userInfo;
[self getRoomGameInfo];
[AccountInfoStorage instance].name = self.userInfo.nick; [AccountInfoStorage instance].name = self.userInfo.nick;
if ((userInfo.nick == nil || userInfo.avatar == nil) && self.isFormLogin == NO) { if ((userInfo.nick == nil || userInfo.avatar == nil) && self.isFormLogin == NO) {
@@ -726,7 +767,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
} }
- (BaseNavigationController *)createTabBarItem:(UIViewController *)itemVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{ - (BaseNavigationController *)createTabBarItem:(UIViewController *)itemVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
itemVc.title = title; itemVc.title = @"" ;
itemVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; itemVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)} forState:UIControlStateSelected]; [itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)} forState:UIControlStateSelected];
@@ -760,7 +801,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
if (model.total > 99) { if (model.total > 99) {
badge = @"99+"; badge = @"99+";
} }
NSUInteger index = 1; NSUInteger index = 2;
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
[item setBadgeValue:badge]; [item setBadgeValue:badge];
} }
@@ -773,7 +814,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
unreadCount += obj.unreadCount; unreadCount += obj.unreadCount;
}]; }];
if(unreadCount > 0){ if(unreadCount > 0){
NSUInteger index = 2; NSUInteger index = 3;
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
[item setBadgeValue:[NSString stringWithFormat:@"%ld",unreadCount]]; [item setBadgeValue:[NSString stringWithFormat:@"%ld",unreadCount]];
} }

View File

@@ -10,15 +10,14 @@
#import "YUMIMacroUitls.h" #import "YUMIMacroUitls.h"
#import "DJDKMIMOMColor.h" #import "DJDKMIMOMColor.h"
CGFloat tabBarHeight = 60.0; // TabBar
CGFloat leftRightSpace = 8.0; // TabBar CGFloat leftRightSpace = 20.0; // TabBar
CGFloat bottomSpace = 29.0; // TabBar CGFloat bottomSpace = 29.0; // TabBar
NSInteger itemCount = 4; // tabBarItem NSInteger itemCount = 5; // tabBarItem
@interface XPTabBar() @interface XPTabBar()
///
@property (nonatomic, strong) UIView *bgView;
@end @end
@@ -28,7 +27,7 @@ NSInteger itemCount = 4; // tabBarItem的数量
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if(self) { if(self) {
[self addSubview:self.bgView]; self.backgroundColor = [UIColor whiteColor];
// 线 // 线
[self setBackgroundImage:[UIImage new]]; [self setBackgroundImage:[UIImage new]];
[self setShadowImage:[UIImage new]]; [self setShadowImage:[UIImage new]];
@@ -57,7 +56,7 @@ NSInteger itemCount = 4; // tabBarItem的数量
- (void)layoutSubviews { - (void)layoutSubviews {
[super layoutSubviews]; [super layoutSubviews];
// tabBar // tabBar
self.frame = CGRectMake(0, KScreenHeight- tabBarHeight-bottomSpace, KScreenWidth, tabBarHeight); self.frame = CGRectMake(0, KScreenHeight- kTabBarHeight, KScreenWidth, kTabBarHeight);
// tabbarbtnframe // tabbarbtnframe
CGFloat tabBarButtonW = (KScreenWidth-leftRightSpace*2)/itemCount; CGFloat tabBarButtonW = (KScreenWidth-leftRightSpace*2)/itemCount;
@@ -65,25 +64,13 @@ NSInteger itemCount = 4; // tabBarItem的数量
for (UIView *child in self.subviews) { for (UIView *child in self.subviews) {
Class class = NSClassFromString(@"UITabBarButton"); Class class = NSClassFromString(@"UITabBarButton");
if ([child isKindOfClass:class]) { if ([child isKindOfClass:class]) {
CGRect frame = CGRectMake(tabBarButtonIndex * tabBarButtonW+leftRightSpace, (tabBarHeight-49)/2, tabBarButtonW, 49); CGRect frame = CGRectMake(tabBarButtonIndex * tabBarButtonW+leftRightSpace, 17, 34, 34);
child.frame = frame; child.frame = frame;
tabBarButtonIndex ++; tabBarButtonIndex ++;
} }
} }
} }
- (UIView *)bgView {
if (!_bgView) {
_bgView = [[UIView alloc] init];
_bgView.backgroundColor = [[DJDKMIMOMColor tabbarViewColor] colorWithAlphaComponent:0.95];
_bgView.frame = CGRectMake(leftRightSpace, 0, KScreenWidth-leftRightSpace*2, tabBarHeight);
_bgView.layer.cornerRadius = tabBarHeight/2.0;
_bgView.layer.shadowColor = [UIColor.blackColor colorWithAlphaComponent:0.5].CGColor;
_bgView.layer.shadowOffset = CGSizeMake(0, 0);
_bgView.layer.shadowOpacity = 0.2;
_bgView.layer.shadowRadius = 5;
}
return _bgView;
}
@end @end

View File

@@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
///关闭webView 目前适用于半屏的情况下 ///关闭webView 目前适用于半屏的情况下
@property (nonatomic,copy) void (^CloseWebViewBlock)(BOOL result); @property (nonatomic,copy) void (^CloseWebViewBlock)(BOOL result);
- (instancetype)initWithCustomizeNav:(BOOL)isCustom; - (instancetype)initWithCustomizeNav:(BOOL)isCustom;
- (instancetype)initWithGame;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -3274,15 +3274,21 @@
///MSRoomGameVictoryView ///MSRoomGameVictoryView
"MSRoomGameVictoryView0"="重新匹配"; "MSRoomGameVictoryView0"="重新匹配";
///MSRoomGameQuitGameView ///MSRoomGameQuitGameView
"MSRoomGameQuitGameView0"="游戏已经开始,退出房间将默认 游戏失败,确认退出房间?"; "MSRoomGameQuitGameView0"="游戏已经开始,退出房间将默认游戏失败,确认退出房间?";
"MSRoomGameQuitGameView1"="退出"; "MSRoomGameQuitGameView1"="退出";
"MSRoomGameQuitGameView2"="继续游戏"; "MSRoomGameQuitGameView2"="继续游戏";
"MSRoomGameQuitGameView3"="匹配失败,是否重新匹配?";
"MSRoomGameQuitGameView4"="游戏进行中,是否返回房间?";
//MSRoomGameHeadView //MSRoomGameHeadView
"MSRoomGameHeadView0"="匹配中"; "MSRoomGameHeadView0"="匹配中";
"MSRoomGameHeadView1"="匹配成功"; "MSRoomGameHeadView1"="匹配成功";
"MSRoomGameHeadView2"="获胜奖励%@金币"; "MSRoomGameHeadView2"="获胜奖励%@金币";
"MSRoomGameHeadView3"="%@金币";
//MSRoomGameVC //MSRoomGameVC
"MSRoomGameVC0"="匹配失败"; "MSRoomGameVC0"="匹配失败";
"MSRoomGameVC1"="钱包";

View File

@@ -3260,3 +3260,22 @@
"MSRoomSetingBackdropCell0"="使用中"; "MSRoomSetingBackdropCell0"="使用中";
"MSRoomSetingBackdropCell1"="確認選擇這張圖片作為房間主題嗎?"; "MSRoomSetingBackdropCell1"="確認選擇這張圖片作為房間主題嗎?";
///MSTabbarBeginGameView
"MSTabbarBeginGameView0"="开始";
///MSRoomGameVictoryView
"MSRoomGameVictoryView0"="重新匹配";
///MSRoomGameQuitGameView
"MSRoomGameQuitGameView0"="游戏已经开始,退出房间将默认游戏失败,确认退出房间?";
"MSRoomGameQuitGameView1"="退出";
"MSRoomGameQuitGameView2"="继续游戏";
"MSRoomGameQuitGameView3"="匹配失败,是否重新匹配?";
"MSRoomGameQuitGameView4"="游戏进行中,是否返回房间?";
//MSRoomGameHeadView
"MSRoomGameHeadView0"="匹配中";
"MSRoomGameHeadView1"="匹配成功";
"MSRoomGameHeadView2"="获胜奖励%@金币";
"MSRoomGameHeadView3"="%@金币";
//MSRoomGameVC
"MSRoomGameVC0"="匹配失败";
"MSRoomGameVC1"="钱包";