Preload media assets and refine process cursors
This commit is contained in:
@@ -362,8 +362,9 @@ class UIInputHandlerModule extends BaseModule {
|
||||
return '';
|
||||
}
|
||||
|
||||
const fallback = state === 'command-waiting' ? 'wait' : 'progress';
|
||||
return this.buildMouseCursor(state, fallback, 12, 12, this.cursorAnimationFrame);
|
||||
const fallback = state === 'command-waiting' || state === 'waiting-generating' ? 'progress' : 'default';
|
||||
const usesArrowBase = state === 'command-waiting' || state === 'waiting-generating';
|
||||
return this.buildMouseCursor(state, fallback, usesArrowBase ? 4 : 5, usesArrowBase ? 3 : 24, this.cursorAnimationFrame);
|
||||
}
|
||||
|
||||
buildMouseCursor(state, fallback = 'default', hotspotX = 12, hotspotY = 12, frame = 0) {
|
||||
@@ -398,25 +399,31 @@ class UIInputHandlerModule extends BaseModule {
|
||||
}
|
||||
|
||||
getMouseCursorSvg(state, frame = 0) {
|
||||
const stroke = '#222222';
|
||||
const common = `xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="${stroke}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"`;
|
||||
const stroke = '#2a1b10';
|
||||
const common = `xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none" stroke="${stroke}" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"`;
|
||||
const spinnerSpokes = Array.from({ length: 8 }, (_, index) => {
|
||||
const opacity = 0.25 + (((index + frame) % 8) / 7) * 0.75;
|
||||
const angle = (index * 45) * Math.PI / 180;
|
||||
const x1 = 12 + Math.cos(angle) * 6;
|
||||
const y1 = 12 + Math.sin(angle) * 6;
|
||||
const x2 = 12 + Math.cos(angle) * 9;
|
||||
const y2 = 12 + Math.sin(angle) * 9;
|
||||
const x1 = 24 + Math.cos(angle) * 3;
|
||||
const y1 = 24 + Math.sin(angle) * 3;
|
||||
const x2 = 24 + Math.cos(angle) * 5;
|
||||
const y2 = 24 + Math.sin(angle) * 5;
|
||||
return `<path opacity="${opacity.toFixed(2)}" d="M${x1.toFixed(2)} ${y1.toFixed(2)} ${x2.toFixed(2)} ${y2.toFixed(2)}"/>`;
|
||||
}).join('');
|
||||
const sandTop = frame % 4 < 2 ? '<path d="M9 5h6"/><path d="M10 8h4"/>' : '<path d="M10 16h4"/><path d="M9 19h6"/>';
|
||||
const arrow = '<path fill="#f6efe2" d="M4 3l9 21 2.4-8.5L24 13z"/><path d="M15.4 15.5 21 21"/>';
|
||||
const pointer = '<path fill="#f6efe2" d="M9 14V5a2.2 2.2 0 0 1 4.4 0v7.5"/><path d="M13.4 12V8.5a2.1 2.1 0 0 1 4.2 0v5"/><path d="M17.6 14v-1.7a2.1 2.1 0 0 1 4.2 0v4.2A8.1 8.1 0 0 1 13.7 24h-1.2a6.8 6.8 0 0 1-5.5-3L3.6 15a2.1 2.1 0 0 1 3.4-2.4l2 2.5"/>';
|
||||
const feather = '<path fill="#f6efe2" d="M5 26c5.8-1.7 12.5-7.9 18.4-20.7 2.3 7.6-.2 16.1-11.8 19.9"/><path d="M5 26c4.8-4.5 8.7-9.2 13-15"/><path d="M12 25.2 5 26"/>';
|
||||
const speaker = '<g transform="translate(20 2) scale(.48)"><path fill="#f6efe2" d="M11 5 6 9H2v6h4l5 4z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M19 5a10 10 0 0 1 0 14"/></g>';
|
||||
const spinner = `<g>${spinnerSpokes}</g>`;
|
||||
const hourglassSand = frame % 4 < 2 ? '<path d="M5.7 4.7h4.6"/><path d="M6.7 7h2.6"/>' : '<path d="M6.7 12h2.6"/><path d="M5.7 14.3h4.6"/>';
|
||||
const hourglass = `<g transform="translate(1 17) scale(.82)"><path fill="#f6efe2" d="M4 2h8M4 16h8M10.8 2v3.1a2 2 0 0 1-.6 1.4L8 8.5l-2.2-2A2 2 0 0 1 5.2 5.1V2M5.2 16v-3.1a2 2 0 0 1 .6-1.4L8 9.5l2.2 2a2 2 0 0 1 .6 1.4V16"/>${hourglassSand}</g>`;
|
||||
const icons = {
|
||||
'default': `<svg ${common}><path d="M4 3l7.5 18 2.1-7.4L21 11z"/><path d="M13.6 13.6 18 18"/></svg>`,
|
||||
'pointer': `<svg ${common}><path d="M8 11V4a2 2 0 1 1 4 0v6"/><path d="M12 10V7a2 2 0 1 1 4 0v5"/><path d="M16 12v-1a2 2 0 1 1 4 0v3a7 7 0 0 1-7 7h-1a6 6 0 0 1-5-2.7L3 13a2 2 0 0 1 3-2.6l2 2.1"/></svg>`,
|
||||
'command-waiting': `<svg ${common}><path d="M5 22h14"/><path d="M5 2h14"/><path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22"/><path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2"/>${sandTop}</svg>`,
|
||||
'waiting-generating': `<svg ${common}>${spinnerSpokes}</svg>`,
|
||||
'playing-generating': `<svg ${common}><path d="M11 5 6 9H2v6h4l5 4z"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>${spinnerSpokes}</svg>`,
|
||||
'playing-ready': `<svg ${common}><path d="M11 5 6 9H2v6h4l5 4z"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/></svg>`
|
||||
'default': `<svg ${common}>${arrow}</svg>`,
|
||||
'pointer': `<svg ${common}>${pointer}</svg>`,
|
||||
'command-waiting': `<svg ${common}>${arrow}${hourglass}</svg>`,
|
||||
'waiting-generating': `<svg ${common}>${arrow}${spinner}</svg>`,
|
||||
'playing-generating': `<svg ${common}>${feather}${speaker}${spinner}</svg>`,
|
||||
'playing-ready': `<svg ${common}>${feather}${speaker}</svg>`
|
||||
};
|
||||
|
||||
return icons[state] || icons['waiting-generating'];
|
||||
|
||||
Reference in New Issue
Block a user