新增 TurboModeStateManager 类以管理全局 Turbo 模式状态,优化房间动画视图中的开关逻辑,确保与 Turbo 模式一致。同时,更新房间更多菜单的 Action 类以支持新的 Turbo 模式开关,提升代码可维护性和用户体验。
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
#import "XPRoomAnchorRankEnterView.h"
|
||||
#import "MSRoomOnLineView.h"
|
||||
#import "XPTurboModeConstants.h"
|
||||
#import "../MoreView/Manager/TurboModeStateManager.h"
|
||||
|
||||
#import "BannerScheduler.h"
|
||||
#import "GameBannerGestureManager.h"
|
||||
@@ -459,6 +460,20 @@ BannerSchedulerDelegate
|
||||
NSString *roomId = @(self.hostDelegate.getRoomInfo.roomId).stringValue;
|
||||
self.currentRoomId = roomId;
|
||||
|
||||
// 1. 先按原逻辑获取状态
|
||||
[self loadSwitchStatesFromCache:roomId];
|
||||
|
||||
// 2. 再按 turbo mode 来调整状态
|
||||
[[TurboModeStateManager sharedManager] applyTurboModeToSwitchesForRoom:roomId];
|
||||
|
||||
// 3. 强制更新本地状态,确保与 turbo mode 一致
|
||||
[self forceUpdateLocalSwitchStates:roomId];
|
||||
|
||||
NSLog(@"🎮 RoomAnimationView Turbo Mode开关初始化完成 - 房间ID: %@", roomId);
|
||||
}
|
||||
|
||||
// 🔧 新增:从缓存加载开关状态
|
||||
- (void)loadSwitchStatesFromCache:(NSString *)roomId {
|
||||
// 礼物特效:从当前会话状态读取(不持久化)
|
||||
self.turboGiftEffectsEnabled = self.hostDelegate.getRoomInfo.hasAnimationEffect;
|
||||
|
||||
@@ -468,12 +483,40 @@ BannerSchedulerDelegate
|
||||
self.turboGlobalGiftScreenEnabled = (giftScreenObj != nil) ? [defaults boolForKey:kTurboGlobalGiftScreenEnabledKey(roomId)] : YES;
|
||||
id gameScreenObj = [defaults objectForKey:kTurboGlobalGameScreenEnabledKey(roomId)];
|
||||
self.turboGlobalGameScreenEnabled = (gameScreenObj != nil) ? [defaults boolForKey:kTurboGlobalGameScreenEnabledKey(roomId)] : YES;
|
||||
}
|
||||
|
||||
// 🔧 新增:更新本地开关状态
|
||||
- (void)updateLocalSwitchStates:(NSString *)roomId {
|
||||
NSDictionary *switchStates = [[TurboModeStateManager sharedManager] getSwitchStatesAfterTurboModeForRoom:roomId];
|
||||
|
||||
NSLog(@"🎮 RoomAnimationView Turbo Mode开关初始化 - 房间ID: %@, 礼物特效: %@, 全局礼物屏幕: %@, 全局游戏屏幕: %@",
|
||||
roomId,
|
||||
self.turboGiftEffectsEnabled ? @"开启" : @"关闭",
|
||||
self.turboGlobalGiftScreenEnabled ? @"开启" : @"关闭",
|
||||
self.turboGlobalGameScreenEnabled ? @"开启" : @"关闭");
|
||||
if (switchStates.count > 0) {
|
||||
self.turboGiftEffectsEnabled = [switchStates[@"giftEffects"] boolValue];
|
||||
self.turboGlobalGiftScreenEnabled = [switchStates[@"globalGiftScreen"] boolValue];
|
||||
self.turboGlobalGameScreenEnabled = [switchStates[@"globalGameScreen"] boolValue];
|
||||
|
||||
NSLog(@"🎮 RoomAnimationView 开关状态已更新 - 礼物特效: %@, 全局礼物屏幕: %@, 全局游戏屏幕: %@",
|
||||
self.turboGiftEffectsEnabled ? @"开启" : @"关闭",
|
||||
self.turboGlobalGiftScreenEnabled ? @"开启" : @"关闭",
|
||||
self.turboGlobalGameScreenEnabled ? @"开启" : @"关闭");
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 新增:强制更新本地开关状态,确保与 turbo mode 一致
|
||||
- (void)forceUpdateLocalSwitchStates:(NSString *)roomId {
|
||||
// 直接获取 turbo mode 状态并强制设置
|
||||
BOOL turboModeEnabled = [[TurboModeStateManager sharedManager] isTurboModeEnabled];
|
||||
|
||||
if (turboModeEnabled) {
|
||||
// turbo mode = YES,强制关闭所有开关
|
||||
self.turboGiftEffectsEnabled = NO;
|
||||
self.turboGlobalGiftScreenEnabled = NO;
|
||||
self.turboGlobalGameScreenEnabled = NO;
|
||||
|
||||
NSLog(@"🎮 RoomAnimationView 强制更新开关状态 - Turbo Mode 开启,所有开关已关闭");
|
||||
} else {
|
||||
// turbo mode = NO,使用原有逻辑
|
||||
[self updateLocalSwitchStates:roomId];
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 新增:设置Turbo Mode通知监听
|
||||
@@ -934,6 +977,12 @@ BannerSchedulerDelegate
|
||||
}
|
||||
|
||||
- (void)receiveRoomGiftBanner:(AttachmentModel *)obj {
|
||||
// 🔧 新增:检查 Turbo Mode 全局礼物屏幕开关
|
||||
if (!self.turboGlobalGiftScreenEnabled) {
|
||||
NSLog(@"🎮 RoomAnimationView 全局礼物屏幕已关闭,跳过 RoomGiftBanner");
|
||||
return;
|
||||
}
|
||||
|
||||
[self inserBannerModelToQueue:obj];
|
||||
}
|
||||
|
||||
@@ -1161,6 +1210,12 @@ BannerSchedulerDelegate
|
||||
}
|
||||
|
||||
- (void)receiveLuckGiftBanner:(AttachmentModel *)attachment {
|
||||
// 🔧 新增:检查 Turbo Mode 全局礼物屏幕开关
|
||||
if (!self.turboGlobalGiftScreenEnabled) {
|
||||
NSLog(@"🎮 RoomAnimationView 全局礼物屏幕已关闭,跳过 LuckyGiftWinningBanner");
|
||||
return;
|
||||
}
|
||||
|
||||
[self inserBannerModelToQueue:attachment];
|
||||
}
|
||||
|
||||
@@ -1206,6 +1261,12 @@ BannerSchedulerDelegate
|
||||
}
|
||||
|
||||
- (void)receiveGameBanner:(AttachmentModel *)attachment {
|
||||
// 🔧 新增:检查 Turbo Mode 全局游戏屏幕开关
|
||||
if (!self.turboGlobalGameScreenEnabled) {
|
||||
NSLog(@"🎮 RoomAnimationView 全局游戏屏幕已关闭,跳过 GameBanner");
|
||||
return;
|
||||
}
|
||||
|
||||
[self inserBannerModelToQueue:attachment];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user