pyscreeps-arena 0.5.7a2__tar.gz → 0.5.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/PKG-INFO +1 -1
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/__init__.py +88 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/compiler.py +70 -31
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/const.py +1 -1
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/localization.py +4 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/project.7z +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/__init__.py +3 -1
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/map_render.py +705 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/mapviewer.py +14 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qcreeplogic/qcreeplogic.py +82 -21
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapker/__init__.py +1 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapker/qmapmarker.py +339 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapker/qvariable.py +303 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapker/test_compact_variable.py +61 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapker/test_qmapmarker.py +71 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapker/test_qvariable.py +49 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapker/to_code.py +100 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/__init__.py +3 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/qcinfo.py +567 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/qco.py +441 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/qmapv.py +728 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/test_array_drag.py +191 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/test_drag.py +107 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/test_qcinfo.py +169 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/test_qco_drag.py +7 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/test_qmapv.py +224 -0
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/ui/qmapv/test_simple_array.py +303 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/PKG-INFO +1 -1
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/SOURCES.txt +19 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/setup.py +1 -1
- pyscreeps_arena-0.5.7a2/pyscreeps_arena/__init__.py +0 -56
- pyscreeps_arena-0.5.7a2/pyscreeps_arena/project.7z +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/build.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/__init__.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/basic.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/config.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/core.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/main.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/utils.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/P2PY.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/creeplogic_edit.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/project_ui.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qcreeplogic/__init__.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qcreeplogic/model.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qrecipe/__init__.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qrecipe/model.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qrecipe/qrecipe.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/rs_icon.py +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/dependency_links.txt +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/entry_points.txt +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/requires.txt +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/top_level.txt +0 -0
- {pyscreeps_arena-0.5.7a2 → pyscreeps_arena-0.5.8.1}/setup.cfg +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import shutil
|
|
4
|
+
import py7zr
|
|
5
|
+
from pyscreeps_arena.core import const, config
|
|
6
|
+
from pyscreeps_arena.ui.mapviewer import run_mapviewer
|
|
7
|
+
from pyscreeps_arena.ui.project_ui import run_project_creator
|
|
8
|
+
from pyscreeps_arena.ui.creeplogic_edit import run_creeplogic_edit
|
|
9
|
+
|
|
10
|
+
def CMD_NewProject():
|
|
11
|
+
"""
|
|
12
|
+
cmd:
|
|
13
|
+
pyscreeps-arena [project_path]
|
|
14
|
+
arena [project_path]
|
|
15
|
+
|
|
16
|
+
* 复制"src" "game" "build.py" 到指定目录
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
|
|
20
|
+
"""
|
|
21
|
+
if len(sys.argv) < 2:
|
|
22
|
+
print("Usage: pyarena new [project_path]\n# or\narena new [project_path]")
|
|
23
|
+
return
|
|
24
|
+
project_path = sys.argv[1]
|
|
25
|
+
if not os.path.exists(project_path):
|
|
26
|
+
os.makedirs(project_path)
|
|
27
|
+
this_path = os.path.dirname(os.path.abspath(__file__))
|
|
28
|
+
extract_7z(os.path.join(this_path, 'project.7z'), project_path)
|
|
29
|
+
print("Project created at", project_path)
|
|
30
|
+
|
|
31
|
+
def CMD_OpenUI():
|
|
32
|
+
"""
|
|
33
|
+
cmd:
|
|
34
|
+
psaui 无参数,启用project ui
|
|
35
|
+
psaui -c/-e 启用creeplogic edit
|
|
36
|
+
psaui -m [-c/-e] 启用mapviewer. 默认cn,可以指定-c/-e
|
|
37
|
+
psaui -h 显示帮助信息
|
|
38
|
+
|
|
39
|
+
* 打开UI界面
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
try:
|
|
45
|
+
# 显示帮助信息
|
|
46
|
+
if len(sys.argv) > 1 and sys.argv[1] == '-h':
|
|
47
|
+
print("Usage:")
|
|
48
|
+
print(" psaui 启用project ui")
|
|
49
|
+
print(" psaui -c/-e 启用creeplogic edit (-c: 中文, -e: 英文)")
|
|
50
|
+
print(" psaui -m [-c/-e] 启用mapviewer (-c: 中文, -e: 英文, 默认: 中文)")
|
|
51
|
+
print(" psaui -h 显示帮助信息")
|
|
52
|
+
print(" --------------------------------------------------------------")
|
|
53
|
+
print(" psaui run `project ui`")
|
|
54
|
+
print(" psaui -c/-e run `creeplogic edit` (-c: chinese, -e: english)")
|
|
55
|
+
print(" psaui -m [-c/-e] run `mapviewer` (-c: chinese, -e: english, default: chinese)")
|
|
56
|
+
print(" psaui -h Show this help message")
|
|
57
|
+
|
|
58
|
+
return
|
|
59
|
+
|
|
60
|
+
# 检查是否使用mapviewer
|
|
61
|
+
if len(sys.argv) > 1 and sys.argv[1] == '-m':
|
|
62
|
+
# 检查语言参数
|
|
63
|
+
if len(sys.argv) > 2 and sys.argv[2] == '-e':
|
|
64
|
+
from pyscreeps_arena.core import config
|
|
65
|
+
config.language = 'en'
|
|
66
|
+
run_mapviewer()
|
|
67
|
+
# 检查是否使用creeplogic edit
|
|
68
|
+
elif len(sys.argv) > 1 and sys.argv[1] == '-c':
|
|
69
|
+
run_creeplogic_edit()
|
|
70
|
+
elif len(sys.argv) > 1 and sys.argv[1] == '-e':
|
|
71
|
+
from pyscreeps_arena.core import config
|
|
72
|
+
config.language = 'en'
|
|
73
|
+
run_creeplogic_edit()
|
|
74
|
+
# 默认启用project ui
|
|
75
|
+
else:
|
|
76
|
+
run_project_creator()
|
|
77
|
+
except ImportError as e:
|
|
78
|
+
print(f"错误: 无法导入UI模块 - {e}")
|
|
79
|
+
print("请确保已安装PyQt6: pip install PyQt6")
|
|
80
|
+
except Exception as e:
|
|
81
|
+
print(f"错误: 打开UI界面失败 - {e}")
|
|
82
|
+
|
|
83
|
+
def extract_7z(file_path, output_dir):
|
|
84
|
+
with py7zr.SevenZipFile(file_path, mode='r') as archive:
|
|
85
|
+
archive.extractall(path=output_dir)
|
|
86
|
+
|
|
87
|
+
if __name__ == '__main__':
|
|
88
|
+
CMD_OpenUI()
|
|
@@ -17,6 +17,10 @@ python_version_info = sys.version_info
|
|
|
17
17
|
python_version_info = f"{python_version_info.major}.{python_version_info.minor}.{python_version_info.micro}"
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
class MatchCaseError(Exception):
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
20
24
|
def replace_src_prefix(file_list):
|
|
21
25
|
"""
|
|
22
26
|
将列表中以'./src.'开头的字符串替换为'./'
|
|
@@ -28,16 +32,17 @@ def replace_src_prefix(file_list):
|
|
|
28
32
|
替换后的新列表
|
|
29
33
|
"""
|
|
30
34
|
_ = []
|
|
31
|
-
|
|
35
|
+
|
|
32
36
|
for item in file_list:
|
|
33
37
|
if isinstance(item, str) and item.startswith('./src.'):
|
|
34
38
|
_new = item.replace('./src.', './', 1)
|
|
35
39
|
if _new in file_list:
|
|
36
40
|
continue
|
|
37
41
|
_.append(item)
|
|
38
|
-
|
|
42
|
+
|
|
39
43
|
return _
|
|
40
44
|
|
|
45
|
+
|
|
41
46
|
# def InsertPragmaBefore(content:str) -> str:
|
|
42
47
|
# """
|
|
43
48
|
# 在content的开头插入__pragma__('noalias', 'undefined')等内容 |
|
|
@@ -159,8 +164,9 @@ class GameConstructionBoost{{
|
|
|
159
164
|
}}
|
|
160
165
|
}};
|
|
161
166
|
import {{ Portal as GamePortal}} from 'arena/season_{config.season}/{const.ARENA_GREEN}/{"advanced" if config.level in ["advance", "advanced"] else "basic"}/prototypes';
|
|
162
|
-
|
|
163
167
|
""",
|
|
168
|
+
# import {Portal} from 'arena/season_1/portal_exploration/basic/prototypes';
|
|
169
|
+
|
|
164
170
|
const.ARENA_BLUE: lambda: f"""
|
|
165
171
|
const ARENA_COLOR_TYPE = "BLUE";
|
|
166
172
|
const GameScoreCollector = GameStructureSpawn;
|
|
@@ -230,12 +236,16 @@ class Compiler_Utils(Compiler_Const):
|
|
|
230
236
|
return f.read()
|
|
231
237
|
except UnicodeDecodeError:
|
|
232
238
|
# 如果使用检测到的编码读取失败,尝试使用chardet检测编码
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
+
try:
|
|
240
|
+
with open(fpath, 'rb') as f: # 以二进制模式打开文件
|
|
241
|
+
raw_data = f.read() # 读取文件的原始数据
|
|
242
|
+
result = chardet.detect(raw_data) # 使用chardet检测编码
|
|
243
|
+
encoding = result['encoding'] # 获取检测到的编码
|
|
244
|
+
with open(fpath, 'r', encoding=encoding) as f: # 使用检测到的编码打开文件
|
|
245
|
+
return f.read()
|
|
246
|
+
except UnicodeDecodeError as e:
|
|
247
|
+
core.error('Compiler_Utils.auto_read', core.lformat(LOC_FILE_READ_FAILED, [fpath, "UnicodeError", e]), end='', head='\n', ln=config.language)
|
|
248
|
+
quit(-1)
|
|
239
249
|
|
|
240
250
|
def copy_to(self) -> list:
|
|
241
251
|
"""
|
|
@@ -410,8 +420,7 @@ class Compiler_Utils(Compiler_Const):
|
|
|
410
420
|
py_files.append(item)
|
|
411
421
|
elif os.path.isdir(_path):
|
|
412
422
|
rel = os.path.relpath(final_dir_path, project_path)
|
|
413
|
-
core.warn(f'Compiler.expand_folder_imports', core.lformat(LOC_DIR_UNDER_NONINIT_DIR, [item, rel]), end='', head='\n', ln=config.language
|
|
414
|
-
|
|
423
|
+
core.warn(f'Compiler.expand_folder_imports', core.lformat(LOC_DIR_UNDER_NONINIT_DIR, [item, rel]), end='', head='\n', ln=config.language)
|
|
415
424
|
|
|
416
425
|
# 为每个 .py 文件生成导入语句
|
|
417
426
|
if py_files:
|
|
@@ -431,7 +440,6 @@ class Compiler_Utils(Compiler_Const):
|
|
|
431
440
|
with open(fpath, 'w', encoding='utf-8') as f:
|
|
432
441
|
f.write(new_content)
|
|
433
442
|
|
|
434
|
-
|
|
435
443
|
def find_chain_import(self, fpath: str, search_dirs: list[str], project_path: str = None, records: dict[str, None] = None) -> list[str]:
|
|
436
444
|
r"""
|
|
437
445
|
查找文件中的所有import语句,并返回所有import的文件路径 | find all import statements in a file and return the paths of all imported files
|
|
@@ -567,13 +575,13 @@ class Compiler_Utils(Compiler_Const):
|
|
|
567
575
|
return imps
|
|
568
576
|
|
|
569
577
|
@staticmethod
|
|
570
|
-
def relist_pyimports_to_jsimports(base_dir:str, pyimps:list[str]) -> list[str]:
|
|
578
|
+
def relist_pyimports_to_jsimports(base_dir: str, pyimps: list[str]) -> list[str]:
|
|
571
579
|
"""
|
|
572
580
|
将python的imports路径列表转换为js的imports路径列表 | convert a list of python imports paths to a list of js imports paths
|
|
573
581
|
"""
|
|
574
582
|
jsimps = []
|
|
575
583
|
for pyimp in pyimps:
|
|
576
|
-
rel_path_nodes:list[str] = os.path.relpath(pyimp, base_dir).replace('\\', '/').split('/')
|
|
584
|
+
rel_path_nodes: list[str] = os.path.relpath(pyimp, base_dir).replace('\\', '/').split('/')
|
|
577
585
|
if rel_path_nodes[-1] == '__init__.py':
|
|
578
586
|
rel_path_nodes.pop()
|
|
579
587
|
else:
|
|
@@ -639,7 +647,7 @@ class Compiler_Utils(Compiler_Const):
|
|
|
639
647
|
result = '\n'.join(calls_to_add) + '\n' + result
|
|
640
648
|
|
|
641
649
|
return result
|
|
642
|
-
|
|
650
|
+
|
|
643
651
|
@staticmethod
|
|
644
652
|
def process_mate_code(code):
|
|
645
653
|
# 用于存储匹配到的信息
|
|
@@ -673,12 +681,11 @@ class Compiler_Utils(Compiler_Const):
|
|
|
673
681
|
for variable_name, class_name in mate_assignments:
|
|
674
682
|
output_string = f"# > insert Object.defineProperty ({class_name}, '{variable_name}', property.call ({class_name}, {class_name}.{variable_name}._MateGet_, {class_name}.{variable_name}._MateSet_));"
|
|
675
683
|
output_strings.append(output_string)
|
|
676
|
-
|
|
677
|
-
return code + '\n'.join(output_strings)
|
|
678
684
|
|
|
685
|
+
return code + '\n'.join(output_strings)
|
|
679
686
|
|
|
680
687
|
@staticmethod
|
|
681
|
-
def remove_long_docstring(content:str) -> str:
|
|
688
|
+
def remove_long_docstring(content: str) -> str:
|
|
682
689
|
"""
|
|
683
690
|
移除长注释 | remove long docstring
|
|
684
691
|
"""
|
|
@@ -1077,7 +1084,6 @@ class Compiler(CompilerBase):
|
|
|
1077
1084
|
with open(fpath, 'w', encoding='utf-8') as f:
|
|
1078
1085
|
f.write(content)
|
|
1079
1086
|
|
|
1080
|
-
|
|
1081
1087
|
core.lprint(GREEN.format('[2/6]'), LOC_DONE, " ", LOC_PREPROCESSING_FINISH, sep="", head="\r", ln=config.language)
|
|
1082
1088
|
return _imports, _js_imports, _pre_sort_, _pre_define_, _js_replace_
|
|
1083
1089
|
|
|
@@ -1148,7 +1154,7 @@ class Compiler(CompilerBase):
|
|
|
1148
1154
|
|
|
1149
1155
|
content = self.auto_read(self.target_js)
|
|
1150
1156
|
if modules is None: modules = []
|
|
1151
|
-
new_modules, new_content = [],""
|
|
1157
|
+
new_modules, new_content = [], ""
|
|
1152
1158
|
for line in content.split('\n'):
|
|
1153
1159
|
m = re.search(self.JS_IMPORT_PAT, line)
|
|
1154
1160
|
if not m:
|
|
@@ -1194,7 +1200,7 @@ class Compiler(CompilerBase):
|
|
|
1194
1200
|
"""
|
|
1195
1201
|
return re.sub(r'import[^\n]*\n', '', raw)
|
|
1196
1202
|
|
|
1197
|
-
def generate_total_js(self, usr_modules, t_imps: list[str], f_sorts, f_replaces, g_replaces) -> str:
|
|
1203
|
+
def generate_total_js(self, usr_modules, t_imps: list[str], f_sorts, f_replaces, g_replaces, min_js_files=None) -> str:
|
|
1198
1204
|
"""
|
|
1199
1205
|
生成总的main.js
|
|
1200
1206
|
按照如下顺序组合:
|
|
@@ -1208,6 +1214,7 @@ class Compiler(CompilerBase):
|
|
|
1208
1214
|
:param f_sorts: dict{module_name: sort_priority}
|
|
1209
1215
|
:param f_replaces: dict{module_name: dict{old: new}}
|
|
1210
1216
|
:param g_replaces: dict{old: new}
|
|
1217
|
+
:param min_js_files: list[str] # .min.js文件路径列表
|
|
1211
1218
|
:return: str
|
|
1212
1219
|
"""
|
|
1213
1220
|
arena_name = const.ARENA_NAMES.get(config.arena, const.ARENA_NAMES['green']) # like green -> spawn_and_swamp
|
|
@@ -1215,6 +1222,13 @@ class Compiler(CompilerBase):
|
|
|
1215
1222
|
total_js = f"const __VERSION__ = '{const.VERSION}';\nconst __PYTHON_VERSION__ = '{python_version_info}';" + self.TOTAL_INSERT_AT_HEAD + f"\nexport var LANGUAGE = '{config.language}';\n"
|
|
1216
1223
|
total_js += f"const __AUTHOR__ = '{const.AUTHOR}';\nconst __AUTHOR_CN__ = '{const.BILIBILI_NAME}';"
|
|
1217
1224
|
|
|
1225
|
+
# 添加.min.js文件的import语句
|
|
1226
|
+
if min_js_files:
|
|
1227
|
+
for min_js_path in min_js_files:
|
|
1228
|
+
min_js_filename = os.path.basename(min_js_path)
|
|
1229
|
+
total_js += f"\nimport \"./{min_js_filename}\";"
|
|
1230
|
+
total_js += "\n"
|
|
1231
|
+
|
|
1218
1232
|
core.lprint(WAIT, LOC_GENERATING_TOTAL_MAIN_JS, end="", ln=config.language)
|
|
1219
1233
|
|
|
1220
1234
|
# TODO: IMPS donot work
|
|
@@ -1280,19 +1294,29 @@ class Compiler(CompilerBase):
|
|
|
1280
1294
|
def find_add_pure_js_files(self, sorts, modules):
|
|
1281
1295
|
"""
|
|
1282
1296
|
找到所有的纯js文件,并添加到modules中
|
|
1297
|
+
忽略.min.js文件,这些文件会被单独处理
|
|
1283
1298
|
:param sorts:
|
|
1284
1299
|
:param modules:
|
|
1285
|
-
:return:
|
|
1300
|
+
:return: list 返回所有.min.js文件的列表
|
|
1286
1301
|
"""
|
|
1302
|
+
min_js_files = []
|
|
1287
1303
|
for root, dirs, files in os.walk(self.lib_dir):
|
|
1288
1304
|
for file in files:
|
|
1289
1305
|
if file.endswith('.js') and file not in modules:
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1306
|
+
# 如果是.min.js文件,不拷贝到target,而是记录到单独列表
|
|
1307
|
+
if file.endswith('.min.js'):
|
|
1308
|
+
fpath = str(os.path.join(root, file))
|
|
1309
|
+
min_js_files.append(fpath)
|
|
1310
|
+
else:
|
|
1311
|
+
# 普通js文件,按原逻辑处理
|
|
1312
|
+
fpath = str(os.path.join(root, file))
|
|
1313
|
+
fname = file.replace('\\', '/')
|
|
1314
|
+
# copy file to target
|
|
1315
|
+
shutil.copy(fpath, os.path.join(self.target_dir, fname))
|
|
1316
|
+
sorts[fname] = self.__parse_js_file_sort(fpath)
|
|
1317
|
+
modules.append("./" + fname)
|
|
1318
|
+
|
|
1319
|
+
return min_js_files
|
|
1296
1320
|
|
|
1297
1321
|
def compile(self, paste=False):
|
|
1298
1322
|
"""
|
|
@@ -1303,8 +1327,7 @@ class Compiler(CompilerBase):
|
|
|
1303
1327
|
imps, jimps, sorts, defs, reps = self.pre_compile()
|
|
1304
1328
|
self.transcrypt_cmd()
|
|
1305
1329
|
imports, modules = self.analyze_rebuild_main_js(defs, jimps)
|
|
1306
|
-
self.find_add_pure_js_files(sorts, modules)
|
|
1307
|
-
total_js = imports + "\n" + self.generate_total_js(replace_src_prefix(modules), imps, sorts, self.FILE_STRONG_REPLACE, reps)
|
|
1330
|
+
min_js_files = self.find_add_pure_js_files(sorts, modules)
|
|
1308
1331
|
|
|
1309
1332
|
core.lprint(WAIT, LOC_EXPORTING_TOTAL_MAIN_JS, end="", ln=config.language)
|
|
1310
1333
|
|
|
@@ -1315,12 +1338,28 @@ class Compiler(CompilerBase):
|
|
|
1315
1338
|
if not mjs_path.endswith('js'):
|
|
1316
1339
|
mjs_path = os.path.join(mjs_path, 'main.mjs')
|
|
1317
1340
|
|
|
1341
|
+
# 获取目标目录路径
|
|
1342
|
+
dir_path = os.path.dirname(mjs_path)
|
|
1343
|
+
build_dir_path = os.path.dirname(build_main_mjs)
|
|
1344
|
+
|
|
1345
|
+
# 复制.min.js文件到目标目录
|
|
1346
|
+
for min_js_path in min_js_files:
|
|
1347
|
+
min_js_filename = os.path.basename(min_js_path)
|
|
1348
|
+
# 复制到build目录
|
|
1349
|
+
shutil.copy(min_js_path, os.path.join(build_dir_path, min_js_filename))
|
|
1350
|
+
# 复制到最终导出目录
|
|
1351
|
+
shutil.copy(min_js_path, os.path.join(dir_path, min_js_filename))
|
|
1352
|
+
|
|
1353
|
+
# 生成total_js,传入.min.js文件列表
|
|
1354
|
+
total_js = imports + "\n" + self.generate_total_js(
|
|
1355
|
+
replace_src_prefix(modules), imps, sorts, self.FILE_STRONG_REPLACE, reps, min_js_files
|
|
1356
|
+
)
|
|
1357
|
+
|
|
1318
1358
|
# write main.mjs
|
|
1319
1359
|
with open(build_main_mjs, 'w', encoding='utf-8') as f:
|
|
1320
1360
|
f.write(total_js)
|
|
1321
1361
|
|
|
1322
1362
|
# export main.mjs
|
|
1323
|
-
dir_path = os.path.dirname(mjs_path)
|
|
1324
1363
|
if not os.path.exists(dir_path):
|
|
1325
1364
|
core.error('Compiler.compile', core.lformat(LOC_EXPORT_DIR_PATH_NOT_EXISTS, [dir_path]), head='\n', ln=config.language)
|
|
1326
1365
|
with open(mjs_path, 'w', encoding='utf-8') as f:
|
|
@@ -17,6 +17,10 @@ LOC_FILE_NOT_EXISTS = {
|
|
|
17
17
|
'en': "{} File not exists: {}. You can ignore if it's a not used file.",
|
|
18
18
|
'cn': "{} 文件不存在: {}. 如果它是一个未使用的文件,您可以忽略它。",
|
|
19
19
|
}
|
|
20
|
+
LOC_FILE_READ_FAILED = {
|
|
21
|
+
'en': "Failed to read file: {}({})\nDetails:\n{}",
|
|
22
|
+
'cn': "读取文件失败: {}({})\n详细信息:\n{}",
|
|
23
|
+
}
|
|
20
24
|
LOC_PREPROCESSING = {
|
|
21
25
|
'en': "Preprocessing ...",
|
|
22
26
|
'cn': "预处理中 ...",
|
|
Binary file
|
|
@@ -6,5 +6,7 @@ PyScreeps Arena UI模块
|
|
|
6
6
|
from .rs_icon import get_icon, get_pixmap
|
|
7
7
|
from .project_ui import ProjectCreatorUI, run_project_creator
|
|
8
8
|
from .P2PY import png_to_py
|
|
9
|
+
from .qmapv import QPSAMapViewer, CellInfo
|
|
9
10
|
|
|
10
|
-
__all__ = ['get_icon', 'get_pixmap', 'ProjectCreatorUI', 'run_project_creator',
|
|
11
|
+
__all__ = ['get_icon', 'get_pixmap', 'ProjectCreatorUI', 'run_project_creator',
|
|
12
|
+
'png_to_py', 'QPSAMapViewer', 'CellInfo']
|