新增 TurboModeStateManager 的功能,支持 CP 麦位开关状态管理,优化房间中各个视图对 Turbo 模式的集成。更新相关视图控制器以使用 TurboModeStateManager 获取和设置开关状态,提升代码可维护性和用户体验。同时,新增 CP 麦位相关的本地化字符串,确保多语言支持。

This commit is contained in:
edwinQQQ
2025-09-10 17:21:09 +08:00
parent 58ab43c7d8
commit d414cd1cfc
30 changed files with 683 additions and 209 deletions

View File

@@ -16,6 +16,7 @@
#import "RtcManager.h"
#import "XPRoomMiniManager.h"
#import "TTPopup.h"
#import "TurboModeStateManager.h"
#import "Api+ArrangeMic.h"
#import "Api+Room.h"
#import "DESEncrypt.h"
@@ -1075,6 +1076,9 @@ XPCandyTreeInsufficientBalanceViewDelegate>
// 🔧 stage viewCPAPI
NSMutableDictionary<NSString *,MicroQueueModel *> *currentQueue = [self.stageView getMicroQueue];
[self callMicCpListByUidListOnMicChangeWithQueue:currentQueue];
// 🔧 19 micposition 6
[self checkCentralPositionUserQualification:currentQueue];
[self addExitGameButton];
@@ -1197,7 +1201,11 @@ XPCandyTreeInsufficientBalanceViewDelegate>
return;
}
_roomInfo = roomInfo;
[[LuckyPackageLogicManager sharedInstance] setRoomUid:@(roomInfo.uid).stringValue];
NSString *roomId = @(self.roomInfo.roomId).stringValue;
NSLog(@"🎮 设置房间ID: %@", roomId);
[[TurboModeStateManager sharedManager] setCurrentRoomId:roomId];
[[LuckyPackageLogicManager sharedInstance] setRoomUid:roomId];
[[RoomResourceManager sharedManager] updateCurrentSkinID:roomInfo.usedMicSkinId
effectID:roomInfo.usedMicEffectId];
@@ -1739,7 +1747,7 @@ XPCandyTreeInsufficientBalanceViewDelegate>
[self.stageView onRoomEntered];
[self.functionView onRoomEntered];
// 🔧
[self initializeCurrentUserMicStatus];
@@ -4303,4 +4311,63 @@ XPCandyTreeInsufficientBalanceViewDelegate>
}
}
/// 19 micposition 6
- (void)checkCentralPositionUserQualification:(NSMutableDictionary<NSString *,MicroQueueModel *> *)queue {
// 19 mic
if (self.roomInfo.type != RoomType_19Mic) {
return;
}
NSLog(@"🔧 检查19 mic房间中央位置用户资格");
// position 6
MicroQueueModel *centralMicModel = nil;
for (NSString *positionKey in queue.allKeys) {
MicroQueueModel *micModel = queue[positionKey];
if (micModel.microState.position == 6) {
centralMicModel = micModel;
break;
}
}
//
if (centralMicModel && centralMicModel.userInfo) {
NSString *userId = [NSString stringWithFormat:@"%ld", (long)centralMicModel.userInfo.uid];
NSLog(@"🔧 中央位置用户:%@,检查资格", userId);
// BossAPI
[Api requestBossMicUp:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSLog(@"✅ 中央位置用户资格检查通过:%@", userId);
} else {
NSLog(@"❌ 中央位置用户资格检查失败:%@,错误:%@", userId, msg);
// mic
[self forceDownMicForUser:userId atPosition:6];
}
} roomUid:@(self.roomInfo.uid).stringValue uid:userId];
} else {
NSLog(@"🔧 中央位置无用户,无需检查");
}
}
/// mic
- (void)forceDownMicForUser:(NSString *)userId atPosition:(NSInteger)position {
NSLog(@"🔧 强制用户下mic%@,位置:%ld", userId, (long)position);
// 使 NIM API mic
NIMChatroomQueueRemoveRequest *request = [[NIMChatroomQueueRemoveRequest alloc] init];
request.key = [NSString stringWithFormat:@"%ld", (long)position];
request.roomId = @(self.roomInfo.uid).stringValue;
[[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary<NSString *,NSString *> * _Nullable element) {
if (error) {
NSLog(@"❌ 强制下mic失败%@,错误:%@", userId, error.localizedDescription);
[XNDJTDDLoadingTool showErrorWithMessage:@"强制下mic失败"];
} else {
NSLog(@"✅ 强制下mic成功%@", userId);
[XNDJTDDLoadingTool showSuccessWithMessage:@"中央位置需要满足贡献值要求已自动下mic"];
}
}];
}
@end