@ohmygame/level-editor 0.0.0-stage → 0.1.0
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.
- package/.ohmygame-plugin/plugin.json +42 -0
- package/LICENSE +201 -0
- package/README.md +43 -2
- package/assets/icon.svg +1 -0
- package/locales/en.json +9 -0
- package/locales/zh-CN.json +9 -0
- package/package.json +27 -4
- package/panel/dom.js +79 -0
- package/panel/i18n.js +225 -0
- package/panel/index.html +15 -0
- package/panel/inspector.js +156 -0
- package/panel/main.js +1697 -0
- package/panel/new-map.js +112 -0
- package/panel/palette.js +196 -0
- package/panel/render.js +321 -0
- package/panel/style.css +137 -0
- package/panel/tmj.js +901 -0
- package/skills/level-maps/SKILL.md +28 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://www.ohmygame.ai/schema/plugin-2.json",
|
|
3
|
+
"id": "ohmygame/level-editor",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"engines": {
|
|
6
|
+
"ohmygame-api": "^2.34.0"
|
|
7
|
+
},
|
|
8
|
+
"displayName": "%displayName%",
|
|
9
|
+
"description": "%description%",
|
|
10
|
+
"longDescription": "%longDescription%",
|
|
11
|
+
"examples": [
|
|
12
|
+
"%example.1%",
|
|
13
|
+
"%example.2%"
|
|
14
|
+
],
|
|
15
|
+
"beta": true,
|
|
16
|
+
"icon": "./assets/icon.svg",
|
|
17
|
+
"categories": ["design"],
|
|
18
|
+
"keywords": ["%keyword.level%", "Tiled", "tilemap"],
|
|
19
|
+
"appliesTo": [
|
|
20
|
+
"general",
|
|
21
|
+
"web-game",
|
|
22
|
+
"godot-game",
|
|
23
|
+
"ohmygame/godot:godot-game"
|
|
24
|
+
],
|
|
25
|
+
"activation": "project",
|
|
26
|
+
"ui": { "major": 1 },
|
|
27
|
+
"capabilities": {
|
|
28
|
+
"project.files": "write"
|
|
29
|
+
},
|
|
30
|
+
"contributes": {
|
|
31
|
+
"skills": "./skills/",
|
|
32
|
+
"panels": [
|
|
33
|
+
{
|
|
34
|
+
"id": "levels",
|
|
35
|
+
"title": "%panel.title%",
|
|
36
|
+
"icon": "./assets/icon.svg",
|
|
37
|
+
"area": "center",
|
|
38
|
+
"entry": "./panel/index.html"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Level Editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Edit levels as Tiled JSON maps in a panel: tiles, layers, collisions and spawn
|
|
4
|
+
points.
|
|
5
|
+
|
|
6
|
+
Official OhMyGame plugin `ohmygame/level-editor`, an optional Beta for
|
|
7
|
+
OhMyGame plugin API **2.34+**. It is off until a project turns it on.
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
The **Levels** panel lists the project's Tiled maps (`.tmj` files, and `.json`
|
|
12
|
+
files that are Tiled maps; build output is skipped) and edits the one you open:
|
|
13
|
+
|
|
14
|
+
- paint with a tile or a rectangle of tiles picked from the tileset palette,
|
|
15
|
+
erase, fill an area and pick a tile from the map;
|
|
16
|
+
- draw rectangles (snapped to the grid; hold Alt for free placement), for
|
|
17
|
+
example on a `collision` object layer, and place points for spawns and goals;
|
|
18
|
+
- move objects (drag, arrow keys, Shift for a whole tile) and edit their name,
|
|
19
|
+
class, position, size and custom properties;
|
|
20
|
+
- add, rename, show or hide, reorder and delete tile and object layers;
|
|
21
|
+
- undo and redo, zoom and pan, and save with ⌘S / Ctrl+S.
|
|
22
|
+
|
|
23
|
+
**New map** writes a map with a `Ground` tile layer and an `Objects` layer, and
|
|
24
|
+
an embedded tileset cut from a PNG in the project.
|
|
25
|
+
|
|
26
|
+
The files stay Tiled's own format, so people with Tiled can use both. Saving
|
|
27
|
+
writes the same layout Tiled writes and keeps every field the panel didn't
|
|
28
|
+
change, including unknown ones, ids and each layer's encoding (arrays, or
|
|
29
|
+
base64 with no compression, gzip or zlib). External tilesets (`.tsj`, `.tsx`)
|
|
30
|
+
are read, never written. If the map changes on disk while you have unsaved
|
|
31
|
+
edits, the panel asks whether to reload it or keep yours.
|
|
32
|
+
|
|
33
|
+
The Skill tells the agent how levels are stored and how to load them in
|
|
34
|
+
Phaser, Cocos Creator and Godot.
|
|
35
|
+
|
|
36
|
+
## Limits
|
|
37
|
+
|
|
38
|
+
- Orthogonal maps only. Isometric, hexagonal and staggered maps, infinite maps
|
|
39
|
+
and maps with Zstandard-compressed layers open read-only.
|
|
40
|
+
- No tileset editing, terrain or Wang brushes, rotation or resize handles
|
|
41
|
+
(edit width and height in the inspector), and no new polygon, ellipse, tile
|
|
42
|
+
or text objects. Existing ones are drawn, can be moved and are kept.
|
|
43
|
+
- Image layers are drawn but can't be edited; parallax and tint aren't shown.
|
|
44
|
+
- Unsaved edits are lost if the panel is closed or reloaded.
|
package/assets/icon.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#24345C"/><g fill="#3E5488"><rect x="8" y="8" width="11" height="11" rx="1.5"/><rect x="21" y="8" width="11" height="11" rx="1.5"/><rect x="34" y="8" width="11" height="11" rx="1.5"/><rect x="47" y="8" width="9" height="11" rx="1.5"/><rect x="8" y="21" width="11" height="11" rx="1.5"/><rect x="21" y="21" width="11" height="11" rx="1.5"/><rect x="34" y="21" width="11" height="11" rx="1.5"/><rect x="47" y="21" width="9" height="11" rx="1.5"/></g><g fill="#7BC77E"><rect x="8" y="45" width="11" height="4" rx="1"/><rect x="21" y="45" width="11" height="4" rx="1"/><rect x="34" y="45" width="11" height="4" rx="1"/><rect x="47" y="45" width="9" height="4" rx="1"/><rect x="34" y="32" width="11" height="4" rx="1"/><rect x="47" y="32" width="9" height="4" rx="1"/></g><g fill="#B9825A"><rect x="8" y="49" width="11" height="7" rx="1"/><rect x="21" y="49" width="11" height="7" rx="1"/><rect x="34" y="49" width="11" height="7" rx="1"/><rect x="47" y="49" width="9" height="7" rx="1"/><rect x="34" y="36" width="11" height="5" rx="1"/><rect x="47" y="36" width="9" height="5" rx="1"/></g><path d="M14 44V24" stroke="#F4F7FC" stroke-width="2.5" stroke-linecap="round"/><path d="M15 24h10l-3 4 3 4H15z" fill="#F2C14E"/><rect x="21" y="30" width="22" height="15" rx="1" fill="none" stroke="#F4F7FC" stroke-width="2" stroke-dasharray="3 2.5" opacity="0.85"/></svg>
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"displayName": "Level Editor",
|
|
3
|
+
"description": "Edit levels as Tiled JSON maps in a panel: tiles, layers, collisions and spawn points.",
|
|
4
|
+
"longDescription": "A Levels panel that opens the project's Tiled maps (.tmj) and edits them in place: paint tiles from the map's tilesets, fill areas, draw collision rectangles and place spawn points with custom properties, and arrange layers. It writes Tiled's own JSON format and keeps every field it doesn't change, so the same file opens in Tiled, Phaser, Cocos and Godot importers. Infinite and Zstandard-compressed maps open read-only.",
|
|
5
|
+
"example.1": "Make a first level map in levels/ with my tileset, then load it in the game with collisions from its collision layer.",
|
|
6
|
+
"example.2": "Read the spawn points in levels/level-1.tmj and spawn the player and enemies there.",
|
|
7
|
+
"keyword.level": "level",
|
|
8
|
+
"panel.title": "Levels"
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"displayName": "关卡编辑器",
|
|
3
|
+
"description": "在面板里把关卡编辑成 Tiled JSON 地图:图块、图层、碰撞和出生点。",
|
|
4
|
+
"longDescription": "“关卡”面板打开项目里的 Tiled 地图(.tmj)并直接编辑:用地图的图块集绘制和填充图块,画碰撞矩形,放置带自定义属性的出生点,整理图层。它写入 Tiled 自己的 JSON 格式,保留所有没有改动的字段,同一个文件可以在 Tiled、Phaser、Cocos 和 Godot 导入器里打开。无限地图和使用 Zstandard 压缩的地图只能查看。",
|
|
5
|
+
"example.1": "用我的图块集在 levels/ 里做第一张关卡地图,再在游戏里加载它,用它的 collision 层做碰撞。",
|
|
6
|
+
"example.2": "读取 levels/level-1.tmj 里的出生点,把玩家和敌人生成在那里。",
|
|
7
|
+
"keyword.level": "关卡",
|
|
8
|
+
"panel.title": "关卡"
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohmygame/level-editor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Edit levels as Tiled JSON maps in a panel: tiles, layers, collisions and spawn points.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"ohmygame-plugin",
|
|
8
|
+
"tiled",
|
|
9
|
+
"tilemap",
|
|
10
|
+
"level-editor"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/WhiteTowerAI/ohmygame-plugins.git",
|
|
16
|
+
"directory": "plugins/level-editor"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
".ohmygame-plugin",
|
|
20
|
+
"assets",
|
|
21
|
+
"locales",
|
|
22
|
+
"panel",
|
|
23
|
+
"skills",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/panel/dom.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Small DOM helpers and the panel's icons.
|
|
2
|
+
|
|
3
|
+
/** An element with attributes and children; `on` maps events to listeners, `props` sets properties. */
|
|
4
|
+
export function h(tag, attributes = {}, ...children) {
|
|
5
|
+
const node = document.createElement(tag);
|
|
6
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
7
|
+
if (key === "on") for (const [type, listener] of Object.entries(value)) node.addEventListener(type, listener);
|
|
8
|
+
else if (key === "props") Object.assign(node, value);
|
|
9
|
+
else if (value !== undefined && value !== null && value !== false) node.setAttribute(key, value === true ? "" : String(value));
|
|
10
|
+
}
|
|
11
|
+
node.append(...children.flat().filter((child) => child !== undefined && child !== null && child !== false));
|
|
12
|
+
return node;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 16 × 16 strokes in currentColor.
|
|
16
|
+
const PATHS = {
|
|
17
|
+
brush: "M10.5 2.5l3 3-6.5 6.5-3-3zM4 9.5l2.5 2.5c-.5 1.8-2 2.5-4 2.5.3-1.6.4-3.8 1.5-5z",
|
|
18
|
+
eraser: "M9.5 2.5l4 4-6.5 6.5H4.5l-2-2a1 1 0 010-1.4zM6.5 5.5l4 4M7 13.5h6.5",
|
|
19
|
+
fill: "M3 7.5l5-5 5.5 5.5-5 5-5.5-5.5zM3 7.5h10M14 11c0 1-.5 2-1 2s-1-1-1-2l1-1.5z",
|
|
20
|
+
eyedropper: "M11.5 2a2 2 0 012.5 2.5l-2 2-2.5-2.5zM9.5 4l2.5 2.5M10.5 5.5L4 12v2h2l6.5-6.5",
|
|
21
|
+
rect: "M2.5 3.5h11v9h-11z",
|
|
22
|
+
point: "M8 14.5s-4.5-4.3-4.5-7.5a4.5 4.5 0 019 0c0 3.2-4.5 7.5-4.5 7.5zM8 8.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z",
|
|
23
|
+
select: "M3.5 2.5l9 5-4 1-2 4z",
|
|
24
|
+
undo: "M5.5 3.5L2.5 6.5l3 3M2.5 6.5h7a4 4 0 010 8H7",
|
|
25
|
+
redo: "M10.5 3.5l3 3-3 3M13.5 6.5h-7a4 4 0 000 8H9",
|
|
26
|
+
zoomIn: "M7 12a5 5 0 100-10 5 5 0 000 10zM14 14l-3.5-3.5M7 4.5v5M4.5 7h5",
|
|
27
|
+
zoomOut: "M7 12a5 5 0 100-10 5 5 0 000 10zM14 14l-3.5-3.5M4.5 7h5",
|
|
28
|
+
fit: "M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10",
|
|
29
|
+
grid: "M2.5 2.5h11v11h-11zM6.2 2.5v11M9.8 2.5v11M2.5 6.2h11M2.5 9.8h11",
|
|
30
|
+
plus: "M8 3v10M3 8h10",
|
|
31
|
+
eye: "M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8zM8 10a2 2 0 100-4 2 2 0 000 4z",
|
|
32
|
+
eyeOff: "M2 2l12 12M6.6 6.6a2 2 0 002.8 2.8M4.3 4.4C2.6 5.6 1.5 8 1.5 8s2.5 4.5 6.5 4.5c1.3 0 2.4-.4 3.4-1M7 3.6c.3 0 .7-.1 1-.1 4 0 6.5 4.5 6.5 4.5s-.5 1-1.5 2",
|
|
33
|
+
up: "M8 13V3M4 7l4-4 4 4",
|
|
34
|
+
down: "M8 3v10M4 9l4 4 4-4",
|
|
35
|
+
trash: "M2.5 4.5h11M6 4.5V3h4v1.5M4 4.5l.7 9h6.6l.7-9",
|
|
36
|
+
tileLayer: "M2.5 2.5h5v5h-5zM8.5 2.5h5v5h-5zM2.5 8.5h5v5h-5zM8.5 8.5h5v5h-5z",
|
|
37
|
+
objectLayer: "M3 3.5h6v5H3zM11.5 13a2 2 0 100-4 2 2 0 000 4zM3 11.5h4",
|
|
38
|
+
group: "M2 4.5h4.5l1.5 1.5h6v7H2z",
|
|
39
|
+
image: "M2.5 3h11v10h-11zM2.5 11l3.5-3.5 3 3 2-2 2.5 2.5M10.5 6.5a1 1 0 100-2 1 1 0 000 2z",
|
|
40
|
+
close: "M4 4l8 8M12 4l-8 8",
|
|
41
|
+
lock: "M4.5 7.5h7v6h-7zM6 7.5V5.5a2 2 0 014 0v2",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** An icon by name, hidden from screen readers (its control has the name). */
|
|
45
|
+
export function icon(name) {
|
|
46
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
47
|
+
svg.setAttribute("viewBox", "0 0 16 16");
|
|
48
|
+
svg.setAttribute("width", "16");
|
|
49
|
+
svg.setAttribute("height", "16");
|
|
50
|
+
svg.setAttribute("fill", "none");
|
|
51
|
+
svg.setAttribute("stroke", "currentColor");
|
|
52
|
+
svg.setAttribute("stroke-width", "1.3");
|
|
53
|
+
svg.setAttribute("stroke-linecap", "round");
|
|
54
|
+
svg.setAttribute("stroke-linejoin", "round");
|
|
55
|
+
svg.setAttribute("aria-hidden", "true");
|
|
56
|
+
svg.classList.add("icon");
|
|
57
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
58
|
+
path.setAttribute("d", PATHS[name] ?? "");
|
|
59
|
+
svg.append(path);
|
|
60
|
+
return svg;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** An icon-only button with a tooltip; `pressed` marks a chosen tool or toggle. */
|
|
64
|
+
export function iconButton(name, label, onClick, { pressed, disabled, variant = "ghost" } = {}) {
|
|
65
|
+
const button = h(
|
|
66
|
+
"omg-button",
|
|
67
|
+
{
|
|
68
|
+
variant,
|
|
69
|
+
class: "icon-button",
|
|
70
|
+
"aria-label": label,
|
|
71
|
+
"aria-pressed": pressed === undefined ? undefined : String(pressed),
|
|
72
|
+
"data-pressed": pressed ? "" : undefined,
|
|
73
|
+
disabled,
|
|
74
|
+
on: { click: onClick },
|
|
75
|
+
},
|
|
76
|
+
icon(name),
|
|
77
|
+
);
|
|
78
|
+
return h("omg-tooltip", { content: label }, button);
|
|
79
|
+
}
|
package/panel/i18n.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// The panel's text, in the app's languages; `host.locale` picks one.
|
|
2
|
+
export const TEXT = {
|
|
3
|
+
en: {
|
|
4
|
+
title: "Levels",
|
|
5
|
+
loading: "Looking for maps…",
|
|
6
|
+
chooseMap: "Map",
|
|
7
|
+
newMap: "New map",
|
|
8
|
+
save: "Save",
|
|
9
|
+
saving: "Saving…",
|
|
10
|
+
unsaved: "Unsaved",
|
|
11
|
+
noMaps: "No levels yet",
|
|
12
|
+
noMapsHint: "Levels are Tiled maps (.tmj). Make one here, or ask the agent to.",
|
|
13
|
+
pickMap: "Choose a map to edit.",
|
|
14
|
+
openFailed: (message) => `Couldn't open this map: ${message}`,
|
|
15
|
+
saveFailed: (message) => `Couldn't save: ${message}`,
|
|
16
|
+
toolbar: "Tools",
|
|
17
|
+
tools: {
|
|
18
|
+
brush: "Brush",
|
|
19
|
+
eraser: "Eraser",
|
|
20
|
+
fill: "Fill",
|
|
21
|
+
eyedropper: "Pick tile",
|
|
22
|
+
rect: "Rectangle",
|
|
23
|
+
point: "Point",
|
|
24
|
+
select: "Select",
|
|
25
|
+
},
|
|
26
|
+
undo: "Undo",
|
|
27
|
+
redo: "Redo",
|
|
28
|
+
zoomIn: "Zoom in",
|
|
29
|
+
zoomOut: "Zoom out",
|
|
30
|
+
fit: "Fit map",
|
|
31
|
+
grid: "Grid",
|
|
32
|
+
layers: "Layers",
|
|
33
|
+
addLayer: "Add layer",
|
|
34
|
+
addTileLayer: "Tile layer",
|
|
35
|
+
addObjectLayer: "Object layer",
|
|
36
|
+
moveUp: "Move up",
|
|
37
|
+
moveDown: "Move down",
|
|
38
|
+
deleteLayer: "Delete layer",
|
|
39
|
+
deleteLayerTitle: (name) => `Delete layer “${name}”?`,
|
|
40
|
+
deleteLayerMessage: "You can undo this until you close the map.",
|
|
41
|
+
delete: "Delete",
|
|
42
|
+
show: "Show",
|
|
43
|
+
hide: "Hide",
|
|
44
|
+
rename: "Double-click to rename",
|
|
45
|
+
newTileLayer: "Tile Layer",
|
|
46
|
+
newObjectLayer: "Object Layer",
|
|
47
|
+
tileset: "Tileset",
|
|
48
|
+
noTilesets: "This map has no tilesets.",
|
|
49
|
+
tilesetMissing: (path) => `Couldn't load ${path}`,
|
|
50
|
+
externalTileset: "Shared tileset file; it isn't changed here.",
|
|
51
|
+
object: "Object",
|
|
52
|
+
noSelection: "Select an object to edit it, or add one with the rectangle or point tool.",
|
|
53
|
+
name: "Name",
|
|
54
|
+
className: "Class",
|
|
55
|
+
x: "X",
|
|
56
|
+
y: "Y",
|
|
57
|
+
width: "Width",
|
|
58
|
+
height: "Height",
|
|
59
|
+
properties: "Properties",
|
|
60
|
+
addProperty: "Add property",
|
|
61
|
+
propertyName: "Name",
|
|
62
|
+
propertyType: "Type",
|
|
63
|
+
propertyValue: "Value",
|
|
64
|
+
removeProperty: "Remove property",
|
|
65
|
+
deleteObject: "Delete object",
|
|
66
|
+
newProperty: "property",
|
|
67
|
+
readOnly: {
|
|
68
|
+
infinite: "Infinite maps open read-only here. Edit them in Tiled.",
|
|
69
|
+
zstd: "This map uses Zstandard compression, which this editor can't read. Save it in Tiled with zlib, gzip or no compression to edit it here.",
|
|
70
|
+
orientation: "Only orthogonal maps can be edited here; this one opens read-only.",
|
|
71
|
+
encoding: "A layer uses an encoding this editor can't read, so the map opens read-only.",
|
|
72
|
+
},
|
|
73
|
+
changedOnDisk: "This map changed on disk.",
|
|
74
|
+
reload: "Reload",
|
|
75
|
+
keepMine: "Keep mine",
|
|
76
|
+
removedOnDisk: "This map's file was removed or can't be read.",
|
|
77
|
+
discardTitle: "Discard unsaved changes?",
|
|
78
|
+
discardMessage: (name) => `Your changes to ${name} aren't saved.`,
|
|
79
|
+
discard: "Discard",
|
|
80
|
+
needTileLayer: "Choose a tile layer to paint on.",
|
|
81
|
+
needObjectLayer: "Add an object layer to place objects.",
|
|
82
|
+
hiddenLayer: "This layer is hidden.",
|
|
83
|
+
locked: "Locked",
|
|
84
|
+
layerLocked: "This layer is locked. Unlock it in Tiled to edit it.",
|
|
85
|
+
chooseFirst: "The map changed on disk. Reload it or keep your changes before saving.",
|
|
86
|
+
couldNotAsk: (message) => `Couldn't ask before deleting the layer: ${message}`,
|
|
87
|
+
cell: (x, y) => `${x}, ${y}`,
|
|
88
|
+
tileLabel: (id) => `tile ${id}`,
|
|
89
|
+
flipped: "flipped",
|
|
90
|
+
mapSize: (w, h, tw, th) => `${w} × ${h} tiles · ${tw} × ${th} px`,
|
|
91
|
+
dialog: {
|
|
92
|
+
heading: "New map",
|
|
93
|
+
description: "A Tiled map with a Ground tile layer and an Objects layer.",
|
|
94
|
+
file: "File",
|
|
95
|
+
fileHint: "A .tmj file in the project.",
|
|
96
|
+
columns: "Width (tiles)",
|
|
97
|
+
rows: "Height (tiles)",
|
|
98
|
+
tileWidth: "Tile width (px)",
|
|
99
|
+
tileHeight: "Tile height (px)",
|
|
100
|
+
tilesetImage: "Tileset image",
|
|
101
|
+
tilesetHint: "A PNG cut into tiles of the size above.",
|
|
102
|
+
noImage: "No tileset",
|
|
103
|
+
search: "Search images",
|
|
104
|
+
noImages: "No PNG files in this project",
|
|
105
|
+
cancel: "Cancel",
|
|
106
|
+
create: "Create",
|
|
107
|
+
exists: "A file with this name already exists.",
|
|
108
|
+
badName: "Use a path ending in .tmj or .json.",
|
|
109
|
+
badNumber: "Use a whole number from 1 to 4096.",
|
|
110
|
+
imageFailed: "Couldn't read this image.",
|
|
111
|
+
imageTooSmall: "The image is smaller than one tile.",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
"zh-CN": {
|
|
115
|
+
title: "关卡",
|
|
116
|
+
loading: "正在查找地图…",
|
|
117
|
+
chooseMap: "地图",
|
|
118
|
+
newMap: "新建地图",
|
|
119
|
+
save: "保存",
|
|
120
|
+
saving: "正在保存…",
|
|
121
|
+
unsaved: "未保存",
|
|
122
|
+
noMaps: "还没有关卡",
|
|
123
|
+
noMapsHint: "关卡是 Tiled 地图(.tmj)。可以在这里新建,也可以让智能体来做。",
|
|
124
|
+
pickMap: "选择要编辑的地图。",
|
|
125
|
+
openFailed: (message) => `无法打开这张地图:${message}`,
|
|
126
|
+
saveFailed: (message) => `无法保存:${message}`,
|
|
127
|
+
toolbar: "工具",
|
|
128
|
+
tools: {
|
|
129
|
+
brush: "画笔",
|
|
130
|
+
eraser: "橡皮擦",
|
|
131
|
+
fill: "填充",
|
|
132
|
+
eyedropper: "吸取图块",
|
|
133
|
+
rect: "矩形",
|
|
134
|
+
point: "点",
|
|
135
|
+
select: "选择",
|
|
136
|
+
},
|
|
137
|
+
undo: "撤销",
|
|
138
|
+
redo: "重做",
|
|
139
|
+
zoomIn: "放大",
|
|
140
|
+
zoomOut: "缩小",
|
|
141
|
+
fit: "适应窗口",
|
|
142
|
+
grid: "网格",
|
|
143
|
+
layers: "图层",
|
|
144
|
+
addLayer: "添加图层",
|
|
145
|
+
addTileLayer: "图块层",
|
|
146
|
+
addObjectLayer: "对象层",
|
|
147
|
+
moveUp: "上移",
|
|
148
|
+
moveDown: "下移",
|
|
149
|
+
deleteLayer: "删除图层",
|
|
150
|
+
deleteLayerTitle: (name) => `删除图层“${name}”?`,
|
|
151
|
+
deleteLayerMessage: "关闭地图之前都可以撤销。",
|
|
152
|
+
delete: "删除",
|
|
153
|
+
show: "显示",
|
|
154
|
+
hide: "隐藏",
|
|
155
|
+
rename: "双击重命名",
|
|
156
|
+
newTileLayer: "图块层",
|
|
157
|
+
newObjectLayer: "对象层",
|
|
158
|
+
tileset: "图块集",
|
|
159
|
+
noTilesets: "这张地图没有图块集。",
|
|
160
|
+
tilesetMissing: (path) => `无法加载 ${path}`,
|
|
161
|
+
externalTileset: "共用的图块集文件,这里不会修改它。",
|
|
162
|
+
object: "对象",
|
|
163
|
+
noSelection: "选中一个对象来编辑,或用矩形、点工具添加。",
|
|
164
|
+
name: "名称",
|
|
165
|
+
className: "类",
|
|
166
|
+
x: "X",
|
|
167
|
+
y: "Y",
|
|
168
|
+
width: "宽",
|
|
169
|
+
height: "高",
|
|
170
|
+
properties: "属性",
|
|
171
|
+
addProperty: "添加属性",
|
|
172
|
+
propertyName: "名称",
|
|
173
|
+
propertyType: "类型",
|
|
174
|
+
propertyValue: "值",
|
|
175
|
+
removeProperty: "移除属性",
|
|
176
|
+
deleteObject: "删除对象",
|
|
177
|
+
newProperty: "属性",
|
|
178
|
+
readOnly: {
|
|
179
|
+
infinite: "无限地图在这里只能查看,请在 Tiled 里编辑。",
|
|
180
|
+
zstd: "这张地图使用 Zstandard 压缩,编辑器无法读取。在 Tiled 里改用 zlib、gzip 或不压缩保存后,就能在这里编辑。",
|
|
181
|
+
orientation: "这里只能编辑正交地图,这张地图只能查看。",
|
|
182
|
+
encoding: "有图层的编码无法读取,这张地图只能查看。",
|
|
183
|
+
},
|
|
184
|
+
changedOnDisk: "这张地图在磁盘上被修改了。",
|
|
185
|
+
reload: "重新载入",
|
|
186
|
+
keepMine: "保留我的",
|
|
187
|
+
removedOnDisk: "这张地图的文件被删除了,或无法读取。",
|
|
188
|
+
discardTitle: "放弃未保存的修改?",
|
|
189
|
+
discardMessage: (name) => `你对 ${name} 的修改还没有保存。`,
|
|
190
|
+
discard: "放弃",
|
|
191
|
+
needTileLayer: "选择一个图块层来绘制。",
|
|
192
|
+
needObjectLayer: "先添加一个对象层来放置对象。",
|
|
193
|
+
hiddenLayer: "这个图层已隐藏。",
|
|
194
|
+
locked: "已锁定",
|
|
195
|
+
layerLocked: "这个图层已锁定。请在 Tiled 中解锁后再编辑。",
|
|
196
|
+
chooseFirst: "地图在磁盘上已更改。请先重新加载或保留你的修改,再保存。",
|
|
197
|
+
couldNotAsk: (message) => `删除图层前无法确认:${message}`,
|
|
198
|
+
cell: (x, y) => `${x}, ${y}`,
|
|
199
|
+
tileLabel: (id) => `图块 ${id}`,
|
|
200
|
+
flipped: "已翻转",
|
|
201
|
+
mapSize: (w, h, tw, th) => `${w} × ${h} 格 · ${tw} × ${th} 像素`,
|
|
202
|
+
dialog: {
|
|
203
|
+
heading: "新建地图",
|
|
204
|
+
description: "一张 Tiled 地图,带 Ground 图块层和 Objects 对象层。",
|
|
205
|
+
file: "文件",
|
|
206
|
+
fileHint: "项目里的 .tmj 文件。",
|
|
207
|
+
columns: "宽(格)",
|
|
208
|
+
rows: "高(格)",
|
|
209
|
+
tileWidth: "图块宽(像素)",
|
|
210
|
+
tileHeight: "图块高(像素)",
|
|
211
|
+
tilesetImage: "图块集图片",
|
|
212
|
+
tilesetHint: "按上面的尺寸切成图块的 PNG。",
|
|
213
|
+
noImage: "不用图块集",
|
|
214
|
+
search: "搜索图片",
|
|
215
|
+
noImages: "项目里没有 PNG 文件",
|
|
216
|
+
cancel: "取消",
|
|
217
|
+
create: "创建",
|
|
218
|
+
exists: "已经有同名文件。",
|
|
219
|
+
badName: "请使用以 .tmj 或 .json 结尾的路径。",
|
|
220
|
+
badNumber: "请输入 1 到 4096 之间的整数。",
|
|
221
|
+
imageFailed: "无法读取这张图片。",
|
|
222
|
+
imageTooSmall: "图片比一个图块还小。",
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
};
|