pyscreeps-arena 0.5.7b0__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.7b0 → 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.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/compiler.py +60 -25
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/const.py +1 -1
- pyscreeps_arena-0.5.8.1/pyscreeps_arena/project.7z +0 -0
- {pyscreeps_arena-0.5.7b0 → 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.7b0 → 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.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/PKG-INFO +1 -1
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/SOURCES.txt +19 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/setup.py +1 -1
- pyscreeps_arena-0.5.7b0/pyscreeps_arena/__init__.py +0 -56
- pyscreeps_arena-0.5.7b0/pyscreeps_arena/project.7z +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/build.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/__init__.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/basic.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/config.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/core.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/main.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/core/utils.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/localization.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/P2PY.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/creeplogic_edit.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/project_ui.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qcreeplogic/__init__.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qcreeplogic/model.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qrecipe/__init__.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qrecipe/model.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/qrecipe/qrecipe.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena/ui/rs_icon.py +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/dependency_links.txt +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/entry_points.txt +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/requires.txt +0 -0
- {pyscreeps_arena-0.5.7b0 → pyscreeps_arena-0.5.8.1}/pyscreeps_arena.egg-info/top_level.txt +0 -0
- {pyscreeps_arena-0.5.7b0 → 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;
|
|
@@ -414,8 +420,7 @@ class Compiler_Utils(Compiler_Const):
|
|
|
414
420
|
py_files.append(item)
|
|
415
421
|
elif os.path.isdir(_path):
|
|
416
422
|
rel = os.path.relpath(final_dir_path, project_path)
|
|
417
|
-
core.warn(f'Compiler.expand_folder_imports', core.lformat(LOC_DIR_UNDER_NONINIT_DIR, [item, rel]), end='', head='\n', ln=config.language
|
|
418
|
-
|
|
423
|
+
core.warn(f'Compiler.expand_folder_imports', core.lformat(LOC_DIR_UNDER_NONINIT_DIR, [item, rel]), end='', head='\n', ln=config.language)
|
|
419
424
|
|
|
420
425
|
# 为每个 .py 文件生成导入语句
|
|
421
426
|
if py_files:
|
|
@@ -435,7 +440,6 @@ class Compiler_Utils(Compiler_Const):
|
|
|
435
440
|
with open(fpath, 'w', encoding='utf-8') as f:
|
|
436
441
|
f.write(new_content)
|
|
437
442
|
|
|
438
|
-
|
|
439
443
|
def find_chain_import(self, fpath: str, search_dirs: list[str], project_path: str = None, records: dict[str, None] = None) -> list[str]:
|
|
440
444
|
r"""
|
|
441
445
|
查找文件中的所有import语句,并返回所有import的文件路径 | find all import statements in a file and return the paths of all imported files
|
|
@@ -571,13 +575,13 @@ class Compiler_Utils(Compiler_Const):
|
|
|
571
575
|
return imps
|
|
572
576
|
|
|
573
577
|
@staticmethod
|
|
574
|
-
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]:
|
|
575
579
|
"""
|
|
576
580
|
将python的imports路径列表转换为js的imports路径列表 | convert a list of python imports paths to a list of js imports paths
|
|
577
581
|
"""
|
|
578
582
|
jsimps = []
|
|
579
583
|
for pyimp in pyimps:
|
|
580
|
-
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('/')
|
|
581
585
|
if rel_path_nodes[-1] == '__init__.py':
|
|
582
586
|
rel_path_nodes.pop()
|
|
583
587
|
else:
|
|
@@ -643,7 +647,7 @@ class Compiler_Utils(Compiler_Const):
|
|
|
643
647
|
result = '\n'.join(calls_to_add) + '\n' + result
|
|
644
648
|
|
|
645
649
|
return result
|
|
646
|
-
|
|
650
|
+
|
|
647
651
|
@staticmethod
|
|
648
652
|
def process_mate_code(code):
|
|
649
653
|
# 用于存储匹配到的信息
|
|
@@ -677,12 +681,11 @@ class Compiler_Utils(Compiler_Const):
|
|
|
677
681
|
for variable_name, class_name in mate_assignments:
|
|
678
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_));"
|
|
679
683
|
output_strings.append(output_string)
|
|
680
|
-
|
|
681
|
-
return code + '\n'.join(output_strings)
|
|
682
684
|
|
|
685
|
+
return code + '\n'.join(output_strings)
|
|
683
686
|
|
|
684
687
|
@staticmethod
|
|
685
|
-
def remove_long_docstring(content:str) -> str:
|
|
688
|
+
def remove_long_docstring(content: str) -> str:
|
|
686
689
|
"""
|
|
687
690
|
移除长注释 | remove long docstring
|
|
688
691
|
"""
|
|
@@ -1081,7 +1084,6 @@ class Compiler(CompilerBase):
|
|
|
1081
1084
|
with open(fpath, 'w', encoding='utf-8') as f:
|
|
1082
1085
|
f.write(content)
|
|
1083
1086
|
|
|
1084
|
-
|
|
1085
1087
|
core.lprint(GREEN.format('[2/6]'), LOC_DONE, " ", LOC_PREPROCESSING_FINISH, sep="", head="\r", ln=config.language)
|
|
1086
1088
|
return _imports, _js_imports, _pre_sort_, _pre_define_, _js_replace_
|
|
1087
1089
|
|
|
@@ -1152,7 +1154,7 @@ class Compiler(CompilerBase):
|
|
|
1152
1154
|
|
|
1153
1155
|
content = self.auto_read(self.target_js)
|
|
1154
1156
|
if modules is None: modules = []
|
|
1155
|
-
new_modules, new_content = [],""
|
|
1157
|
+
new_modules, new_content = [], ""
|
|
1156
1158
|
for line in content.split('\n'):
|
|
1157
1159
|
m = re.search(self.JS_IMPORT_PAT, line)
|
|
1158
1160
|
if not m:
|
|
@@ -1198,7 +1200,7 @@ class Compiler(CompilerBase):
|
|
|
1198
1200
|
"""
|
|
1199
1201
|
return re.sub(r'import[^\n]*\n', '', raw)
|
|
1200
1202
|
|
|
1201
|
-
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:
|
|
1202
1204
|
"""
|
|
1203
1205
|
生成总的main.js
|
|
1204
1206
|
按照如下顺序组合:
|
|
@@ -1212,6 +1214,7 @@ class Compiler(CompilerBase):
|
|
|
1212
1214
|
:param f_sorts: dict{module_name: sort_priority}
|
|
1213
1215
|
:param f_replaces: dict{module_name: dict{old: new}}
|
|
1214
1216
|
:param g_replaces: dict{old: new}
|
|
1217
|
+
:param min_js_files: list[str] # .min.js文件路径列表
|
|
1215
1218
|
:return: str
|
|
1216
1219
|
"""
|
|
1217
1220
|
arena_name = const.ARENA_NAMES.get(config.arena, const.ARENA_NAMES['green']) # like green -> spawn_and_swamp
|
|
@@ -1219,6 +1222,13 @@ class Compiler(CompilerBase):
|
|
|
1219
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"
|
|
1220
1223
|
total_js += f"const __AUTHOR__ = '{const.AUTHOR}';\nconst __AUTHOR_CN__ = '{const.BILIBILI_NAME}';"
|
|
1221
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
|
+
|
|
1222
1232
|
core.lprint(WAIT, LOC_GENERATING_TOTAL_MAIN_JS, end="", ln=config.language)
|
|
1223
1233
|
|
|
1224
1234
|
# TODO: IMPS donot work
|
|
@@ -1284,19 +1294,29 @@ class Compiler(CompilerBase):
|
|
|
1284
1294
|
def find_add_pure_js_files(self, sorts, modules):
|
|
1285
1295
|
"""
|
|
1286
1296
|
找到所有的纯js文件,并添加到modules中
|
|
1297
|
+
忽略.min.js文件,这些文件会被单独处理
|
|
1287
1298
|
:param sorts:
|
|
1288
1299
|
:param modules:
|
|
1289
|
-
:return:
|
|
1300
|
+
:return: list 返回所有.min.js文件的列表
|
|
1290
1301
|
"""
|
|
1302
|
+
min_js_files = []
|
|
1291
1303
|
for root, dirs, files in os.walk(self.lib_dir):
|
|
1292
1304
|
for file in files:
|
|
1293
1305
|
if file.endswith('.js') and file not in modules:
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
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
|
|
1300
1320
|
|
|
1301
1321
|
def compile(self, paste=False):
|
|
1302
1322
|
"""
|
|
@@ -1307,8 +1327,7 @@ class Compiler(CompilerBase):
|
|
|
1307
1327
|
imps, jimps, sorts, defs, reps = self.pre_compile()
|
|
1308
1328
|
self.transcrypt_cmd()
|
|
1309
1329
|
imports, modules = self.analyze_rebuild_main_js(defs, jimps)
|
|
1310
|
-
self.find_add_pure_js_files(sorts, modules)
|
|
1311
|
-
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)
|
|
1312
1331
|
|
|
1313
1332
|
core.lprint(WAIT, LOC_EXPORTING_TOTAL_MAIN_JS, end="", ln=config.language)
|
|
1314
1333
|
|
|
@@ -1319,12 +1338,28 @@ class Compiler(CompilerBase):
|
|
|
1319
1338
|
if not mjs_path.endswith('js'):
|
|
1320
1339
|
mjs_path = os.path.join(mjs_path, 'main.mjs')
|
|
1321
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
|
+
|
|
1322
1358
|
# write main.mjs
|
|
1323
1359
|
with open(build_main_mjs, 'w', encoding='utf-8') as f:
|
|
1324
1360
|
f.write(total_js)
|
|
1325
1361
|
|
|
1326
1362
|
# export main.mjs
|
|
1327
|
-
dir_path = os.path.dirname(mjs_path)
|
|
1328
1363
|
if not os.path.exists(dir_path):
|
|
1329
1364
|
core.error('Compiler.compile', core.lformat(LOC_EXPORT_DIR_PATH_NOT_EXISTS, [dir_path]), head='\n', ln=config.language)
|
|
1330
1365
|
with open(mjs_path, 'w', encoding='utf-8') as f:
|
|
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']
|