pyscreeps-arena 0.5.7b0__py3-none-any.whl → 0.5.7.2__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.
@@ -0,0 +1,14 @@
1
+ import sys
2
+ from PyQt6.QtWidgets import QApplication
3
+ from pyscreeps_arena.ui.qmapker.qmapmarker import QPSAMapMarker
4
+
5
+
6
+ def run_mapviewer():
7
+ app = QApplication(sys.argv)
8
+ window = QPSAMapMarker()
9
+ window.show()
10
+ sys.exit(app.exec())
11
+
12
+
13
+ if __name__ == '__main__':
14
+ run_mapviewer()
@@ -10,6 +10,67 @@ from pyscreeps_arena.ui.qrecipe.qrecipe import QPSARecipe
10
10
  from pyscreeps_arena.ui.qcreeplogic.model import CreepLogicSettings
11
11
  from typing import List, Optional, Union
12
12
 
13
+ # Import configuration from build.py
14
+ import sys
15
+ import os
16
+ # Add the project root directory to Python path
17
+ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
18
+ from pyscreeps_arena import config
19
+
20
+ # Language mapping
21
+ LANG = {
22
+ 'cn': {
23
+ 'class_name': '类名',
24
+ 'inherit_name': '继承类名',
25
+ 'properties': '属性设置',
26
+ 'functions': '函数控制',
27
+ 'creep_recipe': '爬虫配方',
28
+ 'reset': '重置',
29
+ 'copy': '复制',
30
+ 'name': 'NAME',
31
+ 'draw': 'DRAW',
32
+ 'layer': 'LAYER',
33
+ 'once': 'ONCE',
34
+ 'spawnable': 'SPAWNABLE',
35
+ 'optimise': 'OPTIMISE',
36
+ 'extension': 'EXTENSION',
37
+ 'direction': 'DIRECTION',
38
+ 'on_loading': 'onLoading',
39
+ 'on_start': 'onStart',
40
+ 'on_stop': 'onStop',
41
+ 'on_changed': 'onChanged',
42
+ 'on_killed': 'onKilled',
43
+ 'on_draw': 'onDraw',
44
+ },
45
+ 'en': {
46
+ 'class_name': 'Class Name',
47
+ 'inherit_name': 'Inherit Class',
48
+ 'properties': 'Properties',
49
+ 'functions': 'Functions',
50
+ 'creep_recipe': 'Creep Recipe',
51
+ 'reset': 'Reset',
52
+ 'copy': 'Copy',
53
+ 'name': 'NAME',
54
+ 'draw': 'DRAW',
55
+ 'layer': 'LAYER',
56
+ 'once': 'ONCE',
57
+ 'spawnable': 'SPAWNABLE',
58
+ 'optimise': 'OPTIMISE',
59
+ 'extension': 'EXTENSION',
60
+ 'direction': 'DIRECTION',
61
+ 'on_loading': 'onLoading',
62
+ 'on_start': 'onStart',
63
+ 'on_stop': 'onStop',
64
+ 'on_changed': 'onChanged',
65
+ 'on_killed': 'onKilled',
66
+ 'on_draw': 'onDraw',
67
+ }
68
+ }
69
+
70
+ def lang(key: str) -> str:
71
+ """Helper function to get translated text"""
72
+ return LANG[config.language if hasattr(config, 'language') and config.language in LANG else 'cn'][key]
73
+
13
74
  # 全局样式常量
14
75
  CHECKBOX_STYLE = "QCheckBox::indicator { width: 16px; height: 16px; border: 3px solid #555; border-radius: 5px; background-color: white; } QCheckBox::indicator:checked { background-color: #4CAF50; image: url('data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' width=\'18\' height=\'18\' viewBox=\'0 0 24 24\'><path fill=\'white\' d=\'M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\'/></svg>'); }"
15
76
 
@@ -49,7 +110,7 @@ class QPSACreepLogic(QWidget):
49
110
  class_name_group = QWidget()
50
111
  class_name_layout = QVBoxLayout(class_name_group)
51
112
  class_name_layout.setContentsMargins(0, 0, 0, 0)
52
- class_name_label = QLabel("类名")
113
+ class_name_label = QLabel(lang('class_name'))
53
114
  self._class_name_edit = QLineEdit()
54
115
  self._class_name_edit.setPlaceholderText("MyCreep") # 类名默认为MyCreep的placeholder
55
116
  class_name_layout.addWidget(class_name_label)
@@ -60,7 +121,7 @@ class QPSACreepLogic(QWidget):
60
121
  inherit_name_group = QWidget()
61
122
  inherit_name_layout = QVBoxLayout(inherit_name_group)
62
123
  inherit_name_layout.setContentsMargins(0, 0, 0, 0)
63
- inherit_name_label = QLabel("继承类名")
124
+ inherit_name_label = QLabel(lang('inherit_name'))
64
125
  self._inherit_name_edit = QLineEdit("CreepLogic")
65
126
  inherit_name_layout.addWidget(inherit_name_label)
66
127
  inherit_name_layout.addWidget(self._inherit_name_edit)
@@ -72,7 +133,7 @@ class QPSACreepLogic(QWidget):
72
133
  main_layout.addLayout(class_row)
73
134
 
74
135
  # 2. 属性字段行(参考engine.py设计,除了RECIPE)
75
- properties_group = QGroupBox("属性设置")
136
+ properties_group = QGroupBox(lang('properties'))
76
137
  properties_layout = QGridLayout(properties_group)
77
138
  properties_layout.setSpacing(15)
78
139
 
@@ -87,7 +148,7 @@ class QPSACreepLogic(QWidget):
87
148
 
88
149
  # 第一列
89
150
  # NAME属性
90
- name_label = QLabel("NAME")
151
+ name_label = QLabel(lang('name'))
91
152
  name_label.setFixedWidth(label_width)
92
153
  self._name_edit = QLineEdit()
93
154
  # 设置初始PlaceHolder与默认类名一致
@@ -97,7 +158,7 @@ class QPSACreepLogic(QWidget):
97
158
  properties_layout.addWidget(self._name_edit, 0, 1)
98
159
 
99
160
  # Draw属性
100
- draw_label = QLabel("DRAW")
161
+ draw_label = QLabel(lang('draw'))
101
162
  draw_label.setFixedWidth(label_width)
102
163
  self._draw_checkbox = QCheckBox()
103
164
  # 增加复选框大小
@@ -106,7 +167,7 @@ class QPSACreepLogic(QWidget):
106
167
  properties_layout.addWidget(self._draw_checkbox, 1, 1)
107
168
 
108
169
  # Layer属性
109
- layer_label = QLabel("LAYER")
170
+ layer_label = QLabel(lang('layer'))
110
171
  layer_label.setFixedWidth(label_width)
111
172
  self._layer_spinbox = QSpinBox()
112
173
  self._layer_spinbox.setRange(0, 100)
@@ -115,7 +176,7 @@ class QPSACreepLogic(QWidget):
115
176
  properties_layout.addWidget(self._layer_spinbox, 2, 1)
116
177
 
117
178
  # Once属性
118
- once_label = QLabel("ONCE")
179
+ once_label = QLabel(lang('once'))
119
180
  once_label.setFixedWidth(label_width)
120
181
  self._once_checkbox = QCheckBox()
121
182
  self._once_checkbox.setChecked(True)
@@ -126,7 +187,7 @@ class QPSACreepLogic(QWidget):
126
187
 
127
188
  # 第二列
128
189
  # Spawnable属性
129
- spawnable_label = QLabel("SPAWNABLE")
190
+ spawnable_label = QLabel(lang('spawnable'))
130
191
  spawnable_label.setFixedWidth(label_width)
131
192
  self._spawnable_checkbox = QCheckBox()
132
193
  self._spawnable_checkbox.setChecked(True)
@@ -136,7 +197,7 @@ class QPSACreepLogic(QWidget):
136
197
  properties_layout.addWidget(self._spawnable_checkbox, 0, 3)
137
198
 
138
199
  # Optimise属性
139
- optimise_label = QLabel("OPTIMISE")
200
+ optimise_label = QLabel(lang('optimise'))
140
201
  optimise_label.setFixedWidth(label_width)
141
202
  self._optimise_checkbox = QCheckBox()
142
203
  self._optimise_checkbox.setChecked(True)
@@ -148,7 +209,7 @@ class QPSACreepLogic(QWidget):
148
209
  properties_layout.addWidget(self._optimise_checkbox, 1, 3)
149
210
 
150
211
  # Extension属性
151
- extension_label = QLabel("EXTENSION")
212
+ extension_label = QLabel(lang('extension'))
152
213
  extension_label.setFixedWidth(label_width)
153
214
  self._extension_checkbox = QCheckBox()
154
215
  self._extension_checkbox.setChecked(True)
@@ -158,7 +219,7 @@ class QPSACreepLogic(QWidget):
158
219
  properties_layout.addWidget(self._extension_checkbox, 2, 3)
159
220
 
160
221
  # Direction属性
161
- direction_label = QLabel("DIRECTION")
222
+ direction_label = QLabel(lang('direction'))
162
223
  direction_label.setFixedWidth(label_width)
163
224
  # 使用QComboBox显示方向符号
164
225
  self._direction_combo = QComboBox()
@@ -180,50 +241,50 @@ class QPSACreepLogic(QWidget):
180
241
  main_layout.addWidget(properties_group)
181
242
 
182
243
  # 3.5 函数控制行
183
- functions_group = QGroupBox("函数控制")
244
+ functions_group = QGroupBox(lang('functions'))
184
245
  functions_layout = QGridLayout(functions_group)
185
246
  functions_layout.setHorizontalSpacing(20) # 水平间距20px
186
247
  functions_layout.setVerticalSpacing(10) # 垂直间距10px
187
248
 
188
249
  # onLoading复选框
189
- self._on_loading_checkbox = QCheckBox("onLoading")
250
+ self._on_loading_checkbox = QCheckBox(lang('on_loading'))
190
251
  self._on_loading_checkbox.setChecked(True) # 默认开启
191
252
  self._on_loading_checkbox.setStyleSheet(CHECKBOX_STYLE)
192
253
  functions_layout.addWidget(self._on_loading_checkbox, 0, 0)
193
254
 
194
255
  # onStart复选框
195
- self._on_start_checkbox = QCheckBox("onStart")
256
+ self._on_start_checkbox = QCheckBox(lang('on_start'))
196
257
  self._on_start_checkbox.setChecked(False) # 默认关闭
197
258
  self._on_start_checkbox.setStyleSheet(CHECKBOX_STYLE)
198
259
  functions_layout.addWidget(self._on_start_checkbox, 0, 1)
199
260
 
200
261
  # onStop复选框
201
- self._on_stop_checkbox = QCheckBox("onStop")
262
+ self._on_stop_checkbox = QCheckBox(lang('on_stop'))
202
263
  self._on_stop_checkbox.setChecked(False) # 默认关闭
203
264
  self._on_stop_checkbox.setStyleSheet(CHECKBOX_STYLE)
204
265
  functions_layout.addWidget(self._on_stop_checkbox, 0, 2)
205
266
 
206
267
  # onChanged复选框
207
- self._on_changed_checkbox = QCheckBox("onChanged")
268
+ self._on_changed_checkbox = QCheckBox(lang('on_changed'))
208
269
  self._on_changed_checkbox.setChecked(False) # 默认关闭
209
270
  self._on_changed_checkbox.setStyleSheet(CHECKBOX_STYLE)
210
271
  functions_layout.addWidget(self._on_changed_checkbox, 1, 0)
211
272
 
212
273
  # onKilled复选框
213
- self._on_killed_checkbox = QCheckBox("onKilled")
274
+ self._on_killed_checkbox = QCheckBox(lang('on_killed'))
214
275
  self._on_killed_checkbox.setChecked(False) # 默认关闭
215
276
  self._on_killed_checkbox.setStyleSheet(CHECKBOX_STYLE)
216
277
  functions_layout.addWidget(self._on_killed_checkbox, 1, 1)
217
278
 
218
279
  # onDraw复选框
219
- self._on_draw_checkbox = QCheckBox("onDraw")
280
+ self._on_draw_checkbox = QCheckBox(lang('on_draw'))
220
281
  self._on_draw_checkbox.setChecked(False) # 默认关闭
221
282
  self._on_draw_checkbox.setStyleSheet(CHECKBOX_STYLE)
222
283
  functions_layout.addWidget(self._on_draw_checkbox, 1, 2)
223
284
  main_layout.addWidget(functions_group)
224
285
 
225
286
  # 4. QPSARecipe组件
226
- recipe_group = QGroupBox("爬虫配方")
287
+ recipe_group = QGroupBox(lang('creep_recipe'))
227
288
  recipe_layout = QVBoxLayout(recipe_group)
228
289
  recipe_layout.addWidget(self._qrecipe)
229
290
  main_layout.addWidget(recipe_group)
@@ -233,11 +294,11 @@ class QPSACreepLogic(QWidget):
233
294
  buttons_row.setSpacing(10)
234
295
 
235
296
  # Reset按钮
236
- self._reset_button = QPushButton("Reset")
297
+ self._reset_button = QPushButton(lang('reset'))
237
298
  self._reset_button.clicked.connect(self._on_reset_clicked)
238
299
 
239
300
  # Copy按钮
240
- self._copy_button = QPushButton("Copy")
301
+ self._copy_button = QPushButton(lang('copy'))
241
302
  self._copy_button.clicked.connect(self._on_copy_clicked)
242
303
 
243
304
  buttons_row.addWidget(self._reset_button)
@@ -0,0 +1,3 @@
1
+ from pyscreeps_arena.ui.qmapv.qmapv import QPSAMapViewer, CellInfo
2
+ from pyscreeps_arena.ui.qmapv.qcinfo import QPSACellInfo, QPSACellObjectItem as QPSACellInfoItem
3
+ from pyscreeps_arena.ui.qmapv.qco import QPSACellObject, QPSACellObjectItem