@nice2dev/ui-graphics 1.2.1 → 1.2.2
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/CHANGELOG.md +39 -0
- package/dist/cjs/animation/AnimatedPerson.js +3 -1
- package/dist/cjs/core/NiceBrushEngine.js +5 -4
- package/dist/cjs/core/collaboration.js +11 -6
- package/dist/cjs/core/minimap.js +21 -20
- package/dist/cjs/font/NiceFontEditor.js +5 -5
- package/dist/cjs/game/GameAsset2dEditor.js +57 -38
- package/dist/cjs/photo/NiceAITools.js +3 -3
- package/dist/cjs/photo/PhotoEditorLeftPanel.js +14 -14
- package/dist/cjs/pixel/PixelEditor.js +1 -1
- package/dist/cjs/pixel/PixelEditorMenuBar.js +92 -27
- package/dist/cjs/pixel/PixelEditorRightPanel.js +7 -3
- package/dist/cjs/pixel/PixelEditorStatusBar.js +6 -2
- package/dist/cjs/pixel/PixelEditorTimeline.js +5 -1
- package/dist/cjs/pixel/PixelEditorToolbar.js +3 -1
- package/dist/cjs/pixel/SpriteGeneratorPanel.js +18 -11
- package/dist/cjs/texture/Nice3DTexturePainter.js +9 -5
- package/dist/cjs/vector/NiceSvgToCode.js +3 -3
- package/dist/cjs/vector/VectorEditor.js +1 -1
- package/dist/cjs/vector/VectorEditorMenuBar.js +7 -1
- package/dist/cjs/vector/VectorEditorRightPanel.js +1 -1
- package/dist/esm/animation/AnimatedPerson.js +3 -1
- package/dist/esm/core/NiceBrushEngine.js +5 -4
- package/dist/esm/core/collaboration.js +11 -6
- package/dist/esm/core/minimap.js +21 -20
- package/dist/esm/font/NiceFontEditor.js +5 -5
- package/dist/esm/game/GameAsset2dEditor.js +57 -38
- package/dist/esm/photo/NiceAITools.js +3 -3
- package/dist/esm/photo/PhotoEditorLeftPanel.js +14 -14
- package/dist/esm/pixel/PixelEditor.js +1 -1
- package/dist/esm/pixel/PixelEditorMenuBar.js +92 -27
- package/dist/esm/pixel/PixelEditorRightPanel.js +7 -3
- package/dist/esm/pixel/PixelEditorStatusBar.js +6 -2
- package/dist/esm/pixel/PixelEditorTimeline.js +5 -1
- package/dist/esm/pixel/PixelEditorToolbar.js +3 -1
- package/dist/esm/pixel/SpriteGeneratorPanel.js +18 -11
- package/dist/esm/texture/Nice3DTexturePainter.js +9 -5
- package/dist/esm/vector/NiceSvgToCode.js +3 -3
- package/dist/esm/vector/VectorEditor.js +1 -1
- package/dist/esm/vector/VectorEditorMenuBar.js +7 -1
- package/dist/esm/vector/VectorEditorRightPanel.js +1 -1
- package/package.json +3 -3
|
@@ -544,20 +544,21 @@ color = '#000000') {
|
|
|
544
544
|
const NiceBrushEngine = ({ canvas, color = '#000000', onStrokeEnd, className = '', }) => {
|
|
545
545
|
const { t } = useNiceTranslation();
|
|
546
546
|
const engine = useBrushEngine(canvas, color);
|
|
547
|
+
const { endStroke } = engine;
|
|
547
548
|
// Override endStroke to fire callback
|
|
548
549
|
useEffect(() => {
|
|
549
550
|
if (!canvas) {
|
|
550
551
|
return;
|
|
551
552
|
}
|
|
552
553
|
const onUp = () => {
|
|
553
|
-
const stroke =
|
|
554
|
+
const stroke = endStroke();
|
|
554
555
|
if (stroke && onStrokeEnd) {
|
|
555
556
|
onStrokeEnd(stroke);
|
|
556
557
|
}
|
|
557
558
|
};
|
|
558
559
|
canvas.addEventListener('pointerup', onUp);
|
|
559
560
|
return () => canvas.removeEventListener('pointerup', onUp);
|
|
560
|
-
}, [canvas,
|
|
561
|
+
}, [canvas, endStroke, onStrokeEnd]);
|
|
561
562
|
const s = engine.settings;
|
|
562
563
|
return (jsxs("div", { className: `nice-brush-engine ${className}`, style: { display: 'grid', gap: 6, fontSize: 13 }, children: [jsxs("strong", { children: [jsx(NiceIcon, { name: "brush", size: 14 }), " ", t('brushEngine.brushEngineV2', 'Brush Engine v2')] }), jsx("div", { style: { display: 'flex', gap: 2, flexWrap: 'wrap' }, children: engine.presetNames.map((name) => {
|
|
563
564
|
var _a, _b;
|
|
@@ -572,13 +573,13 @@ const NiceBrushEngine = ({ canvas, color = '#000000', onStrokeEnd, className = '
|
|
|
572
573
|
: 'transparent',
|
|
573
574
|
color: s.name === ((_b = BRUSH_PRESETS[name]) === null || _b === void 0 ? void 0 : _b.name) ? 'var(--nice-color-white, #fff)' : 'inherit',
|
|
574
575
|
}, children: BRUSH_PRESETS[name].name }, name));
|
|
575
|
-
}) }), jsxs("label", { children: [
|
|
576
|
+
}) }), jsxs("label", { children: [t('brushEngine.sizePx', 'Size: {size}px').replace('{size}', String(s.size)), jsx("input", { type: "range", min: 1, max: 200, value: s.size, onChange: (e) => engine.setSettings({ ...s, size: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('brushEngine.opacity', 'Opacity: {opacity}%').replace('{opacity}', String(Math.round(s.opacity * 100))), jsx("input", { type: "range", min: 0, max: 1, step: 0.01, value: s.opacity, onChange: (e) => engine.setSettings({ ...s, opacity: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('brushEngine.flow', 'Flow: {flow}%').replace('{flow}', String(Math.round(s.flow * 100))), jsx("input", { type: "range", min: 0, max: 1, step: 0.01, value: s.flow, onChange: (e) => engine.setSettings({ ...s, flow: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('brushEngine.hardness', 'Hardness: {hardness}%').replace('{hardness}', String(Math.round(s.hardness * 100))), jsx("input", { type: "range", min: 0, max: 1, step: 0.01, value: s.hardness, onChange: (e) => engine.setSettings({ ...s, hardness: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('brushEngine.smoothing', 'Smoothing: {smoothing}%').replace('{smoothing}', String(Math.round(s.smoothing * 100))), jsx("input", { type: "range", min: 0, max: 1, step: 0.01, value: s.smoothing, onChange: (e) => engine.setSettings({ ...s, smoothing: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('brushEngine.tip', 'Tip:'), jsxs("select", { value: s.tipShape, onChange: (e) => engine.setSettings({ ...s, tipShape: e.target.value }), style: { width: '100%' }, children: [jsx("option", { value: "circle", children: t('brushEngine.circle', 'Circle') }), jsx("option", { value: "square", children: t('brushEngine.square', 'Square') }), jsx("option", { value: "diamond", children: t('brushEngine.diamond', 'Diamond') }), jsx("option", { value: "texture", children: t('brushEngine.texture', 'Texture') })] })] }), jsxs("label", { children: [t('brushEngine.roundness', 'Roundness: {roundness}%').replace('{roundness}', String(Math.round(s.roundness * 100))), jsx("input", { type: "range", min: 0.05, max: 1, step: 0.05, value: s.roundness, onChange: (e) => engine.setSettings({ ...s, roundness: +e.target.value }), style: { width: '100%' } })] }), jsxs("details", { children: [jsxs("summary", { style: { cursor: 'pointer', fontSize: 12 }, children: [jsx(NiceIcon, { name: "bar-chart", size: 12 }), " ", t('brushEngine.sizeDynamics', 'Size Dynamics')] }), jsxs("label", { children: [t('brushEngine.source', 'Source:'), jsxs("select", { value: s.sizeDynamics.source, onChange: (e) => engine.setSettings({
|
|
576
577
|
...s,
|
|
577
578
|
sizeDynamics: {
|
|
578
579
|
...s.sizeDynamics,
|
|
579
580
|
source: e.target.value,
|
|
580
581
|
},
|
|
581
|
-
}), style: { width: '100%' }, children: [jsx("option", { value: "none", children:
|
|
582
|
+
}), style: { width: '100%' }, children: [jsx("option", { value: "none", children: t('brushEngine.off', 'Off') }), jsx("option", { value: "pressure", children: t('brushEngine.pressure', 'Pressure') }), jsx("option", { value: "tilt", children: t('brushEngine.tilt', 'Tilt') }), jsx("option", { value: "speed", children: t('brushEngine.speed', 'Speed') }), jsx("option", { value: "random", children: t('brushEngine.random', 'Random') })] })] })] }), jsxs("label", { children: [t('brushEngine.scatter', 'Scatter: {scatter}%').replace('{scatter}', String(Math.round(s.scatter * 100))), jsx("input", { type: "range", min: 0, max: 1, step: 0.01, value: s.scatter, onChange: (e) => engine.setSettings({ ...s, scatter: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('brushEngine.blend', 'Blend:'), jsx("select", { value: s.blendMode, onChange: (e) => engine.setSettings({ ...s, blendMode: e.target.value }), style: { width: '100%' }, children: ['normal', 'multiply', 'screen', 'overlay', 'darken', 'lighten'].map((m) => (jsx("option", { value: m, children: m }, m))) })] }), jsxs("label", { style: { display: 'flex', gap: 4, alignItems: 'center' }, children: [jsx("input", { type: "checkbox", checked: s.wetEdges, onChange: (e) => engine.setSettings({ ...s, wetEdges: e.target.checked }) }), t('brushEngine.wetEdges', 'Wet Edges')] })] }));
|
|
582
583
|
};
|
|
583
584
|
|
|
584
585
|
export { BRUSH_PRESETS, NiceBrushEngine, useBrushEngine };
|
|
@@ -169,10 +169,14 @@ function useCollaboration(transport, roomId, currentUser) {
|
|
|
169
169
|
const [users, setUsers] = useState([]);
|
|
170
170
|
const [connected, setConnected] = useState(false);
|
|
171
171
|
const operationHandlers = useRef([]);
|
|
172
|
+
// the user as it is when the room is joined: a new object with the same id must not rejoin
|
|
173
|
+
const currentUserRef = useRef(currentUser);
|
|
174
|
+
currentUserRef.current = currentUser;
|
|
172
175
|
useEffect(() => {
|
|
173
|
-
|
|
176
|
+
const user = currentUserRef.current;
|
|
177
|
+
transport.connect(roomId, user.id);
|
|
174
178
|
setConnected(true);
|
|
175
|
-
transport.send({ type: 'join', user
|
|
179
|
+
transport.send({ type: 'join', user });
|
|
176
180
|
const unsubscribe = transport.onMessage((msg) => {
|
|
177
181
|
switch (msg.type) {
|
|
178
182
|
case 'join':
|
|
@@ -202,17 +206,18 @@ function useCollaboration(transport, roomId, currentUser) {
|
|
|
202
206
|
}
|
|
203
207
|
});
|
|
204
208
|
return () => {
|
|
205
|
-
transport.send({ type: 'leave', userId:
|
|
209
|
+
transport.send({ type: 'leave', userId: user.id });
|
|
206
210
|
unsubscribe();
|
|
207
211
|
transport.disconnect();
|
|
208
212
|
setConnected(false);
|
|
209
213
|
};
|
|
210
|
-
|
|
211
|
-
|
|
214
|
+
// a new transport reconnects (until 1.2.2 it was ignored and messages went to the old one)
|
|
215
|
+
}, [transport, roomId, currentUser.id]);
|
|
216
|
+
const sendCursor = useCallback((x, y) => transport.send({ type: 'cursor', userId: currentUser.id, x, y }), [transport, currentUser.id]);
|
|
212
217
|
const sendOperation = useCallback((op) => transport.send({
|
|
213
218
|
type: 'operation',
|
|
214
219
|
operation: { ...op, timestamp: Date.now(), userId: currentUser.id },
|
|
215
|
-
}), [currentUser.id]);
|
|
220
|
+
}), [transport, currentUser.id]);
|
|
216
221
|
const onOperation = useCallback((handler) => {
|
|
217
222
|
operationHandlers.current.push(handler);
|
|
218
223
|
return () => {
|
package/dist/esm/core/minimap.js
CHANGED
|
@@ -18,6 +18,27 @@ const Minimap = ({ canvasRef, imageDataUrl, documentWidth, documentHeight, viewp
|
|
|
18
18
|
const scale = Math.min(scaleX, scaleY);
|
|
19
19
|
// Draw minimap
|
|
20
20
|
React.useEffect(() => {
|
|
21
|
+
// inside the effect: it draws with this run's viewport, scale and size
|
|
22
|
+
const drawViewport = (ctx) => {
|
|
23
|
+
// Draw viewport rect
|
|
24
|
+
const vx = viewport.x * scale;
|
|
25
|
+
const vy = viewport.y * scale;
|
|
26
|
+
const vw = viewport.width * scale;
|
|
27
|
+
const vh = viewport.height * scale;
|
|
28
|
+
ctx.strokeStyle = resolveCssColor('var(--nice-primary-tint-80, rgba(59, 130, 246, 0.8))', ctx.canvas);
|
|
29
|
+
ctx.lineWidth = 1.5;
|
|
30
|
+
ctx.strokeRect(vx, vy, vw, vh);
|
|
31
|
+
// Dim areas outside viewport
|
|
32
|
+
ctx.fillStyle = resolveCssColor('var(--nice-overlay-30, rgba(0, 0, 0, 0.3))', ctx.canvas);
|
|
33
|
+
// Top
|
|
34
|
+
ctx.fillRect(0, 0, mapW, vy);
|
|
35
|
+
// Bottom
|
|
36
|
+
ctx.fillRect(0, vy + vh, mapW, mapH - vy - vh);
|
|
37
|
+
// Left
|
|
38
|
+
ctx.fillRect(0, vy, vx, vh);
|
|
39
|
+
// Right
|
|
40
|
+
ctx.fillRect(vx + vw, vy, mapW - vx - vw, vh);
|
|
41
|
+
};
|
|
21
42
|
if (!visible) {
|
|
22
43
|
return;
|
|
23
44
|
}
|
|
@@ -62,26 +83,6 @@ const Minimap = ({ canvasRef, imageDataUrl, documentWidth, documentHeight, viewp
|
|
|
62
83
|
mapW,
|
|
63
84
|
mapH,
|
|
64
85
|
]);
|
|
65
|
-
function drawViewport(ctx) {
|
|
66
|
-
// Draw viewport rect
|
|
67
|
-
const vx = viewport.x * scale;
|
|
68
|
-
const vy = viewport.y * scale;
|
|
69
|
-
const vw = viewport.width * scale;
|
|
70
|
-
const vh = viewport.height * scale;
|
|
71
|
-
ctx.strokeStyle = resolveCssColor('var(--nice-primary-tint-80, rgba(59, 130, 246, 0.8))', ctx.canvas);
|
|
72
|
-
ctx.lineWidth = 1.5;
|
|
73
|
-
ctx.strokeRect(vx, vy, vw, vh);
|
|
74
|
-
// Dim areas outside viewport
|
|
75
|
-
ctx.fillStyle = resolveCssColor('var(--nice-overlay-30, rgba(0, 0, 0, 0.3))', ctx.canvas);
|
|
76
|
-
// Top
|
|
77
|
-
ctx.fillRect(0, 0, mapW, vy);
|
|
78
|
-
// Bottom
|
|
79
|
-
ctx.fillRect(0, vy + vh, mapW, mapH - vy - vh);
|
|
80
|
-
// Left
|
|
81
|
-
ctx.fillRect(0, vy, vx, vh);
|
|
82
|
-
// Right
|
|
83
|
-
ctx.fillRect(vx + vw, vy, mapW - vx - vw, vh);
|
|
84
|
-
}
|
|
85
86
|
const handlePointerDown = (e) => {
|
|
86
87
|
isDragging.current = true;
|
|
87
88
|
updateViewportFromPointer(e);
|
|
@@ -237,11 +237,11 @@ const NiceFontEditor = ({ fontName = 'MyFont', onSave, className = '', tutorial,
|
|
|
237
237
|
borderRadius: 3,
|
|
238
238
|
cursor: 'pointer',
|
|
239
239
|
fontSize: 11,
|
|
240
|
-
}, children: t('fontEditor.exportSvgFont', 'Export SVG Font') })] }), jsxs("div", { style: { display: 'flex', gap: 4, borderBottom: '1px solid var(--nice-border, #373a40)' }, children: [jsx("button", { onClick: () => setTab('glyph'), style: tabBtnStyle(tab === 'glyph'), children: t('fontEditor.glyphs', 'Glyphs') }), jsx("button", { onClick: () => setTab('metrics'), style: tabBtnStyle(tab === 'metrics'), children: t('fontEditor.metrics', 'Metrics') }), jsx("button", { onClick: () => setTab('kerning'), style: tabBtnStyle(tab === 'kerning'), children: t('fontEditor.kerning', 'Kerning') })] }), tab === 'glyph' && (jsxs("div", { style: { display: 'flex', gap: 8 }, children: [jsxs("div", { style: { flex: 1 }, children: [
|
|
240
|
+
}, children: t('fontEditor.exportSvgFont', 'Export SVG Font') })] }), jsxs("div", { style: { display: 'flex', gap: 4, borderBottom: '1px solid var(--nice-border, #373a40)' }, children: [jsx("button", { onClick: () => setTab('glyph'), style: tabBtnStyle(tab === 'glyph'), children: t('fontEditor.glyphs', 'Glyphs') }), jsx("button", { onClick: () => setTab('metrics'), style: tabBtnStyle(tab === 'metrics'), children: t('fontEditor.metrics', 'Metrics') }), jsx("button", { onClick: () => setTab('kerning'), style: tabBtnStyle(tab === 'kerning'), children: t('fontEditor.kerning', 'Kerning') })] }), tab === 'glyph' && (jsxs("div", { style: { display: 'flex', gap: 8 }, children: [jsxs("div", { style: { flex: 1 }, children: [jsx("div", { style: {
|
|
241
241
|
fontSize: 11,
|
|
242
242
|
marginBottom: 4,
|
|
243
243
|
color: 'var(--nice-text-secondary, #868e96)',
|
|
244
|
-
}, children:
|
|
244
|
+
}, children: t('fontEditor.glyphs2', '{glyphs} glyphs').replace('{glyphs}', String(editor.glyphs.length)) }), jsx("div", { style: {
|
|
245
245
|
display: 'grid',
|
|
246
246
|
gridTemplateColumns: 'repeat(auto-fill, 36px)',
|
|
247
247
|
gap: 2,
|
|
@@ -272,7 +272,7 @@ const NiceFontEditor = ({ fontName = 'MyFont', onSave, className = '', tutorial,
|
|
|
272
272
|
border: g.path
|
|
273
273
|
? '1px solid var(--nice-border, #373a40)'
|
|
274
274
|
: '1px solid transparent',
|
|
275
|
-
}, children: g.char }, g.unicode))) })] }), jsx("div", { style: { width: 320, fontSize: 11 }, children: selectedG ? (jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 6 }, children: [jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' }, children: [jsxs("strong", { children: ["\"", selectedG.char, "\" (U+", selectedG.unicode.toString(16).toUpperCase().padStart(4, '0'), ")"] }), jsxs("div", { style: { display: 'flex', gap: 2 }, children: [jsx("button", { onClick: () => setDrawMode('select'), style: btnStyle(drawMode === 'select'), children: t('fontEditor.select', 'Select') }), jsx("button", { onClick: () => setDrawMode('pen'), style: btnStyle(drawMode === 'pen'), children:
|
|
275
|
+
}, children: g.char }, g.unicode))) })] }), jsx("div", { style: { width: 320, fontSize: 11 }, children: selectedG ? (jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 6 }, children: [jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' }, children: [jsxs("strong", { children: ["\"", selectedG.char, "\" (U+", selectedG.unicode.toString(16).toUpperCase().padStart(4, '0'), ")"] }), jsxs("div", { style: { display: 'flex', gap: 2 }, children: [jsx("button", { onClick: () => setDrawMode('select'), style: btnStyle(drawMode === 'select'), children: t('fontEditor.select', 'Select') }), jsx("button", { onClick: () => setDrawMode('pen'), style: btnStyle(drawMode === 'pen'), children: t('fontEditor.pen', 'Pen') }), jsx("button", { onClick: clearPath, style: btnStyle(false), children: t('fontEditor.clear', 'Clear') }), jsx("button", { onClick: () => setShowGrid((g) => !g), style: btnStyle(showGrid), children: t('fontEditor.grid', 'Grid') })] })] }), jsxs("svg", { width: 280, height: 280, viewBox: `0 0 ${em} ${em}`, style: {
|
|
276
276
|
background: 'var(--nice-bg, #141517)',
|
|
277
277
|
borderRadius: 4,
|
|
278
278
|
cursor: drawMode === 'pen' ? 'crosshair' : 'default',
|
|
@@ -280,7 +280,7 @@ const NiceFontEditor = ({ fontName = 'MyFont', onSave, className = '', tutorial,
|
|
|
280
280
|
Array.from({ length: 11 }, (_, i) => {
|
|
281
281
|
const pos = (i / 10) * em;
|
|
282
282
|
return (jsxs(React.Fragment, { children: [jsx("line", { x1: pos, y1: 0, x2: pos, y2: em, stroke: "var(--nice-overlay-light-5, rgba(255, 255, 255, 0.05))", strokeWidth: em * 0.002 }), jsx("line", { x1: 0, y1: pos, x2: em, y2: pos, stroke: "var(--nice-overlay-light-5, rgba(255, 255, 255, 0.05))", strokeWidth: em * 0.002 })] }, i));
|
|
283
|
-
}), jsx("line", { x1: 0, y1: em - editor.metrics.ascent, x2: em, y2: em - editor.metrics.ascent, stroke: "rgba(51,154,240,0.3)", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.01}` }), jsx("line", { x1: 0, y1: em, x2: em, y2: em, stroke: "rgba(47,158,68,0.3)", strokeWidth: em * 0.003 }), jsx("line", { x1: 0, y1: em - editor.metrics.xHeight, x2: em, y2: em - editor.metrics.xHeight, stroke: "rgba(249,226,175,0.3)", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.01}` }), jsx("line", { x1: 0, y1: em - editor.metrics.capHeight, x2: em, y2: em - editor.metrics.capHeight, stroke: "rgba(243,139,168,0.3)", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.01}` }), jsx("line", { x1: selectedG.leftBearing, y1: 0, x2: selectedG.leftBearing, y2: em, stroke: "rgba(166,227,161,0.2)", strokeWidth: em * 0.002 }), jsx("line", { x1: selectedG.advanceWidth, y1: 0, x2: selectedG.advanceWidth, y2: em, stroke: "rgba(243,139,168,0.2)", strokeWidth: em * 0.002 }), selectedG.path && (jsx("path", { d: selectedG.path, fill: "rgba(205,214,244,0.8)", stroke: "#89b4fa", strokeWidth: em * 0.005 })), pathPoints.map((p, i) => (jsx("circle", { cx: p.x, cy: p.y, r: em * 0.015, fill: i === 0 ? 'var(--nice-success, #2f9e44)' : 'var(--nice-info, #339af0)', stroke: "var(--nice-bg, #fff)", strokeWidth: em * 0.003 }, i))), jsx("text", { x: em * 0.02, y: em - editor.metrics.ascent - em * 0.01, fill: "rgba(51,154,240,0.5)", fontSize: em * 0.03, children:
|
|
283
|
+
}), jsx("line", { x1: 0, y1: em - editor.metrics.ascent, x2: em, y2: em - editor.metrics.ascent, stroke: "rgba(51,154,240,0.3)", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.01}` }), jsx("line", { x1: 0, y1: em, x2: em, y2: em, stroke: "rgba(47,158,68,0.3)", strokeWidth: em * 0.003 }), jsx("line", { x1: 0, y1: em - editor.metrics.xHeight, x2: em, y2: em - editor.metrics.xHeight, stroke: "rgba(249,226,175,0.3)", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.01}` }), jsx("line", { x1: 0, y1: em - editor.metrics.capHeight, x2: em, y2: em - editor.metrics.capHeight, stroke: "rgba(243,139,168,0.3)", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.01}` }), jsx("line", { x1: selectedG.leftBearing, y1: 0, x2: selectedG.leftBearing, y2: em, stroke: "rgba(166,227,161,0.2)", strokeWidth: em * 0.002 }), jsx("line", { x1: selectedG.advanceWidth, y1: 0, x2: selectedG.advanceWidth, y2: em, stroke: "rgba(243,139,168,0.2)", strokeWidth: em * 0.002 }), selectedG.path && (jsx("path", { d: selectedG.path, fill: "rgba(205,214,244,0.8)", stroke: "#89b4fa", strokeWidth: em * 0.005 })), pathPoints.map((p, i) => (jsx("circle", { cx: p.x, cy: p.y, r: em * 0.015, fill: i === 0 ? 'var(--nice-success, #2f9e44)' : 'var(--nice-info, #339af0)', stroke: "var(--nice-bg, #fff)", strokeWidth: em * 0.003 }, i))), jsx("text", { x: em * 0.02, y: em - editor.metrics.ascent - em * 0.01, fill: "rgba(51,154,240,0.5)", fontSize: em * 0.03, children: t('fontEditor.ascent2', 'ascent') }), jsx("text", { x: em * 0.02, y: em - editor.metrics.xHeight - em * 0.01, fill: "rgba(249,226,175,0.5)", fontSize: em * 0.03, children: t('fontEditor.xHeight2', 'x-height') }), jsx("text", { x: em * 0.02, y: em - editor.metrics.capHeight - em * 0.01, fill: "rgba(243,139,168,0.5)", fontSize: em * 0.03, children: t('fontEditor.cap2', 'cap') })] }), jsxs("div", { children: [jsx("label", { children: t('fontEditor.svgPath', 'SVG Path') }), jsx("textarea", { value: selectedG.path, onChange: (e) => editor.updateGlyph(selectedG.unicode, { path: e.target.value }), rows: 3, style: { ...fieldStyle, fontFamily: 'monospace', resize: 'vertical' } })] }), jsxs("div", { style: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 4 }, children: [jsx("label", { children: t('fontEditor.advanceWidth', 'Advance Width') }), jsx("input", { type: "number", value: selectedG.advanceWidth, onChange: (e) => editor.updateGlyph(selectedG.unicode, {
|
|
284
284
|
advanceWidth: Number(e.target.value),
|
|
285
285
|
}), style: fieldStyle }), jsx("label", { children: t('fontEditor.leftBearing', 'Left Bearing') }), jsx("input", { type: "number", value: selectedG.leftBearing, onChange: (e) => editor.updateGlyph(selectedG.unicode, { leftBearing: Number(e.target.value) }), style: fieldStyle })] })] })) : (jsx("div", { style: {
|
|
286
286
|
color: 'var(--nice-text-secondary, #868e96)',
|
|
@@ -293,7 +293,7 @@ const NiceFontEditor = ({ fontName = 'MyFont', onSave, className = '', tutorial,
|
|
|
293
293
|
['lineGap', 'Line Gap'],
|
|
294
294
|
['xHeight', 'x-Height'],
|
|
295
295
|
['capHeight', 'Cap Height'],
|
|
296
|
-
].map(([key, label]) => (jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginBottom: 4 }, children: [jsx("span", { style: { minWidth: 100, fontSize: 11 }, children: label }), jsx("input", { type: "number", value: editor.metrics[key], onChange: (e) => editor.setMetrics({ ...editor.metrics, [key]: Number(e.target.value) }), style: fieldStyle })] }, key))), jsxs("svg", { width: 300, height: 200, viewBox: `0 0 ${em} ${em}`, style: { background: 'var(--nice-bg, #141517)', borderRadius: 4, marginTop: 12 }, children: [jsx("rect", { x: 0, y: em - editor.metrics.ascent, width: em, height: editor.metrics.ascent - editor.metrics.descent, fill: "rgba(51,154,240,0.05)", stroke: "rgba(51,154,240,0.2)", strokeWidth: em * 0.003 }), jsx("line", { x1: 0, y1: em - editor.metrics.ascent, x2: em, y2: em - editor.metrics.ascent, stroke: "var(--nice-info, #339af0)", strokeWidth: em * 0.004 }), jsx("line", { x1: 0, y1: em, x2: em, y2: em, stroke: "var(--nice-success, #2f9e44)", strokeWidth: em * 0.004 }), jsx("line", { x1: 0, y1: em + Math.abs(editor.metrics.descent), x2: em, y2: em + Math.abs(editor.metrics.descent), stroke: "#e03131", strokeWidth: em * 0.004 }), jsx("line", { x1: 0, y1: em - editor.metrics.xHeight, x2: em, y2: em - editor.metrics.xHeight, stroke: "#f9e2af", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.015}` }), jsx("line", { x1: 0, y1: em - editor.metrics.capHeight, x2: em, y2: em - editor.metrics.capHeight, stroke: "#f38ba8", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.015}` }),
|
|
296
|
+
].map(([key, label]) => (jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginBottom: 4 }, children: [jsx("span", { style: { minWidth: 100, fontSize: 11 }, children: label }), jsx("input", { type: "number", value: editor.metrics[key], onChange: (e) => editor.setMetrics({ ...editor.metrics, [key]: Number(e.target.value) }), style: fieldStyle })] }, key))), jsxs("svg", { width: 300, height: 200, viewBox: `0 0 ${em} ${em}`, style: { background: 'var(--nice-bg, #141517)', borderRadius: 4, marginTop: 12 }, children: [jsx("rect", { x: 0, y: em - editor.metrics.ascent, width: em, height: editor.metrics.ascent - editor.metrics.descent, fill: "rgba(51,154,240,0.05)", stroke: "rgba(51,154,240,0.2)", strokeWidth: em * 0.003 }), jsx("line", { x1: 0, y1: em - editor.metrics.ascent, x2: em, y2: em - editor.metrics.ascent, stroke: "var(--nice-info, #339af0)", strokeWidth: em * 0.004 }), jsx("line", { x1: 0, y1: em, x2: em, y2: em, stroke: "var(--nice-success, #2f9e44)", strokeWidth: em * 0.004 }), jsx("line", { x1: 0, y1: em + Math.abs(editor.metrics.descent), x2: em, y2: em + Math.abs(editor.metrics.descent), stroke: "#e03131", strokeWidth: em * 0.004 }), jsx("line", { x1: 0, y1: em - editor.metrics.xHeight, x2: em, y2: em - editor.metrics.xHeight, stroke: "#f9e2af", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.015}` }), jsx("line", { x1: 0, y1: em - editor.metrics.capHeight, x2: em, y2: em - editor.metrics.capHeight, stroke: "#f38ba8", strokeWidth: em * 0.003, strokeDasharray: `${em * 0.015}` }), jsx("text", { x: em * 0.02, y: em - editor.metrics.ascent + em * 0.05, fill: "var(--nice-info, #339af0)", fontSize: em * 0.04, children: t('fontEditor.ascent', 'Ascent ({ascent})').replace('{ascent}', String(editor.metrics.ascent)) }), jsx("text", { x: em * 0.02, y: em + em * 0.05, fill: "var(--nice-success, #2f9e44)", fontSize: em * 0.04, children: t('fontEditor.baseline', 'Baseline') }), jsx("text", { x: em * 0.02, y: em - editor.metrics.xHeight + em * 0.05, fill: "#f9e2af", fontSize: em * 0.04, children: t('fontEditor.xHeight', 'x-Height ({xHeight})').replace('{xHeight}', String(editor.metrics.xHeight)) }), jsx("text", { x: em * 0.02, y: em - editor.metrics.capHeight + em * 0.05, fill: "#f38ba8", fontSize: em * 0.04, children: t('fontEditor.cap', 'Cap ({capHeight})').replace('{capHeight}', String(editor.metrics.capHeight)) })] })] })), tab === 'kerning' && (jsxs("div", { style: { maxWidth: 500 }, children: [jsx("strong", { style: { fontSize: 12, display: 'block', marginBottom: 8 }, children: t('fontEditor.kerningPairs', 'Kerning Pairs') }), jsxs("div", { style: { display: 'flex', gap: 4, marginBottom: 8, alignItems: 'center', fontSize: 11 }, children: [jsx("input", { value: newKernLeft, onChange: (e) => setNewKernLeft(e.target.value), maxLength: 1, style: { ...fieldStyle, width: 30, textAlign: 'center' } }), jsx("input", { value: newKernRight, onChange: (e) => setNewKernRight(e.target.value), maxLength: 1, style: { ...fieldStyle, width: 30, textAlign: 'center' } }), jsx("button", { onClick: () => {
|
|
297
297
|
if (newKernLeft && newKernRight) {
|
|
298
298
|
setKerningPairs((prev) => [
|
|
299
299
|
...prev,
|
|
@@ -12,7 +12,7 @@ import { useGameAssetEditor } from './useGameAssetEditor.js';
|
|
|
12
12
|
const MenuBar = ({ api }) => {
|
|
13
13
|
const { t } = useNiceTranslation();
|
|
14
14
|
const fileInputRef = useRef(null);
|
|
15
|
-
return (jsxs("div", { className: styles.menuBar, children: [jsxs("h3", { children: [jsx(NiceIcon, { name: "gamepad", size: 16 }), ' ', t('gameAsset2dEditor.gameAssetEditor', 'Game Asset Editor')] }), jsxs("div", { className: styles.menuGroup, children: [jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.newProject('New Project'), children: [jsx(NiceIcon, { name: "file", size: 14 }), " New
|
|
15
|
+
return (jsxs("div", { className: styles.menuBar, children: [jsxs("h3", { children: [jsx(NiceIcon, { name: "gamepad", size: 16 }), ' ', t('gameAsset2dEditor.gameAssetEditor', 'Game Asset Editor')] }), jsxs("div", { className: styles.menuGroup, children: [jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.newProject('New Project'), children: [jsx(NiceIcon, { name: "file", size: 14 }), " ", t('gameAsset2dEditor.new', 'New')] }), jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: [jsx(NiceIcon, { name: "folder", size: 14 }), " ", t('gameAsset2dEditor.open', 'Open')] }), jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.saveProject, children: [jsx(NiceIcon, { name: "save", size: 14 }), " ", t('gameAsset2dEditor.save', 'Save')] })] }), jsx("div", { className: styles.spacer }), jsxs("div", { className: styles.menuGroup, children: [jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.undo, disabled: !api.canUndo, children: [jsx(NiceIcon, { name: "arrow-left", size: 14 }), " ", t('gameAsset2dEditor.undo', 'Undo')] }), jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.redo, disabled: !api.canRedo, children: [jsx(NiceIcon, { name: "arrow-right", size: 14 }), " ", t('gameAsset2dEditor.redo', 'Redo')] })] }), jsx("input", { ref: fileInputRef, type: "file", accept: ".json", style: { display: 'none' }, onChange: (e) => {
|
|
16
16
|
var _a;
|
|
17
17
|
const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
18
18
|
if (file) {
|
|
@@ -25,11 +25,12 @@ const MenuBar = ({ api }) => {
|
|
|
25
25
|
MODE TABS
|
|
26
26
|
──────────────────────────────────────────────────────────────── */
|
|
27
27
|
const ModeTabs = ({ api }) => {
|
|
28
|
+
const { t } = useNiceTranslation();
|
|
28
29
|
const modes = [
|
|
29
|
-
{ id: 'tilemap', label: 'Tile Map', icon: 'grid' },
|
|
30
|
-
{ id: 'spritesheet', label: 'Sprite Sheet', icon: 'image' },
|
|
31
|
-
{ id: 'animation', label: 'Animation', icon: 'video' },
|
|
32
|
-
{ id: 'effects', label: 'Effects', icon: 'wand' },
|
|
30
|
+
{ id: 'tilemap', label: t('gameAsset2dEditor.tileMap', 'Tile Map'), icon: 'grid' },
|
|
31
|
+
{ id: 'spritesheet', label: t('gameAsset2dEditor.spriteSheet', 'Sprite Sheet'), icon: 'image' },
|
|
32
|
+
{ id: 'animation', label: t('gameAsset2dEditor.animation', 'Animation'), icon: 'video' },
|
|
33
|
+
{ id: 'effects', label: t('gameAsset2dEditor.effects2', 'Effects'), icon: 'wand' },
|
|
33
34
|
];
|
|
34
35
|
return (jsx("div", { className: styles.modeTabs, children: modes.map((mode) => (jsxs(NiceButton, { className: `${styles.modeTab} ${api.editorState.mode === mode.id ? styles.active : ''}`, variant: api.editorState.mode === mode.id ? 'primary' : 'ghost', onClick: () => api.setMode(mode.id), children: [jsx(NiceIcon, { name: mode.icon, size: 16 }), " ", mode.label] }, mode.id))) }));
|
|
35
36
|
};
|
|
@@ -39,13 +40,17 @@ const ModeTabs = ({ api }) => {
|
|
|
39
40
|
const TileMapToolbar = ({ api }) => {
|
|
40
41
|
const { t } = useNiceTranslation();
|
|
41
42
|
const tools = [
|
|
42
|
-
{ id: 'select', icon: 'square', label: 'Select' },
|
|
43
|
-
{ id: 'brush', icon: 'brush', label: 'Brush' },
|
|
44
|
-
{ id: 'eraser', icon: 'eraser', label: 'Eraser' },
|
|
45
|
-
{ id: 'fill', icon: 'bucket', label: 'Fill' },
|
|
46
|
-
{ id: 'rectangle', icon: 'square', label: 'Rectangle' },
|
|
47
|
-
{ id: 'line', icon: 'line', label: 'Line' },
|
|
48
|
-
{
|
|
43
|
+
{ id: 'select', icon: 'square', label: t('gameAsset2dEditor.select', 'Select') },
|
|
44
|
+
{ id: 'brush', icon: 'brush', label: t('gameAsset2dEditor.brush', 'Brush') },
|
|
45
|
+
{ id: 'eraser', icon: 'eraser', label: t('gameAsset2dEditor.eraser', 'Eraser') },
|
|
46
|
+
{ id: 'fill', icon: 'bucket', label: t('gameAsset2dEditor.fill', 'Fill') },
|
|
47
|
+
{ id: 'rectangle', icon: 'square', label: t('gameAsset2dEditor.rectangle', 'Rectangle') },
|
|
48
|
+
{ id: 'line', icon: 'line', label: t('gameAsset2dEditor.line', 'Line') },
|
|
49
|
+
{
|
|
50
|
+
id: 'eyedropper',
|
|
51
|
+
icon: 'eyedropper',
|
|
52
|
+
label: t('gameAsset2dEditor.eyedropper', 'Eyedropper'),
|
|
53
|
+
},
|
|
49
54
|
];
|
|
50
55
|
return (jsxs("div", { className: styles.toolbar, children: [jsx("div", { className: styles.toolGroup, children: tools.map((tool) => (jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.tileMapTool === tool.id ? styles.active : ''}`, variant: api.editorState.tileMapTool === tool.id ? 'primary' : 'ghost', size: "sm", onClick: () => api.setTileMapTool(tool.id), title: tool.label, children: jsx(NiceIcon, { name: tool.icon, size: 16 }) }, tool.id))) }), jsx("div", { className: styles.spacer }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.showGrid ? styles.active : ''}`, variant: api.editorState.showGrid ? 'primary' : 'ghost', size: "sm", onClick: api.toggleGrid, title: t('gameAsset2dEditor.toggleGrid', 'Toggle Grid'), "aria-label": t('gameAsset2dEditor.toggleGrid', 'Toggle Grid'), children: jsx(NiceIcon, { name: "grid", size: 16 }) }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.showCollision ? styles.active : ''}`, variant: api.editorState.showCollision ? 'primary' : 'ghost', size: "sm", onClick: api.toggleCollision, title: t('gameAsset2dEditor.showCollision', 'Show Collision'), "aria-label": t('gameAsset2dEditor.showCollision', 'Show Collision'), children: jsx(NiceIcon, { name: "square", size: 16 }) }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.snapToGrid ? styles.active : ''}`, variant: api.editorState.snapToGrid ? 'primary' : 'ghost', size: "sm", onClick: api.toggleSnap, title: t('gameAsset2dEditor.snapToGrid', 'Snap to Grid'), "aria-label": t('gameAsset2dEditor.snapToGrid', 'Snap to Grid'), children: jsx(NiceIcon, { name: "grid", size: 16 }) })] }));
|
|
51
56
|
};
|
|
@@ -56,7 +61,7 @@ const SpriteSheetToolbar = ({ api }) => {
|
|
|
56
61
|
const { t } = useNiceTranslation();
|
|
57
62
|
const [sliceWidth, setSliceWidth] = useState(16);
|
|
58
63
|
const [sliceHeight, setSliceHeight] = useState(16);
|
|
59
|
-
return (jsxs("div", { className: styles.toolbar, children: [jsxs("div", { className: styles.toolGroup, children: [jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.spriteSheetTool === 'select' ? styles.active : ''}`, variant: api.editorState.spriteSheetTool === 'select' ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSpriteSheetTool('select'), title: t('gameAsset2dEditor.select', 'Select'), "aria-label": t('gameAsset2dEditor.select', 'Select'), children: jsx(NiceIcon, { name: "square", size: 16 }) }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.spriteSheetTool === 'slice' ? styles.active : ''}`, variant: api.editorState.spriteSheetTool === 'slice' ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSpriteSheetTool('slice'), title: t('gameAsset2dEditor.manualSlice', 'Manual Slice'), "aria-label": t('gameAsset2dEditor.manualSlice', 'Manual Slice'), children: jsx(NiceIcon, { name: "scissors", size: 16 }) })] }), jsx("div", { className: styles.spacer }), jsxs("label", { style: { fontSize: 11, color: 'var(--nice-text-secondary, #8892a8)' }, children: [
|
|
64
|
+
return (jsxs("div", { className: styles.toolbar, children: [jsxs("div", { className: styles.toolGroup, children: [jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.spriteSheetTool === 'select' ? styles.active : ''}`, variant: api.editorState.spriteSheetTool === 'select' ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSpriteSheetTool('select'), title: t('gameAsset2dEditor.select', 'Select'), "aria-label": t('gameAsset2dEditor.select', 'Select'), children: jsx(NiceIcon, { name: "square", size: 16 }) }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.spriteSheetTool === 'slice' ? styles.active : ''}`, variant: api.editorState.spriteSheetTool === 'slice' ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSpriteSheetTool('slice'), title: t('gameAsset2dEditor.manualSlice', 'Manual Slice'), "aria-label": t('gameAsset2dEditor.manualSlice', 'Manual Slice'), children: jsx(NiceIcon, { name: "scissors", size: 16 }) })] }), jsx("div", { className: styles.spacer }), jsxs("label", { style: { fontSize: 11, color: 'var(--nice-text-secondary, #8892a8)' }, children: [t('gameAsset2dEditor.frameSize', 'Frame size:'), jsx(NiceNumberInput, { value: sliceWidth, onChange: (val) => setSliceWidth(val !== null && val !== void 0 ? val : 16), style: { width: 40, margin: '0 4px' }, className: styles.panelInput }), "\u00D7", jsx(NiceNumberInput, { value: sliceHeight, onChange: (val) => setSliceHeight(val !== null && val !== void 0 ? val : 16), style: { width: 40, marginLeft: 4 }, className: styles.panelInput })] }), jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: () => api.autoSlice(sliceWidth, sliceHeight), style: { marginLeft: 8 }, children: t('gameAsset2dEditor.autoSlice', 'Auto Slice') }), jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: api.detectSprites, style: { marginLeft: 4 }, children: t('gameAsset2dEditor.detectSprites', 'Detect Sprites') })] }));
|
|
60
65
|
};
|
|
61
66
|
/* ────────────────────────────────────────────────────────────────
|
|
62
67
|
TILE PALETTE (LEFT PANEL)
|
|
@@ -64,7 +69,7 @@ const SpriteSheetToolbar = ({ api }) => {
|
|
|
64
69
|
const TilePalette = ({ api }) => {
|
|
65
70
|
const { t } = useNiceTranslation();
|
|
66
71
|
const fileInputRef = useRef(null);
|
|
67
|
-
return (jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.tiles', 'Tiles') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children:
|
|
72
|
+
return (jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.tiles', 'Tiles') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: t('gameAsset2dEditor.add', '+ Add') })] }), jsx("div", { className: styles.panelContent, children: api.project.tileSets.length === 0 ? (jsxs("div", { className: styles.emptyState, children: [jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.noTilesYet', 'No tiles yet') }), jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: t('gameAsset2dEditor.importTiles', 'Import Tiles') })] })) : (jsx("div", { className: styles.tilePalette, children: api.project.tileSets.map((tile) => (jsx("div", { className: `${styles.tileItem} ${api.editorState.selectedTileId === tile.id ? styles.selected : ''}`, onClick: () => api.selectTile(tile.id), title: tile.name, children: jsx("img", { src: tile.thumbnail, alt: tile.name }) }, tile.id))) })) }), jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", style: { display: 'none' }, onChange: (e) => {
|
|
68
73
|
var _a;
|
|
69
74
|
const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
70
75
|
if (file) {
|
|
@@ -79,10 +84,12 @@ const TilePalette = ({ api }) => {
|
|
|
79
84
|
const LayersPanel = ({ api }) => {
|
|
80
85
|
const { t } = useNiceTranslation();
|
|
81
86
|
const activeMap = api.project.tileMaps.find((m) => m.id === api.editorState.activeTileMapId);
|
|
82
|
-
return (jsxs("div", { className: styles.rightPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.layers', 'Layers') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.addLayer, disabled: !activeMap, children:
|
|
87
|
+
return (jsxs("div", { className: styles.rightPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.layers', 'Layers') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.addLayer, disabled: !activeMap, children: t('gameAsset2dEditor.add', '+ Add') })] }), jsx("div", { className: styles.panelContent, children: activeMap ? (jsx("div", { className: styles.layersList, children: [...activeMap.layers].reverse().map((layer) => (jsxs("div", { className: `${styles.layerItem} ${api.editorState.activeLayerId === layer.id ? styles.selected : ''}`, onClick: () => api.selectLayer(layer.id), children: [jsx(NiceButton, { className: `${styles.layerVisibility} ${!layer.visible ? styles.hidden : ''}`, variant: "ghost", size: "sm", onClick: (e) => {
|
|
83
88
|
e.stopPropagation();
|
|
84
89
|
api.toggleLayerVisibility(layer.id);
|
|
85
|
-
}, "aria-label": layer.visible
|
|
90
|
+
}, "aria-label": layer.visible
|
|
91
|
+
? t('gameAsset2dEditor.hideLayer', 'Hide layer')
|
|
92
|
+
: t('gameAsset2dEditor.showLayer', 'Show layer'), children: jsx(NiceIcon, { name: layer.visible ? 'eye' : 'eye-off', size: 16 }) }), jsx("span", { className: styles.layerName, children: layer.name }), jsxs("span", { className: styles.layerOpacity, children: [Math.round(layer.opacity * 100), "%"] })] }, layer.id))) })) : (jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.noTileMapSelected', 'No tile map selected') }) })) }), jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.maps', 'Maps') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.createTileMap('New Map', 32, 32), children: t('gameAsset2dEditor.new2', '+ New') })] }), jsx("div", { className: styles.panelContent, children: api.project.tileMaps.map((map) => (jsxs("div", { className: `${styles.layerItem} ${api.editorState.activeTileMapId === map.id ? styles.selected : ''}`, onClick: () => api.selectTileMap(map.id), children: [jsx("span", { className: styles.layerName, children: map.name }), jsxs("span", { className: styles.layerOpacity, children: [map.width, "\u00D7", map.height] })] }, map.id))) })] }));
|
|
86
93
|
};
|
|
87
94
|
/* ────────────────────────────────────────────────────────────────
|
|
88
95
|
TILE MAP CANVAS
|
|
@@ -264,7 +271,7 @@ const SpriteSheetCanvas = ({ api }) => {
|
|
|
264
271
|
const SpriteSheetsList = ({ api }) => {
|
|
265
272
|
const { t } = useNiceTranslation();
|
|
266
273
|
const fileInputRef = useRef(null);
|
|
267
|
-
return (jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.spriteSheets', 'Sprite Sheets') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children:
|
|
274
|
+
return (jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.spriteSheets', 'Sprite Sheets') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: t('gameAsset2dEditor.import', '+ Import') })] }), jsx("div", { className: styles.panelContent, children: api.project.spriteSheets.length === 0 ? (jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.noSpriteSheets', 'No sprite sheets') }) })) : (jsx("div", { className: styles.layersList, children: api.project.spriteSheets.map((sheet) => (jsxs("div", { className: `${styles.layerItem} ${api.editorState.activeSpriteSheetId === sheet.id ? styles.selected : ''}`, onClick: () => api.selectSpriteSheet(sheet.id), children: [jsx("span", { className: styles.layerName, children: sheet.name }), jsx("span", { className: styles.layerOpacity, children: t('gameAsset2dEditor.frames', '{frames} frames').replace('{frames}', String(sheet.frames.length)) })] }, sheet.id))) })) }), jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", style: { display: 'none' }, onChange: (e) => {
|
|
268
275
|
var _a;
|
|
269
276
|
const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
270
277
|
if (file) {
|
|
@@ -287,7 +294,7 @@ const FramesPanel = ({ api }) => {
|
|
|
287
294
|
setAnimName('');
|
|
288
295
|
}
|
|
289
296
|
}, [animName, api]);
|
|
290
|
-
return (jsxs("div", { className: styles.rightPanel, children: [jsx("div", { className: styles.panelHeader, children:
|
|
297
|
+
return (jsxs("div", { className: styles.rightPanel, children: [jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.frames2', 'Frames ({frames})').replace('{frames}', String((_a = activeSheet === null || activeSheet === void 0 ? void 0 : activeSheet.frames.length) !== null && _a !== void 0 ? _a : 0)) }) }), jsx("div", { className: styles.panelContent, style: { maxHeight: 200 }, children: activeSheet === null || activeSheet === void 0 ? void 0 : activeSheet.frames.map((frame) => (jsxs("div", { className: `${styles.layerItem} ${api.editorState.selectedFrameIds.includes(frame.id) ? styles.selected : ''}`, onClick: () => api.selectFrames([frame.id]), children: [jsx("span", { className: styles.layerName, children: frame.name }), jsxs("span", { className: styles.layerOpacity, children: [frame.width, "\u00D7", frame.height] })] }, frame.id))) }), jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.animations', 'Animations') }) }), jsxs("div", { className: styles.panelContent, children: [api.editorState.selectedFrameIds.length > 0 && (jsxs("div", { className: styles.panelSection, children: [jsx(NiceTextInput, { className: styles.panelInput, placeholder: t('gameAsset2dEditor.animationName', 'Animation name...'), value: animName, onChange: (val) => setAnimName(val) }), jsx(NiceButton, { className: styles.btnPrimary, variant: "primary", onClick: createAnimationFromSelection, style: { marginTop: 8, width: '100%' }, disabled: !animName, children: t('gameAsset2dEditor.createFromFrames', 'Create from {count} frames').replace('{count}', String(api.editorState.selectedFrameIds.length)) })] })), activeSheet === null || activeSheet === void 0 ? void 0 : activeSheet.animations.map((anim) => (jsxs("div", { className: styles.layerItem, children: [jsx("span", { className: styles.layerName, children: anim.name }), jsxs("span", { className: styles.layerOpacity, children: [anim.frameIds.length, "f"] }), jsx(NiceButton, { className: styles.effectRemove, variant: "ghost", size: "sm", onClick: () => api.removeAnimation(anim.id), "aria-label": t('gameAsset2dEditor.removeAnimation', 'Remove animation'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, anim.id)))] })] }));
|
|
291
298
|
};
|
|
292
299
|
/* ────────────────────────────────────────────────────────────────
|
|
293
300
|
ANIMATION STATE MACHINE
|
|
@@ -307,13 +314,16 @@ const AnimationStateMachineView = ({ api }) => {
|
|
|
307
314
|
}
|
|
308
315
|
return result;
|
|
309
316
|
}, [api.project.spriteSheets]);
|
|
310
|
-
return (jsxs("div", { style: { display: 'flex', flex: 1, overflow: 'hidden' }, children: [jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.stateMachines', 'State Machines') }), jsx("button", { className: styles.menuBtn, onClick: () => api.createStateMachine('New State Machine'), children:
|
|
317
|
+
return (jsxs("div", { style: { display: 'flex', flex: 1, overflow: 'hidden' }, children: [jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.stateMachines', 'State Machines') }), jsx("button", { className: styles.menuBtn, onClick: () => api.createStateMachine('New State Machine'), children: t('gameAsset2dEditor.new2', '+ New') })] }), jsx("div", { className: styles.panelContent, style: { maxHeight: 150 }, children: api.project.stateMachines.map((sm) => (jsxs("div", { className: `${styles.layerItem} ${api.editorState.activeStateMachineId === sm.id ? styles.selected : ''}`, onClick: () => api.selectStateMachine(sm.id), children: [jsx("span", { className: styles.layerName, children: sm.name }), jsx("span", { className: styles.layerOpacity, children: t('gameAsset2dEditor.states2', '{states} states').replace('{states}', String(sm.states.length)) })] }, sm.id))) }), activeSM && (jsxs(Fragment, { children: [jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.states', 'States') }) }), jsxs("div", { className: styles.panelContent, children: [jsxs("div", { className: styles.panelSection, children: [jsx(NiceTextInput, { className: styles.panelInput, placeholder: t('gameAsset2dEditor.stateName', 'State name...'), value: newStateName, onChange: (val) => setNewStateName(val) }), allAnimations.length > 0 && newStateName && (jsx(NiceSelect, { className: styles.panelInput, style: { marginTop: 4 }, onChange: (val) => {
|
|
311
318
|
if (val) {
|
|
312
319
|
api.addState(newStateName, val);
|
|
313
320
|
setNewStateName('');
|
|
314
321
|
}
|
|
315
322
|
}, options: [
|
|
316
|
-
{
|
|
323
|
+
{
|
|
324
|
+
value: '',
|
|
325
|
+
label: t('gameAsset2dEditor.selectAnimation', 'Select animation...'),
|
|
326
|
+
},
|
|
317
327
|
...allAnimations.map((anim) => ({
|
|
318
328
|
value: anim.id,
|
|
319
329
|
label: `${anim.sheetName}: ${anim.name}`,
|
|
@@ -330,18 +340,21 @@ const AnimationStateMachineView = ({ api }) => {
|
|
|
330
340
|
return (jsx("line", { x1: from.position.x + 60, y1: from.position.y + 20, x2: to.position.x + 60, y2: to.position.y + 20, className: styles.transition, onClick: () => api.removeTransition(trans.id) }, trans.id));
|
|
331
341
|
}), activeSM.states.map((state) => {
|
|
332
342
|
var _a, _b;
|
|
333
|
-
return (jsx("foreignObject", { x: state.position.x, y: state.position.y, width: 120, height: 50, children: jsxs("div", { className: `${styles.stateNode} ${api.editorState.selectedStateId === state.id ? styles.selected : ''} ${activeSM.entryStateId === state.id ? styles.entry : ''}`, onClick: () => api.selectState(state.id), children: [jsx("div", { className: styles.stateNodeName, children: state.name }), jsx("div", { className: styles.stateNodeAnim, children: (_b = (_a = allAnimations.find((a) => a.id === state.animationId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'No animation' })] }) }, state.id));
|
|
334
|
-
})] })) : (jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.createAStateMachineTo', 'Create a state machine to design animation flows') }) })) }), jsxs("div", { className: styles.rightPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.parameters', 'Parameters') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.addParameter('new_param', 'trigger'), disabled: !activeSM, children:
|
|
343
|
+
return (jsx("foreignObject", { x: state.position.x, y: state.position.y, width: 120, height: 50, children: jsxs("div", { className: `${styles.stateNode} ${api.editorState.selectedStateId === state.id ? styles.selected : ''} ${activeSM.entryStateId === state.id ? styles.entry : ''}`, onClick: () => api.selectState(state.id), children: [jsx("div", { className: styles.stateNodeName, children: state.name }), jsx("div", { className: styles.stateNodeAnim, children: (_b = (_a = allAnimations.find((a) => a.id === state.animationId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : t('gameAsset2dEditor.noAnimation', 'No animation') })] }) }, state.id));
|
|
344
|
+
})] })) : (jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.createAStateMachineTo', 'Create a state machine to design animation flows') }) })) }), jsxs("div", { className: styles.rightPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.parameters', 'Parameters') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.addParameter('new_param', 'trigger'), disabled: !activeSM, children: t('gameAsset2dEditor.add', '+ Add') })] }), jsx("div", { className: styles.panelContent, children: activeSM === null || activeSM === void 0 ? void 0 : activeSM.parameters.map((param) => (jsxs("div", { className: styles.layerItem, children: [jsx("span", { className: styles.layerOpacity, children: param.type }), jsx("span", { className: styles.layerName, children: param.name }), jsx(NiceButton, { className: styles.effectRemove, variant: "ghost", size: "sm", onClick: () => api.removeParameter(param.id), "aria-label": t('gameAsset2dEditor.removeParameter', 'Remove parameter'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, param.id))) }), jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.transitions', 'Transitions') }) }), jsxs("div", { className: styles.panelContent, children: [activeSM === null || activeSM === void 0 ? void 0 : activeSM.transitions.map((trans) => {
|
|
335
345
|
var _a, _b;
|
|
336
346
|
const from = activeSM.states.find((s) => s.id === trans.fromStateId);
|
|
337
347
|
const to = activeSM.states.find((s) => s.id === trans.toStateId);
|
|
338
348
|
return (jsxs("div", { className: styles.layerItem, children: [jsxs("span", { className: styles.layerName, children: [(_a = from === null || from === void 0 ? void 0 : from.name) !== null && _a !== void 0 ? _a : '?', " ", jsx(NiceIcon, { name: "arrow-right", size: 12 }), " ", (_b = to === null || to === void 0 ? void 0 : to.name) !== null && _b !== void 0 ? _b : '?'] }), jsx(NiceButton, { className: styles.effectRemove, variant: "ghost", size: "sm", onClick: () => api.removeTransition(trans.id), "aria-label": t('gameAsset2dEditor.removeTransition', 'Remove transition'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, trans.id));
|
|
339
|
-
}), api.editorState.selectedStateId && (jsxs("div", { className: styles.panelSection, style: { marginTop: 12 }, children: [jsx("label", { className: styles.panelLabel, children:
|
|
349
|
+
}), api.editorState.selectedStateId && (jsxs("div", { className: styles.panelSection, style: { marginTop: 12 }, children: [jsx("label", { className: styles.panelLabel, children: t('gameAsset2dEditor.addTransitionTo', 'Add transition to:') }), jsx(NiceSelect, { className: styles.panelInput, onChange: (val) => {
|
|
340
350
|
if (val && api.editorState.selectedStateId) {
|
|
341
351
|
api.addTransition(api.editorState.selectedStateId, val);
|
|
342
352
|
}
|
|
343
353
|
}, options: [
|
|
344
|
-
{
|
|
354
|
+
{
|
|
355
|
+
value: '',
|
|
356
|
+
label: t('gameAsset2dEditor.selectTargetState', 'Select target state...'),
|
|
357
|
+
},
|
|
345
358
|
...((_a = activeSM === null || activeSM === void 0 ? void 0 : activeSM.states.filter((s) => s.id !== api.editorState.selectedStateId).map((s) => ({ value: s.id, label: s.name }))) !== null && _a !== void 0 ? _a : []),
|
|
346
359
|
] })] }))] })] })] }));
|
|
347
360
|
};
|
|
@@ -353,33 +366,39 @@ const EffectsView = ({ api }) => {
|
|
|
353
366
|
const [_currentEffects, _setCurrentEffects] = useState([]);
|
|
354
367
|
const [presetName, setPresetName] = useState('');
|
|
355
368
|
const effectTypes = [
|
|
356
|
-
{ type: 'brightness', label: 'Brightness' },
|
|
357
|
-
{ type: 'contrast', label: 'Contrast' },
|
|
358
|
-
{ type: 'saturation', label: 'Saturation' },
|
|
359
|
-
{ type: 'hue-shift', label: 'Hue Shift' },
|
|
360
|
-
{ type: 'invert', label: 'Invert' },
|
|
361
|
-
{ type: 'pixelate', label: 'Pixelate' },
|
|
362
|
-
{ type: 'outline', label: 'Outline' },
|
|
363
|
-
{ type: 'tint', label: 'Tint' },
|
|
364
|
-
{ type: 'blur', label: 'Blur' },
|
|
365
|
-
{ type: 'glow', label: 'Glow' },
|
|
366
|
-
{ type: 'shadow', label: 'Shadow' },
|
|
367
|
-
{ type: 'palette-swap', label: 'Palette Swap' },
|
|
369
|
+
{ type: 'brightness', label: t('gameAsset2dEditor.brightness', 'Brightness') },
|
|
370
|
+
{ type: 'contrast', label: t('gameAsset2dEditor.contrast', 'Contrast') },
|
|
371
|
+
{ type: 'saturation', label: t('gameAsset2dEditor.saturation', 'Saturation') },
|
|
372
|
+
{ type: 'hue-shift', label: t('gameAsset2dEditor.hueShift', 'Hue Shift') },
|
|
373
|
+
{ type: 'invert', label: t('gameAsset2dEditor.invert', 'Invert') },
|
|
374
|
+
{ type: 'pixelate', label: t('gameAsset2dEditor.pixelate', 'Pixelate') },
|
|
375
|
+
{ type: 'outline', label: t('gameAsset2dEditor.outline', 'Outline') },
|
|
376
|
+
{ type: 'tint', label: t('gameAsset2dEditor.tint', 'Tint') },
|
|
377
|
+
{ type: 'blur', label: t('gameAsset2dEditor.blur', 'Blur') },
|
|
378
|
+
{ type: 'glow', label: t('gameAsset2dEditor.glow', 'Glow') },
|
|
379
|
+
{ type: 'shadow', label: t('gameAsset2dEditor.shadow', 'Shadow') },
|
|
380
|
+
{ type: 'palette-swap', label: t('gameAsset2dEditor.paletteSwap', 'Palette Swap') },
|
|
368
381
|
];
|
|
369
382
|
return (jsxs("div", { style: { display: 'flex', flex: 1, overflow: 'hidden' }, children: [jsxs("div", { className: styles.leftPanel, children: [jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.addEffect', 'Add Effect') }) }), jsx("div", { className: styles.panelContent, children: effectTypes.map(({ type, label }) => (jsx(NiceButton, { className: styles.layerItem, variant: "ghost", onClick: () => api.addEffect(type), style: { cursor: 'pointer', border: 'none', textAlign: 'left' }, children: jsx("span", { className: styles.layerName, children: label }) }, type))) }), jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.presets', 'Presets') }) }), jsxs("div", { className: styles.panelContent, children: [jsxs("div", { className: styles.panelSection, children: [jsx(NiceTextInput, { className: styles.panelInput, placeholder: t('gameAsset2dEditor.presetName', 'Preset name...'), value: presetName, onChange: (val) => setPresetName(val) }), jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", style: { marginTop: 4, width: '100%' }, onClick: () => {
|
|
370
383
|
if (presetName) {
|
|
371
384
|
api.saveEffectPreset(presetName);
|
|
372
385
|
setPresetName('');
|
|
373
386
|
}
|
|
374
|
-
}, disabled: !presetName, children: t('gameAsset2dEditor.saveCurrentEffects', 'Save Current Effects') })] }), api.project.effectPresets.map((preset) => (jsxs("div", { className: styles.layerItem, onClick: () => api.loadEffectPreset(preset.id), style: { cursor: 'pointer' }, children: [jsx("span", { className: styles.layerName, children: preset.name }),
|
|
387
|
+
}, disabled: !presetName, children: t('gameAsset2dEditor.saveCurrentEffects', 'Save Current Effects') })] }), api.project.effectPresets.map((preset) => (jsxs("div", { className: styles.layerItem, onClick: () => api.loadEffectPreset(preset.id), style: { cursor: 'pointer' }, children: [jsx("span", { className: styles.layerName, children: preset.name }), jsx("span", { className: styles.layerOpacity, children: t('gameAsset2dEditor.effects', '{effects} effects').replace('{effects}', String(preset.effects.length)) })] }, preset.id)))] })] }), jsx("div", { className: styles.viewport, children: jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.selectASpriteOrTile', 'Select a sprite or tile to preview effects') }) }) }), jsxs("div", { className: styles.rightPanel, children: [jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.activeEffects', 'Active Effects') }) }), jsx("div", { className: styles.panelContent, children: jsx("div", { className: styles.effectsList, children: jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.addEffectsFromTheLeft', 'Add effects from the left panel') }) }) }) })] })] }));
|
|
375
388
|
};
|
|
376
389
|
/* ────────────────────────────────────────────────────────────────
|
|
377
390
|
STATUS BAR
|
|
378
391
|
──────────────────────────────────────────────────────────────── */
|
|
379
392
|
const StatusBar = ({ api }) => {
|
|
393
|
+
const { t } = useNiceTranslation();
|
|
380
394
|
const activeMap = api.project.tileMaps.find((m) => m.id === api.editorState.activeTileMapId);
|
|
381
395
|
const activeSheet = api.project.spriteSheets.find((s) => s.id === api.editorState.activeSpriteSheetId);
|
|
382
|
-
return (jsxs("div", { className: styles.statusBar, children: [
|
|
396
|
+
return (jsxs("div", { className: styles.statusBar, children: [jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.mode', 'Mode: {mode}').replace('{mode}', String(api.editorState.mode)) }), api.editorState.mode === 'tilemap' && activeMap && (jsxs(Fragment, { children: [jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.map', 'Map: {name} ({width}×{height})')
|
|
397
|
+
.replace('{name}', String(activeMap.name))
|
|
398
|
+
.replace('{width}', String(activeMap.width))
|
|
399
|
+
.replace('{height}', String(activeMap.height)) }), jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.tilePx', 'Tile: {tileWidth}×{tileHeight}px')
|
|
400
|
+
.replace('{tileWidth}', String(activeMap.tileWidth))
|
|
401
|
+
.replace('{tileHeight}', String(activeMap.tileHeight)) })] })), api.editorState.mode === 'spritesheet' && activeSheet && (jsxs(Fragment, { children: [jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.sheet', 'Sheet: {name}').replace('{name}', String(activeSheet.name)) }), jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.selectedFrames', 'Selected: {selectedFrameIds} frames').replace('{selectedFrameIds}', String(api.editorState.selectedFrameIds.length)) })] })), jsxs("div", { className: styles.zoomControl, children: [jsx(NiceButton, { className: styles.zoomBtn, variant: "ghost", size: "sm", onClick: () => api.setZoom(api.editorState.zoom - 0.25), children: "\u2212" }), jsxs("span", { children: [Math.round(api.editorState.zoom * 100), "%"] }), jsx(NiceButton, { className: styles.zoomBtn, variant: "ghost", size: "sm", onClick: () => api.setZoom(api.editorState.zoom + 0.25), children: "+" }), jsx(NiceButton, { className: styles.zoomBtn, variant: "ghost", size: "sm", onClick: () => api.setZoom(1), children: "\u2299" })] })] }));
|
|
383
402
|
};
|
|
384
403
|
/* ────────────────────────────────────────────────────────────────
|
|
385
404
|
MAIN COMPONENT
|
|
@@ -481,10 +481,10 @@ const NiceAITools = ({ sourceImage, onResult, className = '', }) => {
|
|
|
481
481
|
alignItems: 'center',
|
|
482
482
|
justifyContent: 'center',
|
|
483
483
|
gap: 4,
|
|
484
|
-
}, children: [jsx(NiceIcon, { name: TOOL_ICONS[key], size: 14 }), " ", label] }, key))) }), ai.activeTool === 'colorize' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [
|
|
484
|
+
}, children: [jsx(NiceIcon, { name: TOOL_ICONS[key], size: 14 }), " ", label] }, key))) }), ai.activeTool === 'colorize' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('aiTools.intensity', 'Intensity: {intensity}').replace('{intensity}', String(ai.colorizeOptions.intensity.toFixed(2))), jsx("input", { type: "range", min: 0, max: 1, step: 0.05, value: ai.colorizeOptions.intensity, onChange: (e) => ai.setColorizeOptions({ ...ai.colorizeOptions, intensity: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.saturation', 'Saturation: {saturation}').replace('{saturation}', String(ai.colorizeOptions.saturation.toFixed(1))), jsx("input", { type: "range", min: 0, max: 2, step: 0.1, value: ai.colorizeOptions.saturation, onChange: (e) => ai.setColorizeOptions({ ...ai.colorizeOptions, saturation: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.temperature', 'Temperature:'), jsxs("select", { value: ai.colorizeOptions.temperature, onChange: (e) => ai.setColorizeOptions({
|
|
485
485
|
...ai.colorizeOptions,
|
|
486
486
|
temperature: e.target.value,
|
|
487
|
-
}), style: { width: '100%' }, children: [jsx("option", { value: "warm", children: t('aiTools.warm', 'Warm') }), jsx("option", { value: "neutral", children: t('aiTools.neutral', 'Neutral') }), jsx("option", { value: "cool", children: t('aiTools.cool', 'Cool') })] })] })] })), ai.activeTool === 'background-remove' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [
|
|
487
|
+
}), style: { width: '100%' }, children: [jsx("option", { value: "warm", children: t('aiTools.warm', 'Warm') }), jsx("option", { value: "neutral", children: t('aiTools.neutral', 'Neutral') }), jsx("option", { value: "cool", children: t('aiTools.cool', 'Cool') })] })] })] })), ai.activeTool === 'background-remove' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('aiTools.threshold', 'Threshold: {threshold}').replace('{threshold}', String(ai.bgRemoveOptions.threshold.toFixed(2))), jsx("input", { type: "range", min: 0.1, max: 0.9, step: 0.05, value: ai.bgRemoveOptions.threshold, onChange: (e) => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, threshold: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.iterations', 'Iterations: {iterations}').replace('{iterations}', String(ai.bgRemoveOptions.iterations)), jsx("input", { type: "range", min: 1, max: 20, step: 1, value: ai.bgRemoveOptions.iterations, onChange: (e) => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, iterations: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.featherPx', 'Feather: {featherRadius}px').replace('{featherRadius}', String(ai.bgRemoveOptions.featherRadius)), jsx("input", { type: "range", min: 0, max: 10, step: 1, value: ai.bgRemoveOptions.featherRadius, onChange: (e) => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, featherRadius: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { style: { display: 'flex', gap: 4, alignItems: 'center' }, children: [t('aiTools.replaceBg', 'Replace BG:'), jsx("input", { type: "color", value: (_a = ai.bgRemoveOptions.replacementColor) !== null && _a !== void 0 ? _a : '#ffffff', onChange: (e) => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, replacementColor: e.target.value }) }), jsx("button", { type: "button", onClick: () => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, replacementColor: null }), style: { fontSize: 10 }, children: t('aiTools.transparent', 'Transparent') })] })] })), ai.activeTool === 'upscale' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('aiTools.scale', 'Scale:'), jsxs("select", { value: ai.upscaleOptions.scale, onChange: (e) => ai.setUpscaleOptions({ ...ai.upscaleOptions, scale: +e.target.value }), style: { width: '100%' }, children: [jsx("option", { value: 2, children: "2x" }), jsx("option", { value: 3, children: "3x" }), jsx("option", { value: 4, children: "4x" })] })] }), jsxs("label", { children: [t('aiTools.sharpen', 'Sharpen: {sharpen}').replace('{sharpen}', String(ai.upscaleOptions.sharpen.toFixed(2))), jsx("input", { type: "range", min: 0, max: 1, step: 0.05, value: ai.upscaleOptions.sharpen, onChange: (e) => ai.setUpscaleOptions({ ...ai.upscaleOptions, sharpen: +e.target.value }), style: { width: '100%' } })] })] })), ai.activeTool === 'denoise' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('aiTools.strength', 'Strength: {strength}').replace('{strength}', String(ai.denoiseOptions.strength.toFixed(2))), jsx("input", { type: "range", min: 0, max: 1, step: 0.05, value: ai.denoiseOptions.strength, onChange: (e) => ai.setDenoiseOptions({ ...ai.denoiseOptions, strength: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.detail', 'Detail: {detailPreservation}').replace('{detailPreservation}', String(ai.denoiseOptions.detailPreservation.toFixed(2))), jsx("input", { type: "range", min: 0, max: 1, step: 0.05, value: ai.denoiseOptions.detailPreservation, onChange: (e) => ai.setDenoiseOptions({ ...ai.denoiseOptions, detailPreservation: +e.target.value }), style: { width: '100%' } })] })] })), jsx("button", { type: "button", onClick: handleProcess, disabled: ai.isProcessing || !sourceImage, style: {
|
|
488
488
|
background: ai.isProcessing
|
|
489
489
|
? 'var(--nice-bg-tertiary, #94a3b8)'
|
|
490
490
|
: 'var(--nice-color-accent, #6366f1)',
|
|
@@ -497,7 +497,7 @@ const NiceAITools = ({ sourceImage, onResult, className = '', }) => {
|
|
|
497
497
|
alignItems: 'center',
|
|
498
498
|
justifyContent: 'center',
|
|
499
499
|
gap: 4,
|
|
500
|
-
}, children: ai.isProcessing ? (jsxs(Fragment, { children: [jsx(NiceIcon, { name: "refresh", size: 14 }), " Processing
|
|
500
|
+
}, children: ai.isProcessing ? (jsxs(Fragment, { children: [jsx(NiceIcon, { name: "refresh", size: 14 }), " ", t('aiTools.processing', 'Processing…')] })) : (jsxs(Fragment, { children: [jsx(NiceIcon, { name: "play", size: 14 }), " ", TOOL_LABELS[ai.activeTool]] })) }), ai.lastResult && (jsxs("div", { style: { fontSize: 11, color: 'var(--nice-text-muted, #64748b)' }, children: [t('aiTools.processedInMs', 'Processed in {ms}ms').replace('{ms}', ai.lastResult.processingTimeMs.toFixed(0)), ai.activeTool === 'upscale' &&
|
|
501
501
|
` → ${ai.lastResult.imageData.width}×${ai.lastResult.imageData.height}`] }))] }));
|
|
502
502
|
};
|
|
503
503
|
|