2023-05-14 07:48:34 +00:00
|
|
|
"""
|
|
|
|
This file stores server, such as 'cn', 'en'.
|
|
|
|
Use 'import module.config.server as server' to import, don't use 'from xxx import xxx'.
|
|
|
|
"""
|
2023-09-08 14:23:57 +00:00
|
|
|
lang = 'cn' # Setting default to cn, will avoid errors when using dev_tools
|
2023-09-15 19:39:12 +00:00
|
|
|
server = 'CN-Official'
|
2023-05-14 07:48:34 +00:00
|
|
|
|
2023-09-08 14:23:57 +00:00
|
|
|
VALID_LANG = ['cn', 'en']
|
2023-09-15 19:39:12 +00:00
|
|
|
VALID_SERVER = {
|
|
|
|
'CN-Official': 'com.miHoYo.hkrpg',
|
|
|
|
'CN-Bilibili': 'com.miHoYo.hkrpg.bilibili',
|
|
|
|
'OVERSEA-America': 'com.HoYoverse.hkrpgoversea',
|
|
|
|
'OVERSEA-Asia': 'com.HoYoverse.hkrpgoversea',
|
|
|
|
'OVERSEA-Europe': 'com.HoYoverse.hkrpgoversea',
|
|
|
|
'OVERSEA-TWHKMO': 'com.HoYoverse.hkrpgoversea',
|
2023-05-14 07:48:34 +00:00
|
|
|
}
|
2023-09-15 19:39:12 +00:00
|
|
|
VALID_PACKAGE = set(list(VALID_SERVER.values()))
|
2024-01-14 15:56:06 +00:00
|
|
|
VALID_CLOUD_SERVER = {
|
|
|
|
'CN-Official': 'com.miHoYo.cloudgames.hkrpg',
|
|
|
|
}
|
|
|
|
VALID_CLOUD_PACKAGE = set(list(VALID_SERVER.values()))
|
2023-05-14 07:48:34 +00:00
|
|
|
|
|
|
|
|
2023-09-08 14:23:57 +00:00
|
|
|
def set_lang(lang_: str):
|
2023-05-14 07:48:34 +00:00
|
|
|
"""
|
2023-09-08 14:23:57 +00:00
|
|
|
Change language and this will affect globally,
|
|
|
|
including assets and language specific methods.
|
2023-05-14 07:48:34 +00:00
|
|
|
|
|
|
|
Args:
|
2023-09-08 14:23:57 +00:00
|
|
|
lang_: package name or server.
|
2023-05-14 07:48:34 +00:00
|
|
|
"""
|
2023-09-08 14:23:57 +00:00
|
|
|
global lang
|
|
|
|
lang = lang_
|
2023-05-14 07:48:34 +00:00
|
|
|
|
|
|
|
from module.base.resource import release_resources
|
|
|
|
release_resources()
|
|
|
|
|
|
|
|
|
|
|
|
def to_server(package_or_server: str) -> str:
|
|
|
|
"""
|
|
|
|
Convert package/server to server.
|
|
|
|
To unknown packages, consider they are a CN channel servers.
|
|
|
|
"""
|
2023-09-15 19:39:12 +00:00
|
|
|
# Can't distinguish different regions of oversea servers,
|
|
|
|
# assume it's 'OVERSEA-Asia'
|
|
|
|
if package_or_server == 'com.HoYoverse.hkrpgoversea':
|
|
|
|
return 'OVERSEA-Asia'
|
|
|
|
|
|
|
|
for key, value in VALID_SERVER.items():
|
|
|
|
if value == package_or_server:
|
|
|
|
return key
|
|
|
|
if key == package_or_server:
|
|
|
|
return key
|
2024-01-14 15:56:06 +00:00
|
|
|
for key, value in VALID_CLOUD_SERVER.items():
|
|
|
|
if value == package_or_server:
|
|
|
|
return key
|
|
|
|
if key == package_or_server:
|
|
|
|
return key
|
2023-09-15 19:39:12 +00:00
|
|
|
|
|
|
|
raise ValueError(f'Package invalid: {package_or_server}')
|
2023-05-14 07:48:34 +00:00
|
|
|
|
|
|
|
|
2024-01-14 15:56:06 +00:00
|
|
|
def to_package(package_or_server: str, is_cloud=False) -> str:
|
2023-05-14 07:48:34 +00:00
|
|
|
"""
|
|
|
|
Convert package/server to package.
|
|
|
|
"""
|
2024-01-14 15:56:06 +00:00
|
|
|
if is_cloud:
|
|
|
|
for key, value in VALID_CLOUD_SERVER.items():
|
|
|
|
if value == package_or_server:
|
|
|
|
return value
|
|
|
|
if key == package_or_server:
|
|
|
|
return value
|
|
|
|
else:
|
|
|
|
for key, value in VALID_SERVER.items():
|
|
|
|
if value == package_or_server:
|
|
|
|
return value
|
|
|
|
if key == package_or_server:
|
|
|
|
return value
|
2023-05-14 07:48:34 +00:00
|
|
|
|
|
|
|
raise ValueError(f'Server invalid: {package_or_server}')
|