diff --git a/Tweak.x b/Tweak.x index cffdfce..44186b0 100644 --- a/Tweak.x +++ b/Tweak.x @@ -2,12 +2,12 @@ #include #import "ZSFakeTouch/ZSFakeTouchDome/ZSFakeTouch/ZSFakeTouch.h" -// --- 预设 10 个点的数据模型 --- +// --- نموذج بيانات النقرات --- @interface TapPointModel : NSObject @property (nonatomic, assign) BOOL isEnabled; @property (nonatomic, assign) CGFloat x; @property (nonatomic, assign) CGFloat y; -@property (nonatomic, strong) UIView *indicatorView; // 屏幕上的指示红点 +@property (nonatomic, strong) UIView *indicatorView; // الدائرة الحمراء على الشاشة - (NSDictionary *)toDictionary; - (void)updateWithDictionary:(NSDictionary *)dict; @@ -30,15 +30,15 @@ } @end +// --- واجهة النوافذ الشفافة المانعة للاحتجاز العشوائي --- @interface FloatingOverlayWindow : UIWindow @end @implementation FloatingOverlayWindow -// 重写 hitTest,实现除了面板和按钮之外的区域点击穿透 - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *hitView = [super hitTest:point withEvent:event]; if (hitView == self) { - return nil; // 点在空白区域,事件穿透到下层 App + return nil; // تمرير اللمس للخلفية إذا تم الضغط خارج القائمة } return hitView; } @@ -48,18 +48,17 @@ } @end +// --- مدير الأوتو كليكر الأساسي والواجهات --- @interface AutoClickerManager : NSObject @property (nonatomic, strong) FloatingOverlayWindow *overlayWindow; -@property (nonatomic, strong) UIView *controlBar; // 悬浮控制栏 -@property (nonatomic, strong) UIView *settingsPanel; // 设置面板 -@property (nonatomic, strong) UIButton *toggleBtn; // 启动/停止按钮 -@property (nonatomic, strong) UILabel *intervalLbl; -@property (nonatomic, strong) NSMutableArray *xSliders; -@property (nonatomic, strong) NSMutableArray *ySliders; +@property (nonatomic, strong) UIButton *floatingButton; // الزر العائم الأزرق +@property (nonatomic, strong) UIView *settingsPanel; // القائمة المربعة الصغيرة +@property (nonatomic, strong) UILabel *intervalLbl; // نص عرض السرعة +@property (nonatomic, strong) UISlider *intervalSlider; // شريط التحكم بالسرعة @property (nonatomic, strong) NSMutableArray *points; -@property (nonatomic, assign) CGFloat clickInterval; // 全局点击间隔 (秒) +@property (nonatomic, assign) CGFloat clickInterval; // السرعة بالثواني @property (nonatomic, assign) BOOL isRunning; -@property (nonatomic, strong) dispatch_source_t timer; // GCD定时器 +@property (nonatomic, strong) dispatch_source_t timer; // مؤقت النقر + (instancetype)sharedInstance; - (void)setupUI; @end @@ -81,32 +80,25 @@ return [NSString stringWithFormat:@"AutoClicker_Settings_%@", bundleID]; } -// 保存设置 - (void)saveSettings { NSMutableArray *pointsArray = [NSMutableArray array]; for (TapPointModel *model in self.points) { [pointsArray addObject:[model toDictionary]]; } - NSDictionary *settings = @{ @"clickInterval": @(self.clickInterval), @"points": pointsArray }; - [[NSUserDefaults standardUserDefaults] setObject:settings forKey:[self settingsKeyForCurrentApp]]; [[NSUserDefaults standardUserDefaults] synchronize]; } -// 读取设置 - (void)loadSettings { NSDictionary *settings = [[NSUserDefaults standardUserDefaults] dictionaryForKey:[self settingsKeyForCurrentApp]]; - if (settings) { - // 如果有保存的记录,就读取 if (settings[@"clickInterval"]) { self.clickInterval = [settings[@"clickInterval"] floatValue]; } - NSArray *pointsArray = settings[@"points"]; if (pointsArray && pointsArray.count == 10) { for (int i = 0; i < 10; i++) { @@ -127,374 +119,120 @@ - (instancetype)init { self = [super init]; if (self) { - _clickInterval = 0.1; // 默认 0.1 秒 + _clickInterval = 0.1; _points = [NSMutableArray array]; for (int i = 0; i < 10; i++) { [_points addObject:[[TapPointModel alloc] init]]; } - [self loadSettings]; + [self loadSettings]; } return self; } - (void)setupUI { if (self.overlayWindow) return; - self.xSliders = [NSMutableArray arrayWithCapacity:10]; - self.ySliders = [NSMutableArray arrayWithCapacity:10]; CGSize screenSize = [UIScreen mainScreen].bounds.size; - // 1. 初始化穿透 Window + // 1. إنشاء نافذة النظام الفوقية الشفافة self.overlayWindow = [[FloatingOverlayWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.overlayWindow.windowLevel = UIWindowLevelAlert + 2; self.overlayWindow.hidden = NO; self.overlayWindow.backgroundColor = [UIColor clearColor]; - // 2. 初始化预设点位的视觉指示器 (初始隐藏) + // 2. إعداد الدوائر المؤشرة للنقاط على الشاشة for (int i = 0; i < 10; i++) { TapPointModel *model = self.points[i]; - UIView *indicator = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)]; - indicator.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.6]; - indicator.layer.cornerRadius = 10; + UIView *indicator = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 26, 26)]; + indicator.backgroundColor = [[UIColor systemRedColor] colorWithAlphaComponent:0.7]; + indicator.layer.cornerRadius = 13; + indicator.layer.borderWidth = 1.5; + indicator.layer.borderColor = [UIColor whiteColor].CGColor; indicator.center = CGPointMake(model.x, model.y); indicator.hidden = !model.isEnabled; - indicator.userInteractionEnabled = NO; // 不阻挡点击 + indicator.userInteractionEnabled = YES; // تفعيل السحب المباشر للهدف باليد UILabel *numLbl = [[UILabel alloc] initWithFrame:indicator.bounds]; numLbl.text = [NSString stringWithFormat:@"%d", i+1]; numLbl.textColor = [UIColor whiteColor]; numLbl.textAlignment = NSTextAlignmentCenter; - numLbl.font = [UIFont boldSystemFontOfSize:12]; + numLbl.font = [UIFont boldSystemFontOfSize:13]; [indicator addSubview:numLbl]; + // إضافة مستشعر حركة لسحب الأهداف مباشرة في اللعبة + indicator.tag = i; + UIPanGestureRecognizer *panTarget = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleTargetPan:)]; + [indicator addGestureRecognizer:panTarget]; + [self.overlayWindow addSubview:indicator]; model.indicatorView = indicator; } - CGFloat panelMaxWidth = MIN(screenSize.width - 40, 350); - CGFloat panelMaxHeight = MIN(screenSize.height - 80, 650); - - // 3. 设置面板 (隐藏状态) - self.settingsPanel = [[UIView alloc] initWithFrame:CGRectMake(0, 0, panelMaxWidth, panelMaxHeight)]; - self.settingsPanel.center = self.overlayWindow.center; - self.settingsPanel.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.5]; - self.settingsPanel.layer.cornerRadius = 15; + // 3. تصميم الزر العائم الأزرق المستدير (Floating Button) + self.floatingButton = [UIButton buttonWithType:UIButtonTypeCustom]; + self.floatingButton.frame = CGRectMake(20, 150, 55, 55); + self.floatingButton.backgroundColor = [UIColor systemBlueColor]; + self.floatingButton.layer.cornerRadius = 27.5; + [self.floatingButton setTitle:@"🖱️" forState:UIControlStateNormal]; + self.floatingButton.titleLabel.font = [UIFont systemFontOfSize:24]; + self.floatingButton.layer.shadowColor = [UIColor blackColor].CGColor; + self.floatingButton.layer.shadowOpacity = 0.4; + self.floatingButton.layer.shadowOffset = CGSizeMake(0, 3); + + [self.floatingButton addTarget:self action:@selector(toggleMenu) forControlEvents:UIControlEventTouchUpInside]; + + UIPanGestureRecognizer *panBtn = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleButtonPan:)]; + [self.floatingButton addGestureRecognizer:panBtn]; + [self.overlayWindow addSubview:self.floatingButton]; + + // 4. تصميم القائمة المربعة الصغيرة المنبثقة (Settings Panel) + self.settingsPanel = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 270, 310)]; + self.settingsPanel.center = self.overlayWindow.center; + self.settingsPanel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.88]; + self.settingsPanel.layer.cornerRadius = 16; + self.settingsPanel.layer.borderWidth = 1.5; + self.settingsPanel.layer.borderColor = [UIColor systemBlueColor].CGColor; self.settingsPanel.hidden = YES; - self.settingsPanel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | - UIViewAutoresizingFlexibleRightMargin | - UIViewAutoresizingFlexibleTopMargin | - UIViewAutoresizingFlexibleBottomMargin; [self.overlayWindow addSubview:self.settingsPanel]; - UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.settingsPanel.bounds]; - scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - [self.settingsPanel addSubview:scrollView]; - - CGFloat currentY = 20; - - // 全局间隔设置 - self.intervalLbl = [[UILabel alloc] initWithFrame:CGRectMake(20, currentY, 200, 30)]; - self.intervalLbl.text = [NSString stringWithFormat:@"全局点击间隔: %.2f s", self.clickInterval]; - self.intervalLbl.textColor = [UIColor whiteColor]; - [scrollView addSubview:self.intervalLbl]; - - UISlider *intervalSlider = [[UISlider alloc] initWithFrame:CGRectMake(20, currentY + 30, scrollView.frame.size.width - 40, 30)]; - intervalSlider.minimumValue = 0.05; - intervalSlider.maximumValue = 2.0; - intervalSlider.value = self.clickInterval; - intervalSlider.autoresizingMask = UIViewAutoresizingFlexibleWidth; - [intervalSlider addTarget:self action:@selector(intervalChanged:) forControlEvents:UIControlEventValueChanged]; - [scrollView addSubview:intervalSlider]; - - currentY += 80; - - // 10个点的设置生成 - for (int i = 0; i < 10; i++) { - UILabel *titleLbl = [[UILabel alloc] initWithFrame:CGRectMake(20, currentY, 100, 30)]; - titleLbl.text = [NSString stringWithFormat:@"点位 %d", i+1]; - titleLbl.textColor = [UIColor whiteColor]; - titleLbl.font = [UIFont boldSystemFontOfSize:16]; - [scrollView addSubview:titleLbl]; - - UISwitch *enableSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(120, currentY, 50, 30)]; - enableSwitch.tag = i; - enableSwitch.on = self.points[i].isEnabled; - [enableSwitch addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged]; - [scrollView addSubview:enableSwitch]; - - currentY += 40; - - // X 轴标签 - UILabel *xLbl = [[UILabel alloc] initWithFrame:CGRectMake(20, currentY, 30, 30)]; - xLbl.text = @"X"; - xLbl.textColor = [UIColor whiteColor]; - xLbl.font = [UIFont boldSystemFontOfSize:16]; - [scrollView addSubview:xLbl]; - - // X 轴滑块 - UISlider *xSlider = [[UISlider alloc] initWithFrame:CGRectMake(20 + 30, currentY, scrollView.frame.size.width - 40 - 30, 30)]; - xSlider.minimumValue = 0; - xSlider.maximumValue = screenSize.width; - xSlider.value = self.points[i].x; - xSlider.tag = 100 + i; // 加 100 区分 X - xSlider.autoresizingMask = UIViewAutoresizingFlexibleWidth; - [xSlider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; - [scrollView addSubview:xSlider]; - [self.xSliders addObject:xSlider]; - - currentY += 40; - - // Y 轴标签 - UILabel *yLbl = [[UILabel alloc] initWithFrame:CGRectMake(20, currentY, 30, 30)]; - yLbl.text = @"Y"; - yLbl.textColor = [UIColor whiteColor]; - yLbl.font = [UIFont boldSystemFontOfSize:16]; - [scrollView addSubview:yLbl]; - - // Y 轴滑块 - UISlider *ySlider = [[UISlider alloc] initWithFrame:CGRectMake(20 + 30, currentY, scrollView.frame.size.width - 40 - 30, 30)]; - ySlider.minimumValue = 0; - ySlider.maximumValue = screenSize.height; - ySlider.value = self.points[i].y; - ySlider.tag = 200 + i; // 加 200 区分 Y - ySlider.autoresizingMask = UIViewAutoresizingFlexibleWidth; - [ySlider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; - [scrollView addSubview:ySlider]; - [self.ySliders addObject:ySlider]; - - currentY += 40; - - UIView *line = [[UIView alloc] initWithFrame:CGRectMake(10, currentY, scrollView.frame.size.width - 20, 1)]; - line.backgroundColor = [UIColor darkGrayColor]; - line.autoresizingMask = UIViewAutoresizingFlexibleWidth; - [scrollView addSubview:line]; - - currentY += 20; - } - scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, currentY); - - // 4. 悬浮控制条 (包含设置按钮和启动/停止按钮) - self.controlBar = [[UIView alloc] initWithFrame:CGRectMake(20, screenSize.height/2, 40, 70)]; - self.controlBar.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4]; - self.controlBar.layer.cornerRadius = 20; - [self.overlayWindow addSubview:self.controlBar]; - - // 添加拖拽手势 - UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; - [self.controlBar addGestureRecognizer:pan]; - - // 设置按钮 - UIButton *settingsBtn = [UIButton buttonWithType:UIButtonTypeSystem]; - settingsBtn.frame = CGRectMake(0, 5, 40, 30); - [settingsBtn setTitle:@"⚙️" forState:UIControlStateNormal]; - [settingsBtn addTarget:self action:@selector(toggleSettings) forControlEvents:UIControlEventTouchUpInside]; - [self.controlBar addSubview:settingsBtn]; - - // 启动/停止按钮 - self.toggleBtn = [UIButton buttonWithType:UIButtonTypeSystem]; - self.toggleBtn.frame = CGRectMake(0, 35, 40, 30); - [self.toggleBtn setTitle:@"▶️" forState:UIControlStateNormal]; - [self.toggleBtn addTarget:self action:@selector(toggleAutoClick) forControlEvents:UIControlEventTouchUpInside]; - [self.controlBar addSubview:self.toggleBtn]; - - [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(handleDeviceRotation) - name:UIDeviceOrientationDidChangeNotification - object:nil]; -} - -#pragma mark - 交互逻辑 - -- (void)handleDeviceRotation { - if (!self.overlayWindow) return; - - CGSize targetSize = [UIScreen mainScreen].bounds.size; - - self.overlayWindow.frame = CGRectMake(0, 0, targetSize.width, targetSize.height); - self.settingsPanel.center = self.overlayWindow.center; - - NSLog(@"[AutoClicker] Device rotated. New size: %f x %f", targetSize.width, targetSize.height); - - for (int i = 0; i < 10; i++) { - UISlider *xSlider = self.xSliders[i]; - UISlider *ySlider = self.ySliders[i]; - - if (xSlider) xSlider.maximumValue = targetSize.width; - if (ySlider) ySlider.maximumValue = targetSize.height; - - self.points[i].x = MIN(self.points[i].x, targetSize.width); - self.points[i].y = MIN(self.points[i].y, targetSize.height); - - if (xSlider) xSlider.value = self.points[i].x; - if (ySlider) ySlider.value = self.points[i].y; - - self.points[i].indicatorView.center = CGPointMake(self.points[i].x, self.points[i].y); - } - - [self clampControlBarToScreen]; -} - -- (void)clampControlBarToScreen { - CGSize screenSize = [UIScreen mainScreen].bounds.size; - CGFloat halfWidth = self.controlBar.bounds.size.width / 2.0; - CGFloat halfHeight = self.controlBar.bounds.size.height / 2.0; - CGFloat margin = 5.0; - - CGPoint currentCenter = self.controlBar.center; - currentCenter.x = MAX(halfWidth + margin, MIN(currentCenter.x, screenSize.width - halfWidth - margin)); - currentCenter.y = MAX(halfHeight + 30.0, MIN(currentCenter.y, screenSize.height - halfHeight - 20.0)); - - [UIView animateWithDuration:0.3 animations:^{ - self.controlBar.center = currentCenter; - }]; -} - -- (void)handlePan:(UIPanGestureRecognizer *)recognizer { - UIView *panView = recognizer.view; - CGPoint translation = [recognizer translationInView:self.overlayWindow]; - - CGPoint newCenter = CGPointMake(panView.center.x + translation.x, - panView.center.y + translation.y); - - CGSize screenSize = [UIScreen mainScreen].bounds.size; - CGFloat halfWidth = panView.bounds.size.width / 2.0; - CGFloat halfHeight = panView.bounds.size.height / 2.0; - - CGFloat margin = 5.0; - - CGFloat minX = halfWidth + margin; - CGFloat maxX = screenSize.width - halfWidth - margin; - CGFloat minY = halfHeight + 30.0; - CGFloat maxY = screenSize.height - halfHeight - 20.0; - - newCenter.x = MAX(minX, MIN(newCenter.x, maxX)); - newCenter.y = MAX(minY, MIN(newCenter.y, maxY)); - - panView.center = newCenter; - [recognizer setTranslation:CGPointZero inView:self.overlayWindow]; - [self clampControlBarToScreen]; -} - -- (void)toggleSettings { - self.settingsPanel.hidden = !self.settingsPanel.hidden; -} - -- (void)intervalChanged:(UISlider *)slider { - self.clickInterval = slider.value; - self.intervalLbl.text = [NSString stringWithFormat:@"全局点击间隔: %.2f s", self.clickInterval]; - [self saveSettings]; - if (self.isRunning) { - // 重启定时器以应用新间隔 - [self stopClicking]; - [self startClicking]; - } -} - -- (void)switchChanged:(UISwitch *)sender { - NSInteger index = sender.tag; - self.points[index].isEnabled = sender.isOn; - self.points[index].indicatorView.hidden = !sender.isOn; // 同步显示/隐藏指示点 - - [self saveSettings]; -} - -- (void)sliderChanged:(UISlider *)sender { - NSInteger tag = sender.tag; - NSInteger index = 0; - if (tag >= 200) { // Y轴 - index = tag - 200; - self.points[index].y = sender.value; - } else if (tag >= 100) { // X轴 - index = tag - 100; - self.points[index].x = sender.value; - } - self.points[index].indicatorView.center = CGPointMake(self.points[index].x, self.points[index].y); - - [self saveSettings]; -} - -#pragma mark - 连点核心逻辑 - -- (void)toggleAutoClick { - if (self.isRunning) { - [self stopClicking]; - [self.toggleBtn setTitle:@"▶️" forState:UIControlStateNormal]; - } else { - [self startClicking]; - [self.toggleBtn setTitle:@"⏹" forState:UIControlStateNormal]; - } -} - -- (void)startClicking { - if (self.isRunning) return; - self.isRunning = YES; - - // 使用 GCD 定时器,置于后台线程以免阻塞主线程 UI 渲染 - // dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); - // self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); - self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue()); - - uint64_t interval = (uint64_t)(self.clickInterval * NSEC_PER_SEC); - dispatch_source_set_timer(self.timer, dispatch_time(DISPATCH_TIME_NOW, 0), interval, 0); - - __weak typeof(self) weakSelf = self; - dispatch_source_set_event_handler(self.timer, ^{ - [weakSelf performClicks]; - }); - - dispatch_resume(self.timer); -} - -- (void)stopClicking { - if (!self.isRunning) return; - self.isRunning = NO; - if (self.timer) { - dispatch_source_cancel(self.timer); - self.timer = nil; - } -} - -- (void)performClicks { - // 遍历所有启用的点,模拟点击 - for (TapPointModel *model in self.points) { - if (model.isEnabled) { - // ZSFakeTouch 支持多点,循环快速触发即可 - CGPoint point = CGPointMake(model.x, model.y); - [ZSFakeTouch beginTouchWithPoint:point]; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.03 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [ZSFakeTouch endTouchWithPoint:point]; - }); - } - } -} - -@end - -typedef void (*MSHookMessageEx_t)(Class _class, SEL message, IMP hook, IMP *old); -static MSHookMessageEx_t MSHookMessageEx_p = NULL; - -typedef void (*UIWindow_makeKeyAndVisible_t)(id self, SEL _cmd); -static UIWindow_makeKeyAndVisible_t UIWindow_makeKeyAndVisible_p = NULL; - -static void makeKeyAndVisible(id self, SEL _cmd) { - UIWindow_makeKeyAndVisible_p(self, _cmd); - - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - // 稍微延迟一下,确保宿主应用主界面渲染完毕 - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [[AutoClickerManager sharedInstance] setupUI]; - }); - }); -} - -__attribute__((constructor)) -static void tweakConstructor() { - MSHookMessageEx_p = (MSHookMessageEx_t)dlsym(RTLD_DEFAULT, "MSHookMessageEx"); - if (!MSHookMessageEx_p) { - return; - } - - MSHookMessageEx_p(UIWindow.class, @selector(makeKeyAndVisible), (IMP)makeKeyAndVisible, (IMP *)&UIWindow_makeKeyAndVisible_p); -} \ No newline at end of file + // عنوان الواجهة المربعة + UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 250, 25)]; + titleLabel.text = @"لوحة الأوتو كليكر"; + titleLabel.textColor = [UIColor whiteColor]; + titleLabel.textAlignment = NSTextAlignmentCenter; + titleLabel.font = [UIFont boldSystemFontOfSize:17]; + [self.settingsPanel addSubview:titleLabel]; + + // زِر: إضافة هدف (تفعيل النقطة التالية المتاحة) + UIButton *btnAdd = [UIButton buttonWithType:UIButtonTypeSystem]; + btnAdd.frame = CGRectMake(20, 55, 230, 42); + btnAdd.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.15]; + [btnAdd setTitle:@"➕ إضافة هدف جديد" forState:UIControlStateNormal]; + [btnAdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + btnAdd.layer.cornerRadius = 10; + btnAdd.titleLabel.font = [UIFont boldSystemFontOfSize:14]; + [btnAdd addTarget:self action:@selector(addNewTargetPoint) forControlEvents:UIControlEventTouchUpInside]; + [self.settingsPanel addSubview:btnAdd]; + + // نص عرض السرعة الحالية + self.intervalLbl = [[UILabel alloc] initWithFrame:CGRectMake(20, 110, 230, 20)]; + self.intervalLbl.text = [NSString stringWithFormat:@"سرعة النقر: %.2f ثانية", self.clickInterval]; + self.intervalLbl.textColor = [UIColor systemGray2Color]; + self.intervalLbl.textAlignment = NSTextAlignmentCenter; + self.intervalLbl.font = [UIFont systemFontOfSize:13]; + [self.settingsPanel addSubview:self.intervalLbl]; + + // شريط زيادة وتقليل السرعة (Slider) + self.intervalSlider = [[UISlider alloc] initWithFrame:CGRectMake(20, 135, 230, 30)]; + self.intervalSlider.minimumValue = 0.02; // أسرع شيء (20 جزء من الثانية) + self.intervalSlider.maximumValue = 2.0; // أبطأ شيء (ثانيتين) + self.intervalSlider.value = self.clickInterval; + self.intervalSlider.minimumTrackTintColor = [UIColor systemBlueColor]; + [self.intervalSlider addTarget:self action:@selector(intervalChanged:) forControlEvents:UIControlEventValueChanged]; + [self.settingsPanel addSubview:self.intervalSlider]; + + // زِر: تشغيل (◀️) + UIButton *btnStart = [UIButton buttonWithType:UIButtonTypeSystem]; + btnStart.frame = CGRectMake(20, 185, 230, 45); + btnStart.backgroundColor = [UIColor systemGreenColor]; + [btnStart setTitle:@"▶️ تشغـيـل" forState:UIControlStateNormal];