forked from Passer1072/RookieAI_yolov8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RookieAI_YOLOv8_V2.3.1.py
1464 lines (1227 loc) · 66.6 KB
/
RookieAI_YOLOv8_V2.3.1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import gc
import json
import os
import threading
import time
import sys
import requests
import tkinter as tk
import webbrowser
import dxcam
import bettercam
import psutil
from math import sqrt
from tkinter import filedialog
from PIL import Image, ImageTk
from multiprocessing import Process, freeze_support
from tkinter import ttk
import cv2
import numpy as np
import pyautogui
import win32api
import win32con
import customtkinter as ctk
from mss import mss
from ultralytics import YOLO
###------------------------------------------全局变量---------------------------------------------------------------------
# 选择模型
model_file = "yolov8n.pt"
# 新建一个 MSS 对象(获取截图)
sct = mss()
# returns a DXCamera instance on primary monitor
# camera = dxcam.create(output_idx=0, output_color="BGR", max_buffer_len=2048) # returns a DXCamera instance on primary monitor
camera = bettercam.create(output_idx=0, output_color="BGR", max_buffer_len=2048) # Primary monitor's BetterCam instance
# 截图模式(请勿更改)
screenshot_mode = False
# MSS默认截图长宽(像素)
screen_width = 640
screen_height = 640
# DXcam截图分辨率
DXcam_screenshot = 360
# 初始化帧数计时器(帧数计算)
frame_counter = 0
start_time = time.time()
start_test_time = time.time()
# 新增初始化gc计时器(垃圾清理)
gc_time = time.time()
# 初始化DXcam最大FPS
dxcam_maxFPS = 30
# 自瞄范围
closest_mouse_dist = 100
# 置信度设置
confidence = 0.65
# 垂直瞄准偏移
aimOffset = 0.5
# 预测因子
prediction_factor = 0.1
# 定义额外的像素偏移量
extra_offset_x = 5 # 额外向x方向移动5个像素
extra_offset_y = 5 # 额外向y方向移动10个像素
# 软件页面大小
_win_width = 350
_win_height = 750
# 识别对象限制(敌我识别)
classes = 0
# 分阶段瞄准
stage1_scope = 55 # 强锁范围
stage1_intensity = 0.8 #强锁力度
stage2_scope = 170 # 软锁范围
stage2_intensity = 0.4 #软锁力度
# 分段瞄准开关
segmented_aiming_switch = False
# 是否开启外部测试窗口(小幅影响性能)
test_window_frame = False
# 是否打开内部测试画面(大幅影响性能)
test_images_GUI = False
# 是否跳过公告获取
crawl_information = False
# 初始化加载成功标识
loaded_successfully = False
# 目标列表
target_mapping = {'敌人': 0, '倒地': 1, '队友': 2}
# 人体示意图
img = Image.open("body_photo.png")
# 定义触发器类型和其他参数
# 在全局范围声明 GUI 控件的变量
aimbot_var = None
circle_var = None
lockSpeed_scale = None
triggerType_var = None
arduinoMode_var = None
lockKey_var = None
confidence_scale = None
closest_mouse_dist_scale = None
screen_width_scale = None
screen_height_scale = None
root = None
aimOffset_scale = None
mouse_Side_Button_Witch_var = None
value_label = None
LookSpeed_label_text = None
target_selection = None
target_selection_var = None
target_selection_str = None
method_of_prediction_var = None
readme_content = ""
# 其他全局变量
Thread_to_join = None
restart_thread = False
run_threads = True
draw_center = True
###------------------------------------------def部分---------------------------------------------------------------------
def calculate_screen_monitor(capture_width=640, capture_height=640): # 截图区域
# 获取屏幕的宽度和高度
screen_width, screen_height = pyautogui.size()
# 计算中心点坐标
center_x, center_y = screen_width // 2, screen_height // 2
# 定义截图区域,以中心点为基准,截取一个 capture_width x capture_height 的区域
monitor = {
"top": center_y - capture_height // 2,
"left": center_x - capture_width // 2,
"width": capture_width,
"height": capture_height,
}
return monitor
def calculate_frame_rate(frame_counter, start_time, end_time): # 帧率计算
# 避免被零除
if end_time - start_time != 0:
frame_rate = frame_counter / (end_time - start_time)
# 重置下一秒的frame_counter和start_time
frame_counter = 0
start_time = time.time()
else:
frame_rate = 0 # Or assign something that makes sense in your case
return frame_rate, frame_counter, start_time
def update_and_display_fps(frame_, frame_counter, start_time, end_time):
frame_counter += 1
frame_rate, frame_counter, start_time = calculate_frame_rate(frame_counter, start_time, end_time)
# 在 cv2 窗口中继续显示帧率
cv2.putText(frame_, f"FPS: {frame_rate:.0f}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
# 在图形用户界面上显示帧率
text_fps = "实时FPS:{:.0f}".format(frame_rate)
image_label_FPSlabel.configure(text=text_fps)
print(f"FPS: {frame_rate:.0f}") # 在控制台打印帧率(如果需要的话)
return frame_, frame_counter, start_time
def capture_screen(monitor, sct): # mss截图方式
# 使用 MSS 来抓取屏幕
screenshot = sct.grab(monitor)
# 把 PIL/Pillow Image 转为 OpenCV ndarray 对象,然后从 BGR 转换为 RGB
frame = np.array(screenshot)[:, :, :3]
return frame
def DXcam():
# 获取屏幕的宽度和高度
screen_width, screen_height = pyautogui.size()
# 计算截图区域
left, top = (screen_width - DXcam_screenshot) // 2, (screen_height - DXcam_screenshot) // 2
right, bottom = left + DXcam_screenshot, top + DXcam_screenshot
region = (left, top, right, bottom)
camera.start(region=region, video_mode=True, target_fps=dxcam_maxFPS) # 用于捕获区域的可选参数
def display_debug_window(frame): # 调试窗口
# 在主循环中显示图像
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('.'):
cv2.destroyAllWindows()
return True
else:
return False
def get_desired_size(screen_width_1, screen_height_1):
# 根据屏幕尺寸判断调整的大小
if screen_width_1 == 1920 and screen_height_1 == 1080:
desired_size = (300, 300)
elif screen_width_1 >= 2560 and screen_height_1 >= 1440:
desired_size = (370, 370)
else:
desired_size = (300, 300) # 默认大小
return desired_size
def fetch_readme(): # 从github更新公告
print("开始获取公告......")
try:
readme_url = "https://raw.githubusercontent.com/Passer1072/RookieAI_yolov8/master/README.md"
response = requests.get(readme_url, timeout=10)
response_text = response.text
print("获取成功")
# 找到 "更新日志:" 在字符串中的位置
update_log_start = response_text.find("更新日志:")
# 若找不到 "更新日志:",则返回全部内容
if update_log_start == -1:
return response_text
# 截取 "更新日志:" 及其后的所有文本
update_log = response_text[update_log_start:]
return update_log
except Exception as e:
print("获取失败:", e)
return "无法加载最新的 README 文件,这可能是因为网络问题或其他未知错误。"
def fetch_readme_version_number(): # 从github更新公告
print("开始获取版本号......")
try:
readme_url = "https://raw.githubusercontent.com/Passer1072/RookieAI_yolov8/master/README.md"
response = requests.get(readme_url)
response_text = response.text
print("获取成功")
# 创建搜索字符串
search_str = "Current latest version: "
# 找到 "更新日志:" 在字符串中的位置
update_log_start = response_text.find(search_str)
# 若找不到 "Current latest version: ",则返回全部内容
if update_log_start == -1:
return response_text
# 截取 "Current latest version: " 及其后的所有文本
update_log_start += len(search_str) # Move the index to the end of "Current latest version: "
update_log = response_text[update_log_start:]
# 使用 strip 方法去除两侧空格
update_log = update_log.strip()
return update_log
except Exception as e:
print("获取失败:", e)
return "版本号获取失败"
def crawl_information_by_github():
global readme_content, readme_version
if crawl_information:
# 读取在线公告
readme_content = fetch_readme()
readme_version = fetch_readme_version_number()
def open_web(event):
webbrowser.open('https://github.com/Passer1072/RookieAI_yolov8') # 要跳转的网页
def choose_model(): # 选择模型
global model_file
model_file = filedialog.askopenfilename() # 在这里让用户选择文件
model_file_label.config(text=model_file) # 更新标签上的文本为选择的文件路径
def open_settings_config():
os.startfile("settings.json")
def load_model_file(): # 加载模型文件
# 默认的模型文件地址
default_model_file = "yolov8n.pt"
try:
with open('settings.json', 'r') as f:
settings = json.load(f)
model_file = settings.get('model_file', default_model_file)
# 检查文件是否存在,如果不存在,使用默认模型文件
if not os.path.isfile(model_file):
print("[WARNING] 设置文件中的模型文件路径无效; 使用默认模型文件")
model_file = default_model_file
except FileNotFoundError:
print("[WARNING] 没有找到设置文件; 使用默认模型文件")
model_file = default_model_file
print("加载模型文件:", model_file)
# 如果 model_file 为 None或者空,我们返回None,否则我们返回对应的 YOLO 模型
return YOLO(model_file) if model_file else None
def create_gui_tkinter(): # 软件主题GUI界面
global aimbot_var, lockSpeed_scale, triggerType_var, arduinoMode_var, lockKey_var, confidence_scale \
, closest_mouse_dist_scale, screen_width_scale, screen_height_scale, root, model_file, model_file_label, aimOffset_scale \
, draw_center_var, mouse_Side_Button_Witch_var, LookSpeed_label_text, lockSpeed_variable, confidence_variable \
, closest_mouse_dist_variable, aimOffset_variable, screen_width_scale_variable, screen_height_scale_variable \
, image_label, image_label_switch, image_label_FPSlabel, target_selection_var, target_mapping, prediction_factor_variable \
, prediction_factor_scale, method_of_prediction_var, extra_offset_x_scale, extra_offset_y_scale, extra_offset_y \
, extra_offset_x, extra_offset_x_variable, extra_offset_y_variable, readme_content, screenshot_mode_var\
, screenshot_mode, segmented_aiming_switch_var, stage1_scope, stage1_scope_scale, stage1_scope_variable\
, stage1_intensity_variable, stage1_intensity, stage1_intensity_scale, stage2_scope_variable\
, stage2_intensity_variable, stage2_scope_scale, stage2_intensity_scale
# 版本号
version_number = "V2.3.1"
# 使用customtkinter创建根窗口
root = ctk.CTk()
# ctk.set_appearance_mode("system") # default
ctk.set_appearance_mode("dark")
# 在启动页面结束前隐藏主窗口
root.withdraw()
# 创建一个启动画面窗口
top = tk.Toplevel(root)
top.title("启动中")
top.attributes('-topmost', 1)
logo_file = "logo-bird.png" # 您的LOGO文件路径
photo = tk.PhotoImage(file=logo_file)
label = tk.Label(top, image=photo)
label.pack()
# 在1秒后关闭启动画面窗口并显示主窗口
def end_splash():
top.destroy() # 销毁启动画面
root.deiconify() # 显示主窗口
root.after(2000, end_splash) # 1秒后运行
# 主程序窗口置顶
root.attributes('-topmost', 1)
root.update()
root.title("RookieAI") # 软件名称
root.geometry(f"{_win_width}x{_win_height}")
# 设置当用户点击窗口的关闭按钮时要做的操作
root.protocol("WM_DELETE_WINDOW", stop_program) # 将WM_DELETE_WINDOW的默认操作设置为 _on_closing 函数
# 禁止窗口大小调整
root.resizable(False, True)
# 实例化 CTkTabview 对象
tab_view = ctk.CTkTabview(root, width=320, height=500)
# 创建选项卡
tab_view.add("基础设置")
tab_view.add("高级设置")
tab_view.add("其他设置")
tab_view.add("测试窗口")
# 将 CTkTabview 对象添加到主窗口
tab_view.grid(row=0, column=0, padx=(15, 0), pady=(0, 0))
# 创建一个Frame来包含aimbot开关和其左边的显示瞄准范围
aimbot_draw_center_frame = ctk.CTkFrame(tab_view.tab("基础设置"))
aimbot_draw_center_frame.grid(row=0, column=0, sticky='w', pady=5) # 使用grid布局并靠左对齐
# 创建一个名为 'Aimbot' 的复选框
aimbot_var = ctk.BooleanVar(value=aimbot)
aimbot_check = ctk.CTkCheckBox(aimbot_draw_center_frame, text='Aimbot', variable=aimbot_var,
command=update_values, )
aimbot_check.grid(row=0, column=0) # 使用grid布局并靠左对齐
# 是否显示瞄准范围的开关
draw_center_var = ctk.BooleanVar(value=False) # 默认值为False
draw_center_check = ctk.CTkCheckBox(aimbot_draw_center_frame, text='显示瞄准范围(测试用)', variable=draw_center_var,
command=update_values)
draw_center_check.grid(row=0, column=1)
# 创建一个Frame来包含arduinoMode开关和其左边的显示瞄准范围
arduinoMode_frame = ctk.CTkFrame(tab_view.tab("基础设置"))
arduinoMode_frame.grid(row=1, column=0, sticky='w', pady=5) # 使用grid布局并靠左对齐
# 创建一个名为 'Arduino Mode(未启用)' 的复选框
arduinoMode_var = ctk.BooleanVar(value=arduinoMode)
arduinoMode_check = ctk.CTkCheckBox(arduinoMode_frame, text='Arduino Mode(待开发)', variable=arduinoMode_var,
command=update_values, state="DISABLED")
arduinoMode_check.grid(row=0, column=0, sticky="w", pady=(0, 0)) # 使用grid布局并靠左对齐
triggerType_var = tk.StringVar(value=triggerType)
# 创建一个Frame来包含OptionMenu和其左边的Label
triggerType_frame = ctk.CTkFrame(tab_view.tab("基础设置"))
triggerType_frame.grid(row=2, column=0, sticky='w', pady=5) # 使用grid布局并靠左对齐
# 添加一个Label
triggerType_label = ctk.CTkLabel(triggerType_frame, text="当前触发方式为:")
triggerType_label.pack(side='left') # 在Frame中靠左对齐
# 添加一个OptionMenu小部件
options = ["按下", "切换", "shift+按下"]
triggerType_option = ctk.CTkOptionMenu(triggerType_frame, variable=triggerType_var, values=options,
command=update_values)
triggerType_option.pack(side='left') # 在Frame中靠左对齐
# 创建新的Frame部件以容纳标签和OptionMenu
frame = ctk.CTkLabel(tab_view.tab("基础设置"))
frame.grid(row=3, column=0, sticky='w', pady=5) # frame在root窗口中的位置
# 创建一个标签文本并将其插入frame中
lbl = ctk.CTkLabel(frame, text="当前热键为:")
lbl.grid(row=0, column=0) # 标签在frame部件中的位置
# 创建一个可变的字符串变量以用于OptionMenu的选项值
lockKey_var = ctk.StringVar()
lockKey_var.set('右键') # 设置选项菜单初始值为'左键'
options = ['左键', '右键', '下侧键'] # 定义可用选项的列表
# 创建OptionMenu并使用lockKey_var和options
lockKey_menu = ctk.CTkOptionMenu(frame, variable=lockKey_var, values=options, command=update_values)
lockKey_menu.grid(row=0, column=1) # OptionMenu在frame部件中的位置
# 创建一个Frame来包含arduinoMode开关和其左边的显示瞄准范围
mouse_Side_Button_Witch_frame = ctk.CTkFrame(tab_view.tab("基础设置"))
mouse_Side_Button_Witch_frame.grid(row=4, column=0, sticky='w', pady=5) # 使用grid布局并靠左对齐
# 创建一个名为 '鼠标侧键瞄准开关' 的复选框
mouse_Side_Button_Witch_var = ctk.BooleanVar(value=False)
mouse_Side_Button_Witch_check = ctk.CTkCheckBox(mouse_Side_Button_Witch_frame, text='鼠标侧键瞄准开关',
variable=mouse_Side_Button_Witch_var,
command=update_values)
mouse_Side_Button_Witch_check.grid(row=0, column=0, sticky="w", pady=5) # 使用grid布局并靠左对齐
# 瞄准速度
# 创建一个 StringVar 对象以保存 lockSpeed_scale 的值
lockSpeed_variable = tk.StringVar()
lockSpeed_variable.set(str(lockSpeed))
# 一个名为 'Lock Speed' 的滑动条;瞄准速度模块
# 创建一个Frame来包含OptionMenu和其左边的Label
LookSpeed_frame = ctk.CTkFrame(tab_view.tab("基础设置"))
LookSpeed_frame.grid(row=6, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 一个Label,显示文字"LockSpeed:"
LookSpeed_label_0 = ctk.CTkLabel(LookSpeed_frame, text="LockSpeed:")
LookSpeed_label_0.grid(row=0, column=0) # 在Frame中靠左对齐
# 一个名为 'Lock Speed' 的滑动条;瞄准速度模块
lockSpeed_scale = ctk.CTkSlider(LookSpeed_frame, from_=0, to=1, number_of_steps=100, command=update_values)
lockSpeed_scale.set(lockSpeed)
lockSpeed_scale.grid(row=0, column=1)
# 使用 textvariable 而非 text
LookSpeed_label_text = ctk.CTkLabel(LookSpeed_frame, textvariable=lockSpeed_variable)
LookSpeed_label_text.grid(row=0, column=2)
# 如果分段瞄准打开则停用一般瞄准范围设置
if segmented_aiming_switch:
ban_LookSpeed_label_0 = ctk.CTkLabel(LookSpeed_frame, text="由于分段瞄准启用,该选项已禁用", width=200)
ban_LookSpeed_label_0.grid(row=0, column=1, padx=(12, 0)) # 行号
ban_LookSpeed_label_text = ctk.CTkLabel(LookSpeed_frame, text="###", width=25)
ban_LookSpeed_label_text.grid(row=0, column=2) # 行号
# 自瞄范围调整
# 创建一个 StringVar 对象以保存 closest_mouse_dist 的值
closest_mouse_dist_variable = tk.StringVar()
closest_mouse_dist_variable.set(str(closest_mouse_dist))
# 2创建一个Frame来包含OptionMenu和其左边的Label
closest_mouse_dist_frame = ctk.CTkFrame(tab_view.tab("基础设置"))
closest_mouse_dist_frame.grid(row=7, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
closest_mouse_dist_label = ctk.CTkLabel(closest_mouse_dist_frame, text="自瞄范围:")
closest_mouse_dist_label.grid(row=0, column=1, sticky='w')
# 自瞄范围调整
closest_mouse_dist_scale = ctk.CTkSlider(closest_mouse_dist_frame, from_=0, to=300, command=update_values)
closest_mouse_dist_scale.set(closest_mouse_dist)
closest_mouse_dist_scale.grid(row=0, column=2, padx=(12, 0))
# 使用 textvariable 而非 text
closest_mouse_dist_text = ctk.CTkLabel(closest_mouse_dist_frame, textvariable=closest_mouse_dist_variable)
closest_mouse_dist_text.grid(row=0, column=3)
# 如果分段瞄准打开则停用一般瞄准范围设置
if segmented_aiming_switch:
ban_closest_mouse_dist_label = ctk.CTkLabel(closest_mouse_dist_frame, text="由于分段瞄准启用,该选项已禁用", width=200)
ban_closest_mouse_dist_label.grid(row=0, column=2, padx=(12, 0)) # 行号
ban_closest_mouse_dist_text = ctk.CTkLabel(closest_mouse_dist_frame, text="####", width=30)
ban_closest_mouse_dist_text.grid(row=0, column=3) # 行号
# 创建新的Frame部件以容纳标签和OptionMenu
frame = ctk.CTkLabel(tab_view.tab("基础设置"))
frame.grid(row=8, column=0, sticky='w', pady=5) # frame在root窗口中的位置
# 创建一个标签文本并将其插入frame中
lbl = ctk.CTkLabel(frame, text="预测方法:")
lbl.grid(row=0, column=0) # 标签在frame部件中的位置
# 创建一个可变的字符串变量以用于OptionMenu的选项值
method_of_prediction_var = ctk.StringVar()
method_of_prediction_var.set('禁用预测') # 设置选项菜单初始值为'左键'
options = ['禁用预测', '倍率预测', '像素预测'] # 定义可用选项的列表
# 创建OptionMenu并使用lockKey_var和options
method_of_prediction_menu = ctk.CTkOptionMenu(frame, variable=method_of_prediction_var, values=options,
command=update_values)
method_of_prediction_menu.grid(row=0, column=1) # OptionMenu在frame部件中的位置
# 2创建一个Frame来包含OptionMenu和其左边的Label
message_text_frame = ctk.CTkFrame(tab_view.tab("基础设置"))
message_text_frame.grid(row=9, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 创建Label
message_text_Label = ctk.CTkLabel(message_text_frame, text="更新公告")
message_text_Label.grid(row=0, column=1)
# 创建文本框
message_text_box = ctk.CTkTextbox(message_text_frame, width=300, height=100, corner_radius=5)
message_text_box.grid(row=1, column=1, sticky="nsew")
message_text_box.insert("0.0", readme_content)
# 目标选择框
# 创建一个Frame来包含OptionMenu和其左边的Label
target_selection_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
target_selection_frame.grid(row=1, column=0, sticky='w', pady=5) # 使用grid布局并靠左对齐
# 创建一个标签文本并将其插入frame中
target_selection_label = ctk.CTkLabel(target_selection_frame, text="当前检测目标为:")
target_selection_label.grid(row=0, column=0) # 标签在frame部件中的位置
# 创建一个可变的字符串变量以用于OptionMenu的选项值
target_selection_var = ctk.StringVar()
target_selection_var.set('敌人') # 设置选项菜单初始值为'敌人'
# 定义可用选项的列表
options = list(target_mapping.keys())
# 创建选择框
target_selection_option = ctk.CTkOptionMenu(target_selection_frame, variable=target_selection_var, values=options,
command=update_values)
target_selection_option.grid(row=0, column=1)
# 置信度调整
# 创建一个 StringVar 对象以保存 lockSpeed_scale 的值
confidence_variable = tk.StringVar()
confidence_variable.set(str(confidence))
# 置信度调整滑块:创建一个名为 'Confidence' 的滑动条;置信度调整模块
# 创建一个Frame来包含OptionMenu和其左边的Label
confidence_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
confidence_frame.grid(row=2, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
confidence_label = ctk.CTkLabel(confidence_frame, text="置信度:")
confidence_label.grid(row=0, column=1, sticky='w')
# 置信度调整滑块:创建一个名为 'Confidence' 的滑动条;置信度调整模块
confidence_scale = ctk.CTkSlider(confidence_frame, from_=0, to=1, number_of_steps=100, command=update_values)
confidence_scale.set(confidence)
confidence_scale.grid(row=0, column=2, padx=(25, 0))
# 使用 textvariable 而非 text
confidence_label_text = ctk.CTkLabel(confidence_frame, textvariable=confidence_variable)
confidence_label_text.grid(row=0, column=3)
# 倍率预测调整
# 创建一个 StringVar 对象以保存 prediction_factor 的值
prediction_factor_variable = tk.StringVar()
prediction_factor_variable.set(str(prediction_factor))
# 2创建一个Frame来包含OptionMenu和其左边的Label
prediction_factor_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
prediction_factor_frame.grid(row=3, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
prediction_factor_label = ctk.CTkLabel(prediction_factor_frame, text="预测倍率:")
prediction_factor_label.grid(row=0, column=1, sticky='w')
# 预测因子调整
prediction_factor_scale = ctk.CTkSlider(prediction_factor_frame, from_=0, to=1, number_of_steps=100,
command=update_values)
prediction_factor_scale.set(prediction_factor)
prediction_factor_scale.grid(row=0, column=2, padx=(12, 0))
# 使用 textvariable 而非 text
prediction_factor_text = ctk.CTkLabel(prediction_factor_frame, textvariable=prediction_factor_variable)
prediction_factor_text.grid(row=0, column=3)
# 像素点预测调整
# 创建一个 StringVar 对象以保存 extra_offset_x 的值
extra_offset_x_variable = tk.StringVar()
extra_offset_x_variable.set(str(extra_offset_x))
# 一个名为 'Lock Speed' 的滑动条;瞄准速度模块
# 创建一个Frame来包含OptionMenu和其左边的Label
extra_offset_x_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
extra_offset_x_frame.grid(row=4, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 一个Label,显示文字"LockSpeed:"
extra_offset_x_label = ctk.CTkLabel(extra_offset_x_frame, text="预测像素X:")
extra_offset_x_label.grid(row=0, column=0) # 在Frame中靠左对齐
# 一个名为 'Lock Speed' 的滑动条;瞄准速度模块
extra_offset_x_scale = ctk.CTkSlider(extra_offset_x_frame, from_=0, to=20, number_of_steps=20,
command=update_values)
extra_offset_x_scale.set(extra_offset_x)
extra_offset_x_scale.grid(row=0, column=1, padx=(4, 0))
# 使用 textvariable 而非 text
extra_offset_x_label_text = ctk.CTkLabel(extra_offset_x_frame, textvariable=extra_offset_x_variable)
extra_offset_x_label_text.grid(row=0, column=2)
# 像素点预测调整
# 创建一个 StringVar 对象以保存 extra_offset_y 的值
extra_offset_y_variable = tk.StringVar()
extra_offset_y_variable.set(str(extra_offset_y))
# 一个名为 'Lock Speed' 的滑动条;瞄准速度模块
# 创建一个Frame来包含OptionMenu和其左边的Label
extra_offset_y_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
extra_offset_y_frame.grid(row=5, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 一个Label,显示文字"LockSpeed:"
extra_offset_y_label = ctk.CTkLabel(extra_offset_y_frame, text="预测像素Y:")
extra_offset_y_label.grid(row=0, column=0) # 在Frame中靠左对齐
# 一个名为 'Lock Speed' 的滑动条;瞄准速度模块
extra_offset_y_scale = ctk.CTkSlider(extra_offset_y_frame, from_=0, to=20, number_of_steps=20,
command=update_values)
extra_offset_y_scale.set(extra_offset_y)
extra_offset_y_scale.grid(row=0, column=1, padx=(4, 0))
# 使用 textvariable 而非 text
extra_offset_y_label_text = ctk.CTkLabel(extra_offset_y_frame, textvariable=extra_offset_y_variable)
extra_offset_y_label_text.grid(row=0, column=2)
# 瞄准偏移
# 创建一个 StringVar 对象以保存 closest_mouse_dist 的值
aimOffset_variable = tk.StringVar()
aimOffset_variable.set(str(aimOffset))
# 3创建一个Frame来包含滑块和其左边的Label文字
aimOffset_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
aimOffset_frame.grid(row=6, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
aimOffset_label = ctk.CTkLabel(aimOffset_frame, text="瞄准偏移:")
aimOffset_label.grid(row=0, column=1, sticky='w')
# 瞄准偏移(数值越大越靠上)
aimOffset_scale = ctk.CTkSlider(aimOffset_frame, from_=0, to=1, number_of_steps=100, command=update_values,
orientation="vertical")
aimOffset_scale.set(aimOffset)
aimOffset_scale.grid(row=0, column=2, padx=(12, 0))
# 添加一个Label显示瞄准位置:腰部
aimOffset_label = ctk.CTkLabel(aimOffset_frame, text="胯下")
aimOffset_label.grid(row=0, column=3, pady=(170, 0))
# 添加一个Label显示瞄准位置:腹部
aimOffset_label = ctk.CTkLabel(aimOffset_frame, text="腹部")
aimOffset_label.grid(row=0, column=3, pady=(80, 0))
# 添加一个Label显示瞄准位置:胸口
aimOffset_label = ctk.CTkLabel(aimOffset_frame, text="胸口")
aimOffset_label.grid(row=0, column=3, pady=(0, 5))
# 添加一个Label显示瞄准位置:头部
aimOffset_label = ctk.CTkLabel(aimOffset_frame, text="头部")
aimOffset_label.grid(row=0, column=3, pady=(0, 170))
# 添加一个Label显示人体图片
aimOffset_label = ctk.CTkLabel(aimOffset_frame, image=ctk.CTkImage(img, size=(150, 200)), text="")
aimOffset_label.grid(row=0, column=4)
# 使用 textvariable 而非 text
aimOffset_text = ctk.CTkLabel(aimOffset_frame, textvariable=aimOffset_variable)
aimOffset_text.grid(row=0, column=5, pady=(0, 0))
# 屏幕宽度
# 创建一个 StringVar 对象以保存 screen_width_scale 的值
screen_width_scale_variable = tk.StringVar()
screen_width_scale_variable.set(str(screen_width))
# 4创建一个Frame来包含滑块和其左边的Label文字
screen_width_scale_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
screen_width_scale_frame.grid(row=7, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
screen_width_scale_label = ctk.CTkLabel(screen_width_scale_frame, text="截图宽度:")
screen_width_scale_label.grid(row=0, column=1, sticky='w')
# 创建一个屏幕宽度滑块
screen_width_scale = ctk.CTkSlider(screen_width_scale_frame, from_=100, to=2000, number_of_steps=190,
command=update_values)
screen_width_scale.set(screen_width) # 初始值
screen_width_scale.grid(row=0, column=2, padx=(12, 0)) # 行号
# 使用 textvariable 而非 text
screen_width_scale_text = ctk.CTkLabel(screen_width_scale_frame, textvariable=screen_width_scale_variable)
screen_width_scale_text.grid(row=0, column=3)
# 如果启用DXcam则停用截图宽度/高度调整滑块
if screenshot_mode:
ban_screen_width_scale = ctk.CTkLabel(screen_width_scale_frame, text="由于DXcam启用,该选项已禁用", width=200)
ban_screen_width_scale.grid(row=0, column=2, padx=(12, 0)) # 行号
ban_screen_width_scale_text = ctk.CTkLabel(screen_width_scale_frame, text="####", width=30)
ban_screen_width_scale_text.grid(row=0, column=3) # 行号
# 屏幕高度
# 创建一个 StringVar 对象以保存 screen_height_scale 的值
screen_height_scale_variable = tk.StringVar()
screen_height_scale_variable.set(str(screen_height))
# 5创建一个Frame来包含滑块和其左边的Label文字
screen_height_scale_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
screen_height_scale_frame.grid(row=8, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
screen_height_scale_label = ctk.CTkLabel(screen_height_scale_frame, text="截图高度:")
screen_height_scale_label.grid(row=0, column=1, sticky='w')
# 创建一个屏幕高度滑块
screen_height_scale = ctk.CTkSlider(screen_height_scale_frame, from_=100, to=2000, number_of_steps=190,
command=update_values)
screen_height_scale.set(screen_height) # 初始值
screen_height_scale.grid(row=0, column=2, padx=(12, 0)) # 行号
# 如果启用DXcam则停用截图宽度/高度调整滑块
# 使用 textvariable 而非 text
screen_height_scale_text = ctk.CTkLabel(screen_height_scale_frame, textvariable=screen_height_scale_variable)
screen_height_scale_text.grid(row=0, column=3)
if screenshot_mode:
ban_screen_height_scale = ctk.CTkLabel(screen_height_scale_frame, text="由于DXcam启用,该选项已禁用", width=200)
ban_screen_height_scale.grid(row=0, column=2, padx=(12, 0)) # 行号
ban_screen_height_scale_text = ctk.CTkLabel(screen_height_scale_frame, text="####", width=30)
ban_screen_height_scale_text.grid(row=0, column=3) # 行号
# 截图模式选择
# 创建一个Frame来包含OptionMenu和其左边的Label
screenshot_mode_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
screenshot_mode_frame.grid(row=9, column=0, sticky='w', pady=5) # 使用grid布局并靠左对齐
# 创建一个名为 '启用DXcam模式' 的复选框
screenshot_mode_var = ctk.BooleanVar(value=screenshot_mode)
screenshot_mode_check = ctk.CTkCheckBox(screenshot_mode_frame, text='启用DXcam截图模式(保存后重启生效)', variable=screenshot_mode_var,
command=update_values)
screenshot_mode_check.grid(row=0, column=1) # 使用grid布局并靠左对齐
# 瞄准模式选择
# 创建一个Frame来包含OptionMenu和其左边的Label
segmented_aiming_switch_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
segmented_aiming_switch_frame.grid(row=10, column=0, sticky='w', pady=5) # 使用grid布局并靠左对齐
# 创建一个名为 '启用DXcam模式' 的复选框
segmented_aiming_switch_var = ctk.BooleanVar(value=segmented_aiming_switch)
segmented_aiming_switch_check = ctk.CTkCheckBox(segmented_aiming_switch_frame, text='启用分段瞄准模式(保存后重启生效)', variable=segmented_aiming_switch_var,
command=update_values)
segmented_aiming_switch_check.grid(row=0, column=1) # 使用grid布局并靠左对齐
# 分段自瞄范围调整(强锁范围)
# 创建一个 StringVar 对象以保存 stage1_scope 的值
stage1_scope_variable = tk.StringVar()
stage1_scope_variable.set(str(stage1_scope))
# 2创建一个Frame来包含OptionMenu和其左边的Label
stage1_scope_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
stage1_scope_frame.grid(row=11, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
stage1_scope_label = ctk.CTkLabel(stage1_scope_frame, text="强锁范围:")
stage1_scope_label.grid(row=0, column=1, sticky='w')
# 自瞄范围调整
stage1_scope_scale = ctk.CTkSlider(stage1_scope_frame, from_=0, to=300, number_of_steps=300, command=update_values)
stage1_scope_scale.set(stage1_scope)
stage1_scope_scale.grid(row=0, column=2, padx=(12, 0))
# 使用 textvariable 而非 text
stage1_scope_text = ctk.CTkLabel(stage1_scope_frame, textvariable=stage1_scope_variable)
stage1_scope_text.grid(row=0, column=3)
# 分段瞄准未启用时停用调整
if not segmented_aiming_switch:
ban_screen_height_scale = ctk.CTkLabel(stage1_scope_frame, text="分段瞄准未启用,该选项已禁用", width=200)
ban_screen_height_scale.grid(row=0, column=2, padx=(12, 0)) # 行号
ban_screen_height_scale_text = ctk.CTkLabel(stage1_scope_frame, text="####", width=30)
ban_screen_height_scale_text.grid(row=0, column=3) # 行号
# 分段自瞄范围调整(强锁速度)
# 创建一个 StringVar 对象以保存 stage1_intensity 的值
stage1_intensity_variable = tk.StringVar()
stage1_intensity_variable.set(str(stage1_intensity))
# 2创建一个Frame来包含OptionMenu和其左边的Label
stage1_intensity_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
stage1_intensity_frame.grid(row=12, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
stage1_intensity_label = ctk.CTkLabel(stage1_intensity_frame, text="强锁速度:")
stage1_intensity_label.grid(row=0, column=1, sticky='w')
# 自瞄范围调整
stage1_intensity_scale = ctk.CTkSlider(stage1_intensity_frame, from_=0, to=1, number_of_steps=100, command=update_values)
stage1_intensity_scale.set(stage1_intensity)
stage1_intensity_scale.grid(row=0, column=2, padx=(12, 0))
# 使用 textvariable 而非 text
stage1_intensity_text = ctk.CTkLabel(stage1_intensity_frame, textvariable=stage1_intensity_variable)
stage1_intensity_text.grid(row=0, column=3)
# 分段瞄准未启用时停用调整
if not segmented_aiming_switch:
ban_stage1_intensity_scale = ctk.CTkLabel(stage1_intensity_frame, text="分段瞄准未启用,该选项已禁用", width=200)
ban_stage1_intensity_scale.grid(row=0, column=2, padx=(12, 0)) # 行号
ban_stage1_intensity_scale = ctk.CTkLabel(stage1_intensity_frame, text="####", width=30)
ban_stage1_intensity_scale.grid(row=0, column=3) # 行号
# 分段自瞄范围调整(软锁范围)
# 创建一个 StringVar 对象以保存 stage2_intensity 的值
stage2_scope_variable = tk.StringVar()
stage2_scope_variable.set(str(stage2_intensity))
# 2创建一个Frame来包含OptionMenu和其左边的Label
stage2_scope_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
stage2_scope_frame.grid(row=13, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
stage2_scope_label = ctk.CTkLabel(stage2_scope_frame, text="软锁范围:")
stage2_scope_label.grid(row=0, column=1, sticky='w')
# 自瞄范围调整
stage2_scope_scale = ctk.CTkSlider(stage2_scope_frame, from_=0, to=300, number_of_steps=300, command=update_values)
stage2_scope_scale.set(stage2_scope)
stage2_scope_scale.grid(row=0, column=2, padx=(12, 0))
# 使用 textvariable 而非 text
stage2_scope_text = ctk.CTkLabel(stage2_scope_frame, textvariable=stage2_scope_variable)
stage2_scope_text.grid(row=0, column=3)
# 分段瞄准未启用时停用调整
if not segmented_aiming_switch:
ban_stage2_scope_scale = ctk.CTkLabel(stage2_scope_frame, text="分段瞄准未启用,该选项已禁用", width=200)
ban_stage2_scope_scale.grid(row=0, column=2, padx=(12, 0)) # 行号
ban_stage2_scope_scale = ctk.CTkLabel(stage2_scope_frame, text="####", width=30)
ban_stage2_scope_scale.grid(row=0, column=3) # 行号
# 分段自瞄范围调整(软锁速度)
# 创建一个 StringVar 对象以保存 stage2_intensity 的值
stage2_intensity_variable = tk.StringVar()
stage2_intensity_variable.set(str(stage2_intensity))
# 2创建一个Frame来包含OptionMenu和其左边的Label
stage2_intensity_frame = ctk.CTkFrame(tab_view.tab("高级设置"))
stage2_intensity_frame.grid(row=14, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
# 添加一个Label
stage2_intensity_label = ctk.CTkLabel(stage2_intensity_frame, text="软锁速度:")
stage2_intensity_label.grid(row=0, column=1, sticky='w')
# 自瞄范围调整
stage2_intensity_scale = ctk.CTkSlider(stage2_intensity_frame, from_=0, to=1, number_of_steps=100, command=update_values)
stage2_intensity_scale.set(stage2_intensity)
stage2_intensity_scale.grid(row=0, column=2, padx=(12, 0))
# 使用 textvariable 而非 text
stage2_intensity_text = ctk.CTkLabel(stage2_intensity_frame, textvariable=stage2_intensity_variable)
stage2_intensity_text.grid(row=0, column=3)
# 分段瞄准未启用时停用调整
if not segmented_aiming_switch:
ban_stage2_intensity_scale = ctk.CTkLabel(stage2_intensity_frame, text="分段瞄准未启用,该选项已禁用", width=200)
ban_stage2_intensity_scale.grid(row=0, column=2, padx=(12, 0)) # 行号
ban_stage2_intensity_scale = ctk.CTkLabel(stage2_intensity_frame, text="####", width=30)
ban_stage2_intensity_scale.grid(row=0, column=3) # 行号
# 6创建一个Frame来包其他设置
setting_frame = ctk.CTkFrame(tab_view.tab("其他设置"), width=300, height=300)
setting_frame.grid(row=9, column=0, sticky='w', pady=2) # 使用grid布局并靠左对齐
setting_frame.grid_propagate(False) # 防止框架调整大小以适应其内容
# 显示所选文件路径的标签
model_file_label = tk.Label(setting_frame, text="还未选择模型文件", width=40, anchor='e') # 初始化时显示的文本
model_file_label.grid(row=0, column=0, sticky="w") # 使用grid布局并靠左对齐
# 用户选择模型文件的按钮
model_file_button = ctk.CTkButton(setting_frame, text="选择模型文件(需重启)",
command=choose_model) # 点击此按钮时,将调用choose_model函数
model_file_button.grid(row=1, column=0, padx=(0, 245), pady=(5, 0)) # 使用grid布局并靠左对齐
# 创建一键打开配置文件的按钮
config_file_button = ctk.CTkButton(setting_frame, text="打开配置文件(需重启)",
command=open_settings_config) # 点击此按钮时,将调用open_config函数
config_file_button.grid(row=1, column=0, padx=(55, 0), pady=(5, 0))
# 创建 '保存' 按钮
save_button = ctk.CTkButton(setting_frame, text='保存设置', width=20, command=save_settings)
save_button.grid(row=2, column=0, padx=(0, 320), pady=(10, 0)) # 根据你的需要调整行号
# 创建 '加载' 按钮
load_button = ctk.CTkButton(setting_frame, text='加载设置(未启用)', width=20, command=load_settings,
state="DISABLED")
load_button.grid(row=2, column=0, padx=(0, 120), pady=(10, 0))
# 创建"重启软件"按钮
restart_button = ctk.CTkButton(setting_frame, text='重启软件', width=20, command=restart_program)
restart_button.grid(row=3, column=0, padx=(0, 320), pady=(10, 0))
# 版本号显示1
version_number_text1 = ctk.CTkLabel(setting_frame, text="当前版本:", width=30)
version_number_text1.bind("<Button-1>", command=open_web)
version_number_text1.grid(row=3, column=0, padx=(10, 0), pady=(120, 0))
# 版本号显示1
version_number1 = ctk.CTkLabel(setting_frame, text=version_number, width=30)
version_number1.bind("<Button-1>", command=open_web)
version_number1.grid(row=3, column=0, padx=(120, 0), pady=(120, 0))
# 版本号显示2
version_number_text2 = ctk.CTkLabel(setting_frame, text="最新版本:", width=30)
version_number_text2.bind("<Button-1>", command=open_web)
version_number_text2.grid(row=4, column=0, padx=(10, 0), pady=(0, 0))
# 版本号显示2
version_number2 = ctk.CTkLabel(setting_frame, text=":(", width=30)
version_number2.bind("<Button-1>", command=open_web)
version_number2.grid(row=4, column=0, padx=(120, 0), pady=(0, 0))
# # Fetch version number from GitHub
version = fetch_readme_version_number()
# # 更新version_number2的文本为从 Github 获取的版本号
version_number2.configure(text=version)
# 更新 version_number2 的文本并设置颜色(对比版本号)
if version == version_number1.cget("text"):
version_number2.configure(text=version, text_color="green")
else:
version_number2.configure(text=version, text_color="red")
# 调试窗口标签栏
image_label_frame = ctk.CTkFrame(tab_view.tab("测试窗口"), height=370, width=305)
image_label_frame.grid(row=1, column=0, sticky='w')
image_label_frame.grid_propagate(False)
# 画面开关
image_label_switch = ctk.CTkSwitch(image_label_frame, text="内部测试窗口(影响性能)", onvalue=True, offvalue=False,
command=update_values)
image_label_switch.grid(row=0, column=0, padx=(0, 0), sticky='w')
# 画面显示
image_label = tk.Label(image_label_frame)
image_label.grid(row=1, column=0, padx=(0, 0))
# 帧数显示
image_label_FPSlabel = ctk.CTkLabel(image_label_frame, text="实时FPS:", width=40) # 初始化时显示的文本
image_label_FPSlabel.grid(row=2, column=0, padx=(0, 0), sticky='w') # 使用grid布局并靠左对齐
# 从文件加载设置
load_settings()
# 加载设置后更新变量,也是更新GUI上的显示
update_values()
# 主循环运行GUI
root.mainloop()
def update_values(*args):
global aimbot, lockSpeed, triggerType, arduinoMode, lockKey, lockKey_var, confidence, closest_mouse_dist \
, closest_mouse_dist_scale, screen_width, screen_height, model_file, aimOffset, draw_center \
, mouse_Side_Button_Witch, lockSpeed_text, LookSpeed_label_1, test_images_GUI, target_selection_str \
, prediction_factor_scale, prediction_factor, method_of_prediction, extra_offset_x, extra_offset_y\
, screenshot_mode, segmented_aiming_switch, stage1_scope, stage1_scope_scale, stage1_intensity\
, stage1_intensity_scale, stage2_scope, stage2_scope_scale, stage2_intensity, stage2_intensity_scale
print("update_values function was called(配置已更新)")
aimbot = aimbot_var.get()
lockSpeed = lockSpeed_scale.get()
triggerType = triggerType_var.get()
arduinoMode = arduinoMode_var.get()
lockKey = lockKey_var.get()
target_selection_str = target_selection_var.get()
mouse_Side_Button_Witch = mouse_Side_Button_Witch_var.get()
confidence = confidence_scale.get()
closest_mouse_dist = closest_mouse_dist_scale.get()
screen_width = int(screen_width_scale.get())
screen_height = int(screen_height_scale.get())
aimOffset = aimOffset_scale.get()
draw_center = draw_center_var.get()
test_images_GUI = image_label_switch.get()
prediction_factor = prediction_factor_scale.get()
method_of_prediction = method_of_prediction_var.get()
extra_offset_x = extra_offset_x_scale.get()
extra_offset_y = extra_offset_y_scale.get()
stage1_scope = stage1_scope_scale.get()
stage1_intensity = stage1_intensity_scale.get()
stage2_scope = stage2_scope_scale.get()
stage2_intensity = stage2_intensity_scale.get()
# 更新 lockSpeed_variable
lockSpeed = round(lockSpeed_scale.get(), 2)
lockSpeed_variable.set(str(lockSpeed))
# 更新 confidence_variable
confidence = round(confidence_scale.get(), 2)
confidence_variable.set(str(confidence))
# 更新 closest_mouse_dist_variable
closest_mouse_dist = int(closest_mouse_dist_scale.get())
closest_mouse_dist_variable.set(str(closest_mouse_dist))
# 更新prediction_factor_variable
prediction_factor = round(prediction_factor_scale.get(), 2)
prediction_factor_variable.set(str(prediction_factor))
# 更新extra_offset_x_variable
extra_offset_x = round(extra_offset_x_scale.get())
extra_offset_x_variable.set(str(extra_offset_x))
# 更新extra_offset_y_variable
extra_offset_y = round(extra_offset_y_scale.get())
extra_offset_y_variable.set(str(extra_offset_y))
# 更新 aimOffset_variable
aimOffset = round(aimOffset_scale.get(), 2) # 取两位小数
aimOffset_variable.set(str(aimOffset))
# 更新 screen_width
screen_width = int(screen_width_scale.get())
screen_width_scale_variable.set(str(screen_width))
# 更新 screen_width
screen_height = int(screen_height_scale.get())
screen_height_scale_variable.set(str(screen_height))
# 更新 stage1_scope 显示的数值
stage1_scope = int(stage1_scope_scale.get())
stage1_scope_variable.set(str(stage1_scope))
# 更新 stage1_intensity 显示的数值
stage1_intensity = round(stage1_intensity_scale.get(), 2)
stage1_intensity_variable.set(str(stage1_intensity))
# 更新 stage2_scope 显示的数值
stage2_scope = int(stage2_scope_scale.get())
stage2_scope_variable.set(str(stage2_scope))
# 更新 stage2_intensity 显示的数值
stage2_intensity = round(stage2_intensity_scale.get(), 2)
stage2_intensity_variable.set(str(stage2_intensity))
# 触发键值转换
key = lockKey_var.get()
if key == '左键':
lockKey = 0x01
elif key == '右键':
lockKey = 0x02
elif key == '下侧键':
lockKey = 0x05
def save_settings(): # 保存设置
global model_file
new_settings = {
'aimbot': aimbot_var.get(),
'lockSpeed': lockSpeed_scale.get(),
'triggerType': triggerType_var.get(),
'arduinoMode': arduinoMode_var.get(),
'lockKey': lockKey_var.get(),