forked from ok-oldking/ok-wuthering-waves
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
284 lines (256 loc) · 11.6 KB
/
Copy pathconfig.py
File metadata and controls
284 lines (256 loc) · 11.6 KB
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
import os
import re
from pathlib import Path
from ok import Box, ConfigOption, Icon
from src.task.process_feature import process_feature
version = "dev"
def _find_most_recently_run_pc_exe():
try:
import codecs
import struct
import winreg
except ImportError:
return None
user_assist_key = r"Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist"
candidates = []
try:
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, user_assist_key) as root:
for index in range(winreg.QueryInfoKey(root)[0]):
guid = winreg.EnumKey(root, index)
try:
with winreg.OpenKey(root, fr"{guid}\Count") as count_key:
for value_index in range(winreg.QueryInfoKey(count_key)[1]):
encoded_path, data, _ = winreg.EnumValue(count_key, value_index)
path = os.path.expandvars(codecs.decode(encoded_path, "rot_13"))
if not path.casefold().endswith(r"\wuthering waves.exe"):
continue
if not Path(path).is_file():
continue
last_run = struct.unpack_from("<Q", data, 60)[0] if len(data) >= 68 else 0
candidates.append((last_run, path))
except OSError:
continue
except OSError:
return None
return max(candidates, default=(0, None))[1]
def _find_pc_exe_from_registry():
try:
import winreg
except ImportError:
return None
uninstall_key = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
registry_views = (winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY)
for root in (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE):
for view in registry_views:
try:
with winreg.OpenKey(root, uninstall_key, 0, winreg.KEY_READ | view) as key:
subkey_count = winreg.QueryInfoKey(key)[0]
for index in range(subkey_count):
try:
subkey_name = winreg.EnumKey(key, index)
with winreg.OpenKey(key, subkey_name) as subkey:
display_name = _read_registry_value(subkey, "DisplayName", winreg)
if not _is_wuthering_waves_registry_entry(subkey_name, display_name):
continue
for value_name in (
"InstallPath", "InstallLocation", "LauncherPath",
"DisplayIcon", "UninstallString"):
registered_path = _read_registry_value(subkey, value_name, winreg)
if game_exe := _find_pc_exe_near_registered_path(registered_path):
return game_exe
except OSError:
continue
except OSError:
continue
return None
def _read_registry_value(key, name, winreg):
try:
return str(winreg.QueryValueEx(key, name)[0])
except OSError:
return ""
def _is_wuthering_waves_registry_entry(subkey_name, display_name):
names = f"{subkey_name} {display_name}".casefold()
return "wuthering waves" in names or "鸣潮" in names or "鳴潮" in names
def _find_pc_exe_near_registered_path(registered_path):
if not registered_path:
return None
path_text = os.path.expandvars(registered_path.strip().strip('"'))
exe_end = path_text.casefold().find(".exe")
if exe_end >= 0:
path_text = path_text[:exe_end + 4]
registered = Path(path_text)
install_folder = registered.parent if registered.suffix.casefold() == ".exe" else registered
candidates = (
install_folder / "Wuthering Waves.exe",
install_folder / "Wuthering Waves Game" / "Wuthering Waves.exe",
install_folder.parent / "Wuthering Waves Game" / "Wuthering Waves.exe",
)
for candidate in candidates:
if candidate.is_file():
return str(candidate)
return None
def calculate_pc_exe_path(running_path):
if running_path is None:
return _find_most_recently_run_pc_exe() or _find_pc_exe_from_registry()
game_exe_folder = Path(running_path).parents[3]
return str(game_exe_folder / "Wuthering Waves.exe")
def blur_area(width, height):
blur_width = int(0.12 * width)
blur_height = int(0.024 * height)
return Box(width * 0.879, height * 0.976, blur_width * 0.973, blur_height * 0.994)
key_config_option = ConfigOption('Game Hotkey', {
'Echo Key': 'q',
'Liberation Key': 'r',
'Resonance Key': 'e',
'Tool Key': 't',
'Jump Key': 'space',
'Dodge Key': 'lshift',
'Wheel Key': 'tab',
'Guidebook Key': 'f2',
'Bag Key': 'b',
}, description='In Game Hotkey for Skills', config_description={
'Bag Key': 'In-game hotkey used to open the Bag.',
}, show_at_tab=True, icon=Icon.GAME)
char_config_option = ConfigOption('Character Config', {
'Iuno C6': False,
'Chisa DPS': False,
}, description='Character Config', show_at_tab=True, icon=Icon.PEOPLE)
monthly_card_config_option = ConfigOption('Monthly Card Config', {
'Check Monthly Card': True,
'Monthly Card Time': 4
}, description='Turn on to avoid interruption by monthly card when executing tasks', config_description={
'Check Monthly Card': 'Check for monthly card to avoid interruption of tasks',
'Monthly Card Time': 'Your computer\'s local time when the monthly card will popup, hour in (1-24)'
})
config = {
'debug': False, # Optional, default: False
'custom_tasks': True,
"gui": {
"type": "qt",
},
'config_folder': 'configs',
'blur_area': blur_area,
'gui_icon': 'icons/icon.png',
'global_configs': [key_config_option, char_config_option, monthly_card_config_option],
'custom_tabs': [["src.gui.CharacterCodeTab", "CharacterCodeTab"]],
'ocr': {
'lib': 'onnxocr',
'auto_simplify': True,
'params': {
'use_openvino': True,
'use_npu': True,
}
},
'my_app': ['src.globals', 'Globals'],
'start_timeout': 120, # default 60
'wait_until_settle_time': 0,
# required if using feature detection
'template_matching': {
'coco_feature_json': os.path.join('assets', 'coco_annotations.json'),
'default_horizontal_variance': 0.002,
'default_vertical_variance': 0.002,
'default_threshold': 0.8,
'feature_processor': process_feature,
'vcenter_features': ['monthly_card', 'skip_dialog_check'],
'hcenter_features': ['monthly_card', 'suisui_forte3', 'message_dialog', 'claim_stamina_sign',
'skip_dialog_check', 'login_close', 'garden_confirm', 'garden_continue_game',
'garden_unpause', 'garden_get_gold', 'garden_get_purple', 'garden_get_skip',
'garden_not_interested_confirm', 'garden_not_interested', 'a_garden_back',
'garden_get_confirm_gray', 'the_garden_max', 'garden_shop_close', 'garden_new_stage',
'a_garden_restart', 'suisui_forte2', 'suisui_e1', 'e_forte', 'f_break_full']
},
'windows': { # required when supporting windows game
'top_hwnd_class': [re.compile('CAgreementDlg'), re.compile('CLoginDlg_P_'),
'CefBrowserWindow', 'Chrome_RenderWidgetHostHWND', '#32770',
re.compile('CNativeLoginDlg'), 'Static', 'ComboBox', 'ComboLBox', 'Button'
],
'calculate_pc_exe_path': calculate_pc_exe_path,
'exe': 'Client-Win64-Shipping.exe',
'hwnd_class': 'UnrealWindow',
'interaction': 'PostMessage',
'capture_method': ['WGC', 'BitBlt_RenderFull'], # Windows版本支持的话, 优先使用WGC, 否则使用BitBlt_Full
'check_hdr': False,
'force_no_hdr': False,
'check_night_light': True,
'force_no_night_light': False,
},
'window_size': {
'width': 1200,
'height': 800,
'min_width': 1200,
'min_height': 800,
},
'supported_resolution': {
'ratio': '16:9',
'resize_to': [(2560, 1440), (1920, 1080), (1600, 900), (1280, 720)],
'min_size': (1280, 720)
},
'git_update': {'sources': [{
'name': 'Global',
'git_url': 'https://github.com/zzc-tongji/ok-ww-e.git',
'pip_url': 'https://pypi.org/simple/'
}
]},
'links': {
'default': {
'github': 'https://github.com/zzc-tongji/ok-ww-enhanced'
}
},
'about': """
<p style="color:orange;">
<strong>本软件为OK-WW-E,是基于<a href="https://github.com/ok-oldking/ok-wuthering-waves">OK-WW</a>的增强版。新增功能用⭐标出。</strong>
</p>
<p style="color:orange;">
<strong>欢迎对于新增功能的issue和PR。喜欢本软件请支持原作者ok-oldking。</strong>
</p>
<p style="color:red;">
<strong>本软件是免费开源的。</strong> 如果你被收费,请立即退款。请访问GitHub下载最新的官方版本。
</p>
<p style="color:red;">
<strong>本软件仅供个人使用,用于学习Python编程、计算机视觉、UI自动化等。</strong> 请勿将其用于任何营利性或商业用途。
</p>
<p style="color:red;">
<strong>使用本软件可能会导致账号被封。</strong> 请在了解风险后再使用。
</p>
""",
'screenshots_folder': "screenshots",
'gui_title': 'OK-WW-E', # Optional
# 'coco_feature_folder': get_path(__file__, 'assets/coco_feature'), # required if using feature detection
'log_file': 'logs/ok-ww.log', # Optional, auto rotating every day
'error_log_file': 'logs/ok-ww_error.log',
'launcher_log_file': 'logs/launcher.log',
'launcher_error_log_file': 'logs/launcher_error.log',
'version': version,
'onetime_tasks': [ # tasks to execute
["src.task.DailyTask2", "DailyTask2"],
["src.task.FarmEchoTask2", "FarmEchoTask2"],
["src.task.TacetTask2", "TacetTask2"],
["src.task.ForgeryTask2", "ForgeryTask2"],
["src.task.SimulationTask2", "SimulationTask2"],
#
["src.task.DailyTask", "DailyTask"],
["src.task.FarmEchoTask", "FarmEchoTask"],
["src.task.NightmareNestTask", "NightmareNestTask"],
["src.task.TacetTask", "TacetTask"],
["src.task.ForgeryTask", "ForgeryTask"],
["src.task.SimulationTask", "SimulationTask"],
["src.task.MultiAccountDailyTask", "MultiAccountDailyTask"],
["src.task.MergeEchoTask", "MergeEchoTask"],
["src.task.EnhanceEchoTask", "EnhanceEchoTask"],
["src.task.ChangeEchoTask", "ChangeEchoTask"],
["src.task.GardenTask", "GardenTask"],
# ["src.task.DiagnosisTask", "DiagnosisTask"],
], 'trigger_tasks': [
["src.task.AutoCombatTask", "AutoCombatTask"],
["src.task.AutoPickTask", "AutoPickTask"],
["src.task.AutoLoginTask", "AutoLoginTask"],
["src.task.SkipDialogTask", "AutoDialogTask"],
["src.task.FastTravelTask", "FastTravelTask"],
["src.task.MouseResetTask", "MouseResetTask"],
], 'scene': ["src.scene.WWScene", "WWScene"],
'update_pyappify': {
'to_version': '1.2.3',
'zip_url': 'https://github.com/ok-oldking/ok-wuthering-waves/releases/download/v3.5.30/ok-ww-win32.zip',
'sha256': '447207edbfb6944beb994347048e155df99775eb18c87dcae54dda125071c94a',
}
}