新增 MicMidpointRectManager 类以管理麦位中点矩形的绘制和动画,优化各个 StageView 中的中点矩形处理逻辑。同时,更新相关 StageView 类以集成中点矩形管理器,提升代码可维护性和用户体验。新增 SVGA 动画支持,确保中点矩形的动态展示效果。
This commit is contained in:
@@ -562,6 +562,12 @@
|
||||
4CA532C32D5F37DC00B8F59F /* LuckyPackageMessageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA532C22D5F37DC00B8F59F /* LuckyPackageMessageTableViewCell.m */; };
|
||||
4CA5A3342D93D4AB00CE41D6 /* 大.svga in Resources */ = {isa = PBXBuildFile; fileRef = 4CA5A3332D93D4AB00CE41D6 /* 大.svga */; };
|
||||
4CACCCE42D9A695000CCB135 /* brove_gift.svga in Resources */ = {isa = PBXBuildFile; fileRef = 4CACCCE32D9A695000CCB135 /* brove_gift.svga */; };
|
||||
4CAE69C52E69922B00A9FC35 /* mic_cp_lv1.svga in Resources */ = {isa = PBXBuildFile; fileRef = 4CAE69C02E69922B00A9FC35 /* mic_cp_lv1.svga */; };
|
||||
4CAE69C62E69922B00A9FC35 /* mic_cp_lv2.svga in Resources */ = {isa = PBXBuildFile; fileRef = 4CAE69C12E69922B00A9FC35 /* mic_cp_lv2.svga */; };
|
||||
4CAE69C72E69922B00A9FC35 /* mic_cp_lv4.svga in Resources */ = {isa = PBXBuildFile; fileRef = 4CAE69C32E69922B00A9FC35 /* mic_cp_lv4.svga */; };
|
||||
4CAE69C82E69922B00A9FC35 /* mic_cp_lv5.svga in Resources */ = {isa = PBXBuildFile; fileRef = 4CAE69C42E69922B00A9FC35 /* mic_cp_lv5.svga */; };
|
||||
4CAE69C92E69922B00A9FC35 /* mic_cp_lv3.svga in Resources */ = {isa = PBXBuildFile; fileRef = 4CAE69C22E69922B00A9FC35 /* mic_cp_lv3.svga */; };
|
||||
4CAE69CC2E69A2DB00A9FC35 /* MicMidpointRectManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAE69CB2E69A2DB00A9FC35 /* MicMidpointRectManager.m */; };
|
||||
4CAFEFF62DD2F21B00CD81DF /* CreateEventPickerContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAFEFF52DD2F21B00CD81DF /* CreateEventPickerContainerView.m */; };
|
||||
4CAFF00A2DD342A400CD81DF /* MessagePublicEventModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAFF0092DD342A400CD81DF /* MessagePublicEventModel.m */; };
|
||||
4CAFF00D2DD343B200CD81DF /* PublicEventTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAFF00C2DD343B200CD81DF /* PublicEventTableViewCell.m */; };
|
||||
@@ -2791,6 +2797,13 @@
|
||||
4CA532C22D5F37DC00B8F59F /* LuckyPackageMessageTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LuckyPackageMessageTableViewCell.m; sourceTree = "<group>"; };
|
||||
4CA5A3332D93D4AB00CE41D6 /* 大.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = "大.svga"; sourceTree = "<group>"; };
|
||||
4CACCCE32D9A695000CCB135 /* brove_gift.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = brove_gift.svga; sourceTree = "<group>"; };
|
||||
4CAE69C02E69922B00A9FC35 /* mic_cp_lv1.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = mic_cp_lv1.svga; sourceTree = "<group>"; };
|
||||
4CAE69C12E69922B00A9FC35 /* mic_cp_lv2.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = mic_cp_lv2.svga; sourceTree = "<group>"; };
|
||||
4CAE69C22E69922B00A9FC35 /* mic_cp_lv3.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = mic_cp_lv3.svga; sourceTree = "<group>"; };
|
||||
4CAE69C32E69922B00A9FC35 /* mic_cp_lv4.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = mic_cp_lv4.svga; sourceTree = "<group>"; };
|
||||
4CAE69C42E69922B00A9FC35 /* mic_cp_lv5.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = mic_cp_lv5.svga; sourceTree = "<group>"; };
|
||||
4CAE69CA2E69A2DB00A9FC35 /* MicMidpointRectManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicMidpointRectManager.h; sourceTree = "<group>"; };
|
||||
4CAE69CB2E69A2DB00A9FC35 /* MicMidpointRectManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicMidpointRectManager.m; sourceTree = "<group>"; };
|
||||
4CAFEFF42DD2F21B00CD81DF /* CreateEventPickerContainerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CreateEventPickerContainerView.h; sourceTree = "<group>"; };
|
||||
4CAFEFF52DD2F21B00CD81DF /* CreateEventPickerContainerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CreateEventPickerContainerView.m; sourceTree = "<group>"; };
|
||||
4CAFF0082DD342A400CD81DF /* MessagePublicEventModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessagePublicEventModel.h; sourceTree = "<group>"; };
|
||||
@@ -7110,6 +7123,11 @@
|
||||
54FFD37D2C9BD12600DE61E5 /* 3.svga */,
|
||||
54FFD37E2C9BD12600DE61E5 /* 4.svga */,
|
||||
54FFD37F2C9BD12600DE61E5 /* 5.svga */,
|
||||
4CAE69C02E69922B00A9FC35 /* mic_cp_lv1.svga */,
|
||||
4CAE69C12E69922B00A9FC35 /* mic_cp_lv2.svga */,
|
||||
4CAE69C22E69922B00A9FC35 /* mic_cp_lv3.svga */,
|
||||
4CAE69C32E69922B00A9FC35 /* mic_cp_lv4.svga */,
|
||||
4CAE69C42E69922B00A9FC35 /* mic_cp_lv5.svga */,
|
||||
);
|
||||
path = cp;
|
||||
sourceTree = "<group>";
|
||||
@@ -10904,6 +10922,8 @@
|
||||
E8AEAEEA27141ACC0017FCE0 /* StageView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4CAE69CA2E69A2DB00A9FC35 /* MicMidpointRectManager.h */,
|
||||
4CAE69CB2E69A2DB00A9FC35 /* MicMidpointRectManager.m */,
|
||||
E874B88527215CFF003954B9 /* Model */,
|
||||
E8680707271959090024F48F /* MicroView */,
|
||||
181D7F192726CE2A00B7C059 /* StageView.h */,
|
||||
@@ -11771,6 +11791,11 @@
|
||||
E80EC82628ACD84000D133C5 /* emoji_10@2x.png in Resources */,
|
||||
E80EC82C28ACD84000D133C5 /* emoji_59@2x.png in Resources */,
|
||||
E80EC81A28ACD84000D133C5 /* emoji_161@2x.png in Resources */,
|
||||
4CAE69C52E69922B00A9FC35 /* mic_cp_lv1.svga in Resources */,
|
||||
4CAE69C62E69922B00A9FC35 /* mic_cp_lv2.svga in Resources */,
|
||||
4CAE69C72E69922B00A9FC35 /* mic_cp_lv4.svga in Resources */,
|
||||
4CAE69C82E69922B00A9FC35 /* mic_cp_lv5.svga in Resources */,
|
||||
4CAE69C92E69922B00A9FC35 /* mic_cp_lv3.svga in Resources */,
|
||||
E80EC85228ACD84000D133C5 /* emoji_114@2x.png in Resources */,
|
||||
E80EC81F28ACD84000D133C5 /* emoji_45@2x.png in Resources */,
|
||||
E80EC85A28ACD84000D133C5 /* emoji_14@2x.png in Resources */,
|
||||
@@ -13233,6 +13258,7 @@
|
||||
E878893F273A54F500BF1D57 /* XPGiftPresenter.m in Sources */,
|
||||
1464C5F929A4D00000AF7C94 /* XPIAPRechargeHeaderView.m in Sources */,
|
||||
E83645A82A40AF5400E0DBE4 /* NSBundle+Localizable.m in Sources */,
|
||||
4CAE69CC2E69A2DB00A9FC35 /* MicMidpointRectManager.m in Sources */,
|
||||
23E9EA7F2A839B2F00B792F2 /* MessageTreasureFairyModel.m in Sources */,
|
||||
E8778AFB2989034200CF139B /* XPSessionSayHelloEmptyTableViewCell.m in Sources */,
|
||||
238B37B02AC55A2C00BFC9D5 /* XPTreasureFairyStoreResultCell.m in Sources */,
|
||||
|
@@ -76,6 +76,7 @@
|
||||
#import "XPRoomFunctionContainerView.h"
|
||||
#import "XPRoomRankEntranceView.h"
|
||||
#import "XPRoomAnchorRankEnterView.h"
|
||||
#import "SocialStageView.h"
|
||||
#import "MSRoomOnLineView.h"
|
||||
#import "XPTurboModeConstants.h"
|
||||
#import "../MoreView/Manager/TurboModeStateManager.h"
|
||||
@@ -3874,6 +3875,57 @@ BannerSchedulerDelegate
|
||||
self.savedTapPoint = CGPointZero;
|
||||
}
|
||||
|
||||
/// 调试方法:在界面上绘制所有符合条件(横向相邻,1-4 或 5-8)的麦位中点 75x75 半透明矩形
|
||||
- (void)debug_drawMicMidpointRects {
|
||||
// 移除旧的调试矩形
|
||||
NSArray<UIView *> *subviews = [self.topContainer.subviews copy];
|
||||
for (UIView *view in subviews) {
|
||||
if (view.tag == 56001) {
|
||||
[view removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
// 在宿主视图层级中查找 SocialStageView
|
||||
SocialStageView *stageView = nil;
|
||||
for (UIView *obj in self.hostDelegate.getSuperView.subviews) {
|
||||
if ([obj isKindOfClass:[SocialStageView class]]) {
|
||||
stageView = (SocialStageView *)obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!stageView) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 定义所有横向相邻的有效麦位对
|
||||
NSArray<NSArray<NSNumber *> *> *pairs = @[
|
||||
@[@1, @2], @[@2, @3], @[@3, @4],
|
||||
@[@5, @6], @[@6, @7], @[@7, @8]
|
||||
];
|
||||
|
||||
for (NSArray<NSNumber *> *pair in pairs) {
|
||||
NSInteger left = pair.firstObject.integerValue;
|
||||
NSInteger right = pair.lastObject.integerValue;
|
||||
|
||||
CGRect stageRect = [stageView rectForMidpointBetweenMicAtIndex:left andIndex:right];
|
||||
if (CGRectIsEmpty(stageRect)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 转换到当前视图坐标系
|
||||
CGRect rectInSelf = [self convertRect:stageRect fromView:stageView];
|
||||
|
||||
UIView *overlay = [[UIView alloc] initWithFrame:rectInSelf];
|
||||
overlay.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.25];
|
||||
overlay.layer.borderColor = [UIColor.redColor colorWithAlphaComponent:0.6].CGColor;
|
||||
overlay.layer.borderWidth = 1.0;
|
||||
overlay.layer.cornerRadius = 8.0;
|
||||
overlay.clipsToBounds = YES;
|
||||
overlay.tag = 56001;
|
||||
[self.topContainer addSubview:overlay];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGRect)calculateInteractiveBoundsForView:(UIView *)view {
|
||||
// 计算视图的可交互区域
|
||||
// 这里可以根据具体的 Banner 类型来调整可交互区域
|
||||
|
@@ -6,11 +6,14 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AnchorPKStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
#import "AnchorPKStageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
@@ -60,6 +61,7 @@
|
||||
@property (strong, nonatomic) SVGAParser *parser;
|
||||
///中间进度的动画
|
||||
@property (nonatomic, strong) SVGAImageView *svgDisplayView;
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@@ -67,6 +69,9 @@
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
|
||||
[self addSubview:self.svgDisplayView];
|
||||
[self addSubview:self.ruleButton];
|
||||
[self.svgDisplayView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -142,6 +147,21 @@
|
||||
return point;
|
||||
}
|
||||
|
||||
// 主播PK:两个位置(0、1)互为相邻
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
if (!(left == 0 && right == 1)) return CGRectZero;
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
- (void)onRoomEntered {
|
||||
[super onRoomEntered];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
|
@@ -6,11 +6,14 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AnchorStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "XNDJTDDLoadingTool.h"
|
||||
#import "YUMIMacroUitls.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
#import "TTPopup.h"
|
||||
#import "Api+Room.h"
|
||||
///Model
|
||||
@@ -39,8 +40,22 @@
|
||||
// 下边坑位的左右间距
|
||||
#define marginW 50
|
||||
|
||||
@interface AnchorStageView ()
|
||||
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AnchorStageView
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger)countOfMicroView {
|
||||
return 4;
|
||||
}
|
||||
@@ -90,6 +105,27 @@
|
||||
return point;
|
||||
}
|
||||
|
||||
// 主播房布局:房主(0) + 3个麦位(1-3),仅相邻麦位(1-2, 2-3)返回中点75x75
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
|
||||
// 仅支持1-2, 2-3的相邻对
|
||||
if (!((left == 1 && right == 2) || (left == 2 && right == 3))) {
|
||||
return CGRectZero;
|
||||
}
|
||||
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
- (void)onRoomEntered {
|
||||
[super onRoomEntered];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
|
@@ -6,11 +6,14 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DatingStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
#import "DatingStageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
@@ -52,6 +53,7 @@
|
||||
@interface DatingStageView()
|
||||
///相亲进行的阶段
|
||||
@property (nonatomic,strong) MicroDatingProgressView *datingProgressView;
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@@ -59,6 +61,9 @@
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
|
||||
[self addSubview:self.datingProgressView];
|
||||
[self.datingProgressView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(datingWidth);
|
||||
@@ -152,6 +157,23 @@
|
||||
return point;
|
||||
}
|
||||
|
||||
// 相亲布局:每行两侧各 2 个麦位,中间留 dating 区,允许每侧相邻对返回中点(1-2、3-4;5-6、7-8)
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
BOOL valid = ((left == 1 && right == 2) || (left == 3 && right == 4) ||
|
||||
(left == 5 && right == 6) || (left == 7 && right == 8));
|
||||
if (!valid) return CGRectZero;
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 麦位更新扩展字段。
|
||||
*/
|
||||
|
@@ -6,11 +6,14 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FifteenMicStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#import "FifteenMicStageView.h"
|
||||
#import "SocialMicroView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
//第一行距离顶部
|
||||
#define firstRowTopMargin 60
|
||||
// 房主头像宽 58 + 光圈 5
|
||||
@@ -28,8 +29,22 @@
|
||||
//#define marginV2 15
|
||||
// 第三行坑位的顶部
|
||||
#define tRowTop (sRowTop + mcHeight + lineMargin)
|
||||
@interface FifteenMicStageView ()
|
||||
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FifteenMicStageView
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger)countOfMicroView {
|
||||
return 15;
|
||||
}
|
||||
@@ -111,4 +126,31 @@
|
||||
return point;
|
||||
}
|
||||
|
||||
// 15麦位布局:5x3网格,仅同一行且相邻列(列差1)返回中点75x75
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
|
||||
// 检查是否在同一行且相邻
|
||||
BOOL sameRow = ((left >= 0 && left <= 4 && right >= 0 && right <= 4) ||
|
||||
(left >= 5 && left <= 9 && right >= 5 && right <= 9) ||
|
||||
(left >= 10 && left <= 14 && right >= 10 && right <= 14));
|
||||
if (!sameRow) return CGRectZero;
|
||||
|
||||
// 检查是否相邻(列差为1)
|
||||
NSInteger leftCol = (left <= 4) ? left : ((left <= 9) ? (left - 5) : (left - 10));
|
||||
NSInteger rightCol = (right <= 4) ? right : ((right <= 9) ? (right - 5) : (right - 10));
|
||||
if ((rightCol - leftCol) != 1) return CGRectZero;
|
||||
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -6,11 +6,20 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface LittleGameScrollStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
/// 添加中点矩形到滚动视图
|
||||
- (void)addMidpointRect:(UIView *)rectView;
|
||||
|
||||
/// 移除所有中点矩形
|
||||
- (void)removeAllMidpointRects;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
///View
|
||||
#import "LittleGameMicroView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
|
||||
@@ -27,6 +28,7 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
@interface LittleGameScrollStageView ()
|
||||
|
||||
@property (nonatomic, strong) UIScrollView *scrollView;
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@@ -92,6 +94,8 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self.scrollView];
|
||||
|
||||
[self setupObserver];
|
||||
[self setupMicroScrollView];
|
||||
@@ -133,6 +137,23 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
return point;
|
||||
}
|
||||
|
||||
// 线性可滚动布局,相邻 index(差 1)返回中点 75x75(坐标基于 scrollView)
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
if (left < 0 || right >= [self countOfMicroView]) return CGRectZero;
|
||||
if ((right - left) != 1) return CGRectZero; // 仅相邻
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
// 坐标在自身(scrollView 内),返回给调用方在自身坐标使用
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
- (void)didSelectAtIndex:(NSInteger)index {
|
||||
MicroQueueModel* micModel = [self findMicroInfoByUid:[AccountInfoStorage instance].getUid];
|
||||
if (micModel && micModel.userInfo.uid > 0 && micModel.userInfo.gameStatus == LittleGamePlayStatus_Plying) {
|
||||
@@ -157,10 +178,40 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
_scrollView.scrollEnabled = YES;
|
||||
_scrollView.showsHorizontalScrollIndicator = NO;
|
||||
_scrollView.clipsToBounds = NO;
|
||||
_scrollView.delegate = self;
|
||||
}
|
||||
return _scrollView;
|
||||
}
|
||||
|
||||
#pragma mark - UIScrollViewDelegate
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
// 中点矩形已经基于 scrollView 坐标系,无需额外调整
|
||||
// 因为 rectForMidpointBetweenMicAtIndex:andIndex: 返回的坐标已经是相对于 scrollView 的
|
||||
}
|
||||
|
||||
#pragma mark - 中点矩形管理
|
||||
|
||||
- (void)addMidpointRect:(UIView *)rectView {
|
||||
// 使用新的管理器添加中点矩形
|
||||
NSString *micPairText = @"";
|
||||
for (UIView *subview in rectView.subviews) {
|
||||
if ([subview isKindOfClass:[UILabel class]]) {
|
||||
UILabel *label = (UILabel *)subview;
|
||||
micPairText = label.text ?: @"";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self.midpointRectManager addMidpointRectAtFrame:rectView.frame
|
||||
micPairText:micPairText
|
||||
autoPlaySVGA:YES];
|
||||
}
|
||||
|
||||
- (void)removeAllMidpointRects {
|
||||
[self.midpointRectManager removeAllMidpointRects];
|
||||
}
|
||||
|
||||
#pragma mark - 触摸事件日志
|
||||
|
||||
// 触摸开始
|
||||
|
@@ -6,11 +6,20 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface LittleGameStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
/// 添加中点矩形到视图
|
||||
- (void)addMidpointRect:(UIView *)rectView;
|
||||
|
||||
/// 移除所有中点矩形
|
||||
- (void)removeAllMidpointRects;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
///View
|
||||
#import "LittleGameMicroView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
|
||||
@@ -26,6 +27,8 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
|
||||
@interface LittleGameStageView ()
|
||||
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LittleGameStageView
|
||||
@@ -36,6 +39,9 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeViewState:) name:kRoomRoomLittleGameMiniStageNotificationKey object:nil];
|
||||
}
|
||||
return self;
|
||||
@@ -75,6 +81,22 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
return point;
|
||||
}
|
||||
|
||||
// 同一行线性排布,允许相邻 index(差 1)返回中点 75x75
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
if (left < 0 || right >= [self countOfMicroView]) return CGRectZero;
|
||||
if ((right - left) != 1) return CGRectZero; // 仅相邻
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
- (void)didSelectAtIndex:(NSInteger)index {
|
||||
MicroQueueModel* micModel = [self findMicroInfoByUid:[AccountInfoStorage instance].getUid];
|
||||
if (micModel && micModel.userInfo.uid > 0 && micModel.userInfo.gameStatus == LittleGamePlayStatus_Plying) {
|
||||
@@ -94,4 +116,26 @@ UIKIT_EXTERN NSString * const kRoomRoomLittleGameMiniStageNotificationKey;
|
||||
self.hidden = [[dic objectForKey:@"isMini"] boolValue];
|
||||
}
|
||||
|
||||
#pragma mark - 中点矩形管理
|
||||
|
||||
- (void)addMidpointRect:(UIView *)rectView {
|
||||
// 使用新的管理器添加中点矩形
|
||||
NSString *micPairText = @"";
|
||||
for (UIView *subview in rectView.subviews) {
|
||||
if ([subview isKindOfClass:[UILabel class]]) {
|
||||
UILabel *label = (UILabel *)subview;
|
||||
micPairText = label.text ?: @"";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self.midpointRectManager addMidpointRectAtFrame:rectView.frame
|
||||
micPairText:micPairText
|
||||
autoPlaySVGA:YES];
|
||||
}
|
||||
|
||||
- (void)removeAllMidpointRects {
|
||||
[self.midpointRectManager removeAllMidpointRects];
|
||||
}
|
||||
|
||||
@end
|
||||
|
49
YuMi/Modules/YMRoom/View/StageView/MicMidpointRectManager.h
Normal file
49
YuMi/Modules/YMRoom/View/StageView/MicMidpointRectManager.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// MicMidpointRectManager.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by AI Assistant on 2024/12/19.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MicMidpointRectManager;
|
||||
|
||||
@protocol MicMidpointRectManagerDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
/// 中点矩形动画播放完成
|
||||
- (void)midpointRectManager:(MicMidpointRectManager *)manager didFinishAnimationAtRect:(CGRect)rect;
|
||||
|
||||
@end
|
||||
|
||||
@interface MicMidpointRectManager : NSObject
|
||||
|
||||
@property (nonatomic, weak) id<MicMidpointRectManagerDelegate> delegate;
|
||||
@property (nonatomic, weak) UIView *containerView;
|
||||
|
||||
/// 初始化方法
|
||||
- (instancetype)initWithContainerView:(UIView *)containerView;
|
||||
|
||||
/// 添加中点矩形,支持SVGA动画
|
||||
- (void)addMidpointRectAtFrame:(CGRect)frame
|
||||
micPairText:(NSString *)micPairText
|
||||
autoPlaySVGA:(BOOL)autoPlaySVGA;
|
||||
|
||||
/// 移除所有中点矩形
|
||||
- (void)removeAllMidpointRects;
|
||||
|
||||
/// 移除指定位置的中点矩形
|
||||
- (void)removeMidpointRectAtFrame:(CGRect)frame;
|
||||
|
||||
/// 播放指定位置的SVGA动画
|
||||
- (void)playSVGAAnimationAtFrame:(CGRect)frame;
|
||||
|
||||
/// 停止所有SVGA动画
|
||||
- (void)stopAllSVGAAnimations;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
159
YuMi/Modules/YMRoom/View/StageView/MicMidpointRectManager.m
Normal file
159
YuMi/Modules/YMRoom/View/StageView/MicMidpointRectManager.m
Normal file
@@ -0,0 +1,159 @@
|
||||
//
|
||||
// MicMidpointRectManager.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by AI Assistant on 2024/12/19.
|
||||
//
|
||||
|
||||
#import "MicMidpointRectManager.h"
|
||||
#import <SVGA.h>
|
||||
|
||||
@interface MicMidpointRectManager ()
|
||||
|
||||
@property (nonatomic, strong) NSMutableArray<UIView *> *midpointRects;
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSString *, SVGAImageView *> *svgaViews;
|
||||
@property (nonatomic, strong) SVGAParser *svgaParser;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MicMidpointRectManager
|
||||
|
||||
- (instancetype)initWithContainerView:(UIView *)containerView {
|
||||
if (self = [super init]) {
|
||||
_containerView = containerView;
|
||||
_midpointRects = [NSMutableArray array];
|
||||
_svgaViews = [NSMutableDictionary dictionary];
|
||||
_svgaParser = [[SVGAParser alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)addMidpointRectAtFrame:(CGRect)frame
|
||||
micPairText:(NSString *)micPairText
|
||||
autoPlaySVGA:(BOOL)autoPlaySVGA {
|
||||
|
||||
// 创建背景矩形
|
||||
UIView *rectView = [[UIView alloc] initWithFrame:frame];
|
||||
rectView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.3];
|
||||
rectView.layer.borderColor = [UIColor blueColor].CGColor;
|
||||
rectView.layer.borderWidth = 2.0;
|
||||
rectView.layer.cornerRadius = 8.0;
|
||||
rectView.userInteractionEnabled = NO;
|
||||
rectView.tag = 56002;
|
||||
|
||||
// 添加标签显示麦位对
|
||||
UILabel *label = [[UILabel alloc] init];
|
||||
label.text = micPairText;
|
||||
label.textColor = [UIColor whiteColor];
|
||||
label.font = [UIFont boldSystemFontOfSize:12];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
label.frame = rectView.bounds;
|
||||
[rectView addSubview:label];
|
||||
|
||||
// 添加到容器视图
|
||||
[self.containerView addSubview:rectView];
|
||||
[self.midpointRects addObject:rectView];
|
||||
|
||||
// 如果需要自动播放SVGA动画
|
||||
if (autoPlaySVGA) {
|
||||
[self playSVGAAnimationAtFrame:frame];
|
||||
}
|
||||
|
||||
NSLog(@"🔧 添加中点矩形: %@, frame: %@", micPairText, NSStringFromCGRect(frame));
|
||||
}
|
||||
|
||||
- (void)removeAllMidpointRects {
|
||||
// 停止所有SVGA动画
|
||||
[self stopAllSVGAAnimations];
|
||||
|
||||
// 移除所有中点矩形
|
||||
for (UIView *rectView in self.midpointRects) {
|
||||
[rectView removeFromSuperview];
|
||||
}
|
||||
[self.midpointRects removeAllObjects];
|
||||
|
||||
NSLog(@"🔧 移除所有中点矩形");
|
||||
}
|
||||
|
||||
- (void)removeMidpointRectAtFrame:(CGRect)frame {
|
||||
// 停止对应位置的SVGA动画
|
||||
NSString *frameKey = NSStringFromCGRect(frame);
|
||||
SVGAImageView *svgaView = self.svgaViews[frameKey];
|
||||
if (svgaView) {
|
||||
[svgaView stopAnimation];
|
||||
[svgaView removeFromSuperview];
|
||||
[self.svgaViews removeObjectForKey:frameKey];
|
||||
}
|
||||
|
||||
// 移除对应位置的中点矩形
|
||||
for (UIView *rectView in [self.midpointRects copy]) {
|
||||
if (CGRectEqualToRect(rectView.frame, frame)) {
|
||||
[rectView removeFromSuperview];
|
||||
[self.midpointRects removeObject:rectView];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"🔧 移除指定位置的中点矩形: %@", NSStringFromCGRect(frame));
|
||||
}
|
||||
|
||||
- (void)playSVGAAnimationAtFrame:(CGRect)frame {
|
||||
// 随机选择一个SVGA资源
|
||||
NSArray *svgaFiles = @[@"mic_cp_lv1", @"mic_cp_lv2", @"mic_cp_lv3", @"mic_cp_lv4", @"mic_cp_lv5"];
|
||||
NSString *randomSVGA = svgaFiles[arc4random_uniform((uint32_t)svgaFiles.count)];
|
||||
|
||||
// 构建SVGA文件路径
|
||||
NSString *svgaPath = [[NSBundle mainBundle] pathForResource:randomSVGA ofType:@"svga"];
|
||||
if (!svgaPath) {
|
||||
NSLog(@"⚠️ 找不到SVGA文件: %@", randomSVGA);
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建SVGAImageView
|
||||
SVGAImageView *svgaView = [[SVGAImageView alloc] initWithFrame:frame];
|
||||
svgaView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
svgaView.userInteractionEnabled = NO;
|
||||
svgaView.backgroundColor = [UIColor clearColor];
|
||||
|
||||
// 添加到容器视图
|
||||
[self.containerView addSubview:svgaView];
|
||||
|
||||
// 保存SVGA视图引用
|
||||
NSString *frameKey = NSStringFromCGRect(frame);
|
||||
self.svgaViews[frameKey] = svgaView;
|
||||
|
||||
// 解析并播放SVGA动画
|
||||
[self.svgaParser parseWithURL:[NSURL fileURLWithPath:svgaPath]
|
||||
completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
svgaView.videoItem = videoItem;
|
||||
svgaView.loops = 0;
|
||||
svgaView.clearsAfterStop = YES;
|
||||
[svgaView startAnimation];
|
||||
|
||||
NSLog(@"🎬 开始播放SVGA动画: %@, frame: %@", randomSVGA, NSStringFromCGRect(frame));
|
||||
});
|
||||
} failureBlock:^(NSError * _Nonnull error) {
|
||||
NSLog(@"❌ SVGA动画解析失败: %@, error: %@", randomSVGA, error.localizedDescription);
|
||||
[svgaView removeFromSuperview];
|
||||
[self.svgaViews removeObjectForKey:frameKey];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)stopAllSVGAAnimations {
|
||||
for (SVGAImageView *svgaView in self.svgaViews.allValues) {
|
||||
[svgaView stopAnimation];
|
||||
[svgaView removeFromSuperview];
|
||||
}
|
||||
[self.svgaViews removeAllObjects];
|
||||
|
||||
NSLog(@"🔧 停止所有SVGA动画");
|
||||
}
|
||||
|
||||
#pragma mark - Dealloc
|
||||
|
||||
- (void)dealloc {
|
||||
[self removeAllMidpointRects];
|
||||
}
|
||||
|
||||
@end
|
@@ -6,11 +6,14 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NineteenMicStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#import "NineteenMicStageView.h"
|
||||
#import "SocialMicroView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
//第一行距离顶部
|
||||
#define firstRowTopMargin 60
|
||||
@@ -32,8 +33,22 @@
|
||||
|
||||
static const NSInteger kMicCountPerRow = 5;
|
||||
|
||||
@interface NineteenMicStageView ()
|
||||
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NineteenMicStageView
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger)countOfMicroView {
|
||||
return 19; // 麦位总数
|
||||
}
|
||||
@@ -128,4 +143,59 @@ static const NSInteger kMicCountPerRow = 5;
|
||||
return [self convertPoint:center toView:nil];
|
||||
}
|
||||
|
||||
// 19麦位布局:复杂布局,仅同一行且相邻列(列差1)返回中点75x75
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
|
||||
// 检查是否在同一行且相邻
|
||||
BOOL sameRow = NO;
|
||||
NSInteger leftCol = -1, rightCol = -1;
|
||||
|
||||
// 第一行:0-4 (5列)
|
||||
if (left >= 0 && left <= 4 && right >= 0 && right <= 4) {
|
||||
sameRow = YES;
|
||||
leftCol = left;
|
||||
rightCol = right;
|
||||
}
|
||||
// 第二行:5-6, 8-9 (4列,中间有Boss位7)
|
||||
else if (((left >= 5 && left <= 6) && (right >= 5 && right <= 6)) ||
|
||||
((left >= 8 && left <= 9) && (right >= 8 && right <= 9))) {
|
||||
sameRow = YES;
|
||||
leftCol = (left <= 6) ? left - 5 : left - 6;
|
||||
rightCol = (right <= 6) ? right - 5 : right - 6;
|
||||
}
|
||||
// 第三行:10-13 (4列),但排除11-12
|
||||
else if (left >= 10 && left <= 13 && right >= 10 && right <= 13) {
|
||||
// 排除11-12的相邻对
|
||||
if (left == 11 && right == 12) {
|
||||
return CGRectZero;
|
||||
}
|
||||
sameRow = YES;
|
||||
leftCol = left - 10;
|
||||
rightCol = right - 10;
|
||||
}
|
||||
// 第四行:14-18 (5列)
|
||||
else if (left >= 14 && left <= 18 && right >= 14 && right <= 18) {
|
||||
sameRow = YES;
|
||||
leftCol = left - 14;
|
||||
rightCol = right - 14;
|
||||
}
|
||||
|
||||
if (!sameRow) return CGRectZero;
|
||||
|
||||
// 检查是否相邻(列差为1)
|
||||
if ((rightCol - leftCol) != 1) return CGRectZero;
|
||||
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -6,11 +6,18 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SocialStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
/// 返回两个横向相邻麦位中点位置的矩形区域(75x75)。
|
||||
/// 仅当两个索引同一行且相邻,并且位于 [1-4] 或 [5-8] 范围内时有效;否则返回 CGRectZero。
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#import "YUMIMacroUitls.h"
|
||||
#import "RoomInfoModel.h"
|
||||
#import "ClientConfig.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
//房主距离顶部间距
|
||||
#define ownerTopMargin 100
|
||||
#define ownerTopMargin_little_screen 35
|
||||
@@ -34,8 +35,22 @@
|
||||
// 第一行坑位的顶部
|
||||
#define secondRowTop (firstRowTop + mcHeight + marginV2)
|
||||
|
||||
@interface SocialStageView ()
|
||||
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SocialStageView
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger)countOfMicroView {
|
||||
return 9;
|
||||
}
|
||||
@@ -113,4 +128,47 @@
|
||||
return point;
|
||||
}
|
||||
|
||||
// 计算两个横向相邻麦位之间的中点矩形(75x75)。
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
// 仅支持下排与上排的麦位区间 [1-4], [5-8] 且相邻
|
||||
if (firstIndex == secondIndex) {
|
||||
return CGRectZero;
|
||||
}
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
BOOL sameRowFirst = (left >= 1 && left <= 4 && right >= 1 && right <= 4);
|
||||
BOOL sameRowSecond = (left >= 5 && left <= 8 && right >= 5 && right <= 8);
|
||||
if (!(sameRowFirst || sameRowSecond)) {
|
||||
return CGRectZero;
|
||||
}
|
||||
if (right - left != 1) {
|
||||
return CGRectZero;
|
||||
}
|
||||
|
||||
// 取两个麦位的 rect
|
||||
CGRect leftRect = [self rectForViewAtIndex:left];
|
||||
CGRect rightRect = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(leftRect) || CGRectIsEmpty(rightRect)) {
|
||||
return CGRectZero;
|
||||
}
|
||||
|
||||
// 取头像区域(上方圆形区域)的中心点作为基准。头像宽为 mcWidth 的圆区域,居于麦位 rect 顶部。
|
||||
// 在已有实现中,动画点位使用了 (rect.origin.y + mcWidth/2 - 10)。这里复用相同的纵向基准,保证视觉一致。
|
||||
CGFloat f_top = iPhoneXSeries ? firstRowTop : ownerHeight + marginV1 + ownerTopMargin_little_screen;
|
||||
CGFloat s_top = iPhoneXSeries ? secondRowTop : mcHeight + marginV2 + f_top;
|
||||
|
||||
BOOL inFirstRow = sameRowFirst;
|
||||
CGFloat circleCenterY = (inFirstRow ? (f_top + mcWidth / 2 - 10) : (s_top + mcWidth / 2 - 10));
|
||||
|
||||
// 两个头像中心的 X 坐标
|
||||
CGFloat leftCenterX = CGRectGetMinX(leftRect) + mcWidth / 2;
|
||||
CGFloat rightCenterX = CGRectGetMinX(rightRect) + mcWidth / 2;
|
||||
CGFloat midX = (leftCenterX + rightCenterX) / 2.0;
|
||||
|
||||
// 以中点为中心,返回 75x75 的矩形
|
||||
CGFloat size = 75.0;
|
||||
CGRect midRect = CGRectMake(midX - size / 2.0, circleCenterY - size / 2.0, size, size);
|
||||
return midRect;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -74,6 +74,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate;
|
||||
-(void)exitNIMRoom;
|
||||
|
||||
/// 计算两个横向相邻麦位中点的矩形(默认返回基于两个坑位中心点的 75x75,非同一行或非相邻返回 CGRectZero)。
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -1210,6 +1210,34 @@
|
||||
return CGRectZero;
|
||||
}
|
||||
|
||||
/// 默认实现:基于两个坑位的 rect 中点,返回 75x75 的矩形。
|
||||
/// 子类如有明确排布规则(如相同行的相邻判定),可重写以增强约束。
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) {
|
||||
return CGRectZero;
|
||||
}
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
CGRect leftRect = [self rectForViewAtIndex:left];
|
||||
CGRect rightRect = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(leftRect) || CGRectIsEmpty(rightRect)) {
|
||||
return CGRectZero;
|
||||
}
|
||||
// 判断是否同一“行”:中心 y 差值小于高度的三分之一
|
||||
CGFloat leftCenterY = CGRectGetMidY(leftRect);
|
||||
CGFloat rightCenterY = CGRectGetMidY(rightRect);
|
||||
if (fabs(leftCenterY - rightCenterY) > (CGRectGetHeight(leftRect) / 3.0)) {
|
||||
return CGRectZero;
|
||||
}
|
||||
// 计算中点
|
||||
CGFloat leftCenterX = CGRectGetMidX(leftRect);
|
||||
CGFloat rightCenterX = CGRectGetMidX(rightRect);
|
||||
CGFloat midX = (leftCenterX + rightCenterX) / 2.0;
|
||||
CGFloat midY = (leftCenterY + rightCenterY) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
#pragma mark - StageViewProtocol - 基本上都是工具方法
|
||||
- (NSInteger)positionToIndex:(NSString*)position {
|
||||
return position.intValue + 1;
|
||||
|
@@ -6,11 +6,14 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TenMicStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#import "TenMicStageView.h"
|
||||
#import "SocialMicroView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
//第一行距离顶部
|
||||
#define firstRowTopMargin 60
|
||||
// 房主头像宽 58 + 光圈 5
|
||||
@@ -27,8 +28,22 @@
|
||||
// 第一行坑位与第二行坑位的间距
|
||||
//#define marginV2 15
|
||||
|
||||
@interface TenMicStageView ()
|
||||
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TenMicStageView
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger)countOfMicroView {
|
||||
return 10;
|
||||
}
|
||||
@@ -79,5 +94,30 @@
|
||||
return point;
|
||||
}
|
||||
|
||||
// 10麦位布局:5x2网格,仅同一行且相邻列(列差1)返回中点75x75
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
|
||||
// 检查是否在同一行且相邻
|
||||
BOOL sameRow = ((left >= 0 && left <= 4 && right >= 0 && right <= 4) ||
|
||||
(left >= 5 && left <= 9 && right >= 5 && right <= 9));
|
||||
if (!sameRow) return CGRectZero;
|
||||
|
||||
// 检查是否相邻(列差为1)
|
||||
NSInteger leftCol = (left <= 4) ? left : (left - 5);
|
||||
NSInteger rightCol = (right <= 4) ? right : (right - 5);
|
||||
if ((rightCol - leftCol) != 1) return CGRectZero;
|
||||
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -6,11 +6,14 @@
|
||||
//
|
||||
|
||||
#import "StageView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TwentyMicStageView : StageView
|
||||
|
||||
@property (nonatomic, strong, readonly) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
//- (instancetype)initWithRows:(NSInteger)rows columns:(NSInteger)columns;
|
||||
|
||||
@end
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#import "TwentyMicStageView.h"
|
||||
#import "SocialMicroView.h"
|
||||
#import "MicMidpointRectManager.h"
|
||||
|
||||
//第一行距离顶部
|
||||
#define firstRowTopMargin 60
|
||||
@@ -32,10 +33,20 @@
|
||||
|
||||
@interface TwentyMicStageView ()
|
||||
|
||||
@property (nonatomic, strong) MicMidpointRectManager *midpointRectManager;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TwentyMicStageView
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
if (self = [super initWithDelegate:delegate]) {
|
||||
// 初始化中点矩形管理器
|
||||
_midpointRectManager = [[MicMidpointRectManager alloc] initWithContainerView:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static const NSInteger kMicCountPerRow = 5;
|
||||
|
||||
- (NSInteger)countOfMicroView {
|
||||
@@ -83,5 +94,27 @@ static const NSInteger kMicCountPerRow = 5;
|
||||
return CGPointMake(x, y);
|
||||
}
|
||||
|
||||
// 覆盖:仅当同一行且相邻列(列差 1)时,返回两麦位中点 75x75 矩形
|
||||
- (CGRect)rectForMidpointBetweenMicAtIndex:(NSInteger)firstIndex andIndex:(NSInteger)secondIndex {
|
||||
if (firstIndex == secondIndex) return CGRectZero;
|
||||
NSInteger left = MIN(firstIndex, secondIndex);
|
||||
NSInteger right = MAX(firstIndex, secondIndex);
|
||||
// 同一行且列差为 1
|
||||
NSInteger leftRow = left / kMicCountPerRow;
|
||||
NSInteger rightRow = right / kMicCountPerRow;
|
||||
NSInteger leftCol = left % kMicCountPerRow;
|
||||
NSInteger rightCol = right % kMicCountPerRow;
|
||||
if (!(leftRow == rightRow && (rightCol - leftCol) == 1)) {
|
||||
return CGRectZero;
|
||||
}
|
||||
CGRect l = [self rectForViewAtIndex:left];
|
||||
CGRect r = [self rectForViewAtIndex:right];
|
||||
if (CGRectIsEmpty(l) || CGRectIsEmpty(r)) return CGRectZero;
|
||||
CGFloat midX = (CGRectGetMidX(l) + CGRectGetMidX(r)) / 2.0;
|
||||
CGFloat midY = (CGRectGetMidY(l) + CGRectGetMidY(r)) / 2.0;
|
||||
CGFloat size = 75.0;
|
||||
return CGRectMake(midX - size / 2.0, midY - size / 2.0, size, size);
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -1027,6 +1027,9 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
// 调试:检查最终状态
|
||||
[self debugStageViewStatus];
|
||||
|
||||
// 🔧 新增:如果是 SocialStageView,绘制中点矩形
|
||||
[self drawSocialStageMidpointRects];
|
||||
|
||||
[self addExitGameButton];
|
||||
|
||||
self.quickMessageContainerView.hidden = YES;
|
||||
@@ -3413,4 +3416,114 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
NSLog(@"🎮 卡顿检测模拟已触发,计数将增加");
|
||||
}
|
||||
|
||||
/// 调试方法:在所有 StageView 上绘制符合条件的相邻麦位中点矩形
|
||||
- (void)drawSocialStageMidpointRects {
|
||||
if (!self.stageView) {
|
||||
NSLog(@"🔧 当前没有 stageView,跳过中点矩形绘制");
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *stageViewClass = NSStringFromClass([self.stageView class]);
|
||||
NSLog(@"🔧 开始绘制 %@ 中点矩形", stageViewClass);
|
||||
|
||||
// 移除旧的调试矩形
|
||||
if ([self.stageView respondsToSelector:@selector(midpointRectManager)]) {
|
||||
// 使用新的管理器移除所有中点矩形
|
||||
id manager = [self.stageView valueForKey:@"midpointRectManager"];
|
||||
if ([manager respondsToSelector:@selector(removeAllMidpointRects)]) {
|
||||
[manager removeAllMidpointRects];
|
||||
}
|
||||
} else {
|
||||
// 兼容旧方式
|
||||
NSArray<UIView *> *subviews = [self.stageView.subviews copy];
|
||||
for (UIView *view in subviews) {
|
||||
if (view.tag == 56002) {
|
||||
[view removeFromSuperview];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 根据不同的 StageView 类型绘制相应的中点矩形
|
||||
NSArray *validPairs = nil;
|
||||
|
||||
if ([self.stageView isKindOfClass:[SocialStageView class]]) {
|
||||
validPairs = @[@[@1, @2], @[@2, @3], @[@3, @4], @[@5, @6], @[@6, @7], @[@7, @8]];
|
||||
} else if ([self.stageView isKindOfClass:[TenMicStageView class]]) {
|
||||
validPairs = @[@[@0, @1], @[@1, @2], @[@2, @3], @[@3, @4], @[@5, @6], @[@6, @7], @[@7, @8], @[@8, @9]];
|
||||
} else if ([self.stageView isKindOfClass:[FifteenMicStageView class]]) {
|
||||
validPairs = @[@[@0, @1], @[@1, @2], @[@2, @3], @[@3, @4], @[@5, @6], @[@6, @7], @[@7, @8], @[@8, @9], @[@10, @11], @[@11, @12], @[@12, @13], @[@13, @14]];
|
||||
} else if ([self.stageView isKindOfClass:[NineteenMicStageView class]]) {
|
||||
validPairs = @[@[@0, @1], @[@1, @2], @[@2, @3], @[@3, @4], @[@5, @6], @[@8, @9], @[@10, @11], @[@12, @13], @[@14, @15], @[@15, @16], @[@16, @17], @[@17, @18]];
|
||||
} else if ([self.stageView isKindOfClass:[TwentyMicStageView class]]) {
|
||||
validPairs = @[@[@0, @1], @[@1, @2], @[@2, @3], @[@3, @4], @[@5, @6], @[@6, @7], @[@7, @8], @[@8, @9], @[@10, @11], @[@11, @12], @[@12, @13], @[@13, @14], @[@15, @16], @[@16, @17], @[@17, @18], @[@18, @19]];
|
||||
} else if ([self.stageView isKindOfClass:[AnchorStageView class]]) {
|
||||
validPairs = @[@[@1, @2], @[@2, @3]];
|
||||
} else if ([self.stageView isKindOfClass:[DatingStageView class]]) {
|
||||
validPairs = @[@[@1, @2], @[@3, @4], @[@5, @6], @[@7, @8]];
|
||||
} else if ([self.stageView isKindOfClass:[LittleGameStageView class]]) {
|
||||
validPairs = @[@[@0, @1], @[@1, @2], @[@2, @3], @[@3, @4], @[@4, @5]];
|
||||
} else if ([self.stageView isKindOfClass:[LittleGameScrollStageView class]]) {
|
||||
// 根据实际麦位数量动态生成相邻对
|
||||
NSInteger micCount = [self.stageView countOfMicroView];
|
||||
NSMutableArray *pairs = [NSMutableArray array];
|
||||
for (NSInteger i = 0; i < micCount - 1; i++) {
|
||||
[pairs addObject:@[@(i), @(i + 1)]];
|
||||
}
|
||||
validPairs = pairs;
|
||||
} else if ([self.stageView isKindOfClass:[AnchorPKStageView class]]) {
|
||||
validPairs = @[@[@0, @1]];
|
||||
} else {
|
||||
NSLog(@"🔧 未支持的 StageView 类型: %@", stageViewClass);
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"🔧 开始绘制 %@ 中点矩形,共 %lu 对相邻麦位", stageViewClass, (unsigned long)validPairs.count);
|
||||
|
||||
for (NSArray *pair in validPairs) {
|
||||
NSInteger firstIndex = [pair[0] integerValue];
|
||||
NSInteger secondIndex = [pair[1] integerValue];
|
||||
|
||||
CGRect rect = [self.stageView rectForMidpointBetweenMicAtIndex:firstIndex andIndex:secondIndex];
|
||||
if (!CGRectIsEmpty(rect)) {
|
||||
UIView *debugView = [[UIView alloc] initWithFrame:rect];
|
||||
debugView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.3];
|
||||
debugView.layer.borderColor = [UIColor blueColor].CGColor;
|
||||
debugView.layer.borderWidth = 2.0;
|
||||
debugView.layer.cornerRadius = 8.0;
|
||||
debugView.tag = 56002;
|
||||
debugView.userInteractionEnabled = NO;
|
||||
|
||||
// 添加标签显示麦位对
|
||||
UILabel *label = [[UILabel alloc] init];
|
||||
label.text = [NSString stringWithFormat:@"%ld-%ld", (long)firstIndex, (long)secondIndex];
|
||||
label.textColor = [UIColor whiteColor];
|
||||
label.font = [UIFont boldSystemFontOfSize:12];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
label.frame = debugView.bounds;
|
||||
[debugView addSubview:label];
|
||||
|
||||
// 根据不同的 StageView 类型添加到相应的容器
|
||||
if ([self.stageView isKindOfClass:[LittleGameScrollStageView class]]) {
|
||||
[(LittleGameScrollStageView *)self.stageView addMidpointRect:debugView];
|
||||
} else if ([self.stageView isKindOfClass:[LittleGameStageView class]]) {
|
||||
[(LittleGameStageView *)self.stageView addMidpointRect:debugView];
|
||||
} else if ([self.stageView respondsToSelector:@selector(midpointRectManager)]) {
|
||||
// 使用新的管理器添加中点矩形
|
||||
id manager = [self.stageView valueForKey:@"midpointRectManager"];
|
||||
if ([manager respondsToSelector:@selector(addMidpointRectAtFrame:micPairText:autoPlaySVGA:)]) {
|
||||
NSString *micPairText = [NSString stringWithFormat:@"%ld-%ld", (long)firstIndex, (long)secondIndex];
|
||||
[manager addMidpointRectAtFrame:rect micPairText:micPairText autoPlaySVGA:YES];
|
||||
}
|
||||
} else {
|
||||
[self.stageView addSubview:debugView];
|
||||
}
|
||||
NSLog(@"🔧 绘制中点矩形: %ld-%ld, rect: %@", (long)firstIndex, (long)secondIndex, NSStringFromCGRect(rect));
|
||||
} else {
|
||||
NSLog(@"🔧 跳过无效麦位对: %ld-%ld", (long)firstIndex, (long)secondIndex);
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"🔧 %@ 中点矩形绘制完成", stageViewClass);
|
||||
}
|
||||
|
||||
@end
|
||||
|
BIN
YuMi/Resources/cp/mic_cp_lv1.svga
Normal file
BIN
YuMi/Resources/cp/mic_cp_lv1.svga
Normal file
Binary file not shown.
BIN
YuMi/Resources/cp/mic_cp_lv2.svga
Normal file
BIN
YuMi/Resources/cp/mic_cp_lv2.svga
Normal file
Binary file not shown.
BIN
YuMi/Resources/cp/mic_cp_lv3.svga
Normal file
BIN
YuMi/Resources/cp/mic_cp_lv3.svga
Normal file
Binary file not shown.
BIN
YuMi/Resources/cp/mic_cp_lv4.svga
Normal file
BIN
YuMi/Resources/cp/mic_cp_lv4.svga
Normal file
Binary file not shown.
BIN
YuMi/Resources/cp/mic_cp_lv5.svga
Normal file
BIN
YuMi/Resources/cp/mic_cp_lv5.svga
Normal file
Binary file not shown.
Reference in New Issue
Block a user