pyscreeps-arena 0.3.6__py3-none-any.whl → 0.5.8.0__py3-none-any.whl
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/__init__.py +59 -2
- pyscreeps_arena/compiler.py +616 -73
- pyscreeps_arena/core/config.py +1 -1
- pyscreeps_arena/core/const.py +6 -5
- pyscreeps_arena/localization.py +10 -0
- pyscreeps_arena/project.7z +0 -0
- pyscreeps_arena/ui/P2PY.py +108 -0
- pyscreeps_arena/ui/__init__.py +12 -0
- pyscreeps_arena/ui/creeplogic_edit.py +14 -0
- pyscreeps_arena/ui/map_render.py +705 -0
- pyscreeps_arena/ui/mapviewer.py +14 -0
- pyscreeps_arena/ui/project_ui.py +215 -0
- pyscreeps_arena/ui/qcreeplogic/__init__.py +3 -0
- pyscreeps_arena/ui/qcreeplogic/model.py +72 -0
- pyscreeps_arena/ui/qcreeplogic/qcreeplogic.py +770 -0
- pyscreeps_arena/ui/qmapker/__init__.py +1 -0
- pyscreeps_arena/ui/qmapker/qmapmarker.py +339 -0
- pyscreeps_arena/ui/qmapker/qvariable.py +303 -0
- pyscreeps_arena/ui/qmapker/test_compact_variable.py +61 -0
- pyscreeps_arena/ui/qmapker/test_qmapmarker.py +71 -0
- pyscreeps_arena/ui/qmapker/test_qvariable.py +49 -0
- pyscreeps_arena/ui/qmapker/to_code.py +100 -0
- pyscreeps_arena/ui/qmapv/__init__.py +3 -0
- pyscreeps_arena/ui/qmapv/qcinfo.py +567 -0
- pyscreeps_arena/ui/qmapv/qco.py +441 -0
- pyscreeps_arena/ui/qmapv/qmapv.py +728 -0
- pyscreeps_arena/ui/qmapv/test_array_drag.py +191 -0
- pyscreeps_arena/ui/qmapv/test_drag.py +107 -0
- pyscreeps_arena/ui/qmapv/test_qcinfo.py +169 -0
- pyscreeps_arena/ui/qmapv/test_qco_drag.py +7 -0
- pyscreeps_arena/ui/qmapv/test_qmapv.py +224 -0
- pyscreeps_arena/ui/qmapv/test_simple_array.py +303 -0
- pyscreeps_arena/ui/qrecipe/__init__.py +1 -0
- pyscreeps_arena/ui/qrecipe/model.py +434 -0
- pyscreeps_arena/ui/qrecipe/qrecipe.py +914 -0
- pyscreeps_arena/ui/rs_icon.py +43 -0
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.5.8.0.dist-info}/METADATA +15 -3
- pyscreeps_arena-0.5.8.0.dist-info/RECORD +47 -0
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.5.8.0.dist-info}/WHEEL +1 -1
- pyscreeps_arena-0.5.8.0.dist-info/entry_points.txt +4 -0
- pyscreeps_arena-0.3.6.dist-info/RECORD +0 -17
- pyscreeps_arena-0.3.6.dist-info/entry_points.txt +0 -2
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.5.8.0.dist-info}/top_level.txt +0 -0
pyscreeps_arena/core/config.py
CHANGED
|
@@ -15,5 +15,5 @@ season = "beta"
|
|
|
15
15
|
language = 'cn'
|
|
16
16
|
# 默认路径: 用户 + ScreepsArena + beta-spawn_and_swamp + main.mjs
|
|
17
17
|
target = None
|
|
18
|
-
TARGET_GETTER = lambda: os.path.join(os.path.expanduser('~'), 'ScreepsArena', f'{season}-{const.ARENA_NAMES.get(arena, "spawn_and_swamp")}', 'main.mjs')
|
|
18
|
+
TARGET_GETTER = lambda: os.path.join(os.path.expanduser('~'), 'ScreepsArena', f'{("season" + season) if season.isdigit() else season}-{const.ARENA_NAMES.get(arena, "spawn_and_swamp")}{"-advanced" if level in ["advance", "advanced"] else ""}', 'main.mjs')
|
|
19
19
|
|
pyscreeps_arena/core/const.py
CHANGED
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
#
|
|
10
10
|
import re
|
|
11
11
|
|
|
12
|
-
VERSION = "0.
|
|
13
|
-
AUTHOR = "
|
|
12
|
+
VERSION = "0.5.8.0"
|
|
13
|
+
AUTHOR = "●ω<🤍♪"
|
|
14
14
|
STEAM_ID = "1029562896"
|
|
15
15
|
GITHUB_NAME = "EagleBaby"
|
|
16
|
+
BILIBILI_NAME = "我阅读理解一直可以的"
|
|
16
17
|
|
|
17
|
-
ARENA_GREEN = "
|
|
18
|
-
ARENA_BLUE = "
|
|
19
|
-
ARENA_RED = "
|
|
18
|
+
ARENA_GREEN = "portal_exploration"
|
|
19
|
+
ARENA_BLUE = "spawn_strike"
|
|
20
|
+
ARENA_RED = "construct_and_control"
|
|
20
21
|
ARENA_GRAY = "tutorial"
|
|
21
22
|
|
|
22
23
|
ARENA_NAMES = {
|
pyscreeps_arena/localization.py
CHANGED
|
@@ -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': "预处理中 ...",
|
|
@@ -135,6 +139,12 @@ LOC_NOT_SUPPORT_PYFILE_INIT = {
|
|
|
135
139
|
'cn': '不支持 __init__.py!请删除它(初始化文件)并使用 from directory.xxx import xxxx 代替之。',
|
|
136
140
|
}
|
|
137
141
|
|
|
142
|
+
# V0.5.4
|
|
143
|
+
LOC_DIR_UNDER_NONINIT_DIR = {
|
|
144
|
+
'en': "Directory [{}] is located under [{}] without __init__.py, therefore it is ignored.",
|
|
145
|
+
'cn': "目录 [{}] 位于 `无__init__.py`的目录[{}]下,因此被忽略。",
|
|
146
|
+
}
|
|
147
|
+
|
|
138
148
|
if __name__ == '__main__':
|
|
139
149
|
lprint(TEMPLATE)
|
|
140
150
|
|
pyscreeps_arena/project.7z
CHANGED
|
Binary file
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# png_to_py.py - 将PNG图片转换为Python模块(最终验证版)
|
|
2
|
+
import base64
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def png_to_py(png_path, py_path=None, var_name=None):
|
|
9
|
+
"""
|
|
10
|
+
将PNG图片转换为Python模块文件
|
|
11
|
+
|
|
12
|
+
:param png_path: PNG图片路径
|
|
13
|
+
:param py_path: 输出的.py文件路径(默认为图片同名.py)
|
|
14
|
+
:param var_name: 变量名(默认为文件名的大写形式)
|
|
15
|
+
"""
|
|
16
|
+
png_file = Path(png_path)
|
|
17
|
+
|
|
18
|
+
if not png_file.exists():
|
|
19
|
+
raise FileNotFoundError(f"文件 '{png_path}' 不存在")
|
|
20
|
+
|
|
21
|
+
if png_file.suffix.lower() != '.png':
|
|
22
|
+
print(f"[警告] 文件 '{png_path}' 不是PNG格式")
|
|
23
|
+
return False
|
|
24
|
+
|
|
25
|
+
# 自动生成输出路径
|
|
26
|
+
if py_path is None:
|
|
27
|
+
py_path = png_file.with_suffix('.py')
|
|
28
|
+
else:
|
|
29
|
+
py_path = Path(py_path)
|
|
30
|
+
|
|
31
|
+
# 自动生成变量名
|
|
32
|
+
if var_name is None:
|
|
33
|
+
base_name = png_file.stem.replace('-', '_').replace(' ', '_')
|
|
34
|
+
base_name = re.sub(r'[^0-9a-zA-Z_]', '', base_name)
|
|
35
|
+
if base_name and base_name[0].isdigit():
|
|
36
|
+
base_name = f'ICON_{base_name}'
|
|
37
|
+
var_name = base_name.upper()
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
# 读取PNG文件并转换为base64
|
|
41
|
+
with open(png_file, 'rb') as f:
|
|
42
|
+
png_data = f.read()
|
|
43
|
+
base64_data = base64.b64encode(png_data).decode('utf-8')
|
|
44
|
+
|
|
45
|
+
print(f"[DEBUG] 读取PNG文件: {len(png_data)} 字节")
|
|
46
|
+
print(f"[DEBUG] Base64编码长度: {len(base64_data)} 字符")
|
|
47
|
+
|
|
48
|
+
# 生成Python代码(关键修复:使用 len({var_name}))
|
|
49
|
+
py_content = f'''# -*- coding: utf-8 -*-
|
|
50
|
+
"""
|
|
51
|
+
PyQt6资源模块: {png_file.name}
|
|
52
|
+
由 png_to_py.py 自动生成
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
# Base64编码的PNG数据(单行,无换行符)
|
|
56
|
+
{var_name} = b"{base64_data}"
|
|
57
|
+
|
|
58
|
+
def get_pixmap():
|
|
59
|
+
\"\"\"返回QPixmap对象\"\"\"
|
|
60
|
+
from PyQt6.QtGui import QPixmap
|
|
61
|
+
from PyQt6.QtCore import QByteArray
|
|
62
|
+
|
|
63
|
+
byte_array = QByteArray.fromBase64({var_name})
|
|
64
|
+
pixmap = QPixmap()
|
|
65
|
+
pixmap.loadFromData(byte_array)
|
|
66
|
+
return pixmap
|
|
67
|
+
|
|
68
|
+
def get_icon():
|
|
69
|
+
\"\"\"返回QIcon对象\"\"\"
|
|
70
|
+
from PyQt6.QtGui import QIcon
|
|
71
|
+
return QIcon(get_pixmap())
|
|
72
|
+
|
|
73
|
+
if __name__ == '__main__':
|
|
74
|
+
import sys
|
|
75
|
+
from PyQt6.QtWidgets import QApplication
|
|
76
|
+
|
|
77
|
+
app = QApplication.instance() or QApplication(sys.argv)
|
|
78
|
+
|
|
79
|
+
print(f"资源模块 {var_name} 已加载")
|
|
80
|
+
print(f"字节数据长度: {{len({var_name})}} 字节") # ✅ 修复:使用 {var_name}
|
|
81
|
+
|
|
82
|
+
# 验证能否正确加载
|
|
83
|
+
pixmap = get_pixmap()
|
|
84
|
+
print(f"QPixmap加载成功: 尺寸 {{pixmap.width()}}x{{pixmap.height()}}")
|
|
85
|
+
'''
|
|
86
|
+
|
|
87
|
+
# 写入Python文件
|
|
88
|
+
with open(py_path, 'w', encoding='utf-8') as f:
|
|
89
|
+
f.write(py_content)
|
|
90
|
+
|
|
91
|
+
print(f"✓ 成功: {png_path} -> {py_path}")
|
|
92
|
+
print(f" 变量名: {var_name}")
|
|
93
|
+
return True
|
|
94
|
+
|
|
95
|
+
except Exception as e:
|
|
96
|
+
print(f"错误: 转换失败 - {e}")
|
|
97
|
+
import traceback
|
|
98
|
+
traceback.print_exc()
|
|
99
|
+
return False
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if __name__ == '__main__':
|
|
103
|
+
if len(sys.argv) > 1:
|
|
104
|
+
target = sys.argv[1]
|
|
105
|
+
else:
|
|
106
|
+
target = "icon.png"
|
|
107
|
+
|
|
108
|
+
png_to_py(target, "rs_icon.py")
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
PyScreeps Arena UI模块
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .rs_icon import get_icon, get_pixmap
|
|
7
|
+
from .project_ui import ProjectCreatorUI, run_project_creator
|
|
8
|
+
from .P2PY import png_to_py
|
|
9
|
+
from .qmapv import QPSAMapViewer, CellInfo
|
|
10
|
+
|
|
11
|
+
__all__ = ['get_icon', 'get_pixmap', 'ProjectCreatorUI', 'run_project_creator',
|
|
12
|
+
'png_to_py', 'QPSAMapViewer', 'CellInfo']
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from PyQt6.QtWidgets import QApplication
|
|
3
|
+
from pyscreeps_arena.ui.qcreeplogic import QPSACreepLogic
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def run_creeplogic_edit():
|
|
8
|
+
app = QApplication(sys.argv)
|
|
9
|
+
window = QPSACreepLogic()
|
|
10
|
+
window.show()
|
|
11
|
+
sys.exit(app.exec())
|
|
12
|
+
|
|
13
|
+
if __name__ == '__main__':
|
|
14
|
+
run_creeplogic_edit()
|