更新 XPPartyRoomItemCollectionViewCell,替换 subLabel 为 MarqueeLabel 以支持滚动文本,新增 levelImageView 属性并设置约束。优化 BoomInfoViewController 中比值计算逻辑,确保在速度为 100 时正确显示比值。调整 XPRoomFunctionContainerView 和 XPEffectPanelViewController 中的开关逻辑,移除 CP 麦位开关相关代码,提升代码整洁性和可维护性。
This commit is contained in:
@@ -15,11 +15,11 @@
|
||||
@property (nonatomic, strong) NetImageView *flagImage;
|
||||
@property (nonatomic,strong) NetImageView *boomImageView;
|
||||
@property(nonatomic,strong) UILabel *nameLabel;
|
||||
@property(nonatomic,strong) UILabel *subLabel;
|
||||
@property(nonatomic,strong) MarqueeLabel *subLabel;
|
||||
@property(nonatomic,strong) UIImageView *heatIcon;
|
||||
@property(nonatomic,strong) UILabel *heatNumLable;
|
||||
@property (nonatomic, strong) UIImageView *bottomShadow;
|
||||
|
||||
@property (nonatomic, strong) NetImageView *levelImageView;
|
||||
@end
|
||||
|
||||
@implementation XPPartyRoomItemCollectionViewCell
|
||||
@@ -82,11 +82,6 @@
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.subLabel];
|
||||
[self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.avatarView).offset(10);
|
||||
make.bottom.mas_equalTo(self.avatarView).offset(-8);
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.heatNumLable];
|
||||
[self.heatNumLable mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.trailing.mas_equalTo(self.avatarView).offset(-10);
|
||||
@@ -100,6 +95,13 @@
|
||||
make.size.mas_equalTo(CGSizeMake(15, 15));
|
||||
}];
|
||||
|
||||
|
||||
[self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.avatarView).offset(10);
|
||||
make.trailing.mas_equalTo(self.heatIcon.mas_leading).offset(-4);
|
||||
make.bottom.mas_equalTo(self.avatarView).offset(-8);
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.boomImageView];
|
||||
[self.boomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.trailing.mas_equalTo(self.heatNumLable);
|
||||
@@ -112,11 +114,19 @@
|
||||
make.bottom.leading.trailing.mas_equalTo(self.avatarView);
|
||||
make.height.mas_equalTo(kGetScaleWidth(34));
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.levelImageView];
|
||||
[self.levelImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.avatarView).offset(2);
|
||||
make.top.mas_equalTo(self.tagImageView);
|
||||
make.size.mas_equalTo(CGSizeMake(38, 15));
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setRoomInfo:(HomePlayRoomModel *)roomInfo {
|
||||
_roomInfo = roomInfo;
|
||||
self.avatarView.imageUrl = roomInfo.avatar;
|
||||
self.levelImageView.imageUrl = roomInfo.roomLevelIcon;
|
||||
if (roomInfo.hourTop > 0) {
|
||||
NSString *name = [NSString stringWithFormat:@"room_level_top_%ld", (long)roomInfo.hourTop];
|
||||
self.rankImageView.image = [UIImage getLanguageImage:name];
|
||||
@@ -263,9 +273,16 @@
|
||||
return _nameLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)subLabel{
|
||||
- (MarqueeLabel *)subLabel{
|
||||
if(!_subLabel){
|
||||
_subLabel = [UILabel labelInitWithText:@"" font:kFontRegular(13) textColor:[UIColor whiteColor]];
|
||||
_subLabel = [[MarqueeLabel alloc] init];
|
||||
_subLabel.text = @"";
|
||||
_subLabel.font = kFontRegular(13);
|
||||
_subLabel.textColor = [UIColor whiteColor];
|
||||
_subLabel.textAlignment = NSTextAlignmentLeft;
|
||||
_subLabel.scrollDuration = 3.0;
|
||||
_subLabel.fadeLength = 8.0f;
|
||||
_subLabel.animationDelay = 1.0;
|
||||
}
|
||||
return _subLabel;
|
||||
}
|
||||
@@ -293,4 +310,11 @@
|
||||
return _bottomShadow;
|
||||
}
|
||||
|
||||
- (NetImageView *)levelImageView{
|
||||
if(!_levelImageView){
|
||||
_levelImageView = [[NetImageView alloc]init];
|
||||
}
|
||||
return _levelImageView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -689,9 +689,12 @@
|
||||
}
|
||||
|
||||
// 更新比值 label 并保持发光效果
|
||||
NSString *ratioText = [NSString stringWithFormat:@"%@/%@",
|
||||
@(floor(boom.exp * boom.speed / 100.0)).stringValue,
|
||||
@(boom.exp).stringValue];
|
||||
NSString *ratioText = @"";
|
||||
if (boom.speed == 100) {
|
||||
ratioText = [NSString stringWithFormat:@"%@/%@", @(boom.goldNum), @(boom.goldNum)];
|
||||
} else {
|
||||
ratioText = [NSString stringWithFormat:@"%@/%@", @(floor(boom.exp)), @(boom.goldNum)];
|
||||
}
|
||||
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:ratioText];
|
||||
[attributedString addAttribute:NSStrokeColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, attributedString.length)];
|
||||
|
@@ -636,7 +636,8 @@
|
||||
|
||||
- (void)onRoomEntered {
|
||||
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
|
||||
self.contributeEnterView.title = roomInfo.serialValue.stringValue;
|
||||
self.contributeEnterView.title = [NSString stringWithFormat:@"%.2f",
|
||||
roomInfo.serialValue.floatValue];// roomInfo.serialValue.stringValue;
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
[self updateHourRankEntrance];
|
||||
if (roomInfo.type == RoomType_Anchor) {//个播房
|
||||
|
@@ -219,13 +219,13 @@
|
||||
BOOL turboModeEnabled = [self isTurboModeEnabled];
|
||||
|
||||
if (turboModeEnabled) {
|
||||
// turbo mode = YES,3个开关全部关闭
|
||||
// turbo mode = YES,仅影响非CP三开关
|
||||
[self forceCloseAllSwitches:roomId];
|
||||
NSLog(@"🎮 TurboModeStateManager: 应用 turbo mode,房间 %@ 的3个开关全部关闭", roomId);
|
||||
NSLog(@"🎮 TurboModeStateManager: 应用 turbo mode,房间 %@ 的3个非CP开关全部关闭", roomId);
|
||||
} else {
|
||||
// turbo mode = NO,按最新需求:全部开关打开
|
||||
// turbo mode = NO,仅影响非CP三开关
|
||||
[self forceOpenAllSwitches:roomId];
|
||||
NSLog(@"🎮 TurboModeStateManager: turbo mode 关闭,房间 %@ 的3个开关全部打开", roomId);
|
||||
NSLog(@"🎮 TurboModeStateManager: turbo mode 关闭,房间 %@ 的3个非CP开关全部打开", roomId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,31 +234,28 @@
|
||||
|
||||
BOOL turboModeEnabled = [self isTurboModeEnabled];
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
// 礼物特效:按需求不持久化,这里默认开启(面板或 RoomAnimationView 会基于 roomInfo 决定)
|
||||
BOOL giftEffects = YES;
|
||||
|
||||
id giftScreenObj = [defaults objectForKey:kTurboGlobalGiftScreenEnabledKey(roomId)];
|
||||
BOOL globalGiftScreen = (giftScreenObj != nil) ? [defaults boolForKey:kTurboGlobalGiftScreenEnabledKey(roomId)] : NO;
|
||||
|
||||
id gameScreenObj = [defaults objectForKey:kTurboGlobalGameScreenEnabledKey(roomId)];
|
||||
BOOL globalGameScreen = (gameScreenObj != nil) ? [defaults boolForKey:kTurboGlobalGameScreenEnabledKey(roomId)] : NO;
|
||||
|
||||
id cpMicObj = [defaults objectForKey:kTurboCpMicEnabledKey(roomId)];
|
||||
BOOL cpMic = (cpMicObj != nil) ? [defaults boolForKey:kTurboCpMicEnabledKey(roomId)] : NO;
|
||||
|
||||
if (turboModeEnabled) {
|
||||
// turbo mode = YES,4个开关全部关闭
|
||||
return @{
|
||||
@"giftEffects": @(NO),
|
||||
@"globalGiftScreen": @(NO),
|
||||
@"globalGameScreen": @(NO),
|
||||
@"cpMic": @(NO)
|
||||
@"cpMic": @(cpMic)
|
||||
};
|
||||
} else {
|
||||
// turbo mode = NO,返回当前缓存的状态
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
// 礼物特效:按需求不持久化,这里默认开启(面板或 RoomAnimationView 会基于 roomInfo 决定)
|
||||
BOOL giftEffects = YES;
|
||||
|
||||
// 🔧 修复:使用与 RoomAnimationView 和 XPEffectPanelViewController 一致的逻辑
|
||||
id giftScreenObj = [defaults objectForKey:kTurboGlobalGiftScreenEnabledKey(roomId)];
|
||||
BOOL globalGiftScreen = (giftScreenObj != nil) ? [defaults boolForKey:kTurboGlobalGiftScreenEnabledKey(roomId)] : NO;
|
||||
|
||||
id gameScreenObj = [defaults objectForKey:kTurboGlobalGameScreenEnabledKey(roomId)];
|
||||
BOOL globalGameScreen = (gameScreenObj != nil) ? [defaults boolForKey:kTurboGlobalGameScreenEnabledKey(roomId)] : NO;
|
||||
|
||||
id cpMicObj = [defaults objectForKey:kTurboCpMicEnabledKey(roomId)];
|
||||
BOOL cpMic = (cpMicObj != nil) ? [defaults boolForKey:kTurboCpMicEnabledKey(roomId)] : NO;
|
||||
|
||||
return @{
|
||||
@"giftEffects": @(giftEffects),
|
||||
@"globalGiftScreen": @(globalGiftScreen),
|
||||
@@ -297,9 +294,7 @@
|
||||
roomStates[@"globalGameScreen"] = @(NO);
|
||||
[defaults setBool:NO forKey:kTurboGlobalGameScreenEnabledKey(roomId)];
|
||||
|
||||
// 强制关闭CP麦位开关
|
||||
roomStates[@"cpMic"] = @(NO);
|
||||
[defaults setBool:NO forKey:kTurboCpMicEnabledKey(roomId)];
|
||||
// 不改动 CP 麦位开关
|
||||
|
||||
self.roomSwitchStates[roomId] = roomStates;
|
||||
[defaults synchronize];
|
||||
@@ -328,9 +323,7 @@
|
||||
roomStates[@"globalGameScreen"] = @(YES);
|
||||
[defaults setBool:YES forKey:kTurboGlobalGameScreenEnabledKey(roomId)];
|
||||
|
||||
// 强制打开CP麦位开关
|
||||
roomStates[@"cpMic"] = @(YES);
|
||||
[defaults setBool:YES forKey:kTurboCpMicEnabledKey(roomId)];
|
||||
// 不改动 CP 麦位开关
|
||||
|
||||
self.roomSwitchStates[roomId] = roomStates;
|
||||
[defaults synchronize];
|
||||
@@ -358,11 +351,7 @@
|
||||
object:nil
|
||||
userInfo:@{@"on": @(NO), @"roomId": roomId}];
|
||||
|
||||
// 发送CP麦位开关状态变化通知
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:kTurboCpMicEnabledChanged
|
||||
object:nil
|
||||
userInfo:@{@"on": @(NO), @"roomId": roomId}];
|
||||
// 不发送 CP 麦位开关状态变化通知
|
||||
}
|
||||
|
||||
- (void)sendSwitchStateChangeNotificationsForOpen:(NSString *)roomId {
|
||||
@@ -384,11 +373,7 @@
|
||||
object:nil
|
||||
userInfo:@{@"on": @(YES), @"roomId": roomId}];
|
||||
|
||||
// 发送CP麦位开关状态变化通知
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:kTurboCpMicEnabledChanged
|
||||
object:nil
|
||||
userInfo:@{@"on": @(YES), @"roomId": roomId}];
|
||||
// 不发送 CP 麦位开关状态变化通知
|
||||
}
|
||||
|
||||
- (void)loadTurboModeStatesFromCache {
|
||||
|
@@ -16,11 +16,10 @@
|
||||
@property (nonatomic, strong) UIButton *dismissButton;
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
|
||||
// 四个开关
|
||||
// 开关
|
||||
@property (nonatomic, strong) UISwitch *giftEffectsSwitch; // 礼物特效开关
|
||||
@property (nonatomic, strong) UISwitch *globalGiftScreenSwitch; // 全局礼物屏幕开关
|
||||
@property (nonatomic, strong) UISwitch *globalGameScreenSwitch; // 全局游戏屏幕开关
|
||||
@property (nonatomic, strong) UISwitch *cpMicSwitch; // CP麦位开关
|
||||
|
||||
// 🔧 移除:本地开关状态,改为使用 TurboModeStateManager
|
||||
|
||||
@@ -58,7 +57,7 @@
|
||||
// 设置约束 - 使用 Masonry
|
||||
[self.bottomAreaBackground mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.bottom.mas_equalTo(self.view);
|
||||
make.height.mas_equalTo(370); // 增加高度以容纳第四个开关
|
||||
make.height.mas_equalTo(320);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -109,10 +108,6 @@
|
||||
// 全局游戏屏幕开关(持久化)
|
||||
[self setupSwitchItem:YMLocalizedString(@"20.20.62_text_12") // Global game screen
|
||||
atIndex:2];
|
||||
|
||||
// CP麦位开关(持久化)
|
||||
[self setupSwitchItem:YMLocalizedString(@"20.20.62_text_21") // CP mic
|
||||
atIndex:3];
|
||||
}
|
||||
|
||||
- (void)setupSwitchItem:(NSString *)title
|
||||
@@ -160,8 +155,6 @@
|
||||
self.globalGiftScreenSwitch = switchViewControl;
|
||||
} else if (index == 2) {
|
||||
self.globalGameScreenSwitch = switchViewControl;
|
||||
} else if (index == 3) {
|
||||
self.cpMicSwitch = switchViewControl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,20 +170,17 @@
|
||||
BOOL giftEffectsEnabled = [manager isGiftEffectsEnabledForRoom:roomId];
|
||||
BOOL globalGiftScreenEnabled = [manager isGlobalGiftScreenEnabledForRoom:roomId];
|
||||
BOOL globalGameScreenEnabled = [manager isGlobalGameScreenEnabledForRoom:roomId];
|
||||
BOOL cpMicEnabled = [manager isCpMicEnabledForRoom:roomId];
|
||||
|
||||
// 设置开关初始状态
|
||||
self.giftEffectsSwitch.on = giftEffectsEnabled;
|
||||
self.globalGiftScreenSwitch.on = globalGiftScreenEnabled;
|
||||
self.globalGameScreenSwitch.on = globalGameScreenEnabled;
|
||||
self.cpMicSwitch.on = cpMicEnabled;
|
||||
|
||||
NSLog(@"🎮 Turbo Mode开关初始化完成 - 房间ID: %@, 礼物特效: %@, 全局礼物屏幕: %@, 全局游戏屏幕: %@, CP麦位: %@",
|
||||
NSLog(@"🎮 Turbo Mode开关初始化完成 - 房间ID: %@, 礼物特效: %@, 全局礼物屏幕: %@, 全局游戏屏幕: %@",
|
||||
roomId,
|
||||
giftEffectsEnabled ? @"开启" : @"关闭",
|
||||
globalGiftScreenEnabled ? @"开启" : @"关闭",
|
||||
globalGameScreenEnabled ? @"开启" : @"关闭",
|
||||
cpMicEnabled ? @"开启" : @"关闭");
|
||||
globalGameScreenEnabled ? @"开启" : @"关闭");
|
||||
}
|
||||
|
||||
- (void)switchValueChanged:(UISwitch *)sender {
|
||||
@@ -211,8 +201,6 @@
|
||||
[manager setGlobalGiftScreenEnabledForRoom:self.roomId enabled:YES];
|
||||
} else if (sender.tag == 2) { // 全局游戏屏幕
|
||||
[manager setGlobalGameScreenEnabledForRoom:self.roomId enabled:YES];
|
||||
} else if (sender.tag == 3) { // CP麦位开关
|
||||
[manager setCpMicEnabledForRoom:self.roomId enabled:YES];
|
||||
}
|
||||
|
||||
NSLog(@"🎮 Turbo Mode 已静默关闭,开关 %ld 已开启", (long)sender.tag);
|
||||
@@ -239,13 +227,6 @@
|
||||
// 🔧 新增:显示 toast 提示
|
||||
NSString *toastMessage = isOn ? YMLocalizedString(@"20.20.62_text_19") : YMLocalizedString(@"20.20.62_text_20");
|
||||
[self showToastWithMessage:toastMessage];
|
||||
|
||||
} else if (sender.tag == 3) { // CP麦位开关
|
||||
[manager setCpMicEnabledForRoom:self.roomId enabled:isOn];
|
||||
|
||||
// 🔧 新增:显示 toast 提示
|
||||
NSString *toastMessage = isOn ? YMLocalizedString(@"20.20.62_text_22") : YMLocalizedString(@"20.20.62_text_23");
|
||||
[self showToastWithMessage:toastMessage];
|
||||
}
|
||||
|
||||
// 通知父控制器更新 Turbo_Mode 按钮状态
|
||||
@@ -260,8 +241,7 @@
|
||||
TurboModeStateManager *manager = [TurboModeStateManager sharedManager];
|
||||
BOOL allSwitchesOn = [manager isGiftEffectsEnabledForRoom:self.roomId] &&
|
||||
[manager isGlobalGiftScreenEnabledForRoom:self.roomId] &&
|
||||
[manager isGlobalGameScreenEnabledForRoom:self.roomId] &&
|
||||
[manager isCpMicEnabledForRoom:self.roomId];
|
||||
[manager isGlobalGameScreenEnabledForRoom:self.roomId];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:kTurboModeButtonStateChanged
|
||||
@@ -367,10 +347,7 @@
|
||||
name:kTurboGlobalGameScreenEnabledChanged
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(handleCpMicChanged:)
|
||||
name:kTurboCpMicEnabledChanged
|
||||
object:nil];
|
||||
|
||||
}
|
||||
|
||||
- (void)handleTurboModeStateChanged:(NSNotification *)notification {
|
||||
@@ -399,7 +376,6 @@
|
||||
self.giftEffectsSwitch.on = NO;
|
||||
self.globalGiftScreenSwitch.on = NO;
|
||||
self.globalGameScreenSwitch.on = NO;
|
||||
self.cpMicSwitch.on = NO;
|
||||
} else {
|
||||
// 🔧 修复:Turbo Mode 关闭时,不直接查询状态,而是等待通知更新
|
||||
// 因为 forceOpenAllSwitches 会发送通知,各个 handleXxxChanged 方法会处理UI更新
|
||||
@@ -437,15 +413,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleCpMicChanged:(NSNotification *)notification {
|
||||
BOOL enabled = [notification.userInfo[@"on"] boolValue];
|
||||
NSString *roomId = notification.userInfo[@"roomId"];
|
||||
|
||||
if ([roomId isEqualToString:self.roomId]) {
|
||||
self.cpMicSwitch.on = enabled;
|
||||
NSLog(@"🎮 CP麦位开关状态已更新: %@", enabled ? @"开启" : @"关闭");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
Reference in New Issue
Block a user